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');
41 $massaction =
GETPOST(
'massaction',
'alpha');
42 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
43 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
44 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
46 if (empty($page) || $page == -1) {
49 $offset = $limit * $page;
50 $pageprev = $page - 1;
51 $pagenext = $page + 1;
53 $sortfield =
"c.rowid";
59 $filter =
GETPOST(
"filter",
'alpha');
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 if ($search_status !=
'') {
112 $tmp = explode(
'&', $search_status);
113 if (empty($tmp[1])) {
116 if ($tmp[1] ==
'filter=notexpired') {
117 $filter =
'notexpired';
119 if ($tmp[1] ==
'filter=expired') {
125 $staticcontrat =
new Contrat($db);
127 $companystatic =
new Societe($db);
129 $arrayfields = array(
130 'c.ref'=>array(
'label'=>
"Contract",
'checked'=>1,
'position'=>80),
131 'p.description'=>array(
'label'=>
"Service",
'checked'=>1,
'position'=>80),
132 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>90),
133 'cd.tva_tx'=>array(
'label'=>
"VATRate",
'checked'=>-1,
'position'=>100),
134 'cd.subprice'=>array(
'label'=>
"PriceUHT",
'checked'=>-1,
'position'=>105),
135 'cd.qty'=>array(
'label'=>
"Qty",
'checked'=>1,
'position'=>108),
136 'cd.total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>-1,
'position'=>109,
'isameasure'=>1),
137 'cd.total_tva'=>array(
'label'=>
"TotalVAT",
'checked'=>-1,
'position'=>110),
138 'cd.date_ouverture_prevue'=>array(
'label'=>
"DateStartPlannedShort",
'checked'=>1,
'position'=>150),
139 'cd.date_ouverture'=>array(
'label'=>
"DateStartRealShort",
'checked'=>1,
'position'=>160),
140 'cd.date_fin_validite'=>array(
'label'=>
"DateEndPlannedShort",
'checked'=>1,
'position'=>170),
141 'cd.date_cloture'=>array(
'label'=>
"DateEndRealShort",
'checked'=>1,
'position'=>180),
143 'cd.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
144 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
147 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
159 if (
GETPOST(
'cancel',
'alpha')) {
160 $action =
'list'; $massaction =
'';
162 if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
166 $parameters = array(
'socid'=>$socid);
167 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
172 if (empty($reshook)) {
174 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
176 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
177 $search_product_category = 0;
179 $search_subprice =
"";
181 $search_total_ht =
"";
182 $search_total_tva =
"";
183 $search_total_ttc =
"";
184 $search_contract =
"";
185 $search_service =
"";
187 $opouvertureprevuemonth =
"";
188 $opouvertureprevueday =
"";
189 $opouvertureprevueyear =
"";
190 $filter_opouvertureprevue =
"";
199 $opcloturemonth =
"";
202 $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, cd.product_type as type,";
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 IN (".getEntity($object->element).
")";
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);
268 if ($search_status ==
"0") {
269 $sql .=
" AND cd.statut = 0";
271 if ($search_status ==
"4") {
272 $sql .=
" AND cd.statut = 4";
274 if ($search_status ==
"5") {
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).
"'";
283 if ($search_subprice) {
289 if ($search_total_ht) {
292 if ($search_total_tva) {
295 if ($search_total_ttc) {
301 if ($search_contract) {
304 if ($search_service) {
305 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
308 $sql .=
" AND s.rowid = ".((int) $socid);
311 $filter_dateouvertureprevue =
'';
314 $filter_opcloture =
'';
316 $filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
317 $filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
318 if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
319 $filter_opouvertureprevue =
' BETWEEN ';
322 $filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
323 $filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
324 if ($filter_date1_start !=
'' && $filter_op1 == -1) {
325 $filter_op1 =
' BETWEEN ';
328 $filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
329 $filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
330 if ($filter_date2_start !=
'' && $filter_op2 == -1) {
331 $filter_op2 =
' BETWEEN ';
334 $filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
335 $filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
336 if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
337 $filter_opcloture =
' BETWEEN ';
340 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
341 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
343 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
344 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
346 if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
347 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
349 if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
350 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
352 if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
353 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
355 if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
356 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
358 if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
359 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
361 if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
362 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
365 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
366 $sql .= $db->order($sortfield, $sortorder);
370 $nbtotalofrecords =
'';
372 $result = $db->query(
$sql);
373 $nbtotalofrecords = $db->num_rows($result);
374 if (($page * $limit) > $nbtotalofrecords) {
380 $sql .= $db->plimit($limit + 1, $offset);
383 dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
384 $resql = $db->query(
$sql);
390 $num = $db->num_rows($resql);
401 llxHeader(
null, $langs->trans(
"Services"));
404 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
405 $param .=
'&contextpage='.urlencode($contextpage);
407 if ($limit > 0 && $limit != $conf->liste_limit) {
408 $param .=
'&limit='.$limit;
411 $param .=
'&mode='.urlencode($mode);
413 if ($search_contract) {
414 $param .=
'&search_contract='.urlencode($search_contract);
417 $param .=
'&search_name='.urlencode($search_name);
419 if ($search_subprice) {
420 $param .=
'&search_subprice='.urlencode($search_subprice);
423 $param .=
'&search_qty='.urlencode($search_qty);
425 if ($search_total_ht) {
426 $param .=
'&search_total_ht='.urlencode($search_total_ht);
428 if ($search_total_tva) {
429 $param .=
'&search_total_tva='.urlencode($search_total_tva);
431 if ($search_total_ttc) {
432 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
434 if ($search_service) {
435 $param .=
'&search_service='.urlencode($search_service);
437 if ($search_status) {
438 $param .=
'&search_status='.urlencode($search_status);
441 $param .=
'&filter='.urlencode($filter);
443 if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
444 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
446 if (!empty($filter_op1) && $filter_op1 != -1) {
447 $param .=
'&filter_op1='.urlencode($filter_op1);
449 if (!empty($filter_op2) && $filter_op2 != -1) {
450 $param .=
'&filter_op2='.urlencode($filter_op2);
452 if (!empty($filter_opcloture) && $filter_opcloture != -1) {
453 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
455 if ($filter_dateouvertureprevue_start !=
'') {
456 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
458 if ($filter_date1_start !=
'') {
459 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
461 if ($filter_date2_start !=
'') {
462 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
464 if ($filter_datecloture_start !=
'') {
465 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
468 if ($optioncss !=
'') {
469 $param .=
'&optioncss='.urlencode($optioncss);
472 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
475 $arrayofmassactions = array(
481 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
483 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
484 if ($optioncss !=
'') {
485 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
487 print
'<input type="hidden" name="token" value="'.newToken().
'">';
488 print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
489 print
'<input type="hidden" name="action" value="list">';
490 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
491 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
492 print
'<input type="hidden" name="page" value="'.$page.
'">';
493 print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
495 $title = $langs->trans(
"ListOfServices");
496 if ($search_status ==
"0") {
497 $title = $langs->trans(
"ListOfInactiveServices");
499 if ($search_status ==
"4" && $filter !=
"expired") {
500 $title = $langs->trans(
"ListOfRunningServices");
502 if ($search_status ==
"4" && $filter ==
"expired") {
503 $title = $langs->trans(
"ListOfExpiredServices");
505 if ($search_status ==
"5") {
506 $title = $langs->trans(
"ListOfClosedServices");
509 print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
512 foreach ($fieldstosearchall as $key => $val) {
513 $fieldstosearchall[$key] = $langs->trans($val);
515 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
522 if (
isModEnabled(
'categorie') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
523 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
524 $moreforfilter .=
'<div class="divsearchfield">';
525 $tmptitle = $langs->trans(
'IncludingProductWithTag');
526 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
527 $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);
528 $moreforfilter .=
'</div>';
531 $parameters = array();
532 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters);
533 if (empty($reshook)) {
534 $moreforfilter .= $hookmanager->resPrint;
536 $moreforfilter = $hookmanager->resPrint;
540 if (!empty($moreforfilter)) {
541 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
542 print $moreforfilter;
546 $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
547 $selectedfields =
$form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage);
550 print
'<div class="div-table-responsive">';
551 print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
554 print
'<tr class="liste_titre">';
555 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
556 print
'<td class="liste_titre">';
557 print
'<input type="hidden" name="filter" value="'.$filter.
'">';
558 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
559 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
563 if (!empty($arrayfields[
'p.description'][
'checked'])) {
564 print
'<td class="liste_titre">';
565 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
569 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
570 print
'<td class="liste_titre">';
573 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
574 print
'<td class="liste_titre right">';
575 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
578 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
579 print
'<td class="liste_titre right">';
580 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
583 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
584 print
'<td class="liste_titre right">';
585 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
588 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
589 print
'<td class="liste_titre right">';
590 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
594 if (!empty($arrayfields[
's.nom'][
'checked'])) {
595 print
'<td class="liste_titre">';
596 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
600 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
601 print
'<td class="liste_titre center">';
602 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
603 print
$form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
605 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
606 print
$form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
609 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
610 print
'<td class="liste_titre center">';
611 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
612 print
$form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
614 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
615 print
$form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
618 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
619 print
'<td class="liste_titre center">';
620 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
621 print
$form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
623 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
624 print
$form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
627 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
628 print
'<td class="liste_titre center">';
629 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
630 print
$form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
632 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
633 print
$form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
637 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
640 $parameters = array(
'arrayfields'=>$arrayfields);
641 $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters);
642 print $hookmanager->resPrint;
643 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
645 print
'<td class="liste_titre">';
648 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
650 print
'<td class="liste_titre">';
653 if (!empty($arrayfields[
'status'][
'checked'])) {
655 print
'<td class="liste_titre right parentonrightofpage">';
656 $arrayofstatus = array(
657 '0'=>$langs->trans(
"ServiceStatusInitial"),
658 '4'=>$langs->trans(
"ServiceStatusRunning"),
659 '4&filter=notexpired'=>$langs->trans(
"ServiceStatusNotLate"),
660 '4&filter=expired'=>$langs->trans(
"ServiceStatusLate"),
661 '5'=>$langs->trans(
"ServiceStatusClosed")
663 print
$form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status,
',') ?-1 : $search_status), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
667 print
'<td class="liste_titre maxwidthsearch">';
668 $searchpicto =
$form->showFilterAndCheckAddButtons(0);
673 print
'<tr class="liste_titre">';
674 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
675 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
677 if (!empty($arrayfields[
'p.description'][
'checked'])) {
678 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
680 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
681 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
683 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
684 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
686 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
687 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
689 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
690 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
692 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
693 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
695 if (!empty($arrayfields[
's.nom'][
'checked'])) {
696 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
698 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
699 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
701 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
702 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
704 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
705 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
707 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
708 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
711 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
713 $parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
714 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters);
715 print $hookmanager->resPrint;
716 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
717 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
719 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
720 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
722 if (!empty($arrayfields[
'status'][
'checked'])) {
723 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
725 print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"],
"",
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ');
729 $contractstatic =
new Contrat($db);
730 $productstatic =
new Product($db);
733 $totalarray = array(
'nbfield'=>0,
'cd.qty'=>0,
'cd.total_ht'=>0,
'cd.total_tva'=>0);
734 while ($i < min($num, $limit)) {
735 $obj = $db->fetch_object($resql);
737 $contractstatic->id = $obj->cid;
738 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
739 $contractstatic->ref_customer = $obj->ref_customer;
740 $contractstatic->ref_supplier = $obj->ref_supplier;
742 $companystatic->id = $obj->socid;
743 $companystatic->name = $obj->name;
744 $companystatic->email = $obj->email;
745 $companystatic->client = $obj->client;
746 $companystatic->fournisseur = $obj->fournisseur;
748 $productstatic->id = $obj->pid;
749 $productstatic->type = $obj->ptype;
750 $productstatic->ref = $obj->pref;
751 $productstatic->entity = $obj->pentity;
752 $productstatic->status = $obj->tosell;
753 $productstatic->status_buy = $obj->tobuy;
754 $productstatic->label = $obj->label;
755 $productstatic->description = $obj->description;
756 $productstatic->barcode = $obj->barcode;
758 print
'<tr class="oddeven">';
761 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
762 print
'<td class="nowraponall">';
763 print $contractstatic->getNomUrl(1, 16);
766 $totalarray[
'nbfield']++;
770 if (!empty($arrayfields[
'p.description'][
'checked'])) {
771 print
'<td class="tdoverflowmax300">';
773 print $productstatic->getNomUrl(1,
'', 24);
774 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
775 if (!empty($obj->description) && !empty($conf->global->PRODUCT_DESC_IN_LIST)) {
776 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
779 if ($obj->type == 0) {
782 if ($obj->type == 1) {
788 $totalarray[
'nbfield']++;
792 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
793 print
'<td class="right nowraponall">';
797 $totalarray[
'nbfield']++;
800 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
801 print
'<td class="right nowraponall">';
802 print
price($obj->subprice);
805 $totalarray[
'nbfield']++;
808 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
809 print
'<td class="right nowraponall">';
813 $totalarray[
'nbfield']++;
816 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
819 $totalarray[
'val'][
'cd.qty'] = $obj->qty;
821 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
823 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
824 print
'<td class="right nowraponall">';
825 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
828 $totalarray[
'nbfield']++;
831 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
833 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
835 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
836 print
'<td class="right nowraponall">';
837 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
840 $totalarray[
'nbfield']++;
843 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
845 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
849 if (!empty($arrayfields[
's.nom'][
'checked'])) {
850 print
'<td class="tdoverflowmax100">';
851 print $companystatic->getNomUrl(1,
'customer', 28);
854 $totalarray[
'nbfield']++;
859 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
860 print
'<td class="center nowraponall">';
861 print ($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
862 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
863 print
' '.img_picto($langs->trans(
"Late"),
"warning");
865 print
' ';
869 $totalarray[
'nbfield']++;
872 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
873 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
875 $totalarray[
'nbfield']++;
879 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
880 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
881 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
882 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
883 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
886 print
' ';
890 $totalarray[
'nbfield']++;
894 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
895 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
897 $totalarray[
'nbfield']++;
902 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
904 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
905 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
906 print $hookmanager->resPrint;
908 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
909 print
'<td class="center">';
910 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
913 $totalarray[
'nbfield']++;
917 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
918 print
'<td class="center nowraponall">';
919 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
922 $totalarray[
'nbfield']++;
926 if (!empty($arrayfields[
'status'][
'checked'])) {
927 print
'<td class="right">';
928 if ($obj->cstatut == 0) {
930 print $contractstatic->LibStatut(0, 5);
932 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
936 $totalarray[
'nbfield']++;
940 print
'<td class="nowrap center">';
941 if ($massactionbutton || $massaction) {
943 if (in_array($obj->rowid, $arrayofselected)) {
946 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
950 $totalarray[
'nbfield']++;
958 include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
963 foreach ($arrayfields as $key => $val) {
964 if (!empty($val[
'checked'])) {
968 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
973 $parameters = array(
'sql' =>
$sql);
974 $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters);
975 print $hookmanager->resPrint;