31 require
"../main.inc.php";
32 require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
33 require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
34 require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
37 $langs->loadLangs(array(
'products',
'contracts',
'companies'));
39 $optioncss =
GETPOST(
'optioncss',
'aZ09');
42 $massaction =
GETPOST(
'massaction',
'alpha');
43 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
44 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
45 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
47 if (empty($page) || $page == -1) {
50 $offset = $limit * $page;
51 $pageprev = $page - 1;
52 $pagenext = $page + 1;
54 $sortfield =
"c.rowid";
60 $search_name =
GETPOST(
"search_name",
'alpha');
61 $search_subprice =
GETPOST(
"search_subprice",
'alpha');
62 $search_qty =
GETPOST(
"search_qty",
'alpha');
63 $search_total_ht =
GETPOST(
"search_total_ht",
'alpha');
64 $search_total_tva =
GETPOST(
"search_total_tva",
'alpha');
65 $search_total_ttc =
GETPOST(
"search_total_ttc",
'alpha');
66 $search_contract =
GETPOST(
"search_contract",
'alpha');
67 $search_service =
GETPOST(
"search_service",
'alpha');
68 $search_status =
GETPOST(
"search_status",
'alpha');
69 $search_product_category =
GETPOST(
'search_product_category',
'int');
70 $socid =
GETPOST(
'socid',
'int');
71 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractservicelist'.$mode;
73 $opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
74 $opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
75 $opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
76 $filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue');
78 $op1month =
GETPOST(
'op1month',
'int');
79 $op1day =
GETPOST(
'op1day',
'int');
80 $op1year =
GETPOST(
'op1year',
'int');
81 $filter_op1 =
GETPOST(
'filter_op1',
'alpha');
83 $op2month =
GETPOST(
'op2month',
'int');
84 $op2day =
GETPOST(
'op2day',
'int');
85 $op2year =
GETPOST(
'op2year',
'int');
86 $filter_op2 =
GETPOST(
'filter_op2',
'alpha');
88 $opcloturemonth =
GETPOST(
'opcloturemonth',
'int');
89 $opclotureday =
GETPOST(
'opclotureday',
'int');
90 $opclotureyear =
GETPOST(
'opclotureyear',
'int');
91 $filter_opcloture =
GETPOST(
'filter_opcloture',
'alpha');
96 $hookmanager->initHooks(array(
'contractservicelist'));
100 $extrafields->fetch_name_optionals_label($object->table_element);
102 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
105 $contratid =
GETPOST(
'id',
'int');
106 if (!empty($user->socid)) {
107 $socid = $user->socid;
111 $staticcontrat =
new Contrat($db);
113 $companystatic =
new Societe($db);
115 $arrayfields = array(
116 'c.ref'=>array(
'label'=>
"Contract",
'checked'=>1,
'position'=>80),
117 'p.description'=>array(
'label'=>
"Service",
'checked'=>1,
'position'=>80),
118 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>90),
119 'cd.tva_tx'=>array(
'label'=>
"VATRate",
'checked'=>-1,
'position'=>100),
120 'cd.subprice'=>array(
'label'=>
"PriceUHT",
'checked'=>-1,
'position'=>105),
121 'cd.qty'=>array(
'label'=>
"Qty",
'checked'=>1,
'position'=>108),
122 'cd.total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>-1,
'position'=>109,
'isameasure'=>1),
123 'cd.total_tva'=>array(
'label'=>
"TotalVAT",
'checked'=>-1,
'position'=>110),
124 'cd.date_ouverture_prevue'=>array(
'label'=>
"DateStartPlannedShort",
'checked'=>1,
'position'=>150),
125 'cd.date_ouverture'=>array(
'label'=>
"DateStartRealShort",
'checked'=>1,
'position'=>160),
126 'cd.date_fin_validite'=>array(
'label'=>
"DateEndPlannedShort",
'checked'=>1,
'position'=>170),
127 'cd.date_cloture'=>array(
'label'=>
"DateEndRealShort",
'checked'=>1,
'position'=>180),
129 'cd.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
130 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
133 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
145 if (
GETPOST(
'cancel',
'alpha')) {
146 $action =
'list'; $massaction =
'';
148 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
152 $parameters = array(
'socid'=>$socid);
153 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
158 if (empty($reshook)) {
160 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
162 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
163 $search_product_category = 0;
165 $search_subprice =
"";
167 $search_total_ht =
"";
168 $search_total_tva =
"";
169 $search_total_ttc =
"";
170 $search_contract =
"";
171 $search_service =
"";
173 $opouvertureprevuemonth =
"";
174 $opouvertureprevueday =
"";
175 $opouvertureprevueyear =
"";
176 $filter_opouvertureprevue =
"";
185 $opcloturemonth =
"";
188 $filter_opcloture =
"";
190 $search_array_options = array();
203 $sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
204 $sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
205 $sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
206 $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,";
207 if (empty($user->rights->societe->client->voir) && !$socid) {
208 $sql .=
" sc.fk_soc, sc.fk_user,";
210 $sql .=
" cd.date_ouverture_prevue,";
211 $sql .=
" cd.date_ouverture,";
212 $sql .=
" cd.date_fin_validite,";
213 $sql .=
" cd.date_cloture,";
215 $sql .=
" cd.total_ht,";
216 $sql .=
" cd.total_tva,";
217 $sql .=
" cd.tva_tx,";
218 $sql .=
" cd.subprice,";
220 $sql .=
" cd.tms as date_update";
222 if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
223 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
224 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
228 $parameters = array();
229 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
230 $sql .= $hookmanager->resPrint;
231 $sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
232 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
233 if (empty($user->rights->societe->client->voir) && !$socid) {
234 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
236 $sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
237 if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
238 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
240 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
241 if ($search_product_category > 0) {
242 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
244 $sql .=
" WHERE c.entity IN (".getEntity($object->element).
")";
245 $sql .=
" AND c.rowid = cd.fk_contrat";
246 if ($search_product_category > 0) {
247 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
249 $sql .=
" AND c.fk_soc = s.rowid";
250 if (empty($user->rights->societe->client->voir) && !$socid) {
251 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
253 if ($search_status ==
"0") {
254 $sql .=
" AND cd.statut = 0";
256 if ($search_status ==
"4") {
257 $sql .=
" AND cd.statut = 4";
259 if ($search_status ==
"4&filter=expired") {
260 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
262 if ($search_status ==
"4&filter=notexpired") {
263 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
265 if ($search_status ==
"5") {
266 $sql .=
" AND cd.statut = 5";
268 if ($search_subprice) {
274 if ($search_total_ht) {
277 if ($search_total_tva) {
280 if ($search_total_ttc) {
286 if ($search_contract) {
289 if ($search_service) {
290 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $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);
355 $nbtotalofrecords =
'';
357 $result = $db->query(
$sql);
358 $nbtotalofrecords = $db->num_rows($result);
359 if (($page * $limit) > $nbtotalofrecords) {
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;
396 $param .=
'&mode='.urlencode($mode);
398 if ($search_contract) {
399 $param .=
'&search_contract='.urlencode($search_contract);
402 $param .=
'&search_name='.urlencode($search_name);
404 if ($search_subprice) {
405 $param .=
'&search_subprice='.urlencode($search_subprice);
408 $param .=
'&search_qty='.urlencode($search_qty);
410 if ($search_total_ht) {
411 $param .=
'&search_total_ht='.urlencode($search_total_ht);
413 if ($search_total_tva) {
414 $param .=
'&search_total_tva='.urlencode($search_total_tva);
416 if ($search_total_ttc) {
417 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
419 if ($search_service) {
420 $param .=
'&search_service='.urlencode($search_service);
422 if ($search_status) {
423 $param .=
'&search_status='.urlencode($search_status);
425 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
426 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
428 if (!empty($filter_op1) && $filter_op1 != -1) {
429 $param .=
'&filter_op1='.urlencode($filter_op1);
431 if (!empty($filter_op2) && $filter_op2 != -1) {
432 $param .=
'&filter_op2='.urlencode($filter_op2);
434 if (!empty($filter_opcloture) && $filter_opcloture != -1) {
435 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
437 if ($filter_dateouvertureprevue_start !=
'') {
438 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
440 if ($filter_date1_start !=
'') {
441 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
443 if ($filter_date2_start !=
'') {
444 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
446 if ($filter_datecloture_start !=
'') {
447 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
450 if ($optioncss !=
'') {
451 $param .=
'&optioncss='.urlencode($optioncss);
454 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
457 $arrayofmassactions = array(
463 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
465 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
466 if ($optioncss !=
'') {
467 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
469 print
'<input type="hidden" name="token" value="'.newToken().
'">';
470 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
471 print
'<input type="hidden" name="action" value="list">';
472 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
473 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
474 print
'<input type="hidden" name="page" value="'.$page.
'">';
475 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
477 $title = $langs->trans(
"ListOfServices");
478 if ($search_status ==
"0") {
479 $title = $langs->trans(
"ListOfInactiveServices");
481 if ($search_status ==
"4") {
482 $title = $langs->trans(
"ListOfRunningServices");
484 if ($search_status ==
"4&filter=notexpired") {
485 $title = $langs->trans(
"ListOfNotExpiredServices");
487 if ($search_status ==
"4&filter=expired") {
488 $title = $langs->trans(
"ListOfExpiredServices");
490 if ($search_status ==
"5") {
491 $title = $langs->trans(
"ListOfClosedServices");
494 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
497 foreach ($fieldstosearchall as $key => $val) {
498 $fieldstosearchall[$key] = $langs->trans($val);
500 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
507 if (
isModEnabled(
'categorie') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
508 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
509 $moreforfilter .=
'<div class="divsearchfield">';
510 $tmptitle = $langs->trans(
'IncludingProductWithTag');
511 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
512 $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);
513 $moreforfilter .=
'</div>';
516 $parameters = array();
517 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
518 if (empty($reshook)) {
519 $moreforfilter .= $hookmanager->resPrint;
521 $moreforfilter = $hookmanager->resPrint;
525 if (!empty($moreforfilter)) {
526 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
527 print $moreforfilter;
531 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
532 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
535 print
'<div class="div-table-responsive">';
536 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
539 print
'<tr class="liste_titre">';
540 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
541 print
'<td class="liste_titre">';
542 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
543 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
547 if (!empty($arrayfields[
'p.description'][
'checked'])) {
548 print
'<td class="liste_titre">';
549 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
553 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
554 print
'<td class="liste_titre">';
557 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
558 print
'<td class="liste_titre right">';
559 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
562 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
563 print
'<td class="liste_titre right">';
564 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
567 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
568 print
'<td class="liste_titre right">';
569 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
572 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
573 print
'<td class="liste_titre right">';
574 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
578 if (!empty($arrayfields[
's.nom'][
'checked'])) {
579 print
'<td class="liste_titre">';
580 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
584 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
585 print
'<td class="liste_titre center">';
586 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
587 print
$form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
589 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
590 print
$form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
593 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
594 print
'<td class="liste_titre center">';
595 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
596 print
$form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
598 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
599 print
$form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
602 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
603 print
'<td class="liste_titre center">';
604 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
605 print
$form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
607 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
608 print
$form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
611 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
612 print
'<td class="liste_titre center">';
613 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
614 print
$form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
616 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
617 print
$form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
621 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
624 $parameters = array(
'arrayfields'=>$arrayfields);
625 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
626 print $hookmanager->resPrint;
627 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
629 print
'<td class="liste_titre">';
632 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
634 print
'<td class="liste_titre">';
637 if (!empty($arrayfields[
'status'][
'checked'])) {
639 print
'<td class="liste_titre right parentonrightofpage">';
640 $arrayofstatus = array(
641 '0'=>$langs->trans(
"ServiceStatusInitial"),
642 '4'=>$langs->trans(
"ServiceStatusRunning"),
643 '4&filter=notexpired'=>$langs->trans(
"ServiceStatusNotLate"),
644 '4&filter=expired'=>$langs->trans(
"ServiceStatusLate"),
645 '5'=>$langs->trans(
"ServiceStatusClosed")
647 print
$form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status,
',') ?-1 : $search_status), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
651 print
'<td class="liste_titre maxwidthsearch">';
652 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
657 print
'<tr class="liste_titre">';
658 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
659 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
661 if (!empty($arrayfields[
'p.description'][
'checked'])) {
662 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
664 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
665 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
667 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
668 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
670 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
671 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
673 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
674 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
676 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
677 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
679 if (!empty($arrayfields[
's.nom'][
'checked'])) {
680 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
682 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
683 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
685 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
686 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
688 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
689 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
691 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
692 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
695 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
697 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
698 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
699 print $hookmanager->resPrint;
700 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
701 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
703 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
704 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
706 if (!empty($arrayfields[
'status'][
'checked'])) {
707 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
709 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
713 $contractstatic =
new Contrat($db);
714 $productstatic =
new Product($db);
717 $totalarray = array(
'nbfield'=>0,
'cd.qty'=>0,
'cd.total_ht'=>0,
'cd.total_tva'=>0);
718 while ($i < min($num, $limit)) {
719 $obj = $db->fetch_object($resql);
721 $contractstatic->id = $obj->cid;
722 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
723 $contractstatic->ref_customer = $obj->ref_customer;
724 $contractstatic->ref_supplier = $obj->ref_supplier;
726 $companystatic->id = $obj->socid;
727 $companystatic->name = $obj->name;
728 $companystatic->email = $obj->email;
729 $companystatic->client = $obj->client;
730 $companystatic->fournisseur = $obj->fournisseur;
732 $productstatic->id = $obj->pid;
733 $productstatic->type = $obj->ptype;
734 $productstatic->ref = $obj->pref;
735 $productstatic->entity = $obj->pentity;
736 $productstatic->status = $obj->tosell;
737 $productstatic->status_buy = $obj->tobuy;
738 $productstatic->label = $obj->label;
739 $productstatic->description = $obj->description;
740 $productstatic->barcode = $obj->barcode;
742 print
'<tr class="oddeven">';
745 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
746 print
'<td class="nowraponall">';
747 print $contractstatic->getNomUrl(1, 16);
750 $totalarray[
'nbfield']++;
754 if (!empty($arrayfields[
'p.description'][
'checked'])) {
755 print
'<td class="tdoverflowmax300">';
757 print $productstatic->getNomUrl(1,
'', 24);
758 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
759 if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
760 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
763 if ($obj->type == 0) {
766 if ($obj->type == 1) {
772 $totalarray[
'nbfield']++;
776 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
777 print
'<td class="right nowraponall">';
781 $totalarray[
'nbfield']++;
784 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
785 print
'<td class="right nowraponall">';
786 print
price($obj->subprice);
789 $totalarray[
'nbfield']++;
792 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
793 print
'<td class="right nowraponall">';
797 $totalarray[
'nbfield']++;
800 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
802 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
804 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
805 print
'<td class="right nowraponall">';
806 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
809 $totalarray[
'nbfield']++;
812 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
814 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
816 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
817 print
'<td class="right nowraponall">';
818 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
821 $totalarray[
'nbfield']++;
824 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
826 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
830 if (!empty($arrayfields[
's.nom'][
'checked'])) {
831 print
'<td class="tdoverflowmax100">';
832 print $companystatic->getNomUrl(1,
'customer', 28);
835 $totalarray[
'nbfield']++;
840 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
841 print
'<td class="center nowraponall">';
842 print ($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
843 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
844 print
' '.img_picto($langs->trans(
"Late"),
"warning");
846 print
' ';
850 $totalarray[
'nbfield']++;
853 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
854 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
856 $totalarray[
'nbfield']++;
860 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
861 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
862 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
863 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
864 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
867 print
' ';
871 $totalarray[
'nbfield']++;
875 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
876 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
878 $totalarray[
'nbfield']++;
883 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
885 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
886 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
887 print $hookmanager->resPrint;
889 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
890 print
'<td class="center">';
891 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
894 $totalarray[
'nbfield']++;
898 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
899 print
'<td class="center nowraponall">';
900 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
903 $totalarray[
'nbfield']++;
907 if (!empty($arrayfields[
'status'][
'checked'])) {
908 print
'<td class="right">';
909 if ($obj->cstatut == 0) {
911 print $contractstatic->LibStatut(0, 5);
913 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
917 $totalarray[
'nbfield']++;
921 print
'<td class="nowrap center">';
922 if ($massactionbutton || $massaction) {
924 if (in_array($obj->rowid, $arrayofselected)) {
927 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
931 $totalarray[
'nbfield']++;
939 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
944 foreach ($arrayfields as $key => $val) {
945 if (!empty($val[
'checked'])) {
949 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
954 $parameters = array(
'sql' =>
$sql);
955 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
956 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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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)
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...
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
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.
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.
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.