34 require
'../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
41 if (!empty($conf->categorie->enabled)) {
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;
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');
97 if (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);
123 if ($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();
138 foreach ($object->fields as $key => $val) {
139 if (!empty($val[
'searchall'])) {
140 $fieldstosearchall[
'c.'.$key] = $val[
'label'];
143 $fieldstosearchall[
"s.nom"] =
"ThirdParty";
144 if (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']);
157 $arrayfields = array(
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),
175 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
180 $permissiontoread = $user->rights->contrat->lire;
181 $permissiontoadd = $user->rights->contrat->creer;
182 $permissiontodelete = $user->rights->contrat->supprimer;
189 if (
GETPOST(
'cancel',
'alpha')) {
193 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
197 $parameters = array(
'socid'=>$socid);
198 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
203 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
206 if (
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();
239 if (empty($reshook)) {
240 $objectclass =
'Contrat';
241 $objectlabel =
'Contracts';
242 $uploaddir = $conf->contrat->dir_output;
243 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
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';
274 if (!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 .= preg_replace(
'/^,/',
'', $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)";
291 if ($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";
295 if (!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";
299 if ($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').
')';
305 if ($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);
311 if (empty($user->rights->societe->client->voir) && !$socid) {
312 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
314 if ($search_date_start) {
315 $sql .=
" AND c.date_contrat >= '".$db->idate($search_date_start).
"'";
317 if ($search_date_end) {
318 $sql .=
" AND c.date_contrat <= '".$db->idate($search_date_end).
"'";
326 if ($search_contract) {
329 if (!empty($search_ref_customer)) {
332 if (!empty($search_ref_supplier)) {
341 if ($search_country && $search_country !=
'-1') {
342 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
344 if ($search_sale > 0) {
345 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
350 if ($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);
356 if (!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();
384 if ($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).
")";
428 include 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";
438 if (!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);
450 if (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;
465 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
469 if ($search_dfyear > 0 && $search_op2df) {
470 $resql = $db->query(
$sql, 0,
'auto', 1);
471 while ($db->fetch_object($resql)) {
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);
501 $sql .= $db->order($sortfield, $sortorder);
503 $sql .= $db->plimit($limit + 1, $offset);
506 $resql = $db->query(
$sql);
512 $num = $db->num_rows($resql);
515 if ($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);
526 llxHeader(
'', $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);
544 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
545 $param .=
'&contextpage='.urlencode($contextpage);
547 if ($limit > 0 && $limit != $conf->liste_limit) {
548 $param .=
'&limit='.urlencode($limit);
550 if ($search_all !=
'') {
551 $param .=
'&search_all='.urlencode($search_all);
553 if ($search_contract !=
'') {
554 $param .=
'&search_contract='.urlencode($search_contract);
556 if ($search_name !=
'') {
557 $param .=
'&search_name='.urlencode($search_name);
559 if ($search_email !=
'') {
560 $param .=
'&search_email='.urlencode($search_email);
562 if ($search_ref_customer !=
'') {
563 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
565 if ($search_ref_supplier !=
'') {
566 $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
568 if ($search_op2df !=
'') {
569 $param .=
'&search_op2df='.urlencode($search_op2df);
571 if ($search_date_startday > 0) {
572 $param .=
'&search_date_startday='.urlencode($search_date_startday);
574 if ($search_date_startmonth > 0) {
575 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
577 if ($search_date_startyear > 0) {
578 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
580 if ($search_date_endday > 0) {
581 $param .=
'&search_date_endday='.urlencode($search_date_endday);
583 if ($search_date_endmonth > 0) {
584 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
586 if ($search_date_endyear > 0) {
587 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
589 if ($search_dfyear > 0) {
590 $param .=
'&search_dfyear='.urlencode($search_dfyear);
592 if ($search_dfmonth > 0) {
593 $param .=
'&search_dfmonth='.urlencode($search_dfmonth);
595 if ($search_sale > 0) {
596 $param .=
'&search_sale='.urlencode($search_sale);
598 if ($search_user > 0) {
599 $param .=
'&search_user='.urlencode($search_user);
601 if ($search_type_thirdparty > 0) {
602 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
604 if ($search_country !=
'') {
605 $param .=
"&search_country=".urlencode($search_country);
607 if ($search_product_category > 0) {
608 $param .=
'&search_product_category='.urlencode($search_product_category);
611 $param .=
'&show_files='.urlencode($show_files);
613 if ($optioncss !=
'') {
614 $param .=
'&optioncss='.urlencode($optioncss);
616 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
617 $param .=
"&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
620 include 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"),
628 if (!empty($permissiontodelete)) {
629 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
631 if (
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';
637 if (!empty($socid)) {
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);
645 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
'PHP_SELF'].
'">'.
"\n";
646 if ($optioncss !=
'') {
647 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
649 print
'<input type="hidden" name="token" value="'.newToken().
'">';
650 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
651 print
'<input type="hidden" name="action" value="list">';
652 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
653 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
654 print
'<input type="hidden" name="page" value="'.$page.
'">';
655 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
656 print
'<input type="hidden" name="page_y" value="">';
657 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
659 print_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;
665 include 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";
680 if ($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>';
688 if ($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>';
695 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->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>';
704 if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && !empty($conf->categorie->enabled) && $user->rights->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);
718 if (empty($reshook)) {
719 $moreforfilter .= $hookmanager->resPrint;
721 $moreforfilter = $hookmanager->resPrint;
724 if (!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'));
732 if ($massactionbutton) {
733 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
736 print
'<div class="div-table-responsive">';
737 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
741 print
'<tr class="liste_titre_filter">';
744 print
'<td class="liste_titre maxwidthsearch center">';
745 $searchpicto =
$form->showFilterButtons(
'left');
749 if (!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).
'">';
754 if (!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).
'">';
759 if (!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).
'">';
764 if (!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).
'">';
769 if (!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).
'">';
775 if (!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>';
779 if (!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>';
783 if (!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).
'">';
789 if (!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');
795 if (!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);
800 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
801 print
'<td class="liste_titre"></td>';
803 if (!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'));
814 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
817 $parameters = array(
'arrayfields'=>$arrayfields);
818 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
819 print $hookmanager->resPrint;
821 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
822 print
'<td class="liste_titre">';
826 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
827 print
'<td class="liste_titre">';
831 if (!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,
'');
842 if (!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;
860 print
'<tr class="liste_titre">';
862 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
863 $totalarray[
'nbfield']++;
865 if (!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']++;
869 if (!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']++;
873 if (!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']++;
877 if (!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']++;
881 if (!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']++;
885 if (!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']++;
889 if (!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']++;
893 if (!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']++;
897 if (!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']++;
901 if (!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']++;
905 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
906 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder);
907 $totalarray[
'nbfield']++;
909 if (!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']++;
914 include 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);
918 print $hookmanager->resPrint;
919 if (!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']++;
923 if (!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']++;
927 if (!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']++;
931 if (!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);
956 while ($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 if ($obj->socid > 0) {
968 $result = $socstatic->fetch($obj->socid);
979 if ($obj->country_id > 0) {
980 if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
981 $tmparray =
getCountry($obj->country_id,
'all');
982 $cacheCountryIDCode[$obj->country_id] = array(
'code'=> empty($tmparray[
'code']) ?
'' : $tmparray[
'code'],
'label' => empty($tmparray[
'label']) ?
'' : $tmparray[
'label']);
984 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
985 $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
988 if ($mode ==
'kanban') {
990 print
'<tr><td colspan="'.$savnbfield.
'">';
991 print
'<div class="box-flex-container kanban">';
995 $contracttmp->societe = $socstatic->getNomUrl();
996 $contracttmp->date_contrat = $obj->date_contrat;
997 print $contracttmp->getKanbanView(
'');
998 if ($i == ($imaxinloop - 1)) {
1004 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1007 print
'<td class="nowrap center">';
1008 if ($massactionbutton || $massaction) {
1010 if (in_array($obj->rowid, $arrayofselected)) {
1013 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1017 $totalarray[
'nbfield']++;
1021 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1022 print
'<td class="nowraponall">';
1023 print $contracttmp->getNomUrl(1);
1024 if ($obj->nb_late) {
1027 if (!empty($obj->note_private) || !empty($obj->note_public)) {
1028 print
' <span class="note">';
1029 print
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'note').
'</a>';
1035 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1036 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
1041 $totalarray[
'nbfield']++;
1046 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
1047 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag(
dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).
'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
1049 $totalarray[
'nbfield']++;
1052 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
1053 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>';
1055 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1056 print
'<td class="tdoverflowmax150">';
1057 if ($obj->socid > 0) {
1059 print $socstatic->getNomUrl(1,
'');
1064 if (!empty($arrayfields[
's.email'][
'checked'])) {
1065 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).
'">'.
dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).
'</td>';
1068 if (!empty($arrayfields[
's.town'][
'checked'])) {
1069 print
'<td class="nocellnopadd">';
1073 $totalarray[
'nbfield']++;
1077 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1078 print
'<td class="nocellnopadd">';
1082 $totalarray[
'nbfield']++;
1086 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1087 print
"<td>".$obj->state_name.
"</td>\n";
1089 $totalarray[
'nbfield']++;
1093 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1094 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).
'">';
1098 $totalarray[
'nbfield']++;
1102 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1103 print
'<td class="center">';
1104 if (count($typenArray) == 0) {
1105 $typenArray = $formcompany->typent_array(1);
1107 print $typenArray[$obj->typent_code];
1110 $totalarray[
'nbfield']++;
1113 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1116 if ($obj->socid > 0) {
1117 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
1118 if ($listsalesrepresentatives < 0) {
1121 $nbofsalesrepresentative = count($listsalesrepresentatives);
1122 if ($nbofsalesrepresentative > 6) {
1124 print $nbofsalesrepresentative;
1125 } elseif ($nbofsalesrepresentative > 0) {
1126 $userstatic =
new User($db);
1128 foreach ($listsalesrepresentatives as $val) {
1129 $userstatic->id = $val[
'id'];
1130 $userstatic->lastname = $val[
'lastname'];
1131 $userstatic->firstname = $val[
'firstname'];
1132 $userstatic->email = $val[
'email'];
1133 $userstatic->statut = $val[
'statut'];
1134 $userstatic->entity = $val[
'entity'];
1135 $userstatic->photo = $val[
'photo'];
1136 $userstatic->login = $val[
'login'];
1137 $userstatic->phone = $val[
'phone'];
1138 $userstatic->job = $val[
'job'];
1139 $userstatic->gender = $val[
'gender'];
1142 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
1144 if ($j < $nbofsalesrepresentative) {
1157 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
1158 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat),
'day',
'tzserver').
'</td>';
1161 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1163 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1164 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1165 print $hookmanager->resPrint;
1167 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1168 print
'<td class="center nowrap">';
1169 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1172 $totalarray[
'nbfield']++;
1176 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1177 print
'<td class="center nowrap">';
1178 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1181 $totalarray[
'nbfield']++;
1185 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
1186 print
'<td class="center nowrapforall">';
1187 print
dol_print_date($db->jdate($obj->lower_planned_end_date),
'day',
'tzuser');
1190 $totalarray[
'nbfield']++;
1194 if (!empty($arrayfields[
'status'][
'checked'])) {
1195 print
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial :
'').
'</td>';
1196 print
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running :
'').
'</td>';
1197 print
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired :
'').
'</td>';
1198 print
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed :
'').
'</td>';
1200 $totalarray[
'nbfield']++;
1201 $totalarray[
'nbfield']++;
1202 $totalarray[
'nbfield']++;
1203 $totalarray[
'nbfield']++;
1208 print
'<td class="nowrap center">';
1209 if ($massactionbutton || $massaction) {
1211 if (in_array($obj->rowid, $arrayofselected)) {
1214 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1218 $totalarray[
'nbfield']++;
1230 foreach ($arrayfields as $key => $val) {
1231 if (!empty($val[
'checked'])) {
1235 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1240 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>
$sql);
1241 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1242 print $hookmanager->resPrint;
1244 print
'</table>'.
"\n";
1245 print
'</div>'.
"\n";
1247 print
'</form>'.
"\n";
1249 $hidegeneratedfilelistifempty = 1;
1250 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1251 $hidegeneratedfilelistifempty = 0;
1255 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1256 $urlsource .= str_replace(
'&',
'&', $param);
1258 $filedir = $diroutputmassaction;
1259 $genallowed = $permissiontoread;
1260 $delallowed = $permissiontoadd;
1262 print $formfile->showdocuments(
'massfilesarea_contract',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);