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 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
39 $sortfield =
GETPOST(
"sortfield",
'alpha');
40 $sortorder =
GETPOST(
"sortorder",
'alpha');
42 if (empty($page) || $page == -1) { $page = 0; }
43 $offset = $limit * $page;
44 $pageprev = $page - 1;
45 $pagenext = $page + 1;
46 if (!$sortfield) $sortfield =
"c.rowid";
47 if (!$sortorder) $sortorder =
"ASC";
51 $search_name =
GETPOST(
"search_name",
'alpha');
52 $search_contract =
GETPOST(
"search_contract",
'alpha');
53 $search_service =
GETPOST(
"search_service",
'alpha');
54 $search_status =
GETPOST(
"search_status",
'alpha');
56 $search_product_category =
GETPOST(
'search_product_category',
'int');
57 $socid =
GETPOST(
'socid',
'int');
58 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractservicelist'.$mode;
60 $opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
61 $opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
62 $opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
63 $filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue');
65 $op1month =
GETPOST(
'op1month',
'int');
66 $op1day =
GETPOST(
'op1day',
'int');
67 $op1year =
GETPOST(
'op1year',
'int');
68 $filter_op1 =
GETPOST(
'filter_op1',
'alpha');
70 $op2month =
GETPOST(
'op2month',
'int');
71 $op2day =
GETPOST(
'op2day',
'int');
72 $op2year =
GETPOST(
'op2year',
'int');
73 $filter_op2 =
GETPOST(
'filter_op2',
'alpha');
75 $opcloturemonth =
GETPOST(
'opcloturemonth',
'int');
76 $opclotureday =
GETPOST(
'opclotureday',
'int');
77 $opclotureyear =
GETPOST(
'opclotureyear',
'int');
78 $filter_opcloture =
GETPOST(
'filter_opcloture',
'alpha');
83 $hookmanager->initHooks(array(
'contractservicelist'));
87 $extrafields->fetch_name_optionals_label($object->table_element);
89 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
92 $contratid =
GETPOST(
'id',
'int');
93 if (!empty($user->socid)) $socid = $user->socid;
96 if ($search_status !=
'')
98 $tmp = explode(
'&', $search_status);
100 if (empty($tmp[1])) $filter =
'';
102 if ($tmp[1] ==
'filter=notexpired') $filter =
'notexpired';
103 if ($tmp[1] ==
'filter=expired') $filter =
'expired';
106 $search_status = $mode;
107 if ($filter ==
'expired') $search_status .=
'&filter=expired';
108 if ($filter ==
'notexpired') $search_status .=
'&filter=notexpired';
111 $staticcontrat =
new Contrat($db);
113 $companystatic =
new Societe($db);
115 $arrayfields = array(
116 'c.ref'=>array(
'label'=>$langs->trans(
"Contract"),
'checked'=>1,
'position'=>80),
117 'p.description'=>array(
'label'=>$langs->trans(
"Service"),
'checked'=>1,
'position'=>80),
118 'cd.qty'=>array(
'label'=>$langs->trans(
"Qty"),
'checked'=>0,
'position'=>100),
119 'cd.total_ht'=>array(
'label'=>$langs->trans(
"TotalHT"),
'checked'=>0,
'position'=>100),
120 'cd.total_tva'=>array(
'label'=>$langs->trans(
"TotalVAT"),
'checked'=>0,
'position'=>100),
121 'cd.tva_tx'=>array(
'label'=>$langs->trans(
"VAT"),
'checked'=>0,
'position'=>100),
122 'cd.subprice'=>array(
'label'=>$langs->trans(
"PriceUHT"),
'checked'=>0,
'position'=>100),
123 's.nom'=>array(
'label'=>$langs->trans(
"ThirdParty"),
'checked'=>1,
'position'=>100),
124 'cd.date_ouverture_prevue'=>array(
'label'=>$langs->trans(
"DateStartPlannedShort"),
'checked'=>(($mode ==
"" || $mode == -1) || $mode ==
"0")),
125 'cd.date_ouverture'=>array(
'label'=>$langs->trans(
"DateStartRealShort"),
'checked'=>(($mode ==
"" || $mode == -1) || $mode > 0)),
126 'cd.date_fin_validite'=>array(
'label'=>$langs->trans(
"DateEndPlannedShort"),
'checked'=>(($mode ==
"" || $mode == -1) || $mode < 5)),
127 'cd.date_cloture'=>array(
'label'=>$langs->trans(
"DateEndRealShort"),
'checked'=>(($mode ==
"" || $mode == -1) || $mode >= 5)),
128 'status'=>array(
'label'=>$langs->trans(
"Status"),
'checked'=>1),
130 'cd.tms'=>array(
'label'=>$langs->trans(
"DateModificationShort"),
'checked'=>0,
'position'=>500)
133 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
145 if (
GETPOST(
'cancel',
'alpha')) { $action =
'list'; $massaction =
''; }
146 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend' && $massaction !=
'confirm_createbills') { $massaction =
''; }
148 $parameters = array(
'socid'=>$socid);
149 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
150 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
155 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
157 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
159 $search_product_category = 0;
161 $search_contract =
"";
162 $search_service =
"";
164 $opouvertureprevuemonth =
"";
165 $opouvertureprevueday =
"";
166 $opouvertureprevueyear =
"";
167 $filter_opouvertureprevue =
"";
176 $opcloturemonth =
"";
179 $filter_opcloture =
"";
183 $search_array_options = array();
194 $form =
new Form($db);
196 $sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
197 $sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
198 $sql .=
" cd.rowid, cd.description, cd.statut,";
199 $sql .=
" p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,";
200 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" sc.fk_soc, sc.fk_user,";
201 $sql .=
" cd.date_ouverture_prevue,";
202 $sql .=
" cd.date_ouverture,";
203 $sql .=
" cd.date_fin_validite,";
204 $sql .=
" cd.date_cloture,";
206 $sql .=
" cd.total_ht,";
207 $sql .=
" cd.total_tva,";
208 $sql .=
" cd.tva_tx,";
209 $sql .=
" cd.subprice,";
211 $sql .=
" cd.tms as date_update";
213 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
214 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
217 $parameters = array();
218 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
219 $sql .= $hookmanager->resPrint;
220 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
221 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
222 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
223 $sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
224 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 (cd.rowid = ef.fk_object)";
225 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
226 if ($search_product_category > 0) $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
227 $sql .=
" WHERE c.entity = ".$conf->entity;
228 $sql .=
" AND c.rowid = cd.fk_contrat";
229 if ($search_product_category > 0) $sql .=
" AND cp.fk_categorie = ".$search_product_category;
230 $sql .=
" AND c.fk_soc = s.rowid";
231 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
232 if ($mode ==
"0") $sql .=
" AND cd.statut = 0";
233 if ($mode ==
"4") $sql .=
" AND cd.statut = 4";
234 if ($mode ==
"5") $sql .=
" AND cd.statut = 5";
235 if ($filter ==
"expired") $sql .=
" AND cd.date_fin_validite < '".$db->idate($now).
"'";
236 if ($filter ==
"notexpired") $sql .=
" AND cd.date_fin_validite >= '".$db->idate($now).
"'";
237 if ($search_name) $sql .=
" AND s.nom LIKE '%".$db->escape($search_name).
"%'";
238 if ($search_contract) $sql .=
" AND c.ref LIKE '%".$db->escape($search_contract).
"%' ";
239 if ($search_service) $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).
"%')";
240 if ($socid > 0) $sql .=
" AND s.rowid = ".$socid;
242 $filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
243 $filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
244 if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) $filter_opouvertureprevue =
' BETWEEN ';
246 $filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
247 $filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
248 if ($filter_date1_start !=
'' && $filter_op1 == -1) $filter_op1 =
' BETWEEN ';
250 $filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
251 $filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
252 if ($filter_date2_start !=
'' && $filter_op2 == -1) $filter_op2 =
' BETWEEN ';
254 $filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
255 $filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
256 if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) $filter_opcloture =
' BETWEEN ';
258 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
259 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') $sql .=
" AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
260 if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
261 if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') $sql .=
" AND '".$db->idate($filter_date1_end).
"'";
262 if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
263 if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') $sql .=
" AND '".$db->idate($filter_date2_end).
"'";
264 if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
265 if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') $sql .=
" AND '".$db->idate($filter_datecloture_end).
"'";
267 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
268 $sql .= $db->order($sortfield, $sortorder);
272 $nbtotalofrecords =
'';
273 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
275 $result = $db->query($sql);
276 $nbtotalofrecords = $db->num_rows($result);
277 if (($page * $limit) > $nbtotalofrecords)
284 $sql .= $db->plimit($limit + 1, $offset);
287 dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
288 $resql = $db->query($sql);
295 $num = $db->num_rows(
$resql);
306 llxHeader(null, $langs->trans(
"Services"));
309 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
310 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.$limit;
311 if ($search_contract) $param .=
'&search_contract='.urlencode($search_contract);
312 if ($search_name) $param .=
'&search_name='.urlencode($search_name);
313 if ($search_service) $param .=
'&search_service='.urlencode($search_service);
314 if ($mode) $param .=
'&mode='.urlencode($mode);
315 if ($filter) $param .=
'&filter='.urlencode($filter);
316 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
317 if (!empty($filter_op1) && $filter_op1 != -1) $param .=
'&filter_op1='.urlencode($filter_op1);
318 if (!empty($filter_op2) && $filter_op2 != -1) $param .=
'&filter_op2='.urlencode($filter_op2);
319 if (!empty($filter_opcloture) && $filter_opcloture != -1) $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
320 if ($filter_dateouvertureprevue !=
'') $param .=
'&opouvertureprevueday='.$opouvertureprevueday.
'&opouvertureprevuemonth='.$opouvertureprevuemonth.
'&opouvertureprevueyear='.$opouvertureprevueyear;
321 if ($filter_date1 !=
'') $param .=
'&op1day='.$op1day.
'&op1month='.$op1month.
'&op1year='.$op1year;
322 if ($filter_date2 !=
'') $param .=
'&op2day='.$op2day.
'&op2month='.$op2month.
'&op2year='.$op2year;
323 if ($filter_datecloture !=
'') $param .=
'&opclotureday='.$op2day.
'&opcloturemonth='.$op2month.
'&opclotureyear='.$op2year;
324 if ($optioncss !=
'') $param .=
'&optioncss='.$optioncss;
326 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
329 $arrayofmassactions = array(
335 $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
337 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
338 if ($optioncss !=
'')
print '<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
339 print '<input type="hidden" name="token" value="'.newToken().
'">';
340 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
341 print '<input type="hidden" name="action" value="list">';
342 print '<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
343 print '<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
344 print '<input type="hidden" name="page" value="'.$page.
'">';
345 print '<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
347 $title = $langs->trans(
"ListOfServices");
348 if ($mode ==
"0") $title = $langs->trans(
"ListOfInactiveServices");
349 if ($mode ==
"4" && $filter !=
"expired") $title = $langs->trans(
"ListOfRunningServices");
350 if ($mode ==
"4" && $filter ==
"expired") $title = $langs->trans(
"ListOfExpiredServices");
351 if ($mode ==
"5") $title = $langs->trans(
"ListOfClosedServices");
353 print_barre_liste($title, $page,
$_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
357 foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
358 print '<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
364 if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
366 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
367 $moreforfilter .=
'<div class="divsearchfield">';
368 $moreforfilter .= $langs->trans(
'IncludingProductWithTag').
': ';
369 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null,
'parent', null, null, 1);
370 $moreforfilter .= $form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, 1, 0, 0,
'', 0, 0, 0, 0,
'maxwidth300', 1);
371 $moreforfilter .=
'</div>';
374 $parameters = array();
375 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
376 if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
377 else $moreforfilter = $hookmanager->resPrint;
380 if (!empty($moreforfilter))
382 print '<div class="liste_titre liste_titre_bydiv centpercent">';
383 print $moreforfilter;
387 $varpage = empty($contextpage) ?
$_SERVER[
"PHP_SELF"] : $contextpage;
388 $selectedfields = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
391 print '<div class="div-table-responsive">';
392 print '<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
394 print '<tr class="liste_titre">';
395 if (!empty($arrayfields[
'c.ref'][
'checked']))
print_liste_field_titre($arrayfields[
'c.ref'][
'label'],
$_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
396 if (!empty($arrayfields[
'p.description'][
'checked']))
print_liste_field_titre($arrayfields[
'p.description'][
'label'],
$_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
397 if (!empty($arrayfields[
'cd.qty'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.qty'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
398 if (!empty($arrayfields[
'cd.total_ht'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
399 if (!empty($arrayfields[
'cd.total_tva'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
400 if (!empty($arrayfields[
'cd.tva_tx'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
401 if (!empty($arrayfields[
'cd.subprice'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
402 if (!empty($arrayfields[
's.nom'][
'checked']))
print_liste_field_titre($arrayfields[
's.nom'][
'label'],
$_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
403 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
404 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
405 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
406 if (!empty($arrayfields[
'cd.date_cloture'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
408 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
410 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
411 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
412 print $hookmanager->resPrint;
413 if (!empty($arrayfields[
'cd.datec'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.datec'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
414 if (!empty($arrayfields[
'cd.tms'][
'checked']))
print_liste_field_titre($arrayfields[
'cd.tms'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
415 if (!empty($arrayfields[
'status'][
'checked']))
print_liste_field_titre($arrayfields[
'status'][
'label'],
$_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
419 print
'<tr class="liste_titre">';
420 if (!empty($arrayfields[
'c.ref'][
'checked']))
422 print
'<td class="liste_titre">';
423 print
'<input type="hidden" name="filter" value="'.$filter.
'">';
424 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
425 print
'<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
429 if (!empty($arrayfields[
'p.description'][
'checked']))
431 print
'<td class="liste_titre">';
432 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
436 if (!empty($arrayfields[
'cd.qty'][
'checked']))
438 print
'<td class="liste_titre">';
441 if (!empty($arrayfields[
'cd.total_ht'][
'checked']))
443 print
'<td class="liste_titre">';
446 if (!empty($arrayfields[
'cd.total_tva'][
'checked']))
448 print
'<td class="liste_titre">';
451 if (!empty($arrayfields[
'cd.tva_tx'][
'checked']))
453 print
'<td class="liste_titre">';
456 if (!empty($arrayfields[
'cd.subprice'][
'checked']))
458 print
'<td class="liste_titre">';
462 if (!empty($arrayfields[
's.nom'][
'checked']))
464 print
'<td class="liste_titre">';
465 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
470 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked']))
472 print
'<td class="liste_titre center">';
473 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
474 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1);
476 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
477 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
480 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked']))
482 print
'<td class="liste_titre center">';
483 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
484 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1);
486 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
487 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
490 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked']))
492 print
'<td class="liste_titre center">';
493 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
494 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1);
496 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
497 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
500 if (!empty($arrayfields[
'cd.date_cloture'][
'checked']))
502 print
'<td class="liste_titre center">';
503 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
504 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1);
506 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
507 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
511 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
514 $parameters = array(
'arrayfields'=>$arrayfields);
515 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
516 print $hookmanager->resPrint;
517 if (!empty($arrayfields[
'cd.datec'][
'checked']))
520 print
'<td class="liste_titre">';
523 if (!empty($arrayfields[
'cd.tms'][
'checked']))
526 print
'<td class="liste_titre">';
529 if (!empty($arrayfields[
'status'][
'checked']))
532 print
'<td class="liste_titre right">';
533 $arrayofstatus = array(
534 '0'=>$langs->trans(
"ServiceStatusInitial"),
535 '4'=>$langs->trans(
"ServiceStatusRunning"),
536 '4&filter=notexpired'=>$langs->trans(
"ServiceStatusNotLate"),
537 '4&filter=expired'=>$langs->trans(
"ServiceStatusLate"),
538 '5'=>$langs->trans(
"ServiceStatusClosed")
540 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status,
',') ?-1 : $search_status), 1, 0,
'', 0, 0, 0,
'',
'maxwidth100onsmartphone');
544 print
'<td class="liste_titre maxwidthsearch">';
545 $searchpicto = $form->showFilterAndCheckAddButtons(0);
550 $contractstatic =
new Contrat($db);
551 $productstatic =
new Product($db);
554 $totalarray = array();
555 while ($i < min($num, $limit))
557 $obj = $db->fetch_object(
$resql);
559 $contractstatic->id = $obj->cid;
560 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
561 $contractstatic->ref_customer = $obj->ref_customer;
562 $contractstatic->ref_supplier = $obj->ref_supplier;
564 $companystatic->id = $obj->socid;
565 $companystatic->name = $obj->name;
566 $companystatic->email = $obj->email;
567 $companystatic->client = $obj->client;
568 $companystatic->fournisseur = $obj->fournisseur;
570 print
'<tr class="oddeven">';
573 if (!empty($arrayfields[
'c.ref'][
'checked']))
575 print
'<td class="nowraponall">';
576 print $contractstatic->getNomUrl(1, 16);
578 if (!$i) $totalarray[
'nbfield']++;
581 if (!empty($arrayfields[
'p.description'][
'checked']))
586 $productstatic->id = $obj->pid;
587 $productstatic->type = $obj->ptype;
588 $productstatic->ref = $obj->pref;
589 $productstatic->entity = $obj->pentity;
590 print $productstatic->getNomUrl(1,
'', 24);
591 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
592 if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) print
'<br>'.dol_nl2br($obj->description);
594 if ($obj->type == 0) print
img_object($obj->description,
'product').
' '.
dol_trunc($obj->description, 24);
595 if ($obj->type == 1) print
img_object($obj->description,
'service').
' '.
dol_trunc($obj->description, 24);
598 if (!$i) $totalarray[
'nbfield']++;
601 if (!empty($arrayfields[
'cd.qty'][
'checked']))
606 if (!$i) $totalarray[
'nbfield']++;
608 if (!empty($arrayfields[
'cd.total_ht'][
'checked']))
610 print
'<td class="right">';
611 print
price($obj->total_ht);
613 if (!$i) $totalarray[
'nbfield']++;
614 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
615 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
617 if (!empty($arrayfields[
'cd.total_tva'][
'checked']))
619 print
'<td class="right">';
620 print
price($obj->total_tva);
622 if (!$i) $totalarray[
'nbfield']++;
623 if (!$i) $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
624 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
626 if (!empty($arrayfields[
'cd.tva_tx'][
'checked']))
628 print
'<td class="right">';
631 if (!$i) $totalarray[
'nbfield']++;
633 if (!empty($arrayfields[
'cd.subprice'][
'checked']))
635 print
'<td class="right">';
636 print
price($obj->subprice);
638 if (!$i) $totalarray[
'nbfield']++;
643 if (!empty($arrayfields[
's.nom'][
'checked']))
646 print $companystatic->getNomUrl(1,
'customer', 28);
648 if (!$i) $totalarray[
'nbfield']++;
652 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked']))
654 print
'<td class="center">';
655 print ($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
656 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0)
657 print
' '.
img_picto($langs->trans(
"Late"),
"warning");
658 else print
' ';
660 if (!$i) $totalarray[
'nbfield']++;
662 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked']))
664 print
'<td class="center">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
665 if (!$i) $totalarray[
'nbfield']++;
668 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked']))
670 print
'<td class="center">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
671 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5)
673 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
674 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
676 }
else print
' ';
678 if (!$i) $totalarray[
'nbfield']++;
681 if (!empty($arrayfields[
'cd.date_cloture'][
'checked']))
683 print
'<td class="center">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
684 if (!$i) $totalarray[
'nbfield']++;
688 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
690 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
691 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
692 print $hookmanager->resPrint;
694 if (!empty($arrayfields[
'cd.datec'][
'checked']))
696 print
'<td class="center">';
697 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
699 if (!$i) $totalarray[
'nbfield']++;
702 if (!empty($arrayfields[
'cd.tms'][
'checked']))
704 print
'<td class="center">';
705 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
707 if (!$i) $totalarray[
'nbfield']++;
710 if (!empty($arrayfields[
'status'][
'checked']))
712 print
'<td class="right">';
713 if ($obj->cstatut == 0)
716 print $contractstatic->LibStatut(0, 5);
718 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
721 if (!$i) $totalarray[
'nbfield']++;
724 print
'<td class="nowrap center">';
725 if ($massactionbutton || $massaction)
728 if (in_array($obj->rowid, $arrayofselected)) $selected = 1;
729 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
732 if (!$i) $totalarray[
'nbfield']++;
739 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
743 $parameters = array(
'sql' => $sql);
744 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
745 print $hookmanager->resPrint;
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
Class to manage products or services.
dol_now($mode= 'auto')
Return date for now.
Class to manage contracts.
Class to manage lines of contracts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
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.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
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...
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...
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.