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';
55 $search_name =
GETPOST(
'search_name',
'alpha');
56 $search_email =
GETPOST(
'search_email',
'alpha');
57 $search_town =
GETPOST(
'search_town',
'alpha');
58 $search_zip =
GETPOST(
'search_zip',
'alpha');
59 $search_state =
GETPOST(
"search_state",
'alpha');
60 $search_country =
GETPOST(
"search_country",
'int');
61 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
62 $search_contract =
GETPOST(
'search_contract',
'alpha');
63 $search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
64 $search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
65 $sall = (
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml');
66 $search_status =
GETPOST(
'search_status',
'alpha');
67 $socid =
GETPOST(
'socid',
'int');
68 $search_user =
GETPOST(
'search_user',
'int');
69 $search_sale =
GETPOST(
'search_sale',
'int');
70 $search_product_category =
GETPOST(
'search_product_category',
'int');
71 $search_dfmonth =
GETPOST(
'search_dfmonth',
'int');
72 $search_dfyear =
GETPOST(
'search_dfyear',
'int');
73 $search_op2df =
GETPOST(
'search_op2df',
'alpha');
74 $search_date_startday =
GETPOST(
'search_date_startday',
'int');
75 $search_date_startmonth =
GETPOST(
'search_date_startmonth',
'int');
76 $search_date_startyear =
GETPOST(
'search_date_startyear',
'int');
77 $search_date_endday =
GETPOST(
'search_date_endday',
'int');
78 $search_date_endmonth =
GETPOST(
'search_date_endmonth',
'int');
79 $search_date_endyear =
GETPOST(
'search_date_endyear',
'int');
80 $search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
81 $search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
82 $searchCategoryCustomerOperator = 0;
84 $searchCategoryCustomerOperator =
GETPOST(
'search_category_customer_operator',
'int');
85 } elseif (!empty($conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT)) {
86 $searchCategoryCustomerOperator = $conf->global->MAIN_SEARCH_CAT_OR_BY_DEFAULT;
88 $searchCategoryCustomerList =
GETPOST(
'search_category_customer_list',
'array');
90 $optioncss =
GETPOST(
'optioncss',
'alpha');
92 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
93 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
94 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
96 if (empty($page) || $page == -1) {
99 $offset = $limit * $page;
100 $pageprev = $page - 1;
101 $pagenext = $page + 1;
103 $sortfield =
'c.ref';
112 $socid = $user->socid;
116 $diroutputmassaction = $conf->contrat->dir_output.
'/temp/massgeneration/'.$user->id;
118 $staticcontrat =
new Contrat($db);
121 if ($search_status ==
'') {
127 $hookmanager->initHooks(array(
'contractlist'));
131 $extrafields->fetch_name_optionals_label($object->table_element);
133 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
135 $fieldstosearchall = array(
137 'c.ref_customer'=>
'RefCustomer',
138 'c.ref_supplier'=>
'RefSupplier',
139 's.nom'=>
"ThirdParty",
140 'c.note_public'=>
'NotePublic',
142 if (empty($user->socid)) {
143 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
146 $arrayfields = array(
147 'c.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1,
'position'=>10),
148 'c.ref_customer'=>array(
'label'=>$langs->trans(
"RefCustomer"),
'checked'=>1,
'position'=>12),
149 'c.ref_supplier'=>array(
'label'=>$langs->trans(
"RefSupplier"),
'checked'=>1,
'position'=>14),
150 's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1,
'position'=>30),
151 's.email'=>array(
'label'=>$langs->trans(
"ThirdPartyEmail"),
'checked'=>0,
'position'=>30),
152 's.town'=>array(
'label'=>$langs->trans(
"Town"),
'checked'=>0,
'position'=>31),
153 's.zip'=>array(
'label'=>$langs->trans(
"Zip"),
'checked'=>1,
'position'=>32),
154 'state.nom'=>array(
'label'=>$langs->trans(
"StateShort"),
'checked'=>0,
'position'=>33),
155 'country.code_iso'=>array(
'label'=>$langs->trans(
"Country"),
'checked'=>0,
'position'=>34),
156 'sale_representative'=>array(
'label'=>$langs->trans(
"SaleRepresentativesOfThirdParty"),
'checked'=>-1,
'position'=>80),
157 'c.date_contrat'=>array(
'label'=>$langs->trans(
"DateContract"),
'checked'=>1,
'position'=>45),
158 'c.datec'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
159 'c.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
160 'lower_planned_end_date'=>array(
'label'=>$langs->trans(
"LowerDateEndPlannedShort"),
'checked'=>1,
'position'=>900,
'help'=>$langs->trans(
"LowerDateEndPlannedShort")),
161 'status'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
164 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
174 if (
GETPOST(
'cancel',
'alpha')) {
175 $action =
'list'; $massaction =
'';
177 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
181 $parameters = array(
'socid'=>$socid);
182 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
187 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
190 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
191 $search_dfmonth =
'';
200 $search_country =
'';
201 $search_contract =
"";
202 $search_ref_customer =
"";
203 $search_ref_supplier =
"";
206 $search_product_category =
'';
207 $search_date_startday =
'';
208 $search_date_startmonth =
'';
209 $search_date_startyear =
'';
210 $search_date_endday =
'';
211 $search_date_endmonth =
'';
212 $search_date_endyear =
'';
213 $search_date_start =
'';
214 $search_date_end =
'';
218 $search_type_thirdparty =
'';
219 $searchCategoryCustomerList = array();
220 $search_array_options = array();
223 if (empty($reshook)) {
224 $objectclass =
'Contrat';
225 $objectlabel =
'Contracts';
226 $permissiontoread = $user->rights->contrat->lire;
227 $permissiontodelete = $user->rights->contrat->supprimer;
228 $uploaddir = $conf->contrat->dir_output;
229 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
243 $contracttmp =
new Contrat($db);
247 $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,";
248 $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,';
249 $sql .=
" typent.code as typent_code,";
250 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
251 $sql .=
" MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") as lower_planned_end_date,";
252 $sql .=
" SUM(".$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
253 $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,';
254 $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,';
255 $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,';
256 $sql .=
" SUM(".$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed';
258 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
259 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
260 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
264 $parameters = array();
265 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
266 $sql .= $hookmanager->resPrint;
267 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
268 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
269 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
270 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
271 if ($search_sale > 0 || (empty($user->rights->societe->client->voir) && !$socid)) {
272 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
274 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as c";
275 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
276 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (c.rowid = ef.fk_object)";
278 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
279 if ($search_user > 0) {
280 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
281 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
283 $sql .=
" WHERE c.fk_soc = s.rowid ";
284 $sql .=
' AND c.entity IN ('.getEntity(
'contract').
')';
285 if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
286 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
289 $sql .=
" AND s.rowid = ".((int) $socid);
291 if (empty($user->rights->societe->client->voir) && !$socid) {
292 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
294 if ($search_date_start) {
295 $sql .=
" AND c.date_contrat >= '".$db->idate($search_date_start).
"'";
297 if ($search_date_end) {
298 $sql .=
" AND c.date_contrat <= '".$db->idate($search_date_end).
"'";
306 if ($search_contract) {
307 $sql .=
natural_search(array(
'c.rowid',
'c.ref'), $search_contract);
309 if (!empty($search_ref_customer)) {
310 $sql .=
natural_search(array(
'c.ref_customer'), $search_ref_customer);
312 if (!empty($search_ref_supplier)) {
313 $sql .=
natural_search(array(
'c.ref_supplier'), $search_ref_supplier);
321 if ($search_country && $search_country !=
'-1') {
322 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
324 if ($search_sale > 0) {
325 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $search_sale);
330 if ($search_user > 0) {
331 $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);
334 $searchCategoryProductOperator = -1;
335 $searchCategoryProductList = array($search_product_category);
336 if (!empty($searchCategoryProductList)) {
337 $searchCategoryProductSqlList = array();
338 $listofcategoryid =
'';
339 foreach ($searchCategoryProductList as $searchCategoryProduct) {
340 if (intval($searchCategoryProduct) == -2) {
341 $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)";
342 } elseif (intval($searchCategoryProduct) > 0) {
343 if ($searchCategoryProductOperator == 0) {
344 $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).
")";
346 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
350 if ($listofcategoryid) {
351 $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).
"))";
353 if ($searchCategoryProductOperator == 1) {
354 if (!empty($searchCategoryProductSqlList)) {
355 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
358 if (!empty($searchCategoryProductSqlList)) {
359 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
363 $searchCategoryCustomerSqlList = array();
364 if ($searchCategoryCustomerOperator == 1) {
365 $existsCategoryCustomerList = array();
366 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
367 if (intval($searchCategoryCustomer) == -2) {
368 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
369 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
370 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
371 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
372 $sqlCategoryCustomerNotExists .=
" )";
373 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
374 } elseif (intval($searchCategoryCustomer) > 0) {
375 $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
378 if (!empty($existsCategoryCustomerList)) {
379 $sqlCategoryCustomerExists =
" EXISTS (";
380 $sqlCategoryCustomerExists .=
" SELECT cat_cus.fk_soc";
381 $sqlCategoryCustomerExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
382 $sqlCategoryCustomerExists .=
" WHERE cat_cus.fk_soc = s.rowid";
383 $sqlCategoryCustomerExists .=
" AND cat_cus.fk_categorie IN (".$db->sanitize(implode(
',', $existsCategoryCustomerList)).
")";
384 $sqlCategoryCustomerExists .=
" )";
385 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
387 if (!empty($searchCategoryCustomerSqlList)) {
388 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
391 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
392 if (intval($searchCategoryCustomer) == -2) {
393 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
394 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
395 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
396 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
397 $sqlCategoryCustomerNotExists .=
" )";
398 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
399 } elseif (intval($searchCategoryCustomer) > 0) {
400 $searchCategoryCustomerSqlList[] =
"s.rowid IN (SELECT fk_soc FROM ".$db->prefix().
"categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).
")";
403 if (!empty($searchCategoryCustomerSqlList)) {
404 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
408 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
410 $parameters = array();
411 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
412 $sql .= $hookmanager->resPrint;
413 $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,";
414 $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,';
415 $sql .=
" typent.code,";
416 $sql .=
" state.code_departement, state.nom";
418 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
419 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
420 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
424 $parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df'=>$search_op2df);
425 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
426 $sql .= $hookmanager->resPrint;
428 $parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df'=>$search_op2df);
429 $reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
430 if (empty($reshook)) {
431 if ($search_dfyear > 0 && $search_op2df) {
432 if ($search_op2df ==
'<=') {
433 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth,
false)).
"'";
434 } elseif ($search_op2df ==
'>=') {
435 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth,
false)).
"'";
437 $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)).
"'";
441 $sql .= $hookmanager->resPrint;
444 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
448 if ($search_dfyear > 0 && $search_op2df) {
449 $resql = $db->query($sql, 0,
'auto', 1);
450 while ($db->fetch_object(
$resql)) {
458 $sqlforcount = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/Ui',
'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
459 $sqlforcount = preg_replace(
'/LEFT JOIN '.MAIN_DB_PREFIX.
'contratdet as cd ON c.rowid = cd.fk_contrat/',
'', $sqlforcount);
460 $sqlforcount = preg_replace(
'/GROUP BY.*$/',
'', $sqlforcount);
462 $resql = $db->query($sqlforcount);
463 $objforcount = $db->fetch_object(
$resql);
473 $sql .= $db->order($sortfield, $sortorder);
475 $sql .= $db->plimit($limit + 1, $offset);
478 $resql = $db->query($sql);
484 $num = $db->num_rows(
$resql);
487 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page) {
488 $obj = $db->fetch_object(
$resql);
490 header(
"Location: ".DOL_URL_ROOT.
'/contrat/card.php?id='.$id);
498 llxHeader(
'', $langs->trans(
"Contracts"));
502 $arrayofselected = is_array($toselect) ? $toselect : array();
507 if (empty($search_name)) {
508 $search_name = $soc->name;
513 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
514 $param .=
'&contextpage='.urlencode($contextpage);
516 if ($limit > 0 && $limit != $conf->liste_limit) {
517 $param .=
'&limit='.urlencode($limit);
520 $param .=
'&sall='.urlencode($sall);
522 if ($search_contract !=
'') {
523 $param .=
'&search_contract='.urlencode($search_contract);
525 if ($search_name !=
'') {
526 $param .=
'&search_name='.urlencode($search_name);
528 if ($search_email !=
'') {
529 $param .=
'&search_email='.urlencode($search_email);
531 if ($search_ref_customer !=
'') {
532 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
534 if ($search_ref_supplier !=
'') {
535 $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
537 if ($search_op2df !=
'') {
538 $param .=
'&search_op2df='.urlencode($search_op2df);
540 if ($search_date_startday > 0) {
541 $param .=
'&search_date_startday='.urlencode($search_date_startday);
543 if ($search_date_startmonth > 0) {
544 $param .=
'&search_date_startmonth='.urlencode($search_date_startmonth);
546 if ($search_date_startyear > 0) {
547 $param .=
'&search_date_startyear='.urlencode($search_date_startyear);
549 if ($search_date_endday > 0) {
550 $param .=
'&search_date_endday='.urlencode($search_date_endday);
552 if ($search_date_endmonth > 0) {
553 $param .=
'&search_date_endmonth='.urlencode($search_date_endmonth);
555 if ($search_date_endyear > 0) {
556 $param .=
'&search_date_endyear='.urlencode($search_date_endyear);
558 if ($search_dfyear > 0) {
559 $param .=
'&search_dfyear='.urlencode($search_dfyear);
561 if ($search_dfmonth > 0) {
562 $param .=
'&search_dfmonth='.urlencode($search_dfmonth);
564 if ($search_sale > 0) {
565 $param .=
'&search_sale='.urlencode($search_sale);
567 if ($search_user > 0) {
568 $param .=
'&search_user='.urlencode($search_user);
570 if ($search_type_thirdparty > 0) {
571 $param .=
'&search_type_thirdparty='.urlencode($search_type_thirdparty);
573 if ($search_country !=
'') {
574 $param .=
"&search_country=".urlencode($search_country);
576 if ($search_product_category > 0) {
577 $param .=
'&search_product_category='.urlencode($search_product_category);
580 $param .=
'&show_files='.urlencode($show_files);
582 if ($optioncss !=
'') {
583 $param .=
'&optioncss='.urlencode($optioncss);
585 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
586 $param .=
"&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
589 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
592 $arrayofmassactions = array(
593 'generate_doc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
594 'builddoc'=>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
595 'presend'=>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
597 if ($user->rights->contrat->supprimer) {
598 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
600 if (in_array($massaction, array(
'presend',
'predelete'))) {
601 $arrayofmassactions = array();
603 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
605 $url = DOL_URL_ROOT.
'/contrat/card.php?action=create';
606 if (!empty($socid)) {
607 $url .=
'&socid='.((int) $socid);
609 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewContractSubscription'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->contrat->creer);
611 print
'<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'">';
612 if ($optioncss !=
'') {
613 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
615 print
'<input type="hidden" name="token" value="'.newToken().
'">';
616 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
617 print
'<input type="hidden" name="action" value="list">';
618 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
619 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
620 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
622 print_barre_liste($langs->trans(
"Contracts"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'contract', 0, $newcardbutton,
'', $limit, 0, 0, 1);
624 $topicmail =
"SendContractRef";
625 $modelmail =
"contract";
627 $trackid =
'con'.$object->id;
628 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
631 foreach ($fieldstosearchall as $key => $val) {
632 $fieldstosearchall[$key] = $langs->trans($val);
634 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
640 if ($user->rights->user->user->lire) {
641 $langs->load(
"commercial");
642 $moreforfilter .=
'<div class="divsearchfield">';
643 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
644 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'widthcentpercentminusx maxwidth300');
645 $moreforfilter .=
'</div>';
648 if ($user->rights->user->user->lire) {
649 $moreforfilter .=
'<div class="divsearchfield">';
650 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
651 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
652 $moreforfilter .=
'</div>';
655 if (
isModEnabled(
'categorie') && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire)) {
656 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
657 $moreforfilter .=
'<div class="divsearchfield">';
658 $tmptitle = $langs->trans(
'IncludingProductWithTag');
659 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
660 $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);
661 $moreforfilter .=
'</div>';
664 if (!empty($conf->global->MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST) && !empty($conf->categorie->enabled) && $user->rights->categorie->lire) {
665 $moreforfilter .=
'<div class="divsearchfield">';
666 $tmptitle = $langs->transnoentities(
'CustomersProspectsCategoriesShort');
667 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
668 $categoriesArr =
$form->select_all_categories(Categorie::TYPE_CUSTOMER,
'',
'', 64, 0, 1);
669 $categoriesArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
670 $moreforfilter .=
Form::multiselectarray(
'search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0,
'minwidth300', 0, 0,
'',
'category', $tmptitle);
671 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ?
' checked="checked"' :
'').
'/>';
672 $moreforfilter .=
$form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') .
' : ' . $tmptitle, 1,
'help',
'', 0, 2,
'tooltip_cat_cus');
673 $moreforfilter .=
'</div>';
676 $parameters = array();
677 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
678 if (empty($reshook)) {
679 $moreforfilter .= $hookmanager->resPrint;
681 $moreforfilter = $hookmanager->resPrint;
684 if (!empty($moreforfilter)) {
685 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
686 print $moreforfilter;
690 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
691 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
692 if ($massactionbutton) {
693 $selectedfields .=
$form->showCheckAddButtons(
'checkforselect', 1);
696 print
'<div class="div-table-responsive">';
697 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
699 print
'<tr class="liste_titre_filter">';
702 print
'<td class="liste_titre center">';
703 $searchpicto =
$form->showFilterButtons(
'left');
707 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
708 print
'<td class="liste_titre">';
709 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
712 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
713 print
'<td class="liste_titre">';
714 print
'<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
717 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
718 print
'<td class="liste_titre">';
719 print
'<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
722 if (!empty($arrayfields[
's.nom'][
'checked'])) {
723 print
'<td class="liste_titre">';
724 print
'<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
727 if (!empty($arrayfields[
's.email'][
'checked'])) {
728 print
'<td class="liste_titre">';
729 print
'<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
733 if (!empty($arrayfields[
's.town'][
'checked'])) {
734 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
737 if (!empty($arrayfields[
's.zip'][
'checked'])) {
738 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
741 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
742 print
'<td class="liste_titre">';
743 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
747 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
748 print
'<td class="liste_titre center">';
749 print
$form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
753 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
754 print
'<td class="liste_titre maxwidthonsmartphone center">';
755 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);
758 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
759 print
'<td class="liste_titre"></td>';
761 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
762 print
'<td class="liste_titre center">';
763 print
'<div class="nowrap">';
764 print
$form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
766 print
'<div class="nowrap">';
767 print
$form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
772 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
775 $parameters = array(
'arrayfields'=>$arrayfields);
776 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
777 print $hookmanager->resPrint;
779 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
780 print
'<td class="liste_titre">';
784 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
785 print
'<td class="liste_titre">';
789 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
790 print
'<td class="liste_titre nowraponall center">';
791 $arrayofoperators = array(
'0'=>
'',
'='=>
'=',
'<='=>
'<=',
'>='=>
'>=');
792 print
$form->selectarray(
'search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth50imp');
794 print $formother->select_month($search_dfmonth,
'search_dfmonth', 1, 0);
796 print $formother->selectyear($search_dfyear,
'search_dfyear', 1, 20, 5, 0, 0,
'');
800 if (!empty($arrayfields[
'status'][
'checked'])) {
801 print
'<td class="liste_titre right" colspan="4"></td>';
806 print
'<td class="liste_titre center">';
807 $searchpicto =
$form->showFilterButtons();
813 print
'<tr class="liste_titre">';
815 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
817 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
818 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
'', $sortfield, $sortorder);
820 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
821 print_liste_field_titre($arrayfields[
'c.ref_customer'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_customer",
"", $param,
'', $sortfield, $sortorder);
823 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
824 print_liste_field_titre($arrayfields[
'c.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_supplier",
"", $param,
'', $sortfield, $sortorder);
826 if (!empty($arrayfields[
's.nom'][
'checked'])) {
827 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
829 if (!empty($arrayfields[
's.email'][
'checked'])) {
830 print_liste_field_titre($arrayfields[
's.email'][
'label'], $_SERVER[
"PHP_SELF"],
"s.email",
"", $param,
'', $sortfield, $sortorder);
832 if (!empty($arrayfields[
's.town'][
'checked'])) {
833 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
835 if (!empty($arrayfields[
's.zip'][
'checked'])) {
836 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
838 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
839 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
841 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
842 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
844 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
845 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
847 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
848 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder);
850 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
851 print_liste_field_titre($arrayfields[
'c.date_contrat'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_contrat",
"", $param,
'', $sortfield, $sortorder,
'center ');
854 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
856 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
857 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
858 print $hookmanager->resPrint;
859 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
860 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
862 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
863 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
865 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
866 print_liste_field_titre($arrayfields[
'lower_planned_end_date'][
'label'], $_SERVER[
"PHP_SELF"],
"lower_planned_end_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
868 if (!empty($arrayfields[
'status'][
'checked'])) {
869 print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
870 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
871 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
872 print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
875 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
879 $totalarray = array();
880 $totalarray[
'nbfield'] = 0;
881 $typenArray = array();
882 $cacheCountryIDCode = array();
884 while ($i < min($num, $limit)) {
885 $obj = $db->fetch_object(
$resql);
887 $contracttmp->ref = $obj->ref;
888 $contracttmp->id = $obj->rowid;
889 $contracttmp->ref_customer = $obj->ref_customer;
890 $contracttmp->ref_supplier = $obj->ref_supplier;
892 if ($obj->socid > 0) {
893 $result = $socstatic->fetch($obj->socid);
904 if ($obj->country_id > 0) {
905 if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
906 $tmparray =
getCountry($obj->country_id,
'all');
907 $cacheCountryIDCode[$obj->country_id] = array(
'code'=> empty($tmparray[
'code']) ?
'' : $tmparray[
'code'],
'label' => empty($tmparray[
'label']) ?
'' : $tmparray[
'label']);
909 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
910 $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
914 print
'<tr class="oddeven">';
917 print
'<td class="nowrap center">';
918 if ($massactionbutton || $massaction) {
920 if (in_array($obj->rowid, $arrayofselected)) {
923 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
928 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
929 print
'<td class="nowraponall">';
930 print $contracttmp->getNomUrl(1);
934 if (!empty($obj->note_private) || !empty($obj->note_public)) {
935 print
' <span class="note">';
936 print
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'note').
'</a>';
942 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
943 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
950 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
951 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag(
dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).
'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
953 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
954 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>';
956 if (!empty($arrayfields[
's.nom'][
'checked'])) {
957 print
'<td class="tdoverflowmax150">';
958 if ($obj->socid > 0) {
960 print $socstatic->getNomUrl(1,
'');
965 if (!empty($arrayfields[
's.email'][
'checked'])) {
966 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).
'">'.
dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).
'</td>';
969 if (!empty($arrayfields[
's.town'][
'checked'])) {
970 print
'<td class="nocellnopadd">';
974 $totalarray[
'nbfield']++;
978 if (!empty($arrayfields[
's.zip'][
'checked'])) {
979 print
'<td class="nocellnopadd">';
983 $totalarray[
'nbfield']++;
987 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
988 print
"<td>".$obj->state_name.
"</td>\n";
990 $totalarray[
'nbfield']++;
994 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
995 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).
'">';
999 $totalarray[
'nbfield']++;
1003 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1004 print
'<td class="center">';
1005 if (count($typenArray) == 0) {
1006 $typenArray = $formcompany->typent_array(1);
1008 print $typenArray[$obj->typent_code];
1011 $totalarray[
'nbfield']++;
1014 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1017 if ($obj->socid > 0) {
1018 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
1019 if ($listsalesrepresentatives < 0) {
1022 $nbofsalesrepresentative = count($listsalesrepresentatives);
1023 if ($nbofsalesrepresentative > 6) {
1025 print $nbofsalesrepresentative;
1026 } elseif ($nbofsalesrepresentative > 0) {
1027 $userstatic =
new User($db);
1029 foreach ($listsalesrepresentatives as $val) {
1030 $userstatic->id = $val[
'id'];
1031 $userstatic->lastname = $val[
'lastname'];
1032 $userstatic->firstname = $val[
'firstname'];
1033 $userstatic->email = $val[
'email'];
1034 $userstatic->statut = $val[
'statut'];
1035 $userstatic->entity = $val[
'entity'];
1036 $userstatic->photo = $val[
'photo'];
1037 $userstatic->login = $val[
'login'];
1038 $userstatic->phone = $val[
'phone'];
1039 $userstatic->job = $val[
'job'];
1040 $userstatic->gender = $val[
'gender'];
1043 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
1045 if ($j < $nbofsalesrepresentative) {
1058 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
1059 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat),
'day',
'tzserver').
'</td>';
1062 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1064 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
1065 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1066 print $hookmanager->resPrint;
1068 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1069 print
'<td class="center nowrap">';
1070 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1073 $totalarray[
'nbfield']++;
1077 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1078 print
'<td class="center nowrap">';
1079 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
1082 $totalarray[
'nbfield']++;
1086 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
1087 print
'<td class="center nowrapforall">';
1088 print
dol_print_date($db->jdate($obj->lower_planned_end_date),
'day',
'tzuser');
1091 $totalarray[
'nbfield']++;
1095 if (!empty($arrayfields[
'status'][
'checked'])) {
1096 print
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial :
'').
'</td>';
1097 print
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running :
'').
'</td>';
1098 print
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired :
'').
'</td>';
1099 print
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed :
'').
'</td>';
1103 print
'<td class="nowrap center">';
1104 if ($massactionbutton || $massaction) {
1106 if (in_array($obj->rowid, $arrayofselected)) {
1109 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1114 $totalarray[
'nbfield']++;
1124 foreach ($arrayfields as $key => $val) {
1125 if (!empty($val[
'checked'])) {
1129 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1134 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
1135 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1136 print $hookmanager->resPrint;
1143 $hidegeneratedfilelistifempty = 1;
1144 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1145 $hidegeneratedfilelistifempty = 0;
1149 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1150 $urlsource .= str_replace(
'&',
'&', $param);
1152 $filedir = $diroutputmassaction;
1153 $genallowed = $user->rights->contrat->lire;
1154 $delallowed = $user->rights->contrat->lire;
1156 print $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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
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.
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.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
$nbtotalofrecords
Count total nb of records.
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.