37require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
44if (isModEnabled(
"category")) {
45 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
57$langs->loadLangs(array(
'contracts',
'products',
'companies',
'compta'));
59$action =
GETPOST(
'action',
'aZ09');
60$massaction =
GETPOST(
'massaction',
'alpha');
62$confirm =
GETPOST(
'confirm',
'alpha');
63$toselect =
GETPOST(
'toselect',
'array');
64$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractlist';
65$optioncss =
GETPOST(
'optioncss',
'alpha');
66$mode =
GETPOST(
'mode',
'alpha');
70$search_name =
GETPOST(
'search_name',
'alpha');
71$search_email =
GETPOST(
'search_email',
'alpha');
72$search_town =
GETPOST(
'search_town',
'alpha');
73$search_zip =
GETPOST(
'search_zip',
'alpha');
74$search_state =
GETPOST(
"search_state",
'alpha');
75$search_country =
GETPOST(
"search_country",
'aZ09');
76$search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'intcomma');
77$search_contract =
GETPOST(
'search_contract',
'alpha');
78$search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
79$search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
80$search_all =
GETPOST(
'search_all',
'alphanohtml');
81$search_status =
GETPOST(
'search_status',
'alpha');
82$search_signed_status =
GETPOST(
'search_signed_status',
'alpha');
83$search_user =
GETPOST(
'search_user',
'intcomma');
84$search_sale =
GETPOST(
'search_sale',
'intcomma');
85$search_product_category =
GETPOST(
'search_product_category',
'intcomma');
88$search_op2df =
GETPOST(
'search_op2df',
'alpha');
89$search_date_startday =
GETPOSTINT(
'search_date_startday');
90$search_date_startmonth =
GETPOSTINT(
'search_date_startmonth');
91$search_date_startyear =
GETPOSTINT(
'search_date_startyear');
92$search_date_endday =
GETPOSTINT(
'search_date_endday');
93$search_date_endmonth =
GETPOSTINT(
'search_date_endmonth');
94$search_date_endyear =
GETPOSTINT(
'search_date_endyear');
95$search_date_start =
dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
96$search_date_end =
dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
97$searchCategoryCustomerOperator = 0;
98if (GETPOSTISSET(
'formfilteraction')) {
99 $searchCategoryCustomerOperator =
GETPOSTINT(
'search_category_customer_operator');
101 $searchCategoryCustomerOperator =
getDolGlobalString(
'MAIN_SEARCH_CAT_OR_BY_DEFAULT');
103$searchCategoryCustomerList =
GETPOST(
'search_category_customer_list',
'array');
105$search_date_creation_startmonth =
GETPOSTINT(
'search_date_creation_startmonth');
106$search_date_creation_startyear =
GETPOSTINT(
'search_date_creation_startyear');
107$search_date_creation_startday =
GETPOSTINT(
'search_date_creation_startday');
108$search_date_creation_start =
dol_mktime(0, 0, 0, $search_date_creation_startmonth, $search_date_creation_startday, $search_date_creation_startyear);
109$search_date_creation_endmonth =
GETPOSTINT(
'search_date_creation_endmonth');
110$search_date_creation_endyear =
GETPOSTINT(
'search_date_creation_endyear');
111$search_date_creation_endday =
GETPOSTINT(
'search_date_creation_endday');
112$search_date_creation_end =
dol_mktime(23, 59, 59, $search_date_creation_endmonth, $search_date_creation_endday, $search_date_creation_endyear);
114$search_date_modif_startmonth =
GETPOSTINT(
'search_date_modif_startmonth');
115$search_date_modif_startyear =
GETPOSTINT(
'search_date_modif_startyear');
116$search_date_modif_startday =
GETPOSTINT(
'search_date_modif_startday');
117$search_date_modif_start =
dol_mktime(0, 0, 0, $search_date_modif_startmonth, $search_date_modif_startday, $search_date_modif_startyear);
118$search_date_modif_endmonth =
GETPOSTINT(
'search_date_modif_endmonth');
119$search_date_modif_endyear =
GETPOSTINT(
'search_date_modif_endyear');
120$search_date_modif_endday =
GETPOSTINT(
'search_date_modif_endday');
121$search_date_modif_end =
dol_mktime(23, 59, 59, $search_date_modif_endmonth, $search_date_modif_endday, $search_date_modif_endyear);
125$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
126$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
128if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
132$offset = $limit * $page;
133$pageprev = $page - 1;
134$pagenext = $page + 1;
136 $sortfield =
'c.ref';
144if ($user->socid > 0) {
145 $socid = $user->socid;
148$hookmanager->initHooks(array(
'contractlist'));
152$diroutputmassaction =
$conf->contract->dir_output.
'/temp/massgeneration/'.$user->id;
154if ($search_status ==
'') {
164$extrafields->fetch_name_optionals_label(
$object->table_element);
166$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
168$fieldstosearchall = array();
169foreach (
$object->fields as $key => $val) {
170 if (!empty($val[
'searchall'])) {
171 $fieldstosearchall[
'c.'.$key] = $val[
'label'];
174$fieldstosearchall[
"s.nom"] =
"ThirdParty";
175if (empty($user->socid)) {
176 $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
178$parameters = array(
'fieldstosearchall' => $fieldstosearchall);
179$reshook = $hookmanager->executeHooks(
'completeFieldsToSearchAll', $parameters, $object, $action);
181 $fieldstosearchall = $hookmanager->resArray[
'fieldstosearchall'];
182} elseif ($reshook == 0) {
183 if (!empty($hookmanager->resArray[
'fieldstosearchall'])) {
184 $fieldstosearchall = array_merge($fieldstosearchall, $hookmanager->resArray[
'fieldstosearchall']);
189 'c.ref' => array(
'label' => $langs->trans(
"Ref"),
'checked' =>
'1',
'position' => 10),
190 'c.ref_customer' => array(
'label' => $langs->trans(
"RefCustomer"),
'checked' =>
'1',
'position' => 12),
191 'c.ref_supplier' => array(
'label' => $langs->trans(
"RefSupplier"),
'checked' =>
'1',
'position' => 14),
192 's.nom' => array(
'label' => $langs->trans(
"ThirdParty"),
'checked' =>
'1',
'position' => 30),
193 's.email' => array(
'label' => $langs->trans(
"ThirdPartyEmail"),
'checked' =>
'0',
'position' => 30),
194 's.town' => array(
'label' => $langs->trans(
"Town"),
'checked' =>
'0',
'position' => 31),
195 's.zip' => array(
'label' => $langs->trans(
"Zip"),
'checked' =>
'1',
'position' => 32),
196 'state.nom' => array(
'label' => $langs->trans(
"StateShort"),
'checked' =>
'0',
'position' => 33),
197 'country.code_iso' => array(
'label' => $langs->trans(
"Country"),
'checked' =>
'0',
'position' => 34),
198 'sale_representative' => array(
'label' => $langs->trans(
"SaleRepresentativesOfThirdParty"),
'checked' =>
'-1',
'position' => 80),
199 'c.date_contrat' => array(
'label' => $langs->trans(
"DateContract"),
'checked' =>
'1',
'position' => 45),
200 'c.datec' => array(
'label' => $langs->trans(
"DateCreation"),
'checked' =>
'0',
'position' => 500),
201 'c.tms' => array(
'label' => $langs->trans(
"DateModificationShort"),
'checked' =>
'0',
'position' => 500),
202 'lower_planned_end_date' => array(
'label' => $langs->trans(
"LowerDateEndPlannedShort"),
'checked' =>
'1',
'position' => 900,
'help' => $langs->trans(
"LowerDateEndPlannedShort")),
203 'status' => array(
'label' => $langs->trans(
"Status"),
'checked' =>
'1',
'position' => 1000),
204 'c.signed_status' => array(
'label' => $langs->trans(
'SignedStatus'),
'checked' =>
'0',
'position' => 1001),
207include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
212if (empty($user->socid) && !$user->hasRight(
'societe',
'client',
'voir')) {
213 $search_sale = $user->id;
216$permissiontoread = $user->hasRight(
'contrat',
'lire');
217$permissiontoadd = $user->hasRight(
'contrat',
'creer');
218$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
228if (
GETPOST(
'cancel',
'alpha')) {
232if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
236$parameters = array(
'socid' => $socid,
'arrayfields' => &$arrayfields);
237$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
242include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
244if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
245 $search_dfmonth =
'';
253 $search_type_thirdparty =
'';
254 $search_country =
'';
255 $search_contract =
"";
256 $search_ref_customer =
"";
257 $search_ref_supplier =
"";
260 $search_product_category =
'';
261 $search_date_startday =
'';
262 $search_date_startmonth =
'';
263 $search_date_startyear =
'';
264 $search_date_endday =
'';
265 $search_date_endmonth =
'';
266 $search_date_endyear =
'';
267 $search_date_start =
'';
268 $search_date_end =
'';
270 $search_date_creation_startmonth =
"";
271 $search_date_creation_startyear =
"";
272 $search_date_creation_startday =
"";
273 $search_date_creation_start =
"";
274 $search_date_creation_endmonth =
"";
275 $search_date_creation_endyear =
"";
276 $search_date_creation_endday =
"";
277 $search_date_creation_end =
"";
278 $search_date_modif_startmonth =
"";
279 $search_date_modif_startyear =
"";
280 $search_date_modif_startday =
"";
281 $search_date_modif_start =
"";
282 $search_date_modif_endmonth =
"";
283 $search_date_modif_endyear =
"";
284 $search_date_modif_endday =
"";
285 $search_date_modif_end =
"";
287 $search_signed_status =
'';
289 $searchCategoryCustomerList = array();
290 $search_array_options = array();
293if (empty($reshook)) {
294 $objectclass =
'Contrat';
295 $objectlabel =
'Contracts';
296 $uploaddir =
$conf->contract->dir_output;
297 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
305$form =
new Form($db);
310$contracttmp =
new Contrat($db);
317$sql .=
" c.rowid, c.ref, c.datec as date_creation, c.tms as date_modification, c.date_contrat, c.statut, c.ref_customer, c.ref_supplier, c.note_private, c.note_public, c.entity, c.signed_status,";
318$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,';
319$sql .=
" typent.code as typent_code,";
320$sql .=
" state.code_departement as state_code, state.nom as state_name,";
323$sql .=
" MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") as lower_planned_end_date,";
324$sql .=
" SUM(".$db->ifsql(
"cd.statut=0",
'1',
'0').
') as nb_initial,';
325$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,';
326$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,';
327$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,';
328$sql .=
" SUM(".$db->ifsql(
"cd.statut=5",
'1',
'0').
') as nb_closed';
330if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
331 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
332 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
336$parameters = array();
337$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
338$sql .= $hookmanager->resPrint;
339$sql = preg_replace(
'/,\s*$/',
'', $sql);
343$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c";
344$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as s ON (c.fk_soc = s.rowid)";
345$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
346$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
347$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
348if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
349 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (c.rowid = ef.fk_object)";
351$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
352if ($search_user > 0) {
353 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
354 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
357$parameters = array();
358$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, $object, $action);
359$sql .= $hookmanager->resPrint;
360$sql .=
" WHERE c.entity IN (".getEntity(
'contract').
")";
361if ($search_type_thirdparty !=
'' && $search_type_thirdparty > 0) {
362 $sql .=
" AND s.fk_typent IN (".$db->sanitize($db->escape($search_type_thirdparty)).
')';
365 $sql .=
" AND s.rowid = ".((int) $socid);
367if ($search_date_start) {
368 $sql .=
" AND c.date_contrat >= '".$db->idate($search_date_start).
"'";
370if ($search_date_end) {
371 $sql .=
" AND c.date_contrat <= '".$db->idate($search_date_end).
"'";
379if ($search_contract) {
380 $sql .=
natural_search(array(
'c.rowid',
'c.ref'), $search_contract);
382if (!empty($search_ref_customer)) {
383 $sql .=
natural_search(array(
'c.ref_customer'), $search_ref_customer);
385if (!empty($search_ref_supplier)) {
386 $sql .=
natural_search(array(
'c.ref_supplier'), $search_ref_supplier);
394if ($search_country && $search_country !=
'-1') {
395 $sql .=
" AND s.fk_pays IN (".$db->sanitize($search_country).
')';
398 $sql .=
natural_search(array_keys($fieldstosearchall), $search_all);
400if ($search_user > 0) {
401 $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);
404if ($search_sale && $search_sale !=
'-1') {
405 if ($search_sale == -2) {
406 $sql .=
" AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc)";
407 } elseif ($search_sale > 0) {
408 $sql .=
" AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX.
"societe_commerciaux as sc WHERE sc.fk_soc = c.fk_soc AND sc.fk_user = ".((int) $search_sale).
")";
412$searchCategoryProductOperator =
GETPOSTINT(
'search_category_product_operator');
413$searchCategoryProductList = array($search_product_category);
414if (!empty($searchCategoryProductList)) {
415 $searchCategoryProductSqlList = array();
416 $listofcategoryid =
'';
417 foreach ($searchCategoryProductList as $searchCategoryProduct) {
418 if (intval($searchCategoryProduct) == -2) {
419 $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)";
420 } elseif (intval($searchCategoryProduct) > 0) {
421 if ($searchCategoryProductOperator == 0) {
422 $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).
")";
424 $listofcategoryid .= ($listofcategoryid ?
', ' :
'') .((
int) $searchCategoryProduct);
428 if ($listofcategoryid) {
429 $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).
"))";
431 if ($searchCategoryProductOperator == 1) {
432 if (!empty($searchCategoryProductSqlList)) {
433 $sql .=
" AND (".implode(
' OR ', $searchCategoryProductSqlList).
")";
436 if (!empty($searchCategoryProductSqlList)) {
437 $sql .=
" AND (".implode(
' AND ', $searchCategoryProductSqlList).
")";
441$searchCategoryCustomerSqlList = array();
442if ($searchCategoryCustomerOperator == 1) {
443 $existsCategoryCustomerList = array();
444 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
445 if (intval($searchCategoryCustomer) == -2) {
446 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
447 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
448 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
449 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
450 $sqlCategoryCustomerNotExists .=
" )";
451 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
452 } elseif (intval($searchCategoryCustomer) > 0) {
453 $existsCategoryCustomerList[] = $db->escape($searchCategoryCustomer);
456 if (!empty($existsCategoryCustomerList)) {
457 $sqlCategoryCustomerExists =
" EXISTS (";
458 $sqlCategoryCustomerExists .=
" SELECT cat_cus.fk_soc";
459 $sqlCategoryCustomerExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
460 $sqlCategoryCustomerExists .=
" WHERE cat_cus.fk_soc = s.rowid";
461 $sqlCategoryCustomerExists .=
" AND cat_cus.fk_categorie IN (".$db->sanitize(implode(
',', $existsCategoryCustomerList)).
")";
462 $sqlCategoryCustomerExists .=
" )";
463 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerExists;
465 if (!empty($searchCategoryCustomerSqlList)) {
466 $sql .=
" AND (".implode(
' OR ', $searchCategoryCustomerSqlList).
")";
469 foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
470 if (intval($searchCategoryCustomer) == -2) {
471 $sqlCategoryCustomerNotExists =
" NOT EXISTS (";
472 $sqlCategoryCustomerNotExists .=
" SELECT cat_cus.fk_soc";
473 $sqlCategoryCustomerNotExists .=
" FROM ".$db->prefix().
"categorie_societe AS cat_cus";
474 $sqlCategoryCustomerNotExists .=
" WHERE cat_cus.fk_soc = s.rowid";
475 $sqlCategoryCustomerNotExists .=
" )";
476 $searchCategoryCustomerSqlList[] = $sqlCategoryCustomerNotExists;
477 } elseif (intval($searchCategoryCustomer) > 0) {
478 $searchCategoryCustomerSqlList[] =
"s.rowid IN (SELECT fk_soc FROM ".$db->prefix().
"categorie_societe WHERE fk_categorie = ".((int) $searchCategoryCustomer).
")";
481 if (!empty($searchCategoryCustomerSqlList)) {
482 $sql .=
" AND (".implode(
' AND ', $searchCategoryCustomerSqlList).
")";
486if ($search_date_creation_start) {
487 $sql .=
" AND c.datec >= '".$db->idate($search_date_creation_start).
"'";
489if ($search_date_creation_end) {
490 $sql .=
" AND c.datec <= '".$db->idate($search_date_creation_end).
"'";
493if ($search_date_modif_start) {
494 $sql .=
" AND c.tms >= '".$db->idate($search_date_modif_start).
"'";
496if ($search_date_modif_end) {
497 $sql .=
" AND c.tms <= '".$db->idate($search_date_modif_end).
"'";
499if ($search_signed_status !=
'' && $search_signed_status >= 0) {
500 $sql .=
' AND c.signed_status = '.urlencode($search_signed_status);
504include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
506$parameters = array();
507$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
508$sql .= $hookmanager->resPrint;
509$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, c.signed_status,";
510$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,';
511$sql .=
" typent.code,";
512$sql .=
" state.code_departement, state.nom";
514if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
515 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
516 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
520$parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df' => $search_op2df);
521$reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters, $object);
522$sql .= $hookmanager->resPrint;
524$parameters = array(
'search_dfyear' => $search_dfyear,
'search_op2df' => $search_op2df);
525$reshook = $hookmanager->executeHooks(
'printFieldListHaving', $parameters, $object, $action);
526if (empty($reshook)) {
527 if ($search_dfyear > 0 && $search_op2df) {
528 if ($search_op2df ==
'<=') {
529 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth,
false)).
"'";
530 } elseif ($search_op2df ==
'>=') {
531 $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth,
false)).
"'";
533 $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)).
"'";
537$sql .= $hookmanager->resPrint;
540$nbtotalofrecords =
'';
545 if ($search_dfyear > 0 && $search_op2df) {
546 $resql = $db->query($sql, 0,
'auto', 1);
547 while ($db->fetch_object($resql)) {
548 if (empty($nbtotalofrecords)) {
549 $nbtotalofrecords = 1;
556 $sqlforcount = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT COUNT(*) as nbtotalofrecords', $sql);
558 $sqlforcount = str_replace(
'LEFT JOIN '.MAIN_DB_PREFIX.
'c_country as country on (country.rowid = s.fk_pays)',
'', $sqlforcount);
559 $sqlforcount = str_replace(
'LEFT JOIN '.MAIN_DB_PREFIX.
'c_typent as typent on (typent.id = s.fk_typent)',
'', $sqlforcount);
560 $sqlforcount = str_replace(
'LEFT JOIN '.MAIN_DB_PREFIX.
'c_departements as state on (state.rowid = s.fk_departement)',
'', $sqlforcount);
561 $sqlforcount = str_replace(
'LEFT JOIN '.MAIN_DB_PREFIX.
'contratdet as cd ON c.rowid = cd.fk_contrat',
'', $sqlforcount);
563 $sqlforcount = preg_replace(
'/GROUP BY.*$/',
'', $sqlforcount);
565 $resql = $db->query($sqlforcount);
567 $objforcount = $db->fetch_object($resql);
568 $nbtotalofrecords = $objforcount->nbtotalofrecords;
574 if (($page * $limit) > $nbtotalofrecords) {
582$sql .= $db->order($sortfield, $sortorder);
584 $sql .= $db->plimit($limit + 1, $offset);
587$resql = $db->query($sql);
593$num = $db->num_rows($resql);
596if ($num == 1 &&
getDolGlobalString(
'MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE') && $search_all && !$page) {
597 $obj = $db->fetch_object($resql);
599 header(
"Location: ".DOL_URL_ROOT.
'/contrat/card.php?id='.
$id);
606$title = $langs->trans(
"Contracts");
607$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
609llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-list bodyforlist');
613$arrayofselected = is_array($toselect) ? $toselect : array();
618 if (empty($search_name)) {
619 $search_name = $soc->name;
625 $param .=
'&mode='.urlencode($mode);
627if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
628 $param .=
'&contextpage='.urlencode($contextpage);
630if ($limit > 0 && $limit !=
$conf->liste_limit) {
631 $param .=
'&limit='.((int) $limit);
633if ($search_all !=
'') {
634 $param .=
'&search_all='.urlencode($search_all);
636if ($search_contract !=
'') {
637 $param .=
'&search_contract='.urlencode($search_contract);
639if ($search_name !=
'') {
640 $param .=
'&search_name='.urlencode($search_name);
642if ($search_email !=
'') {
643 $param .=
'&search_email='.urlencode($search_email);
645if ($search_ref_customer !=
'') {
646 $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
648if ($search_ref_supplier !=
'') {
649 $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
651if ($search_op2df !=
'') {
652 $param .=
'&search_op2df='.urlencode($search_op2df);
654if ($search_date_creation_startmonth) {
655 $param .=
'&search_date_creation_startmonth='.urlencode((
string) ($search_date_creation_startmonth));
657if ($search_date_creation_startyear) {
658 $param .=
'&search_date_creation_startyear='.urlencode((
string) ($search_date_creation_startyear));
660if ($search_date_creation_startday) {
661 $param .=
'&search_date_creation_startday='.urlencode((
string) ($search_date_creation_startday));
663if ($search_date_creation_start) {
664 $param .=
'&search_date_creation_start='.urlencode((
string) $search_date_creation_start);
666if ($search_date_creation_endmonth) {
667 $param .=
'&search_date_creation_endmonth='.urlencode((
string) ($search_date_creation_endmonth));
669if ($search_date_creation_endyear) {
670 $param .=
'&search_date_creation_endyear='.urlencode((
string) ($search_date_creation_endyear));
672if ($search_date_creation_endday) {
673 $param .=
'&search_date_creation_endday='.urlencode((
string) ($search_date_creation_endday));
675if ($search_date_creation_end) {
676 $param .=
'&search_date_creation_end='.urlencode((
string) $search_date_creation_end);
678if ($search_date_modif_startmonth) {
679 $param .=
'&search_date_modif_startmonth='.urlencode((
string) ($search_date_modif_startmonth));
681if ($search_date_modif_startyear) {
682 $param .=
'&search_date_modif_startyear='.urlencode((
string) ($search_date_modif_startyear));
684if ($search_date_modif_startday) {
685 $param .=
'&search_date_modif_startday='.urlencode((
string) ($search_date_modif_startday));
687if ($search_date_modif_start) {
688 $param .=
'&search_date_modif_start='.urlencode((
string) $search_date_modif_start);
690if ($search_date_modif_endmonth) {
691 $param .=
'&search_date_modif_endmonth='.urlencode((
string) ($search_date_modif_endmonth));
693if ($search_date_modif_endyear) {
694 $param .=
'&search_date_modif_endyear='.urlencode((
string) ($search_date_modif_endyear));
696if ($search_date_modif_endday) {
697 $param .=
'&search_date_modif_endday='.urlencode((
string) ($search_date_modif_endday));
699if ($search_date_modif_end) {
700 $param .=
'&search_date_modif_end=' . urlencode((
string) $search_date_modif_end);
702if ($search_date_startday > 0) {
703 $param .=
'&search_date_startday='.urlencode((
string) ($search_date_startday));
705if ($search_date_startmonth > 0) {
706 $param .=
'&search_date_startmonth='.urlencode((
string) ($search_date_startmonth));
708if ($search_date_startyear > 0) {
709 $param .=
'&search_date_startyear='.urlencode((
string) ($search_date_startyear));
711if ($search_date_endday > 0) {
712 $param .=
'&search_date_endday='.urlencode((
string) ($search_date_endday));
714if ($search_date_endmonth > 0) {
715 $param .=
'&search_date_endmonth='.urlencode((
string) ($search_date_endmonth));
717if ($search_date_endyear > 0) {
718 $param .=
'&search_date_endyear='.urlencode((
string) ($search_date_endyear));
720if ($search_dfyear > 0) {
721 $param .=
'&search_dfyear='.urlencode((
string) ($search_dfyear));
723if ($search_dfmonth > 0) {
724 $param .=
'&search_dfmonth='.urlencode((
string) ($search_dfmonth));
726if ($search_signed_status !=
'' && $search_signed_status >= 0) {
727 $param .=
'&search_signed_status='.urlencode($search_signed_status);
729if ($search_sale > 0) {
730 $param .=
'&search_sale='.urlencode($search_sale);
732if ($search_user > 0) {
733 $param .=
'&search_user='.urlencode((
string) ($search_user));
735if ($search_type_thirdparty > 0) {
736 $param .=
'&search_type_thirdparty='.urlencode((
string) ($search_type_thirdparty));
738if ($search_country !=
'') {
739 $param .=
"&search_country=".urlencode($search_country);
741if ($search_product_category > 0) {
742 $param .=
'&search_product_category='.urlencode((
string) ($search_product_category));
745 $param .=
'&show_files='.urlencode((
string) ($show_files));
747if ($optioncss !=
'') {
748 $param .=
'&optioncss='.urlencode($optioncss);
750foreach ($searchCategoryCustomerList as $searchCategoryCustomer) {
751 $param .=
"&search_category_customer_list[]=".urlencode($searchCategoryCustomer);
754include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
757$arrayofmassactions = array(
758 'generate_doc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"ReGeneratePDF"),
759 'builddoc' =>
img_picto(
'',
'pdf',
'class="pictofixedwidth"').$langs->trans(
"PDFMerge"),
760 'presend' =>
img_picto(
'',
'email',
'class="pictofixedwidth"').$langs->trans(
"SendByMail"),
762if (!empty($permissiontodelete)) {
763 $arrayofmassactions[
'predelete'] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"Delete");
765if (
GETPOSTINT(
'nomassaction') || in_array($massaction, array(
'presend',
'predelete'))) {
766 $arrayofmassactions = array();
768$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
770$url = DOL_URL_ROOT.
'/contrat/card.php?action=create';
772 $url .=
'&socid='.((int) $socid);
775$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'));
776$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'));
778$newcardbutton .=
dolGetButtonTitle($langs->trans(
'NewContractSubscription'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
'contrat',
'creer'));
780print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
'PHP_SELF'].
'">'.
"\n";
781if ($optioncss !=
'') {
782 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
784print
'<input type="hidden" name="token" value="'.newToken().
'">';
785print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
786print
'<input type="hidden" name="action" value="list">';
787print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
788print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
789print
'<input type="hidden" name="page" value="'.$page.
'">';
790print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
791print
'<input type="hidden" name="page_y" value="">';
792print
'<input type="hidden" name="mode" value="'.$mode.
'">';
795print_barre_liste($langs->trans(
"Contracts"), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0, $newcardbutton,
'', $limit, 0, 0, 1);
797$topicmail =
"SendContractRef";
798$modelmail =
"contract";
800$trackid =
'con'.$object->id;
801include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
805 foreach ($fieldstosearchall as $key => $val) {
806 $fieldstosearchall[$key] = $langs->trans($val);
807 $setupstring .= $key.
"=".$val.
";";
809 print
'<!-- Search done like if CONTRACT_QUICKSEARCH_ON_FIELDS = '.$setupstring.
' -->'.
"\n";
810 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $search_all).implode(
', ', $fieldstosearchall).
'</div>'.
"\n";
816if ($user->hasRight(
'user',
'user',
'lire')) {
817 $langs->load(
"commercial");
818 $moreforfilter .=
'<div class="divsearchfield">';
819 $tmptitle = $langs->trans(
'ThirdPartiesOfSaleRepresentative');
820 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, $tmptitle,
'widthcentpercentminusx maxwidth300');
821 $moreforfilter .=
'</div>';
824if ($user->hasRight(
'user',
'user',
'lire')) {
825 $moreforfilter .=
'<div class="divsearchfield">';
826 $tmptitle = $langs->trans(
'LinkedToSpecificUsers');
827 $moreforfilter .=
img_picto($tmptitle,
'user',
'class="pictofixedwidth"').$form->select_dolusers($search_user,
'search_user', $tmptitle,
null, 0,
'',
'',
'0', 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
828 $moreforfilter .=
'</div>';
831if (isModEnabled(
'category') && $user->hasRight(
'categorie',
'lire') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
832 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
833 $moreforfilter .=
'<div class="divsearchfield">';
834 $tmptitle = $langs->trans(
'IncludingProductWithTag');
835 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 2);
836 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx maxwidth300', 1);
837 $moreforfilter .=
'</div>';
840if (
getDolGlobalString(
'MAIN_SEARCH_CATEGORY_CUSTOMER_ON_CONTRACT_LIST') && isModEnabled(
"category") && $user->hasRight(
'categorie',
'lire')) {
841 $moreforfilter .=
'<div class="divsearchfield">';
842 $tmptitle = $langs->transnoentities(
'CustomersProspectsCategoriesShort');
843 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"');
844 $categoriesArr = $form->select_all_categories(Categorie::TYPE_CUSTOMER,
'',
'', 64, 0, 2);
845 $categoriesArr[-2] =
'- '.$langs->trans(
'NotCategorized').
' -';
846 $moreforfilter .=
Form::multiselectarray(
'search_category_customer_list', $categoriesArr, $searchCategoryCustomerList, 0, 0,
'minwidth300', 0, 0,
'',
'category', $tmptitle);
847 $moreforfilter .=
' <input type="checkbox" class="valignmiddle" id="search_category_customer_operator" name="search_category_customer_operator" value="1"'.($searchCategoryCustomerOperator == 1 ?
' checked="checked"' :
'').
'/>';
848 $moreforfilter .= $form->textwithpicto(
'', $langs->trans(
'UseOrOperatorForCategories') .
' : ' . $tmptitle, 1,
'help',
'', 0, 2,
'tooltip_cat_cus');
849 $moreforfilter .=
'</div>';
852$parameters = array();
853$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
854if (empty($reshook)) {
855 $moreforfilter .= $hookmanager->resPrint;
857 $moreforfilter = $hookmanager->resPrint;
860if (!empty($moreforfilter)) {
861 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
862 print $moreforfilter;
866$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
867$selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
868if ($massactionbutton) {
869 $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
872print
'<div class="div-table-responsive">';
873print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
877print
'<tr class="liste_titre_filter">';
880 print
'<td class="liste_titre maxwidthsearch center">';
881 $searchpicto = $form->showFilterButtons(
'left');
885if (!empty($arrayfields[
'c.ref'][
'checked'])) {
886 print
'<td class="liste_titre">';
887 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
890if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
891 print
'<td class="liste_titre">';
892 print
'<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
895if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
896 print
'<td class="liste_titre">';
897 print
'<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
900if (!empty($arrayfields[
's.nom'][
'checked'])) {
901 print
'<td class="liste_titre">';
902 print
'<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).
'"'.($user->socid > 0 ?
" disabled" :
"").
'>';
905if (!empty($arrayfields[
's.email'][
'checked'])) {
906 print
'<td class="liste_titre">';
907 print
'<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
911if (!empty($arrayfields[
's.town'][
'checked'])) {
912 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.dol_escape_htmltag($search_town).
'"></td>';
915if (!empty($arrayfields[
's.zip'][
'checked'])) {
916 print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.dol_escape_htmltag($search_zip).
'"></td>';
919if (!empty($arrayfields[
'state.nom'][
'checked'])) {
920 print
'<td class="liste_titre">';
921 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
925if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
926 print
'<td class="liste_titre center">';
927 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
931if (!empty($arrayfields[
'typent.code'][
'checked'])) {
932 print
'<td class="liste_titre maxwidthonsmartphone center">';
933 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 1, 0, 0,
'', 0, 0, 0, (!
getDolGlobalString(
'SOCIETE_SORT_ON_TYPEENT') ?
'ASC' :
$conf->global->SOCIETE_SORT_ON_TYPEENT),
'', 1);
936if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
937 print
'<td class="liste_titre"></td>';
939if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
940 print
'<td class="liste_titre center">';
941 print
'<div class="nowrapfordate">';
942 print $form->selectDate($search_date_start ? $search_date_start : -1,
'search_date_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
944 print
'<div class="nowrapfordate">';
945 print $form->selectDate($search_date_end ? $search_date_end : -1,
'search_date_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
950if (!empty($arrayfields[
'c.signed_status'][
'checked'])) {
951 print
'<td class="liste_titre center">';
952 $list_signed_status =
$object->getSignedStatusLocalisedArray();
953 print $form->selectarray(
'search_signed_status', $list_signed_status, $search_signed_status, 1, 0, 0,
'', 1, 0, 0,
'',
'search_status');
957include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
960$parameters = array(
'arrayfields' => $arrayfields);
961$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
962print $hookmanager->resPrint;
964if (!empty($arrayfields[
'c.datec'][
'checked'])) {
965 print
'<td class="liste_titre center nowraponall">';
966 print
'<div class="nowrapfordate">';
967 print $form->selectDate($search_date_creation_start ? $search_date_creation_start : -1,
'search_date_creation_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
969 print
'<div class="nowrapfordate">';
970 print $form->selectDate($search_date_creation_end ? $search_date_creation_end : -1,
'search_date_creation_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
975if (!empty($arrayfields[
'c.tms'][
'checked'])) {
976 print
'<td class="liste_titre center nowraponall">';
977 print
'<div class="nowrapfordate">';
978 print $form->selectDate($search_date_modif_start ? $search_date_modif_start : -1,
'search_date_modif_start', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'From'));
980 print
'<div class="nowrapfordate">';
981 print $form->selectDate($search_date_modif_end ? $search_date_modif_end : -1,
'search_date_modif_end', 0, 0, 1,
'', 1, 0, 0,
'',
'',
'',
'', 1,
'', $langs->trans(
'to'));
986if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
987 print
'<td class="liste_titre nowraponall center">';
988 $arrayofoperators = array(
'0' =>
'',
'=' =>
'=',
'<=' =>
'<=',
'>=' =>
'>=');
989 print $form->selectarray(
'search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth50imp');
991 print $formother->select_month($search_dfmonth,
'search_dfmonth', 1, 0);
993 print $formother->selectyear($search_dfyear,
'search_dfyear', 1, 20, 5, 0, 0,
'');
997if (!empty($arrayfields[
'status'][
'checked'])) {
998 print
'<td class="liste_titre right" colspan="4"></td>';
1003 print
'<td class="liste_titre center">';
1004 $searchpicto = $form->showFilterButtons();
1015print
'<tr class="liste_titre">';
1017 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1020if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1022 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
'', $sortfield, $sortorder);
1025if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
1026 print_liste_field_titre($arrayfields[
'c.ref_customer'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_customer",
"", $param,
'', $sortfield, $sortorder);
1029if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
1030 print_liste_field_titre($arrayfields[
'c.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_supplier",
"", $param,
'', $sortfield, $sortorder);
1033if (!empty($arrayfields[
's.nom'][
'checked'])) {
1034 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
1037if (!empty($arrayfields[
's.email'][
'checked'])) {
1038 print_liste_field_titre($arrayfields[
's.email'][
'label'], $_SERVER[
"PHP_SELF"],
"s.email",
"", $param,
'', $sortfield, $sortorder);
1041if (!empty($arrayfields[
's.town'][
'checked'])) {
1042 print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
1045if (!empty($arrayfields[
's.zip'][
'checked'])) {
1046 print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
1049if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1050 print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
1053if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1054 print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
1057if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1058 print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
1061if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1062 print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder);
1065if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
1066 print_liste_field_titre($arrayfields[
'c.date_contrat'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_contrat",
"", $param,
'', $sortfield, $sortorder,
'center ');
1069if (!empty($arrayfields[
'c.signed_status'][
'checked'])) {
1070 print_liste_field_titre($arrayfields[
'c.signed_status'][
'label'], $_SERVER[
"PHP_SELF"],
"c.signed_status",
"", $param,
'', $sortfield, $sortorder,
'center ');
1074include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
1076$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder,
'totalarray' => &$totalarray);
1077$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
1078print $hookmanager->resPrint;
1079if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1080 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1083if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1084 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
1087if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
1088 print_liste_field_titre($arrayfields[
'lower_planned_end_date'][
'label'], $_SERVER[
"PHP_SELF"],
"lower_planned_end_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
1091if (!empty($arrayfields[
'status'][
'checked'])) {
1092 print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
1094 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
1096 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
1098 print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
1102 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
1113$typenArray = array();
1114$cacheCountryIDCode = array();
1115$imaxinloop = ($limit ? min($num, $limit) : $num);
1116while ($i < $imaxinloop) {
1117 $obj = $db->fetch_object($resql);
1122 $contracttmp->ref = $obj->ref;
1123 $contracttmp->id = $obj->rowid;
1124 $contracttmp->ref_customer = $obj->ref_customer;
1125 $contracttmp->ref_supplier = $obj->ref_supplier;
1127 $contracttmp->nbofserviceswait = $obj->nb_initial;
1128 $contracttmp->nbofservicesopened = $obj->nb_running;
1129 $contracttmp->nbofservicesexpired = $obj->nb_expired;
1130 $contracttmp->nbofservicesclosed = $obj->nb_closed;
1131 $contracttmp->signed_status = $obj->signed_status;
1133 $socstatic->id = $obj->socid;
1134 $socstatic->name = $obj->name;
1135 $socstatic->name_alias = $obj->name_alias;
1136 $socstatic->email = $obj->email;
1137 $socstatic->status = $obj->company_status;
1138 $socstatic->logo = $obj->company_logo;
1139 $socstatic->country_id = $obj->country_id;
1140 $socstatic->country_code =
'';
1141 $socstatic->country =
'';
1143 if ($obj->country_id > 0) {
1144 if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
1145 $tmparray =
getCountry($obj->country_id,
'all');
1146 $cacheCountryIDCode[$obj->country_id] = array(
'code' => empty($tmparray[
'code']) ?
'' : $tmparray[
'code'],
'label' => empty($tmparray[
'label']) ?
'' : $tmparray[
'label']);
1148 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
1149 $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
1152 if ($mode ==
'kanban') {
1154 print
'<tr class="trkanban"><td colspan="'.$savnbfield.
'">';
1155 print
'<div class="box-flex-container kanban">';
1158 $arraydata = array();
1159 $arraydata[
'thirdparty'] = $socstatic;
1160 $arraydata[
'selected'] = in_array($obj->rowid, $arrayofselected);
1161 $contracttmp->date_contrat = $obj->date_contrat;
1162 print $contracttmp->getKanbanView(
'', $arraydata);
1163 if ($i == ($imaxinloop - 1)) {
1169 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
1172 print
'<td class="nowrap center">';
1173 if ($massactionbutton || $massaction) {
1175 if (in_array($obj->rowid, $arrayofselected)) {
1178 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1186 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
1187 print
'<td class="nowraponall">';
1188 print $contracttmp->getNomUrl(1);
1189 if ($obj->nb_late) {
1192 if (!empty($obj->note_private) || !empty($obj->note_public)) {
1193 print
' <span class="note">';
1194 print
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'note').
'</a>';
1200 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
1201 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
1211 if (!empty($arrayfields[
'c.ref_customer'][
'checked'])) {
1212 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag(
dol_string_nohtmltag($contracttmp->getFormatedCustomerRef($obj->ref_customer))).
'">'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
1217 if (!empty($arrayfields[
'c.ref_supplier'][
'checked'])) {
1218 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->ref_supplier).
'">'.
dol_escape_htmltag($obj->ref_supplier).
'</td>';
1220 if (!empty($arrayfields[
's.nom'][
'checked'])) {
1221 print
'<td class="tdoverflowmax150">';
1222 if ($obj->socid > 0) {
1224 print $socstatic->getNomUrl(1,
'');
1229 if (!empty($arrayfields[
's.email'][
'checked'])) {
1230 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($obj->email).
'">'.
dol_print_email($obj->email, 0, $obj->socid, 1, 0, 1, 1).
'</td>';
1233 if (!empty($arrayfields[
's.town'][
'checked'])) {
1234 print
'<td class="nocellnopadd">';
1242 if (!empty($arrayfields[
's.zip'][
'checked'])) {
1243 print
'<td class="center nocellnopadd">';
1251 if (!empty($arrayfields[
'state.nom'][
'checked'])) {
1252 print
"<td>".$obj->state_name.
"</td>\n";
1258 if (!empty($arrayfields[
'country.code_iso'][
'checked'])) {
1259 print
'<td class="center tdoverflowmax100" title="'.dol_escape_htmltag($socstatic->country).
'">';
1267 if (!empty($arrayfields[
'typent.code'][
'checked'])) {
1268 print
'<td class="center">';
1269 if (count($typenArray) == 0) {
1270 $typenArray = $formcompany->typent_array(1);
1272 print $typenArray[$obj->typent_code];
1278 if (!empty($arrayfields[
'sale_representative'][
'checked'])) {
1281 if ($obj->socid > 0) {
1282 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
1283 if ($listsalesrepresentatives < 0) {
1286 $nbofsalesrepresentative = count($listsalesrepresentatives);
1287 if ($nbofsalesrepresentative > 6) {
1289 print $nbofsalesrepresentative;
1290 } elseif ($nbofsalesrepresentative > 0) {
1291 $userstatic =
new User($db);
1293 foreach ($listsalesrepresentatives as $val) {
1294 $userstatic->id = $val[
'id'];
1295 $userstatic->lastname = $val[
'lastname'];
1296 $userstatic->firstname = $val[
'firstname'];
1297 $userstatic->email = $val[
'email'];
1298 $userstatic->status = $val[
'statut'];
1299 $userstatic->entity = $val[
'entity'];
1300 $userstatic->photo = $val[
'photo'];
1301 $userstatic->login = $val[
'login'];
1302 $userstatic->phone = $val[
'phone'];
1303 $userstatic->job = $val[
'job'];
1304 $userstatic->gender = $val[
'gender'];
1307 print ($nbofsalesrepresentative < 2) ? $userstatic->getNomUrl(-1,
'', 0, 0, 12) : $userstatic->getNomUrl(-2);
1309 if ($j < $nbofsalesrepresentative) {
1322 if (!empty($arrayfields[
'c.date_contrat'][
'checked'])) {
1323 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat),
'day',
'tzserver').
'</td>';
1326 if (!empty($arrayfields[
'c.signed_status'][
'checked'])) {
1327 print
'<td class="center">'.$contracttmp->getLibSignedStatus(5).
'</td>';
1333 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1335 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1336 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $object, $action);
1337 print $hookmanager->resPrint;
1339 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
1340 print
'<td class="center nowrap">';
1341 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1348 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
1349 print
'<td class="center nowrap">';
1350 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
1357 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
1358 print
'<td class="center nowrapforall">';
1359 print
dol_print_date($db->jdate($obj->lower_planned_end_date),
'day',
'tzuser');
1366 if (!empty($arrayfields[
'status'][
'checked'])) {
1367 print
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial :
'').
'</td>';
1368 print
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running :
'').
'</td>';
1369 print
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired :
'').
'</td>';
1370 print
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed :
'').
'</td>';
1380 print
'<td class="nowrap center">';
1381 if ($massactionbutton || $massaction) {
1383 if (in_array($obj->rowid, $arrayofselected)) {
1386 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1402 foreach ($arrayfields as $key => $val) {
1403 if (!empty($val[
'checked'])) {
1407 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1412$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1413$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1414print $hookmanager->resPrint;
1416print
'</table>'.
"\n";
1419print
'</form>'.
"\n";
1421$hidegeneratedfilelistifempty = 1;
1422if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) {
1423 $hidegeneratedfilelistifempty = 0;
1427$urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
1428$urlsource .= str_replace(
'&',
'&', $param);
1430$filedir = $diroutputmassaction;
1431$genallowed = $permissiontoread;
1432$delallowed = $permissiontoadd;
1434print $formfile->showdocuments(
'massfilesarea_contract',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'',
null, $hidegeneratedfilelistifempty);
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage lines of contracts.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
dol_print_email($email, $cid=0, $socid=0, $addlink=0, $max=64, $showinvalid=1, $withpicto=0, $morecss='paddingrightonly')
Show EMail link formatted for HTML output.
dolGetButtonTitleSeparator($moreClass="")
Add space between dolGetButtonTitle.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.