34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41if (isModEnabled(
"categorie")) {
42 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
46$langs->loadLangs(array(
'contracts',
'products',
'companies',
'compta'));
48$action =
GETPOST(
'action',
'aZ09');
49$massaction =
GETPOST(
'massaction',
'alpha');
50$show_files =
GETPOST(
'show_files',
'int');
51$confirm =
GETPOST(
'confirm',
'alpha');
52$toselect =
GETPOST(
'toselect',
'array');
53$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractlist';
54$optioncss =
GETPOST(
'optioncss',
'alpha');
55$mode =
GETPOST(
'mode',
'alpha');
57$search_name =
GETPOST(
'search_name',
'alpha');
58$search_email =
GETPOST(
'search_email',
'alpha');
59$search_town =
GETPOST(
'search_town',
'alpha');
60$search_zip =
GETPOST(
'search_zip',
'alpha');
61$search_state =
GETPOST(
"search_state",
'alpha');
62$search_country =
GETPOST(
"search_country",
'int');
63$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
64$search_contract =
GETPOST(
'search_contract',
'alpha');
65$search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
66$search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
67$search_all = (
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml');
68$search_status =
GETPOST(
'search_status',
'alpha');
69$socid =
GETPOST(
'socid',
'int');
70$search_user =
GETPOST(
'search_user',
'int');
71$search_sale =
GETPOST(
'search_sale',
'int');
72$search_product_category =
GETPOST(
'search_product_category',
'int');
73$search_dfmonth =
GETPOST(
'search_dfmonth',
'int');
74$search_dfyear =
GETPOST(
'search_dfyear',
'int');
75$search_op2df =
GETPOST(
'search_op2df',
'alpha');
76$search_date_startday =
GETPOST(
'search_date_startday',
'int');
77$search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
78$search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
79$search_date_endday =
GETPOST(
'search_date_endday',
'int');
80$search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
81$search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
82$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
83$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
84$searchCategoryCustomerOperator = 0;
85if (GETPOSTISSET(
'formfilteraction')) {
86 $searchCategoryCustomerOperator =
GETPOST(
'search_category_customer_operator',
'int');
87} elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
88 $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
90$searchCategoryCustomerList =
GETPOST(
'search_category_customer_list',
'array');
93$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
94$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
95$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
96$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
97if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
101$offset = $limit * $page;
102$pageprev = $page - 1;
103$pagenext = $page + 1;
105 $sortfield =
'c.ref';
114 $socid = $user->socid;
118$diroutputmassaction = $conf->contrat->dir_output.
'/temp/massgeneration/'.$user->id;
120$staticcontrat =
new Contrat($db);
123if ($search_status ==
'') {
129$hookmanager->initHooks(array(
'contractlist'));
133$extrafields->fetch_name_optionals_label($object->table_element);
135$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
137$fieldstosearchall = array();
138foreach ($object->fields as $key => $val) {
139 if (!empty($val[
'searchall'])) {
140 $fieldstosearchall[
'c.'.$key] = $val[
'label'];
143$fieldstosearchall[
"s.nom"] =
"ThirdParty";
144if (empty($user->socid)) {
145 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
147$parameters = array(
'fieldstosearchall'=>$fieldstosearchall);
148$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
150 $fieldstosearchall = $hookmanager->resArray[
'fieldstosearchall'];
151} elseif ($reshook == 0) {
152 if (!empty($hookmanager->resArray[
'fieldstosearchall'])) {
153 $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray[
'fieldstosearchall']);
158 'c.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1,
'position'=>10),
159 'c.ref_customer'=>array(
'label'=>$langs->trans(
"RefCustomer"),
'checked'=>1,
'position'=>12),
160 'c.ref_supplier'=>array(
'label'=>$langs->trans(
"RefSupplier"),
'checked'=>1,
'position'=>14),
161 's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1,
'position'=>30),
162 's.email'=>array(
'label'=>$langs->trans(
"ThirdPartyEmail"),
'checked'=>0,
'position'=>30),
163 's.town'=>array(
'label'=>$langs->trans(
"Town"),
'checked'=>0,
'position'=>31),
164 's.zip'=>array(
'label'=>$langs->trans(
"Zip"),
'checked'=>1,
'position'=>32),
165 'state.nom'=>array(
'label'=>$langs->trans(
"StateShort"),
'checked'=>0,
'position'=>33),
166 'country.code_iso'=>array(
'label'=>$langs->trans(
"Country"),
'checked'=>0,
'position'=>34),
167 'sale_representative'=>array(
'label'=>$langs->trans(
"SaleRepresentativesOfThirdParty"),
'checked'=>-1,
'position'=>80),
168 'c.date_contrat'=>array(
'label'=>$langs->trans(
"DateContract"),
'checked'=>1,
'position'=>45),
169 'c.datec'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
170 'c.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
171 'lower_planned_end_date'=>array(
'label'=>$langs->trans(
"LowerDateEndPlannedShort"),
'checked'=>1,
'position'=>900,
'help'=>$langs->trans(
"LowerDateEndPlannedShort")),
172 'status'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
175include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
180$permissiontoread = $user->hasRight(
'contrat',
'lire');
181$permissiontoadd = $user->hasRight(
'contrat',
'creer');
182$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
189if (
GETPOST(
'cancel',
'alpha')) {
193if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
197$parameters = array(
'socid'=>$socid);
198$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
203include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
206if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
207 $search_dfmonth =
'';
216 $search_country =
'';
217 $search_contract =
"";
218 $search_ref_customer =
"";
219 $search_ref_supplier =
"";
222 $search_product_category =
'';
223 $search_date_startday =
'';
224 $search_date_startmonth =
'';
225 $search_date_startyear =
'';
226 $search_date_endday =
'';
227 $search_date_endmonth =
'';
228 $search_date_endyear =
'';
229 $search_date_start =
'';
230 $search_date_end =
'';
234 $search_type_thirdparty =
'';
235 $searchCategoryCustomerList = array();
236 $search_array_options = array();
239if (empty($reshook)) {
240 $objectclass =
'Contrat';
241 $objectlabel =
'Contracts';
242 $uploaddir = $conf->contrat->dir_output;
243 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
251$form =
new Form($db);
256$contracttmp =
new Contrat($db);
263$sql .=
" c.rowid, c.ref, c.datec as date_creation, c.tms as date_update, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
264$sql .=
' s.rowid as socid, s.nom as name, s.name_alias, s.email, s.town, s.zip, s.fk_pays as country_id, s.client, s.code_client, s.status as company_status, s.logo as company_logo,';
265$sql .=
" typent.code as typent_code,";
266$sql .=
" state.code_departement as state_code, state.nom as state_name,";
267$sql .=
" MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") as lower_planned_end_date,";
268$sql .=
" SUM(".$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
269$sql .=
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NULL OR cd.date_fin_validite >= '".$db->idate($now).
"')", 1, 0).
') as nb_running,';
270$sql .=
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now).
"')", 1, 0).
') as nb_expired,';
271$sql .=
" SUM(".$db->ifsql(
"cd.statut=4 AND (cd.date_fin_validite IS NOT NULL AND cd.date_fin_validite < '".$db->idate($now - $conf->contrat->services->expires->warning_delay).
"')", 1, 0).
') as nb_late,';
272$sql .=
" SUM(".$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed';
274if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
275 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
276 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
280$parameters = array();
281$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
282$sql .= $hookmanager->resPrint;
283$sql = preg_replace(
'/,\s*$/',
'', $sql);
287$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
288$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
289$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
290$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
291if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
292 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
294$sql .=
", ".MAIN_DB_PREFIX.
"contrat as c";
295if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
296 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (c.rowid = ef.fk_object)";
298$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
299if ($search_user > 0) {
300 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
301 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
303$sql .=
" WHERE c.fk_soc = s.rowid ";
304$sql .=
' AND c.entity IN ('.getEntity(
'contract').
')';
305if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
306 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
309 $sql .=
" AND s.rowid = ".((int) $socid);
311if (empty($user->rights->societe->client->voir) && !$socid) {
312 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
314if ($search_date_start) {
315 $sql .=
" AND c.date_contrat >= '".$db->idate($search_date_start).
"'";
317if ($search_date_end) {
318 $sql .=
" AND c.date_contrat <= '".$db->idate($search_date_end).
"'";
326if ($search_contract) {
327 $sql .=
natural_search(array(
'c.rowid',
'c.ref'), $search_contract);
329if (!empty($search_ref_customer)) {
330 $sql .=
natural_search(array(
'c.ref_customer'), $search_ref_customer);
332if (!empty($search_ref_supplier)) {
333 $sql .=
natural_search(array(
'c.ref_supplier'), $search_ref_supplier);
341if ($search_country && $search_country !=
'-1') {
342 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
344if ($search_sale > 0) {
345 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
348 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
350if ($search_user > 0) {
351 $sql .=
" AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user);
354$searchCategoryProductOperator = -1;
355$searchCategoryProductList = array($search_product_category);
356if (!empty($searchCategoryProductList)) {
357 $searchCategoryProductSqlList = array();
358 $listofcategoryid =
'';
359 foreach ($searchCategoryProductList as $searchCategoryProduct) {
360 if (intval($searchCategoryProduct) == -2) {
361 $searchCategoryProductSqlList[] =
"NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product)";
362 } elseif (intval($searchCategoryProduct) > 0) {
363 if ($searchCategoryProductOperator == 0) {
364 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).
")";
366 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
370 if ($listofcategoryid) {
371 $searchCategoryProductSqlList[] =
" EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX.
"categorie_product as ck, ".MAIN_DB_PREFIX.
"contratdet as cd WHERE cd.fk_contrat = c.rowid AND cd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid).
"))";
373 if ($searchCategoryProductOperator == 1) {
374 if (!empty($searchCategoryProductSqlList)) {
375 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
378 if (!empty($searchCategoryProductSqlList)) {
379 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
383$searchCategoryCustomerSqlList = array();
384if ($searchCategoryCustomerOperator == 1) {
385 $existsCategoryCustomerList = array();
386 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
387 if (intval($searchCategoryCustomer) == -2) {
388 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
389 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
390 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
391 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
392 $sqlCategoryCustomerNotExists .=
" )";
393 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
394 } elseif (intval($searchCategoryCustomer) > 0) {
395 $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
398 if (!empty($existsCategoryCustomerList)) {
399 $sqlCategoryCustomerExists =
" EXISTS (";
400 $sqlCategoryCustomerExists .=
" SELECT cat_cus.fk_soc";
401 $sqlCategoryCustomerExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
402 $sqlCategoryCustomerExists .=
" WHERE cat_cus.fk_soc = s.rowid";
403 $sqlCategoryCustomerExists .=
" AND cat_cus.fk_categorie IN (".$db->sanitize(implode(
',', $existsCategoryCustomerList)).
")";
404 $sqlCategoryCustomerExists .=
" )";
405 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
407 if (!empty($searchCategoryCustomerSqlList)) {
408 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
411 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
412 if (intval($searchCategoryCustomer) == -2) {
413 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
414 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
415 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
416 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
417 $sqlCategoryCustomerNotExists .=
" )";
418 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
419 } elseif (intval($searchCategoryCustomer) > 0) {
420 $searchCategoryCustomerSqlList[] =
"s.rowid IN (SELECT fk_soc FROM ".$db->prefix().
"categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).
")";
423 if (!empty($searchCategoryCustomerSqlList)) {
424 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
428include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
430$parameters = array();
431$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
432$sql .= $hookmanager->resPrint;
433$sql .=
" GROUP BY c.rowid, c.ref, c.datec, c.tms, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity,";
434$sql .=
' s.rowid, s.nom, s.name_alias, s.email, s.town, s.zip, s.fk_pays, s.client, s.code_client, s.status, s.logo,';
435$sql .=
" typent.code,";
436$sql .=
" state.code_departement, state.nom";
438if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
439 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
440 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
444$parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df'=>$search_op2df);
445$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
446$sql .= $hookmanager->resPrint;
448$parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df'=>$search_op2df);
449$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
450if (empty($reshook)) {
451 if ($search_dfyear > 0 && $search_op2df) {
452 if ($search_op2df ==
'<=') {
453 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth,
false)).
"'";
454 } elseif ($search_op2df ==
'>=') {
455 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth,
false)).
"'";
457 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth,
false)).
"' AND MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth,
false)).
"'";
461$sql .= $hookmanager->resPrint;
464$nbtotalofrecords =
'';
469 if ($search_dfyear > 0 && $search_op2df) {
470 $resql = $db->query($sql, 0,
'auto', 1);
471 while ($db->fetch_object($resql)) {
472 if (empty($nbtotalofrecords)) {
473 $nbtotalofrecords = 1;
480 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
481 $sqlforcount = preg_replace(
'/LEFT JOIN '.MAIN_DB_PREFIX.
'contratdet as cd ON c.rowid = cd.fk_contrat /',
'', $sqlforcount);
482 $sqlforcount = preg_replace(
'/GROUP BY.*$/',
'', $sqlforcount);
484 $resql = $db->query($sqlforcount);
486 $objforcount = $db->fetch_object($resql);
487 $nbtotalofrecords = $objforcount->nbtotalofrecords;
493 if (($page * $limit) > $nbtotalofrecords) {
501$sql .= $db->order($sortfield, $sortorder);
503 $sql .= $db->plimit($limit + 1, $offset);
506$resql = $db->query($sql);
512$num = $db->num_rows($resql);
515if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
516 $obj = $db->fetch_object($resql);
518 header(
"Location: ".DOL_URL_ROOT.
'/contrat/card.php?id='.$id);
526llxHeader(
'', $langs->trans(
"Contracts"));
530$arrayofselected = is_array($toselect) ? $toselect : array();
535 if (empty($search_name)) {
536 $search_name = $soc->name;
542 $param .=
'&mode='.urlencode($mode);
544if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
545 $param .=
'&contextpage='.urlencode($contextpage);
547if ($limit > 0 && $limit != $conf->liste_limit) {
548 $param .=
'&limit='.((int) $limit);
550if ($search_all !=
'') {
551 $param .=
'&search_all='.urlencode($search_all);
553if ($search_contract !=
'') {
554 $param .=
'&search_contract='.urlencode($search_contract);
556if ($search_name !=
'') {
557 $param .=
'&search_name='.urlencode($search_name);
559if ($search_email !=
'') {
560 $param .=
'&search_email='.urlencode($search_email);
562if ($search_ref_customer !=
'') {
563 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
565if ($search_ref_supplier !=
'') {
566 $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
568if ($search_op2df !=
'') {
569 $param .=
'&search_op2df='.urlencode($search_op2df);
571if ($search_date_startday > 0) {
572 $param .=
'&search_date_startday='.urlencode($search_date_startday);
574if ($search_date_startmonth > 0) {
575 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
577if ($search_date_startyear > 0) {
578 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
580if ($search_date_endday > 0) {
581 $param .=
'&search_date_endday='.urlencode($search_date_endday);
583if ($search_date_endmonth > 0) {
584 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
586if ($search_date_endyear > 0) {
587 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
589if ($search_dfyear > 0) {
590 $param .=
'&search_dfyear='.urlencode($search_dfyear);
592if ($search_dfmonth > 0) {
593 $param .=
'&search_dfmonth='.urlencode($search_dfmonth);
595if ($search_sale > 0) {
596 $param .=
'&search_sale='.urlencode($search_sale);
598if ($search_user > 0) {
599 $param .=
'&search_user='.urlencode($search_user);
601if ($search_type_thirdparty > 0) {
602 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
604if ($search_country !=
'') {
605 $param .=
"&search_country=".urlencode($search_country);
607if ($search_product_category > 0) {
608 $param .=
'&search_product_category='.urlencode($search_product_category);
611 $param .=
'&show_files='.urlencode($show_files);
613if ($optioncss !=
'') {
614 $param .=
'&optioncss='.urlencode($optioncss);
616foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
617 $param .=
"&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
620include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
623$arrayofmassactions = array(
624 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
625 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
626 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
628if (!empty($permissiontodelete)) {
629 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
631if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
632 $arrayofmassactions = array();
634$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
636$url = DOL_URL_ROOT.
'/contrat/card.php?action=create';
638 $url .=
'&socid='.((int) $socid);
641$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=common'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ((empty($mode) || $mode ==
'common') ? 2 : 1), array(
'morecss'=>
'reposition'));
642$newcardbutton .=
dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', $_SERVER[
"PHP_SELF"].
'?mode=kanban'.preg_replace(
'/(&|\?)*mode=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss'=>
'reposition'));
643$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewContractSubscription'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->contrat->creer);
645print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
'PHP_SELF'].
'">'.
"\n";
646if ($optioncss !=
'') {
647 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
649print
'<input type="hidden" name="token" value="'.newToken().
'">';
650print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
651print
'<input type="hidden" name="action" value="list">';
652print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
653print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
654print
'<input type="hidden" name="page" value="'.$page.
'">';
655print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
656print
'<input type="hidden" name="page_y" value="">';
657print
'<input type="hidden" name="mode" value="'.$mode.
'">';
659print_barre_liste($langs->trans(
"Contracts"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0, $newcardbutton,
'', $limit, 0, 0, 1);
661$topicmail =
"SendContractRef";
662$modelmail =
"contract";
664$trackid =
'con'.$object->id;
665include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
669 foreach ($fieldstosearchall as $key => $val) {
670 $fieldstosearchall[$key] = $langs->trans($val);
671 $setupstring .= $key.
"=".$val.
";";
673 print
'<!-- Search done like if CONTRACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
674 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).join(
', ', $fieldstosearchall).
'</div>'.
"\n";
680if ($user->rights->user->user->lire) {
681 $langs->load(
"commercial");
682 $moreforfilter .=
'<div class="divsearchfield">';
683 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
684 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'widthcentpercentminusx maxwidth300');
685 $moreforfilter .=
'</div>';
688if ($user->rights->user->user->lire) {
689 $moreforfilter .=
'<div class="divsearchfield">';
690 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
691 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
692 $moreforfilter .=
'</div>';
695if (isModEnabled(
'categorie') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
696 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
697 $moreforfilter .=
'<div class="divsearchfield">';
698 $tmptitle = $langs->trans(
'IncludingProductWithTag');
699 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
700 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'widthcentpercentminusx maxwidth300', 1);
701 $moreforfilter .=
'</div>';
704if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && isModEnabled(
"categorie") && $user->hasRight(
'categorie',
'lire')) {
705 $moreforfilter .=
'<div class="divsearchfield">';
706 $tmptitle = $langs->transnoentities(
'CustomersProspectsCategoriesShort');
707 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
708 $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
'',
'', 64, 0, 1);
709 $categoriesArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
710 $moreforfilter .=
Form::multiselectarray(
'search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0,
'minwidth300', 0, 0,
'',
'category', $tmptitle);
711 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ?
' checked="checked"' :
'').
'/>';
712 $moreforfilter .= $form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') .
' : ' . $tmptitle, 1,
'help',
'', 0, 2,
'tooltip_cat_cus');
713 $moreforfilter .=
'</div>';
716$parameters = array();
717$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
718if (empty($reshook)) {
719 $moreforfilter .= $hookmanager->resPrint;
721 $moreforfilter = $hookmanager->resPrint;
724if (!empty($moreforfilter)) {
725 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
726 print $moreforfilter;
730$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
731$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
732if ($massactionbutton) {
733 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
736print
'<div class="div-table-responsive">';
737print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
741print
'<tr class="liste_titre_filter">';
744 print
'<td class="liste_titre maxwidthsearch center">';
745 $searchpicto = $form->showFilterButtons(
'left');
749if (!empty($arrayfields[
'c.ref'][
'checked'])) {
750 print
'<td class="liste_titre">';
751 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
754if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
755 print
'<td class="liste_titre">';
756 print
'<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
759if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
760 print
'<td class="liste_titre">';
761 print
'<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
764if (!empty($arrayfields[
's.nom'][
'checked'])) {
765 print
'<td class="liste_titre">';
766 print
'<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
769if (!empty($arrayfields[
's.email'][
'checked'])) {
770 print
'<td class="liste_titre">';
771 print
'<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
775if (!empty($arrayfields[
's.town'][
'checked'])) {
776 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
779if (!empty($arrayfields[
's.zip'][
'checked'])) {
780 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
783if (!empty($arrayfields[
'state.nom'][
'checked'])) {
784 print
'<td class="liste_titre">';
785 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
789if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
790 print
'<td class="liste_titre center">';
791 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
795if (!empty($arrayfields[
'typent.code'][
'checked'])) {
796 print
'<td class="liste_titre maxwidthonsmartphone center">';
797 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
800if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
801 print
'<td class="liste_titre"></td>';
803if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
804 print
'<td class="liste_titre center">';
805 print
'<div class="nowrap">';
806 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
808 print
'<div class="nowrap">';
809 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
814include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
817$parameters = array(
'arrayfields'=>$arrayfields);
818$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
819print $hookmanager->resPrint;
821if (!empty($arrayfields[
'c.datec'][
'checked'])) {
822 print
'<td class="liste_titre">';
826if (!empty($arrayfields[
'c.tms'][
'checked'])) {
827 print
'<td class="liste_titre">';
831if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
832 print
'<td class="liste_titre nowraponall center">';
833 $arrayofoperators = array(
'0'=>
'',
'='=>
'=',
'<='=>
'<=',
'>='=>
'>=');
834 print $form->selectarray(
'search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth50imp');
836 print $formother->select_month($search_dfmonth,
'search_dfmonth', 1, 0);
838 print $formother->selectyear($search_dfyear,
'search_dfyear', 1, 20, 5, 0, 0,
'');
842if (!empty($arrayfields[
'status'][
'checked'])) {
843 print
'<td class="liste_titre right" colspan="4"></td>';
848 print
'<td class="liste_titre center">';
849 $searchpicto = $form->showFilterButtons();
855$totalarray = array();
856$totalarray[
'nbfield'] = 0;
860print
'<tr class="liste_titre">';
862 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
863 $totalarray[
'nbfield']++;
865if (!empty($arrayfields[
'c.ref'][
'checked'])) {
866 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
'', $sortfield, $sortorder);
867 $totalarray[
'nbfield']++;
869if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
870 print_liste_field_titre($arrayfields[
'c.ref_customer'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_customer",
"", $param,
'', $sortfield, $sortorder);
871 $totalarray[
'nbfield']++;
873if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
874 print_liste_field_titre($arrayfields[
'c.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_supplier",
"", $param,
'', $sortfield, $sortorder);
875 $totalarray[
'nbfield']++;
877if (!empty($arrayfields[
's.nom'][
'checked'])) {
878 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
879 $totalarray[
'nbfield']++;
881if (!empty($arrayfields[
's.email'][
'checked'])) {
882 print_liste_field_titre($arrayfields[
's.email'][
'label'], $_SERVER[
"PHP_SELF"],
"s.email",
"", $param,
'', $sortfield, $sortorder);
883 $totalarray[
'nbfield']++;
885if (!empty($arrayfields[
's.town'][
'checked'])) {
886 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
887 $totalarray[
'nbfield']++;
889if (!empty($arrayfields[
's.zip'][
'checked'])) {
890 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
891 $totalarray[
'nbfield']++;
893if (!empty($arrayfields[
'state.nom'][
'checked'])) {
894 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
895 $totalarray[
'nbfield']++;
897if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
898 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
899 $totalarray[
'nbfield']++;
901if (!empty($arrayfields[
'typent.code'][
'checked'])) {
902 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
903 $totalarray[
'nbfield']++;
905if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
906 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder);
907 $totalarray[
'nbfield']++;
909if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
910 print_liste_field_titre($arrayfields[
'c.date_contrat'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_contrat",
"", $param,
'', $sortfield, $sortorder,
'center ');
911 $totalarray[
'nbfield']++;
914include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
916$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder,
'totalarray'=>&$totalarray);
917$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
918print $hookmanager->resPrint;
919if (!empty($arrayfields[
'c.datec'][
'checked'])) {
920 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
921 $totalarray[
'nbfield']++;
923if (!empty($arrayfields[
'c.tms'][
'checked'])) {
924 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
925 $totalarray[
'nbfield']++;
927if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
928 print_liste_field_titre($arrayfields[
'lower_planned_end_date'][
'label'], $_SERVER[
"PHP_SELF"],
"lower_planned_end_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
929 $totalarray[
'nbfield']++;
931if (!empty($arrayfields[
'status'][
'checked'])) {
932 print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
933 $totalarray[
'nbfield']++;
934 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
935 $totalarray[
'nbfield']++;
936 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
937 $totalarray[
'nbfield']++;
938 print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
939 $totalarray[
'nbfield']++;
942 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
943 $totalarray[
'nbfield']++;
950$savnbfield = $totalarray[
'nbfield'];
951$totalarray = array();
952$totalarray[
'nbfield'] = 0;
953$typenArray = array();
954$cacheCountryIDCode = array();
955$imaxinloop = ($limit ? min($num, $limit) : $num);
956while ($i < $imaxinloop) {
957 $obj = $db->fetch_object($resql);
962 $contracttmp->ref = $obj->ref;
963 $contracttmp->id = $obj->rowid;
964 $contracttmp->ref_customer = $obj->ref_customer;
965 $contracttmp->ref_supplier = $obj->ref_supplier;
967 $contracttmp->nbofserviceswait = $obj->nb_initial;
968 $contracttmp->nbofservicesopened = $obj->nb_running;
969 $contracttmp->nbofservicesexpired = $obj->nb_expired;
970 $contracttmp->nbofservicesclosed = $obj->nb_closed;
972 $socstatic->id = $obj->socid;
973 $socstatic->name = $obj->name;
974 $socstatic->name_alias = $obj->name_alias;
975 $socstatic->email = $obj->email;
976 $socstatic->status = $obj->company_status;
977 $socstatic->logo = $obj->company_logo;
978 $socstatic->country_id = $obj->country_id;
979 $socstatic->country_code =
'';
980 $socstatic->country =
'';
982 if ($obj->country_id > 0) {
983 if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
984 $tmparray =
getCountry($obj->country_id,
'all');
985 $cacheCountryIDCode[$obj->country_id] = array(
'code'=> empty($tmparray[
'code']) ?
'' : $tmparray[
'code'],
'label' => empty($tmparray[
'label']) ?
'' : $tmparray[
'label']);
987 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
988 $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
991 if ($mode ==
'kanban') {
993 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
994 print
'<div class="box-flex-container kanban">';
997 $arraydata[
'thirdparty'] = $socstatic;
998 $arraydata[
'selected'] = in_array($obj->rowid, $arrayofselected);
999 $contracttmp->date_contrat = $obj->date_contrat;
1000 print $contracttmp->getKanbanView(
'', $arraydata);
1001 if ($i == ($imaxinloop - 1)) {
1007 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1010 print
'<td class="nowrap center">';
1011 if ($massactionbutton || $massaction) {
1013 if (in_array($obj->rowid, $arrayofselected)) {
1016 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1020 $totalarray[
'nbfield']++;
1024 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1025 print
'<td class="nowraponall">';
1026 print $contracttmp->getNomUrl(1);
1027 if ($obj->nb_late) {
1030 if (!empty($obj->note_private) || !empty($obj->note_public)) {
1031 print
' <span class="note">';
1032 print
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'note').
'</a>';
1038 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1039 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
1044 $totalarray[
'nbfield']++;
1049 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
1050 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag(
dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).
'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
1052 $totalarray[
'nbfield']++;
1055 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
1056 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>';
1058 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1059 print
'<td class="tdoverflowmax150">';
1060 if ($obj->socid > 0) {
1062 print $socstatic->getNomUrl(1,
'');
1067 if (!empty($arrayfields[
's.email'][
'checked'])) {
1068 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).
'">'.
dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).
'</td>';
1071 if (!empty($arrayfields[
's.town'][
'checked'])) {
1072 print
'<td class="nocellnopadd">';
1076 $totalarray[
'nbfield']++;
1080 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1081 print
'<td class="nocellnopadd">';
1085 $totalarray[
'nbfield']++;
1089 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1090 print
"<td>".$obj->state_name.
"</td>\n";
1092 $totalarray[
'nbfield']++;
1096 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1097 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).
'">';
1101 $totalarray[
'nbfield']++;
1105 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1106 print
'<td class="center">';
1107 if (count($typenArray) == 0) {
1108 $typenArray = $formcompany->typent_array(1);
1110 print $typenArray[$obj->typent_code];
1113 $totalarray[
'nbfield']++;
1116 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1119 if ($obj->socid > 0) {
1120 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
1121 if ($listsalesrepresentatives < 0) {
1124 $nbofsalesrepresentative = count($listsalesrepresentatives);
1125 if ($nbofsalesrepresentative > 6) {
1127 print $nbofsalesrepresentative;
1128 } elseif ($nbofsalesrepresentative > 0) {
1129 $userstatic =
new User($db);
1131 foreach ($listsalesrepresentatives as $val) {
1132 $userstatic->id = $val[
'id'];
1133 $userstatic->lastname = $val[
'lastname'];
1134 $userstatic->firstname = $val[
'firstname'];
1135 $userstatic->email = $val[
'email'];
1136 $userstatic->statut = $val[
'statut'];
1137 $userstatic->entity = $val[
'entity'];
1138 $userstatic->photo = $val[
'photo'];
1139 $userstatic->login = $val[
'login'];
1140 $userstatic->phone = $val[
'phone'];
1141 $userstatic->job = $val[
'job'];
1142 $userstatic->gender = $val[
'gender'];
1145 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
1147 if ($j < $nbofsalesrepresentative) {
1160 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
1161 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat),
'day',
'tzserver').
'</td>';
1164 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1166 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1167 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1168 print $hookmanager->resPrint;
1170 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1171 print
'<td class="center nowrap">';
1172 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1175 $totalarray[
'nbfield']++;
1179 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1180 print
'<td class="center nowrap">';
1181 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1184 $totalarray[
'nbfield']++;
1188 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
1189 print
'<td class="center nowrapforall">';
1190 print
dol_print_date($db->jdate($obj->lower_planned_end_date),
'day',
'tzuser');
1193 $totalarray[
'nbfield']++;
1197 if (!empty($arrayfields[
'status'][
'checked'])) {
1198 print
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial :
'').
'</td>';
1199 print
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running :
'').
'</td>';
1200 print
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired :
'').
'</td>';
1201 print
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed :
'').
'</td>';
1203 $totalarray[
'nbfield']++;
1204 $totalarray[
'nbfield']++;
1205 $totalarray[
'nbfield']++;
1206 $totalarray[
'nbfield']++;
1211 print
'<td class="nowrap center">';
1212 if ($massactionbutton || $massaction) {
1214 if (in_array($obj->rowid, $arrayofselected)) {
1217 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1221 $totalarray[
'nbfield']++;
1233 foreach ($arrayfields as $key => $val) {
1234 if (!empty($val[
'checked'])) {
1238 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1243$parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1244$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1245print $hookmanager->resPrint;
1247print
'</table>'.
"\n";
1250print
'</form>'.
"\n";
1252$hidegeneratedfilelistifempty = 1;
1253if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1254 $hidegeneratedfilelistifempty = 0;
1258$urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1259$urlsource .= str_replace(
'&',
'&', $param);
1261$filedir = $diroutputmassaction;
1262$genallowed = $permissiontoread;
1263$delallowed = $permissiontoadd;
1265print $formfile->showdocuments(
'massfilesarea_contract',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
Class to manage lines of contracts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0)
Show EMail link formatted for HTML output.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.