32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
40 $langs->loadLangs(array(
'contracts',
'products',
'companies',
'compta'));
42 $action =
GETPOST(
'action',
'aZ09');
43 $massaction =
GETPOST(
'massaction',
'alpha');
44 $show_files =
GETPOST(
'show_files',
'int');
45 $confirm =
GETPOST(
'confirm',
'alpha');
46 $toselect =
GETPOST(
'toselect',
'array');
47 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractlist';
49 $search_name =
GETPOST(
'search_name',
'alpha');
50 $search_email =
GETPOST(
'search_email',
'alpha');
51 $search_town =
GETPOST(
'search_town',
'alpha');
52 $search_zip =
GETPOST(
'search_zip',
'alpha');
53 $search_state =
GETPOST(
"search_state",
'alpha');
54 $search_country =
GETPOST(
"search_country",
'int');
55 $search_type_thirdparty =
GETPOST(
"search_type_thirdparty",
'int');
56 $search_contract =
GETPOST(
'search_contract',
'alpha');
57 $search_ref_customer =
GETPOST(
'search_ref_customer',
'alpha');
58 $search_ref_supplier =
GETPOST(
'search_ref_supplier',
'alpha');
59 $sall = (
GETPOST(
'search_all',
'alphanohtml') !=
'') ?
GETPOST(
'search_all',
'alphanohtml') :
GETPOST(
'sall',
'alphanohtml');
60 $search_status =
GETPOST(
'search_status',
'alpha');
61 $socid =
GETPOST(
'socid',
'int');
62 $search_user =
GETPOST(
'search_user',
'int');
63 $search_sale =
GETPOST(
'search_sale',
'int');
64 $search_product_category =
GETPOST(
'search_product_category',
'int');
65 $search_dfmonth =
GETPOST(
'search_dfmonth',
'int');
66 $search_dfyear =
GETPOST(
'search_dfyear',
'int');
67 $search_op2df =
GETPOST(
'search_op2df',
'alpha');
70 $month =
GETPOST(
"month",
"int");
72 $optioncss =
GETPOST(
'optioncss',
'alpha');
74 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
75 $sortfield =
GETPOST(
"sortfield",
'alpha');
76 $sortorder =
GETPOST(
"sortorder",
'alpha');
78 if (empty($page) || $page == -1) { $page = 0; }
79 $offset = $limit * $page;
80 $pageprev = $page - 1;
81 $pagenext = $page + 1;
82 if (!$sortfield) $sortfield =
'c.ref';
83 if (!$sortorder) $sortorder =
'DESC';
87 if ($user->socid) $socid = $user->socid;
90 $diroutputmassaction = $conf->contrat->dir_output.
'/temp/massgeneration/'.$user->id;
92 $staticcontrat =
new Contrat($db);
95 if ($search_status ==
'') $search_status = 1;
99 $hookmanager->initHooks(array(
'contractlist'));
103 $extrafields->fetch_name_optionals_label($object->table_element);
105 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
107 $fieldstosearchall = array(
109 'c.ref_customer'=>
'RefCustomer',
110 'c.ref_supplier'=>
'RefSupplier',
111 's.nom'=>
"ThirdParty",
112 'c.note_public'=>
'NotePublic',
114 if (empty($user->socid)) $fieldstosearchall[
"c.note_private"] =
"NotePrivate";
116 $arrayfields = array(
117 'c.ref'=>array(
'label'=>$langs->trans(
"Ref"),
'checked'=>1,
'position'=>10),
118 'c.ref_customer'=>array(
'label'=>$langs->trans(
"RefCustomer"),
'checked'=>1,
'position'=>12),
119 'c.ref_supplier'=>array(
'label'=>$langs->trans(
"RefSupplier"),
'checked'=>1,
'position'=>14),
120 's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1,
'position'=>30),
121 's.email'=>array(
'label'=>$langs->trans(
"ThirdPartyEmail"),
'checked'=>0,
'position'=>30),
122 's.town'=>array(
'label'=>$langs->trans(
"Town"),
'checked'=>0,
'position'=>31),
123 's.zip'=>array(
'label'=>$langs->trans(
"Zip"),
'checked'=>0,
'position'=>32),
124 'state.nom'=>array(
'label'=>$langs->trans(
"StateShort"),
'checked'=>0,
'position'=>33),
125 'country.code_iso'=>array(
'label'=>$langs->trans(
"Country"),
'checked'=>0,
'position'=>34),
126 'sale_representative'=>array(
'label'=>$langs->trans(
"SaleRepresentativesOfThirdParty"),
'checked'=>1,
'position'=>80),
127 'c.date_contrat'=>array(
'label'=>$langs->trans(
"DateContract"),
'checked'=>1,
'position'=>45),
128 'c.datec'=>array(
'label'=>$langs->trans(
"DateCreation"),
'checked'=>0,
'position'=>500),
129 'c.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500),
130 'lower_planned_end_date'=>array(
'label'=>$langs->trans(
"LowerDateEndPlannedShort"),
'checked'=>1,
'position'=>900,
'help'=>$langs->trans(
"LowerDateEndPlannedShort")),
131 'status'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1,
'position'=>1000),
134 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
144 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
145 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') { $massaction =
''; }
147 $parameters = array(
'socid'=>$socid);
148 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
149 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
151 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
154 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
159 $search_dfmonth =
'';
168 $search_country =
'';
169 $search_contract =
"";
170 $search_ref_customer =
"";
171 $search_ref_supplier =
"";
174 $search_product_category =
'';
178 $search_array_options = array();
183 $objectclass =
'Contrat';
184 $objectlabel =
'Contracts';
185 $permissiontoread = $user->rights->contrat->lire;
186 $permissiontodelete = $user->rights->contrat->supprimer;
187 $uploaddir = $conf->contrat->dir_output;
188 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
197 $form =
new Form($db);
201 $contracttmp =
new Contrat($db);
204 $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,";
205 $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,';
206 $sql .=
" typent.code as typent_code,";
207 $sql .=
" state.code_departement as state_code, state.nom as state_name,";
208 $sql .=
" MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") as lower_planned_end_date,";
209 $sql .=
' SUM('.$db->ifsql(
"cd.statut=0", 1, 0).
') as nb_initial,';
210 $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,';
211 $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,';
212 $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,';
213 $sql .=
' SUM('.$db->ifsql(
"cd.statut=5", 1, 0).
') as nb_closed';
215 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
216 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
219 $parameters = array();
220 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
221 $sql .= $hookmanager->resPrint;
222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
223 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as country on (country.rowid = s.fk_pays)";
224 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_typent as typent on (typent.id = s.fk_typent)";
225 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_departements as state on (state.rowid = s.fk_departement)";
226 if ($search_sale > 0 || (!$user->rights->societe->client->voir && !$socid)) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
227 $sql .=
", ".MAIN_DB_PREFIX.
"contrat as c";
228 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (c.rowid = ef.fk_object)";
229 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"contratdet as cd ON c.rowid = cd.fk_contrat";
230 if ($search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
231 if ($search_user > 0)
233 $sql .=
", ".MAIN_DB_PREFIX.
"element_contact as ec";
234 $sql .=
", ".MAIN_DB_PREFIX.
"c_type_contact as tc";
236 $sql .=
" WHERE c.fk_soc = s.rowid ";
237 $sql .=
' AND c.entity IN ('.getEntity(
'contract').
')';
238 if ($search_product_category > 0) $sql .=
" AND cp.fk_categorie = ".$search_product_category;
239 if ($socid) $sql .=
" AND s.rowid = ".$db->escape($socid);
240 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
243 if ($search_email) $sql .=
natural_search(
's.email', $search_email);
244 if ($search_contract) $sql .=
natural_search(array(
'c.rowid',
'c.ref'), $search_contract);
245 if (!empty($search_ref_customer)) $sql .=
natural_search(array(
'c.ref_customer'), $search_ref_customer);
246 if (!empty($search_ref_supplier)) $sql .=
natural_search(array(
'c.ref_supplier'), $search_ref_supplier);
247 if ($search_sale > 0)
249 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$search_sale;
251 if ($sall) $sql .=
natural_search(array_keys($fieldstosearchall), $sall);
252 if ($search_user > 0) $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 = ".$search_user;
254 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
256 $parameters = array();
257 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
258 $sql .= $hookmanager->resPrint;
259 $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,";
260 $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,';
261 $sql .=
" typent.code,";
262 $sql .=
" state.code_departement, state.nom";
264 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
265 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key :
'');
268 $parameters = array();
269 $reshook = $hookmanager->executeHooks(
'printFieldListGroupBy', $parameters);
270 $sql .= $hookmanager->resPrint;
271 if ($search_dfyear > 0 && $search_op2df)
273 if ($search_op2df ==
'<=') $sql .=
" HAVING MIN(".$db->ifsql(
"cd.statut=4",
"cd.date_fin_validite",
"null").
") <= '".$db->idate(
dol_get_last_day($search_dfyear, $search_dfmonth,
false)).
"'";
274 elseif ($search_op2df ==
'>=') $sql .= " HAVING MIN(".$db->ifsql("cd.
statut=4", "cd.date_fin_validite", "null").") >= '".$db->idate(
dol_get_first_day($search_dfyear, $search_dfmonth, false))."'";
275 else $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))."'";
277 $sql .= $db->order($sortfield, $sortorder);
281 $result = $db->query($sql);
284 $totalnboflines = $db->num_rows($result);
287 $nbtotalofrecords =
'';
288 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
290 $result = $db->query($sql);
291 $nbtotalofrecords = $db->num_rows($result);
292 if (($page * $limit) > $nbtotalofrecords)
299 $sql .= $db->plimit($limit + 1, $offset);
301 $resql = $db->query($sql);
308 $num = $db->num_rows(
$resql);
311 if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $sall && !$page)
313 $obj = $db->fetch_object(
$resql);
315 header(
"Location: ".DOL_URL_ROOT.
'/contrat/card.php?id='.$id);
323 llxHeader(
'', $langs->trans(
"Contracts"));
327 $arrayofselected = is_array($toselect) ? $toselect : array();
333 if (empty($search_name)) $search_name = $soc->name;
337 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
338 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
339 if ($sall !=
'') $param .=
'&sall='.urlencode($sall);
340 if ($search_contract !=
'') $param .=
'&search_contract='.urlencode($search_contract);
341 if ($search_name !=
'') $param .=
'&search_name='.urlencode($search_name);
342 if ($search_email !=
'') $param .=
'&search_email='.urlencode($search_email);
343 if ($search_ref_customer !=
'') $param .=
'&search_ref_customer='.urlencode($search_ref_customer);
344 if ($search_ref_supplier !=
'') $param .=
'&search_ref_supplier='.urlencode($search_ref_supplier);
345 if ($search_op2df !=
'') $param .=
'&search_op2df='.urlencode($search_op2df);
346 if ($search_dfyear !=
'') $param .=
'&search_dfyear='.urlencode($search_dfyear);
347 if ($search_dfmonth !=
'') $param .=
'&search_dfmonth='.urlencode($search_dfmonth);
348 if ($search_sale !=
'') $param .=
'&search_sale='.urlencode($search_sale);
349 if ($search_user !=
'') $param .=
'&search_user='.urlencode($search_user);
350 if ($search_product_category !=
'') $param .=
'&search_product_category='.urlencode($search_product_category);
351 if ($show_files) $param .=
'&show_files='.urlencode($show_files);
352 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
354 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
357 $arrayofmassactions = array(
358 'generate_doc'=>$langs->trans(
"ReGeneratePDF"),
359 'builddoc'=>$langs->trans(
"PDFMerge"),
360 'presend'=>$langs->trans(
"SendByMail"),
362 if ($user->rights->contrat->supprimer) $arrayofmassactions[
'predelete'] =
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
363 if (in_array($massaction, array(
'presend',
'predelete'))) $arrayofmassactions = array();
364 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
366 $url = DOL_URL_ROOT.
'/contrat/card.php?action=create';
367 if (!empty($socid)) $url .=
'&socid='.$socid;
368 $newcardbutton =
dolGetButtonTitle($langs->trans(
'NewContractSubscription'),
'',
'fa fa-plus-circle', $url,
'', $user->rights->contrat->creer);
370 print '<form method="POST" action="'.$_SERVER[
'PHP_SELF'].
'">';
371 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
372 print '<input type="hidden" name="token" value="'.newToken().
'">';
373 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
374 print '<input type="hidden" name="action" value="list">';
375 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
376 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
377 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
379 print_barre_liste($langs->trans(
"ListOfContracts"), $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines,
'contract', 0, $newcardbutton,
'', $limit, 0, 0, 1);
381 $topicmail =
"SendContractRef";
382 $modelmail =
"contract";
384 $trackid =
'con'.$object->id;
385 include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
389 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
390 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
396 if ($user->rights->societe->client->voir || $socid)
398 $langs->load(
"commercial");
399 $moreforfilter .=
'<div class="divsearchfield">';
400 $moreforfilter .= $langs->trans(
'ThirdPartiesOfSaleRepresentative').
': ';
401 $moreforfilter .= $formother->select_salesrepresentatives($search_sale,
'search_sale', $user, 0, 1,
'maxwidth200');
402 $moreforfilter .=
'</div>';
405 if ($user->rights->user->user->lire)
407 $moreforfilter .=
'<div class="divsearchfield">';
408 $moreforfilter .= $langs->trans(
'LinkedToSpecificUsers').
': ';
409 $moreforfilter .= $form->select_dolusers($search_user,
'search_user', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth200');
410 $moreforfilter .=
'</div>';
413 if (!empty($conf->categorie->enabled) && $user->rights->categorie->lire && ($user->rights->produit->lire || $user->rights->service->lire))
415 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
416 $moreforfilter .=
'<div class="divsearchfield">';
417 $moreforfilter .= $langs->trans(
'IncludingProductWithTag').
': ';
418 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null,
'parent', null, null, 1);
419 $moreforfilter .= $form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, 1, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300', 1);
420 $moreforfilter .=
'</div>';
423 $parameters = array();
424 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
425 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
426 else $moreforfilter = $hookmanager->resPrint;
428 if (!empty($moreforfilter))
430 print '<div class="liste_titre liste_titre_bydiv centpercent">';
431 print $moreforfilter;
435 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
436 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
437 if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons(
'checkforselect', 1);
439 print '<div class="div-table-responsive">';
440 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
442 print '<tr class="liste_titre_filter">';
443 if (!empty($arrayfields[
'c.ref'][
'checked']))
445 print
'<td class="liste_titre">';
446 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
449 if (!empty($arrayfields[
'c.ref_customer'][
'checked']))
451 print
'<td class="liste_titre">';
452 print
'<input type="text" class="flat" size="6" name="search_ref_customer" value="'.dol_escape_htmltag($search_ref_customer).
'">';
455 if (!empty($arrayfields[
'c.ref_supplier'][
'checked']))
457 print
'<td class="liste_titre">';
458 print
'<input type="text" class="flat" size="6" name="search_ref_supplier" value="'.dol_escape_htmltag($search_ref_supplier).
'">';
461 if (!empty($arrayfields[
's.nom'][
'checked']))
463 print
'<td class="liste_titre">';
464 print
'<input type="text" class="flat" size="8" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
467 if (!empty($arrayfields[
's.email'][
'checked']))
469 print
'<td class="liste_titre">';
470 print
'<input type="text" class="flat" size="6" name="search_email" value="'.dol_escape_htmltag($search_email).
'">';
474 if (!empty($arrayfields[
's.town'][
'checked'])) print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_town" value="'.$search_town.
'"></td>';
476 if (!empty($arrayfields[
's.zip'][
'checked'])) print
'<td class="liste_titre"><input class="flat" type="text" size="6" name="search_zip" value="'.$search_zip.
'"></td>';
478 if (!empty($arrayfields[
'state.nom'][
'checked']))
480 print
'<td class="liste_titre">';
481 print
'<input class="flat" size="4" type="text" name="search_state" value="'.dol_escape_htmltag($search_state).
'">';
485 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
487 print
'<td class="liste_titre center">';
488 print $form->select_country($search_country,
'search_country',
'', 0,
'minwidth100imp maxwidth100');
492 if (!empty($arrayfields[
'typent.code'][
'checked']))
494 print
'<td class="liste_titre maxwidthonsmartphone center">';
495 print $form->selectarray(
"search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0,
'', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ?
'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT));
498 if (!empty($arrayfields[
'sale_representative'][
'checked']))
500 print
'<td class="liste_titre"></td>';
502 if (!empty($arrayfields[
'c.date_contrat'][
'checked']))
505 print
'<td class="liste_titre center nowraponall">';
507 if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="day" value="'.$day.
'">';
508 print
'<input class="flat width25 valignmiddle" type="text" maxlength="2" name="month" value="'.$month.
'">';
511 print $formother->selectyear($syear,
'year', 1, 20, 5);
515 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
518 $parameters = array(
'arrayfields'=>$arrayfields);
519 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
520 print $hookmanager->resPrint;
522 if (!empty($arrayfields[
'c.datec'][
'checked']))
524 print
'<td class="liste_titre">';
528 if (!empty($arrayfields[
'c.tms'][
'checked']))
530 print
'<td class="liste_titre">';
534 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked']))
536 print
'<td class="liste_titre nowraponall center">';
537 $arrayofoperators = array(
'0'=>
'',
'='=>
'=',
'<='=>
'<=',
'>='=>
'>=');
538 print $form->selectarray(
'search_op2df', $arrayofoperators, $search_op2df, 0, 0, 0,
'', 0, 0, 0,
'',
'maxwidth50imp');
540 print $formother->select_month($search_dfmonth,
'search_dfmonth', 1, 0);
542 $formother->select_year($search_dfyear,
'search_dfyear', 1, 20, 5, 0, 0,
'');
546 if (!empty($arrayfields[
'status'][
'checked']))
548 print
'<td class="liste_titre right" colspan="4"></td>';
550 print
'<td class="liste_titre center">';
551 $searchpicto = $form->showFilterButtons();
556 print
'<tr class="liste_titre">';
557 if (!empty($arrayfields[
'c.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
'', $sortfield, $sortorder);
558 if (!empty($arrayfields[
'c.ref_customer'][
'checked']))
print_liste_field_titre($arrayfields[
'c.ref_customer'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_customer",
"", $param,
'', $sortfield, $sortorder);
559 if (!empty($arrayfields[
'c.ref_supplier'][
'checked']))
print_liste_field_titre($arrayfields[
'c.ref_supplier'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref_supplier",
"", $param,
'', $sortfield, $sortorder);
560 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
'', $sortfield, $sortorder);
561 if (!empty($arrayfields[
's.email'][
'checked']))
print_liste_field_titre($arrayfields[
's.email'][
'label'], $_SERVER[
"PHP_SELF"],
"s.email",
"", $param,
'', $sortfield, $sortorder);
562 if (!empty($arrayfields[
's.town'][
'checked']))
print_liste_field_titre($arrayfields[
's.town'][
'label'], $_SERVER[
"PHP_SELF"],
's.town',
'', $param,
'', $sortfield, $sortorder);
563 if (!empty($arrayfields[
's.zip'][
'checked']))
print_liste_field_titre($arrayfields[
's.zip'][
'label'], $_SERVER[
"PHP_SELF"],
's.zip',
'', $param,
'', $sortfield, $sortorder);
564 if (!empty($arrayfields[
'state.nom'][
'checked']))
print_liste_field_titre($arrayfields[
'state.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"state.nom",
"", $param,
'', $sortfield, $sortorder);
565 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
print_liste_field_titre($arrayfields[
'country.code_iso'][
'label'], $_SERVER[
"PHP_SELF"],
"country.code_iso",
"", $param,
'', $sortfield, $sortorder,
'center ');
566 if (!empty($arrayfields[
'typent.code'][
'checked']))
print_liste_field_titre($arrayfields[
'typent.code'][
'label'], $_SERVER[
"PHP_SELF"],
"typent.code",
"", $param,
'', $sortfield, $sortorder,
'center ');
567 if (!empty($arrayfields[
'sale_representative'][
'checked']))
print_liste_field_titre($arrayfields[
'sale_representative'][
'label'], $_SERVER[
"PHP_SELF"],
"",
"", $param,
'', $sortfield, $sortorder);
568 if (!empty($arrayfields[
'c.date_contrat'][
'checked']))
print_liste_field_titre($arrayfields[
'c.date_contrat'][
'label'], $_SERVER[
"PHP_SELF"],
"c.date_contrat",
"", $param,
'', $sortfield, $sortorder,
'center ');
570 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
572 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
573 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
574 print $hookmanager->resPrint;
575 if (!empty($arrayfields[
'c.datec'][
'checked'])) {
576 print_liste_field_titre($arrayfields[
'c.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"c.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
578 if (!empty($arrayfields[
'c.tms'][
'checked'])) {
579 print_liste_field_titre($arrayfields[
'c.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"c.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
581 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked'])) {
582 print_liste_field_titre($arrayfields[
'lower_planned_end_date'][
'label'], $_SERVER[
"PHP_SELF"],
"lower_planned_end_date",
"", $param,
'', $sortfield, $sortorder,
'center ');
584 if (!empty($arrayfields[
'status'][
'checked'])) {
585 print_liste_field_titre($staticcontratligne->LibStatut(0, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
586 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 0,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
587 print_liste_field_titre($staticcontratligne->LibStatut(4, 3, 1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
588 print_liste_field_titre($staticcontratligne->LibStatut(5, 3, -1,
'class="nochangebackground"'),
'',
'',
'',
'',
'width="16"');
590 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
593 $totalarray = array();
594 $typenArray = array();
595 $cacheCountryIDCode = array();
597 while ($i < min($num, $limit))
599 $obj = $db->fetch_object(
$resql);
601 $contracttmp->ref = $obj->ref;
602 $contracttmp->id = $obj->rowid;
603 $contracttmp->ref_customer = $obj->ref_customer;
604 $contracttmp->ref_supplier = $obj->ref_supplier;
606 if ($obj->socid > 0) {
607 $result = $socstatic->fetch($obj->socid);
618 if ($obj->country_id > 0) {
619 if (!isset($cacheCountryIDCode[$obj->country_id][
'code'])) {
620 $tmparray =
getCountry($obj->country_id,
'all');
621 $cacheCountryIDCode[$obj->country_id] = array(
'code'=> empty($tmparray[
'code']) ?
'' : $tmparray[
'code'],
'label' => empty($tmparray[
'label']) ?
'' : $tmparray[
'label']);
623 $socstatic->country_code = $cacheCountryIDCode[$obj->country_id][
'code'];
624 $socstatic->country = $cacheCountryIDCode[$obj->country_id][
'label'];
628 print
'<tr class="oddeven">';
631 if (!empty($arrayfields[
'c.ref'][
'checked']))
633 print
'<td class="nowraponall">';
634 print $contracttmp->getNomUrl(1);
635 if ($obj->nb_late) print
img_warning($langs->trans(
"Late"));
636 if (!empty($obj->note_private) || !empty($obj->note_public)) {
637 print
' <span class="note">';
638 print
'<a href="'.DOL_URL_ROOT.
'/contrat/note.php?id='.$obj->rowid.
'&save_lastsearch_values=1">'.
img_picto($langs->trans(
"ViewPrivateNote"),
'note').
'</a>';
644 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
645 print $formfile->getDocumentsLink($contracttmp->element, $filename, $filedir);
651 if (!empty($arrayfields[
'c.ref_customer'][
'checked']))
653 print
'<td>'.$contracttmp->getFormatedCustomerRef($obj->ref_customer).
'</td>';
655 if (!empty($arrayfields[
'c.ref_supplier'][
'checked']))
657 print
'<td>'.$obj->ref_supplier.
'</td>';
659 if (!empty($arrayfields[
's.nom'][
'checked']))
661 print
'<td class="tdoverflowmax150">';
662 if ($obj->socid > 0) {
664 print $socstatic->getNomUrl(1,
'');
668 if (!empty($arrayfields[
's.email'][
'checked']))
670 print
'<td>'.$obj->email.
'</td>';
673 if (!empty($arrayfields[
's.town'][
'checked']))
675 print
'<td class="nocellnopadd">';
678 if (!$i) $totalarray[
'nbfield']++;
681 if (!empty($arrayfields[
's.zip'][
'checked']))
683 print
'<td class="nocellnopadd">';
686 if (!$i) $totalarray[
'nbfield']++;
689 if (!empty($arrayfields[
'state.nom'][
'checked']))
691 print
"<td>".$obj->state_name.
"</td>\n";
692 if (!$i) $totalarray[
'nbfield']++;
695 if (!empty($arrayfields[
'country.code_iso'][
'checked']))
697 print
'<td class="center">';
698 print $socstatic->country;
700 if (!$i) $totalarray[
'nbfield']++;
703 if (!empty($arrayfields[
'typent.code'][
'checked']))
705 print
'<td class="center">';
706 if (count($typenArray) == 0) $typenArray = $formcompany->typent_array(1);
707 print $typenArray[$obj->typent_code];
709 if (!$i) $totalarray[
'nbfield']++;
711 if (!empty($arrayfields[
'sale_representative'][
'checked']))
717 $listsalesrepresentatives = $socstatic->getSalesRepresentatives($user);
719 $nbofsalesrepresentative = count($listsalesrepresentatives);
720 if ($nbofsalesrepresentative > 3) {
722 print $nbofsalesrepresentative;
723 } elseif ($nbofsalesrepresentative > 0)
725 $userstatic =
new User($db);
727 foreach ($listsalesrepresentatives as $val)
729 $userstatic->id = $val[
'id'];
730 $userstatic->lastname = $val[
'lastname'];
731 $userstatic->firstname = $val[
'firstname'];
732 $userstatic->email = $val[
'email'];
733 $userstatic->statut = $val[
'statut'];
734 $userstatic->entity = $val[
'entity'];
735 $userstatic->photo = $val[
'photo'];
738 print $userstatic->getNomUrl(-2);
740 if ($j < $nbofsalesrepresentative) print
' ';
751 if (!empty($arrayfields[
'c.date_contrat'][
'checked']))
753 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_contrat),
'day',
'tzserver').
'</td>';
756 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
758 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
759 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
760 print $hookmanager->resPrint;
762 if (!empty($arrayfields[
'c.datec'][
'checked']))
764 print
'<td class="center nowrap">';
765 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
767 if (!$i) $totalarray[
'nbfield']++;
770 if (!empty($arrayfields[
'c.tms'][
'checked']))
772 print
'<td class="center nowrap">';
773 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
775 if (!$i) $totalarray[
'nbfield']++;
778 if (!empty($arrayfields[
'lower_planned_end_date'][
'checked']))
780 print
'<td class="center nowrapforall">';
781 print
dol_print_date($db->jdate($obj->lower_planned_end_date),
'day',
'tzuser');
783 if (!$i) $totalarray[
'nbfield']++;
786 if (!empty($arrayfields[
'status'][
'checked']))
788 print
'<td class="center">'.($obj->nb_initial > 0 ? $obj->nb_initial :
'').
'</td>';
789 print
'<td class="center">'.($obj->nb_running > 0 ? $obj->nb_running :
'').
'</td>';
790 print
'<td class="center">'.($obj->nb_expired > 0 ? $obj->nb_expired :
'').
'</td>';
791 print
'<td class="center">'.($obj->nb_closed > 0 ? $obj->nb_closed :
'').
'</td>';
794 print
'<td class="nowrap center">';
795 if ($massactionbutton || $massaction)
798 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
799 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
802 if (!$i) $totalarray[
'nbfield']++;
809 $parameters = array(
'arrayfields'=>$arrayfields,
'sql'=>$sql);
810 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
811 print $hookmanager->resPrint;
818 $hidegeneratedfilelistifempty = 1;
819 if ($massaction ==
'builddoc' || $action ==
'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
822 $urlsource = $_SERVER[
'PHP_SELF'].
'?sortfield='.$sortfield.
'&sortorder='.$sortorder;
823 $urlsource .= str_replace(
'&',
'&', $param);
825 $filedir = $diroutputmassaction;
826 $genallowed = $user->rights->contrat->lire;
827 $delallowed = $user->rights->contrat->lire;
829 print $formfile->showdocuments(
'massfilesarea_contract',
'', $filedir, $urlsource, 0, $delallowed,
'', 1, 1, 0, 48, 1, $param, $title,
'',
'',
'', null, $hidegeneratedfilelistifempty);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
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.
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
Class to manage contracts.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Class to manage lines of contracts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options= '', $sortfield= '', $sortorder= '', $morehtmlcenter= '', $num=-1, $totalnboflines= '', $picto= 'generic', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow= '')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
print $_SERVER["PHP_SELF"]
Edit parameters.
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...
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.