30 require
"../main.inc.php";
31 require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
32 require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
33 require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
36 $langs->loadLangs(array(
'products',
'contracts',
'companies'));
38 $optioncss =
GETPOST(
'optioncss',
'aZ09');
40 $massaction =
GETPOST(
'massaction',
'alpha');
41 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
42 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
43 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
45 if (empty($page) || $page == -1) {
48 $offset = $limit * $page;
49 $pageprev = $page - 1;
50 $pagenext = $page + 1;
52 $sortfield =
"c.rowid";
60 $search_name =
GETPOST(
"search_name",
'alpha');
61 $search_contract =
GETPOST(
"search_contract",
'alpha');
62 $search_service =
GETPOST(
"search_service",
'alpha');
63 $search_status =
GETPOST(
"search_status",
'alpha');
64 $search_product_category =
GETPOST(
'search_product_category',
'int');
65 $socid =
GETPOST(
'socid',
'int');
66 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractservicelist'.$mode;
68 $opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
69 $opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
70 $opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
71 $filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue');
73 $op1month =
GETPOST(
'op1month',
'int');
74 $op1day =
GETPOST(
'op1day',
'int');
75 $op1year =
GETPOST(
'op1year',
'int');
76 $filter_op1 =
GETPOST(
'filter_op1',
'alpha');
78 $op2month =
GETPOST(
'op2month',
'int');
79 $op2day =
GETPOST(
'op2day',
'int');
80 $op2year =
GETPOST(
'op2year',
'int');
81 $filter_op2 =
GETPOST(
'filter_op2',
'alpha');
83 $opcloturemonth =
GETPOST(
'opcloturemonth',
'int');
84 $opclotureday =
GETPOST(
'opclotureday',
'int');
85 $opclotureyear =
GETPOST(
'opclotureyear',
'int');
86 $filter_opcloture =
GETPOST(
'filter_opcloture',
'alpha');
91 $hookmanager->initHooks(array(
'contractservicelist'));
95 $extrafields->fetch_name_optionals_label($object->table_element);
97 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
100 $contratid =
GETPOST(
'id',
'int');
101 if (!empty($user->socid)) {
102 $socid = $user->socid;
106 if ($search_status !=
'') {
107 $tmp = explode(
'&', $search_status);
109 if (empty($tmp[1])) {
112 if ($tmp[1] ==
'filter=notexpired') {
113 $filter =
'notexpired';
115 if ($tmp[1] ==
'filter=expired') {
120 $search_status = $mode;
121 if ($filter ==
'expired') {
122 $search_status .=
'&filter=expired';
124 if ($filter ==
'notexpired') {
125 $search_status .=
'&filter=notexpired';
129 $staticcontrat =
new Contrat($db);
131 $companystatic =
new Societe($db);
133 $arrayfields = array(
134 'c.ref'=>array(
'label'=>
"Contract",
'checked'=>1,
'position'=>80),
135 'p.description'=>array(
'label'=>
"Service",
'checked'=>1,
'position'=>80),
136 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>90),
137 'cd.tva_tx'=>array(
'label'=>
"VATRate",
'checked'=>-1,
'position'=>100),
138 'cd.subprice'=>array(
'label'=>
"PriceUHT",
'checked'=>-1,
'position'=>105),
139 'cd.qty'=>array(
'label'=>
"Qty",
'checked'=>-1,
'position'=>108),
140 'cd.total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>-1,
'position'=>109),
141 'cd.total_tva'=>array(
'label'=>
"TotalVAT",
'checked'=>-1,
'position'=>110),
142 'cd.date_ouverture_prevue'=>array(
'label'=>
"DateStartPlannedShort",
'checked'=>(($mode ==
"" || $mode == -1) || $mode ==
"0"),
'position'=>150),
143 'cd.date_ouverture'=>array(
'label'=>
"DateStartRealShort",
'checked'=>(($mode ==
"" || $mode == -1) || $mode > 0),
'position'=>160),
144 'cd.date_fin_validite'=>array(
'label'=>
"DateEndPlannedShort",
'checked'=>(($mode ==
"" || $mode == -1) || $mode < 5),
'position'=>170),
145 'cd.date_cloture'=>array(
'label'=>
"DateEndRealShort",
'checked'=>(($mode ==
"" || $mode == -1) || $mode >= 5),
'position'=>180),
147 'cd.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
148 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
151 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
163 if (
GETPOST(
'cancel',
'alpha')) {
164 $action =
'list'; $massaction =
'';
166 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
170 $parameters = array(
'socid'=>$socid);
171 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
176 if (empty($reshook)) {
178 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
180 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
181 $search_product_category = 0;
183 $search_contract =
"";
184 $search_service =
"";
186 $opouvertureprevuemonth =
"";
187 $opouvertureprevueday =
"";
188 $opouvertureprevueyear =
"";
189 $filter_opouvertureprevue =
"";
198 $opcloturemonth =
"";
201 $filter_opcloture =
"";
205 $search_array_options = array();
218 $sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
219 $sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
220 $sql .=
" cd.rowid, cd.description, cd.statut,";
221 $sql .=
" p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.tobuy, p.tosell, p.barcode, p.entity as pentity,";
222 if (empty($user->rights->societe->client->voir) && !$socid) {
223 $sql .=
" sc.fk_soc, sc.fk_user,";
225 $sql .=
" cd.date_ouverture_prevue,";
226 $sql .=
" cd.date_ouverture,";
227 $sql .=
" cd.date_fin_validite,";
228 $sql .=
" cd.date_cloture,";
230 $sql .=
" cd.total_ht,";
231 $sql .=
" cd.total_tva,";
232 $sql .=
" cd.tva_tx,";
233 $sql .=
" cd.subprice,";
235 $sql .=
" cd.tms as date_update";
237 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
238 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
239 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
243 $parameters = array();
244 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
245 $sql .= $hookmanager->resPrint;
246 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
247 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
248 if (empty($user->rights->societe->client->voir) && !$socid) {
249 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
251 $sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
252 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
253 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
255 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
256 if ($search_product_category > 0) {
257 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
259 $sql .=
" WHERE c.entity = ".$conf->entity;
260 $sql .=
" AND c.rowid = cd.fk_contrat";
261 if ($search_product_category > 0) {
262 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
264 $sql .=
" AND c.fk_soc = s.rowid";
265 if (empty($user->rights->societe->client->voir) && !$socid) {
266 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
269 $sql .=
" AND cd.statut = 0";
272 $sql .=
" AND cd.statut = 4";
275 $sql .=
" AND cd.statut = 5";
277 if ($filter ==
"expired") {
278 $sql .=
" AND cd.date_fin_validite < '".$db->idate($now).
"'";
280 if ($filter ==
"notexpired") {
281 $sql .=
" AND cd.date_fin_validite >= '".$db->idate($now).
"'";
284 $sql .=
" AND s.nom LIKE '%".$db->escape($search_name).
"%'";
286 if ($search_contract) {
287 $sql .=
" AND c.ref LIKE '%".$db->escape($search_contract).
"%' ";
289 if ($search_service) {
290 $sql .=
" AND (p.ref LIKE '%".$db->escape($search_service).
"%' OR p.description LIKE '%".$db->escape($search_service).
"%' OR cd.description LIKE '%".$db->escape($search_service).
"%')";
293 $sql .=
" AND s.rowid = ".((int) $socid);
296 $filter_dateouvertureprevue =
'';
299 $filter_opcloture =
'';
301 $filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
302 $filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
303 if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
304 $filter_opouvertureprevue =
' BETWEEN ';
307 $filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
308 $filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
309 if ($filter_date1_start !=
'' && $filter_op1 == -1) {
310 $filter_op1 =
' BETWEEN ';
313 $filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
314 $filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
315 if ($filter_date2_start !=
'' && $filter_op2 == -1) {
316 $filter_op2 =
' BETWEEN ';
319 $filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
320 $filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
321 if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
322 $filter_opcloture =
' BETWEEN ';
325 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
326 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
328 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
329 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
331 if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
332 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
334 if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
335 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
337 if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
338 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
340 if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
341 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
343 if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
344 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
346 if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
347 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
350 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
351 $sql .= $db->order($sortfield, $sortorder);
356 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
357 $result = $db->query($sql);
365 $sql .= $db->plimit($limit + 1, $offset);
368 dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
369 $resql = $db->query($sql);
375 $num = $db->num_rows(
$resql);
386 llxHeader(
null, $langs->trans(
"Services"));
389 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
390 $param .=
'&contextpage='.urlencode($contextpage);
392 if ($limit > 0 && $limit != $conf->liste_limit) {
393 $param .=
'&limit='.$limit;
395 if ($search_contract) {
396 $param .=
'&search_contract='.urlencode($search_contract);
399 $param .=
'&search_name='.urlencode($search_name);
401 if ($search_service) {
402 $param .=
'&search_service='.urlencode($search_service);
405 $param .=
'&mode='.urlencode($mode);
408 $param .=
'&filter='.urlencode($filter);
410 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
411 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
413 if (!empty($filter_op1) && $filter_op1 != -1) {
414 $param .=
'&filter_op1='.urlencode($filter_op1);
416 if (!empty($filter_op2) && $filter_op2 != -1) {
417 $param .=
'&filter_op2='.urlencode($filter_op2);
419 if (!empty($filter_opcloture) && $filter_opcloture != -1) {
420 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
422 if ($filter_dateouvertureprevue_start !=
'') {
423 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
425 if ($filter_date1_start !=
'') {
426 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
428 if ($filter_date2_start !=
'') {
429 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
431 if ($filter_datecloture_start !=
'') {
432 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
435 if ($optioncss !=
'') {
436 $param .=
'&optioncss='.urlencode($optioncss);
439 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
442 $arrayofmassactions = array(
448 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
450 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
451 if ($optioncss !=
'') {
452 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
454 print
'<input type="hidden" name="token" value="'.newToken().
'">';
455 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
456 print
'<input type="hidden" name="action" value="list">';
457 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
458 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
459 print
'<input type="hidden" name="page" value="'.$page.
'">';
460 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
462 $title = $langs->trans(
"ListOfServices");
464 $title = $langs->trans(
"ListOfInactiveServices");
466 if ($mode ==
"4" && $filter !=
"expired") {
467 $title = $langs->trans(
"ListOfRunningServices");
469 if ($mode ==
"4" && $filter ==
"expired") {
470 $title = $langs->trans(
"ListOfExpiredServices");
473 $title = $langs->trans(
"ListOfClosedServices");
476 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num,
$nbtotalofrecords,
'contract', 0,
'',
'', $limit);
479 foreach ($fieldstosearchall as $key => $val) {
480 $fieldstosearchall[$key] = $langs->trans($val);
482 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
489 if (
isModEnabled(
'categorie') && ($user->rights->produit->lire || $user->rights->service->lire)) {
490 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
491 $moreforfilter .=
'<div class="divsearchfield">';
492 $tmptitle = $langs->trans(
'IncludingProductWithTag');
493 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
494 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0, 0,
'widthcentpercentminusx maxwidth300', 1);
495 $moreforfilter .=
'</div>';
498 $parameters = array();
499 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
500 if (empty($reshook)) {
501 $moreforfilter .= $hookmanager->resPrint;
503 $moreforfilter = $hookmanager->resPrint;
507 if (!empty($moreforfilter)) {
508 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
509 print $moreforfilter;
513 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
514 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
517 print
'<div class="div-table-responsive">';
518 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
520 print
'<tr class="liste_titre">';
521 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
522 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
524 if (!empty($arrayfields[
'p.description'][
'checked'])) {
525 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
527 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
528 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
530 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
531 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
533 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
534 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
536 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
537 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
539 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
540 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
542 if (!empty($arrayfields[
's.nom'][
'checked'])) {
543 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
545 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
546 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
548 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
549 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
551 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
552 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
554 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
555 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
558 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
560 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
561 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
562 print $hookmanager->resPrint;
563 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
564 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
566 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
567 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
569 if (!empty($arrayfields[
'status'][
'checked'])) {
570 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
572 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
575 print
'<tr class="liste_titre">';
576 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
577 print
'<td class="liste_titre">';
578 print
'<input type="hidden" name="filter" value="'.$filter.
'">';
579 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
580 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
584 if (!empty($arrayfields[
'p.description'][
'checked'])) {
585 print
'<td class="liste_titre">';
586 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
590 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
591 print
'<td class="liste_titre">';
594 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
595 print
'<td class="liste_titre">';
598 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
599 print
'<td class="liste_titre">';
602 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
603 print
'<td class="liste_titre">';
606 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
607 print
'<td class="liste_titre">';
611 if (!empty($arrayfields[
's.nom'][
'checked'])) {
612 print
'<td class="liste_titre">';
613 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
618 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
619 print
'<td class="liste_titre center">';
620 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
621 print
$form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
623 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
624 print
$form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
627 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
628 print
'<td class="liste_titre center">';
629 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
630 print
$form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
632 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
633 print
$form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
636 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
637 print
'<td class="liste_titre center">';
638 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
639 print
$form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
641 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
642 print
$form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
645 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
646 print
'<td class="liste_titre center">';
647 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
648 print
$form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
650 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
651 print
$form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
655 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
658 $parameters = array(
'arrayfields'=>$arrayfields);
659 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
660 print $hookmanager->resPrint;
661 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
663 print
'<td class="liste_titre">';
666 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
668 print
'<td class="liste_titre">';
671 if (!empty($arrayfields[
'status'][
'checked'])) {
673 print
'<td class="liste_titre right">';
674 $arrayofstatus = array(
675 '0'=>$langs->trans(
"ServiceStatusInitial"),
676 '4'=>$langs->trans(
"ServiceStatusRunning"),
677 '4&filter=notexpired'=>$langs->trans(
"ServiceStatusNotLate"),
678 '4&filter=expired'=>$langs->trans(
"ServiceStatusLate"),
679 '5'=>$langs->trans(
"ServiceStatusClosed")
681 print
$form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status,
',') ?-1 : $search_status), 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth100imp maxwidth150');
685 print
'<td class="liste_titre maxwidthsearch">';
686 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
691 $contractstatic =
new Contrat($db);
692 $productstatic =
new Product($db);
695 $totalarray = array();
696 while ($i < min($num, $limit)) {
697 $obj = $db->fetch_object(
$resql);
699 $contractstatic->id = $obj->cid;
700 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
701 $contractstatic->ref_customer = $obj->ref_customer;
702 $contractstatic->ref_supplier = $obj->ref_supplier;
704 $companystatic->id = $obj->socid;
705 $companystatic->name = $obj->name;
706 $companystatic->email = $obj->email;
707 $companystatic->client = $obj->client;
708 $companystatic->fournisseur = $obj->fournisseur;
710 $productstatic->id = $obj->pid;
711 $productstatic->type = $obj->ptype;
712 $productstatic->ref = $obj->pref;
713 $productstatic->entity = $obj->pentity;
714 $productstatic->status = $obj->tosell;
715 $productstatic->status_buy = $obj->tobuy;
716 $productstatic->label = $obj->label;
717 $productstatic->description = $obj->description;
718 $productstatic->barcode = $obj->barcode;
720 print
'<tr class="oddeven">';
723 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
724 print
'<td class="nowraponall">';
725 print $contractstatic->getNomUrl(1, 16);
728 $totalarray[
'nbfield']++;
732 if (!empty($arrayfields[
'p.description'][
'checked'])) {
733 print
'<td class="tdoverflowmax300">';
735 print $productstatic->getNomUrl(1,
'', 24);
736 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
737 if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
738 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
741 if ($obj->type == 0) {
744 if ($obj->type == 1) {
750 $totalarray[
'nbfield']++;
754 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
755 print
'<td class="right nowraponall">';
759 $totalarray[
'nbfield']++;
762 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
763 print
'<td class="right nowraponall">';
764 print
price($obj->subprice);
767 $totalarray[
'nbfield']++;
770 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
771 print
'<td class="right nowraponall">';
775 $totalarray[
'nbfield']++;
778 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
779 print
'<td class="right nowraponall">';
780 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
783 $totalarray[
'nbfield']++;
786 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
788 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
790 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
791 print
'<td class="right nowraponall">';
792 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
795 $totalarray[
'nbfield']++;
798 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
800 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
804 if (!empty($arrayfields[
's.nom'][
'checked'])) {
805 print
'<td class="tdoverflowmax100">';
806 print $companystatic->getNomUrl(1,
'customer', 28);
809 $totalarray[
'nbfield']++;
814 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
815 print
'<td class="center nowraponall">';
816 print ($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
817 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
818 print
' '.img_picto($langs->trans(
"Late"),
"warning");
820 print
' ';
824 $totalarray[
'nbfield']++;
827 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
828 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
830 $totalarray[
'nbfield']++;
834 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
835 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
836 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
837 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
838 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
841 print
' ';
845 $totalarray[
'nbfield']++;
849 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
850 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
852 $totalarray[
'nbfield']++;
857 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
859 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
860 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
861 print $hookmanager->resPrint;
863 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
864 print
'<td class="center">';
865 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
868 $totalarray[
'nbfield']++;
872 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
873 print
'<td class="center nowraponall">';
874 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
877 $totalarray[
'nbfield']++;
881 if (!empty($arrayfields[
'status'][
'checked'])) {
882 print
'<td class="right">';
883 if ($obj->cstatut == 0) {
885 print $contractstatic->LibStatut(0, 5);
887 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
891 $totalarray[
'nbfield']++;
895 print
'<td class="nowrap center">';
896 if ($massactionbutton || $massaction) {
898 if (in_array($obj->rowid, $arrayofselected)) {
901 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
905 $totalarray[
'nbfield']++;
913 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
917 $parameters = array(
'sql' => $sql);
918 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
919 print $hookmanager->resPrint;
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
Class to manage lines of contracts.
Class to manage products or services.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$nbtotalofrecords
Count total nb of records.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.