31require
"../main.inc.php";
32require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
33require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
34require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
37$langs->loadLangs(array(
'products',
'contracts',
'companies'));
40$massaction =
GETPOST(
'massaction',
'alpha');
41$toselect =
GETPOST(
'toselect',
'array');
42$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php'));
43$optioncss =
GETPOST(
'optioncss',
'aZ');
47$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
48$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
49$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
50$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
51if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
55$offset = $limit * $page;
59 $sortfield =
"c.rowid";
65$search_name =
GETPOST(
"search_name",
'alpha');
66$search_subprice =
GETPOST(
"search_subprice",
'alpha');
67$search_qty =
GETPOST(
"search_qty",
'alpha');
68$search_total_ht =
GETPOST(
"search_total_ht",
'alpha');
69$search_total_tva =
GETPOST(
"search_total_tva",
'alpha');
70$search_total_ttc =
GETPOST(
"search_total_ttc",
'alpha');
71$search_contract =
GETPOST(
"search_contract",
'alpha');
72$search_service =
GETPOST(
"search_service",
'alpha');
73$search_status =
GETPOST(
"search_status",
'alpha');
74$search_product_category =
GETPOST(
'search_product_category',
'int');
75$socid =
GETPOST(
'socid',
'int');
76$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'contractservicelist'.$mode;
78$opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
79$opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
80$opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
81$filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue',
'alphawithlgt');
83$op1month =
GETPOST(
'op1month',
'int');
84$op1day =
GETPOST(
'op1day',
'int');
85$op1year =
GETPOST(
'op1year',
'int');
86$filter_op1 =
GETPOST(
'filter_op1',
'alphawithlgt');
88$op2month =
GETPOST(
'op2month',
'int');
89$op2day =
GETPOST(
'op2day',
'int');
90$op2year =
GETPOST(
'op2year',
'int');
91$filter_op2 =
GETPOST(
'filter_op2',
'alphawithlgt');
93$opcloturemonth =
GETPOST(
'opcloturemonth',
'int');
94$opclotureday =
GETPOST(
'opclotureday',
'int');
95$opclotureyear =
GETPOST(
'opclotureyear',
'int');
96$filter_opcloture =
GETPOST(
'filter_opcloture',
'alphalgt');
101$hookmanager->initHooks(array(
'contractservicelist'));
105$extrafields->fetch_name_optionals_label($object->table_element);
107$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,
'',
'search_');
110$contratid =
GETPOST(
'id',
'int');
111if (!empty($user->socid)) {
112 $socid = $user->socid;
116$staticcontrat =
new Contrat($db);
118$companystatic =
new Societe($db);
121 'c.ref'=>array(
'label'=>
"Contract",
'checked'=>1,
'position'=>80),
122 'p.description'=>array(
'label'=>
"Service",
'checked'=>1,
'position'=>80),
123 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1,
'position'=>90),
124 'cd.tva_tx'=>array(
'label'=>
"VATRate",
'checked'=>-1,
'position'=>100),
125 'cd.subprice'=>array(
'label'=>
"PriceUHT",
'checked'=>-1,
'position'=>105),
126 'cd.qty'=>array(
'label'=>
"Qty",
'checked'=>1,
'position'=>108),
127 'cd.total_ht'=>array(
'label'=>
"TotalHT",
'checked'=>-1,
'position'=>109,
'isameasure'=>1),
128 'cd.total_tva'=>array(
'label'=>
"TotalVAT",
'checked'=>-1,
'position'=>110),
129 'cd.date_ouverture_prevue'=>array(
'label'=>
"DateStartPlannedShort",
'checked'=>1,
'position'=>150),
130 'cd.date_ouverture'=>array(
'label'=>
"DateStartRealShort",
'checked'=>1,
'position'=>160),
131 'cd.date_fin_validite'=>array(
'label'=>
"DateEndPlannedShort",
'checked'=>1,
'position'=>170),
132 'cd.date_cloture'=>array(
'label'=>
"DateEndRealShort",
'checked'=>1,
'position'=>180),
134 'cd.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
135 'status'=>array(
'label'=>
"Status",
'checked'=>1,
'position'=>1000)
138include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
143$permissiontoread = $user->hasRight(
'contrat',
'lire');
144$permissiontoadd = $user->hasRight(
'contrat',
'creer');
145$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
154if (
GETPOST(
'cancel',
'alpha')) {
158if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
162$parameters = array(
'socid'=>$socid);
163$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
168if (empty($reshook)) {
170 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
172 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
173 $search_product_category = 0;
175 $search_subprice =
"";
177 $search_total_ht =
"";
178 $search_total_tva =
"";
179 $search_total_ttc =
"";
180 $search_contract =
"";
181 $search_service =
"";
183 $opouvertureprevuemonth =
"";
184 $opouvertureprevueday =
"";
185 $opouvertureprevueyear =
"";
186 $filter_opouvertureprevue =
"";
195 $opcloturemonth =
"";
198 $filter_opcloture =
"";
200 $search_array_options = array();
209$form =
new Form($db);
213$title = $langs->trans(
"ListOfServices");
214if ($search_status ==
"0") {
215 $title = $langs->trans(
"ListOfInactiveServices");
217if ($search_status ==
"4" && $filter !=
"expired") {
218 $title = $langs->trans(
"ListOfRunningServices");
220if ($search_status ==
"4" && $filter ==
"expired") {
221 $title = $langs->trans(
"ListOfExpiredServices");
223if ($search_status ==
"5") {
224 $title = $langs->trans(
"ListOfClosedServices");
230$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
231$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
232$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
233$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,";
234if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
235 $sql .=
" sc.fk_soc, sc.fk_user,";
237$sql .=
" cd.date_ouverture_prevue,";
238$sql .=
" cd.date_ouverture,";
239$sql .=
" cd.date_fin_validite,";
240$sql .=
" cd.date_cloture,";
242$sql .=
" cd.total_ht,";
243$sql .=
" cd.total_tva,";
244$sql .=
" cd.tva_tx,";
245$sql .=
" cd.subprice,";
247$sql .=
" cd.tms as date_update";
249if (!empty($extrafields->attributes[$object->table_element][
'label'])) {
250 foreach ($extrafields->attributes[$object->table_element][
'label'] as $key => $val) {
251 $sql .= ($extrafields->attributes[$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
255$parameters = array();
256$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
257$sql .= $hookmanager->resPrint;
258$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
259$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
260if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
261 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
263$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
264if (!empty($extrafields->attributes[$object->table_element][
'label']) && is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
265 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
267$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
268if ($search_product_category > 0) {
269 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
271$sql .=
" WHERE c.entity IN (".getEntity($object->element).
")";
272$sql .=
" AND c.rowid = cd.fk_contrat";
273if ($search_product_category > 0) {
274 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
276$sql .=
" AND c.fk_soc = s.rowid";
277if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
278 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
280if ($search_status ==
"0") {
281 $sql .=
" AND cd.statut = 0";
283if ($search_status ==
"4") {
284 $sql .=
" AND cd.statut = 4";
286if ($search_status ==
"4&filter=expired") {
287 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
289if ($search_status ==
"4&filter=notexpired") {
290 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
292if ($search_status ==
"5") {
293 $sql .=
" AND cd.statut = 5";
295if ($search_subprice) {
301if ($search_total_ht) {
304if ($search_total_tva) {
307if ($search_total_ttc) {
313if ($search_contract) {
316if ($search_service) {
317 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
320 $sql .=
" AND s.rowid = ".((int) $socid);
323$filter_dateouvertureprevue =
'';
326$filter_opcloture =
'';
328$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
329$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
330if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
331 $filter_opouvertureprevue =
' BETWEEN ';
334$filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
335$filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
336if ($filter_date1_start !=
'' && $filter_op1 == -1) {
337 $filter_op1 =
' BETWEEN ';
340$filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
341$filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
342if ($filter_date2_start !=
'' && $filter_op2 == -1) {
343 $filter_op2 =
' BETWEEN ';
346$filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
347$filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
348if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
349 $filter_opcloture =
' BETWEEN ';
352if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
353 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
355if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
356 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
358if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
359 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
361if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
362 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
364if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
365 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
367if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
368 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
370if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
371 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
373if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
374 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
377include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
380$parameters = array();
381$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
382$sql .= $hookmanager->resPrint;
385$nbtotalofrecords =
'';
387 $result = $db->query($sql);
388 $nbtotalofrecords = $db->num_rows($result);
389 if (($page * $limit) > $nbtotalofrecords) {
396$sql .= $db->order($sortfield, $sortorder);
398 $sql .= $db->plimit($limit + 1, $offset);
402dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
403$resql = $db->query($sql);
409$num = $db->num_rows($resql);
426$arrayofselected = is_array($toselect) ? $toselect : array();
430 $param .=
'&mode='.urlencode($mode);
432if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
433 $param .=
'&contextpage='.urlencode($contextpage);
435if ($limit > 0 && $limit != $conf->liste_limit) {
436 $param .=
'&limit='.((int) $limit);
438if ($optioncss !=
'') {
439 $param .=
'&optioncss='.urlencode($optioncss);
441if ($search_contract) {
442 $param .=
'&search_contract='.urlencode($search_contract);
445 $param .=
'&search_name='.urlencode($search_name);
447if ($search_subprice) {
448 $param .=
'&search_subprice='.urlencode($search_subprice);
451 $param .=
'&search_qty='.urlencode($search_qty);
453if ($search_total_ht) {
454 $param .=
'&search_total_ht='.urlencode($search_total_ht);
456if ($search_total_tva) {
457 $param .=
'&search_total_tva='.urlencode($search_total_tva);
459if ($search_total_ttc) {
460 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
462if ($search_service) {
463 $param .=
'&search_service='.urlencode($search_service);
466 $param .=
'&search_status='.urlencode($search_status);
468if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
469 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
471if (!empty($filter_op1) && $filter_op1 != -1) {
472 $param .=
'&filter_op1='.urlencode($filter_op1);
474if (!empty($filter_op2) && $filter_op2 != -1) {
475 $param .=
'&filter_op2='.urlencode($filter_op2);
477if (!empty($filter_opcloture) && $filter_opcloture != -1) {
478 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
480if ($filter_dateouvertureprevue_start !=
'') {
481 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
483if ($filter_date1_start !=
'') {
484 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
486if ($filter_date2_start !=
'') {
487 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
489if ($filter_datecloture_start !=
'') {
490 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
493include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
495$parameters = array();
496$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
497$param .= $hookmanager->resPrint;
500$arrayofmassactions = array(
506$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
508print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
509if ($optioncss !=
'') {
510 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
512print
'<input type="hidden" name="token" value="'.newToken().
'">';
513print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
514print
'<input type="hidden" name="action" value="list">';
515print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
516print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
517print
'<input type="hidden" name="page" value="'.$page.
'">';
518print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
519print
'<input type="hidden" name="page_y" value="">';
520print
'<input type="hidden" name="mode" value="'.$mode.
'">';
525print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
528 foreach ($fieldstosearchall as $key => $val) {
529 $fieldstosearchall[$key] = $langs->trans($val);
531 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).join(
', ', $fieldstosearchall).
'</div>';
538if (isModEnabled(
'categorie') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
539 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
540 $moreforfilter .=
'<div class="divsearchfield">';
541 $tmptitle = $langs->trans(
'IncludingProductWithTag');
542 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
543 $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);
544 $moreforfilter .=
'</div>';
547$parameters = array();
548$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
549if (empty($reshook)) {
550 $moreforfilter .= $hookmanager->resPrint;
552 $moreforfilter = $hookmanager->resPrint;
556if (!empty($moreforfilter)) {
557 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
558 print $moreforfilter;
559 $parameters = array();
560 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
561 print $hookmanager->resPrint;
565$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
566$selectedfields = ($mode !=
'kanban' ? $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN',
'')) :
'');
567$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
570print
'<div class="div-table-responsive">';
571print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
575print
'<tr class="liste_titre_filter">';
578 print
'<td class="liste_titre center maxwidthsearch">';
579 $searchpicto = $form->showFilterButtons(
'left');
583if (!empty($arrayfields[
'c.ref'][
'checked'])) {
584 print
'<td class="liste_titre">';
585 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
586 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
590if (!empty($arrayfields[
'p.description'][
'checked'])) {
591 print
'<td class="liste_titre">';
592 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
596if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
597 print
'<td class="liste_titre">';
600if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
601 print
'<td class="liste_titre right">';
602 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
605if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
606 print
'<td class="liste_titre right">';
607 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
610if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
611 print
'<td class="liste_titre right">';
612 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
615if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
616 print
'<td class="liste_titre right">';
617 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
621if (!empty($arrayfields[
's.nom'][
'checked'])) {
622 print
'<td class="liste_titre">';
623 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
627if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
628 print
'<td class="liste_titre center">';
629 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
630 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
632 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
633 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
636if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
637 print
'<td class="liste_titre center">';
638 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
639 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
641 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
642 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
645if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
646 print
'<td class="liste_titre center">';
647 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
648 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
650 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
651 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
654if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
655 print
'<td class="liste_titre center">';
656 $arrayofoperators = array(
'<'=>
'<',
'>'=>
'>');
657 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
659 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
660 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
664include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
667$parameters = array(
'arrayfields'=>$arrayfields);
668$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
669print $hookmanager->resPrint;
670if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
672 print
'<td class="liste_titre">';
675if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
677 print
'<td class="liste_titre">';
680if (!empty($arrayfields[
'status'][
'checked'])) {
682 print
'<td class="liste_titre right parentonrightofpage">';
683 $arrayofstatus = array(
684 '0'=>$langs->trans(
"ServiceStatusInitial"),
685 '4'=>$langs->trans(
"ServiceStatusRunning"),
686 '4&filter=notexpired'=>$langs->trans(
"ServiceStatusNotLate"),
687 '4&filter=expired'=>$langs->trans(
"ServiceStatusLate"),
688 '5'=>$langs->trans(
"ServiceStatusClosed")
690 $search_status_new =
GETPOST(
'search_status',
'alpha');
691 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
692 $search_status_new .=
'&filter=expired';
694 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
699 print
'<td class="liste_titre center maxwidthsearch">';
700 $searchpicto = $form->showFilterButtons();
706$totalarray = array();
707$totalarray[
'nbfield'] = 0;
711print
'<tr class="liste_titre">';
714 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
715 $totalarray[
'nbfield']++;
717if (!empty($arrayfields[
'c.ref'][
'checked'])) {
718 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
720if (!empty($arrayfields[
'p.description'][
'checked'])) {
721 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
723if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
724 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
726if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
727 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
729if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
730 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
732if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
733 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
735if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
736 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
738if (!empty($arrayfields[
's.nom'][
'checked'])) {
739 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
741if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
742 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
744if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
745 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
747if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
748 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
750if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
751 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
754include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
756$parameters = array(
'arrayfields'=>$arrayfields,
'param'=>$param,
'sortfield'=>$sortfield,
'sortorder'=>$sortorder);
757$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
758print $hookmanager->resPrint;
759if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
760 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
762if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
763 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
765if (!empty($arrayfields[
'status'][
'checked'])) {
766 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
770 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
771 $totalarray[
'nbfield']++;
779$contractstatic =
new Contrat($db);
780$productstatic =
new Product($db);
783$savnbfield = $totalarray[
'nbfield'];
784$totalarray = array(
'nbfield'=>0,
'cd.qty'=>0,
'cd.total_ht'=>0,
'cd.total_tva'=>0);
785$imaxinloop = ($limit ? min($num, $limit) : $num);
786while ($i < $imaxinloop) {
787 $obj = $db->fetch_object($resql);
792 $contractstatic->id = $obj->cid;
793 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
794 $contractstatic->ref_customer = $obj->ref_customer;
795 $contractstatic->ref_supplier = $obj->ref_supplier;
797 $companystatic->id = $obj->socid;
798 $companystatic->name = $obj->name;
799 $companystatic->email = $obj->email;
800 $companystatic->client = $obj->client;
801 $companystatic->fournisseur = $obj->fournisseur;
803 $productstatic->id = $obj->pid;
804 $productstatic->type = $obj->ptype;
805 $productstatic->ref = $obj->pref;
806 $productstatic->entity = $obj->pentity;
807 $productstatic->status = $obj->tosell;
808 $productstatic->status_buy = $obj->tobuy;
809 $productstatic->label = $obj->label;
810 $productstatic->description = $obj->description;
811 $productstatic->barcode = $obj->barcode;
813 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
817 print
'<td class="nowrap center">';
818 if ($massactionbutton || $massaction) {
820 if (in_array($obj->rowid, $arrayofselected)) {
823 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
827 $totalarray[
'nbfield']++;
831 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
832 print
'<td class="nowraponall">';
833 print $contractstatic->getNomUrl(1, 16);
836 $totalarray[
'nbfield']++;
840 if (!empty($arrayfields[
'p.description'][
'checked'])) {
841 print
'<td class="tdoverflowmax300">';
843 print $productstatic->getNomUrl(1,
'', 24);
844 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
846 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
849 if ($obj->type == 0) {
852 if ($obj->type == 1) {
858 $totalarray[
'nbfield']++;
862 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
863 print
'<td class="right nowraponall">';
867 $totalarray[
'nbfield']++;
870 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
871 print
'<td class="right nowraponall">';
872 print
price($obj->subprice);
875 $totalarray[
'nbfield']++;
878 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
879 print
'<td class="right nowraponall">';
883 $totalarray[
'nbfield']++;
886 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
888 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
890 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
891 print
'<td class="right nowraponall">';
892 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
895 $totalarray[
'nbfield']++;
898 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
900 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
902 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
903 print
'<td class="right nowraponall">';
904 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
907 $totalarray[
'nbfield']++;
910 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
912 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
916 if (!empty($arrayfields[
's.nom'][
'checked'])) {
917 print
'<td class="tdoverflowmax100">';
918 print $companystatic->getNomUrl(1,
'customer', 28);
921 $totalarray[
'nbfield']++;
926 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
927 print
'<td class="center nowraponall">';
928 print($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
929 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
930 print
' '.img_picto($langs->trans(
"Late"),
"warning");
932 print
' ';
936 $totalarray[
'nbfield']++;
939 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
940 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
942 $totalarray[
'nbfield']++;
946 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
947 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
948 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
949 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
950 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
953 print
' ';
957 $totalarray[
'nbfield']++;
961 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
962 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
964 $totalarray[
'nbfield']++;
969 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
971 $parameters = array(
'arrayfields'=>$arrayfields,
'obj'=>$obj,
'i'=>$i,
'totalarray'=>&$totalarray);
972 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
973 print $hookmanager->resPrint;
975 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
976 print
'<td class="center">';
977 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
980 $totalarray[
'nbfield']++;
984 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
985 print
'<td class="center nowraponall">';
986 print
dol_print_date($db->jdate($obj->date_update),
'dayhour',
'tzuser');
989 $totalarray[
'nbfield']++;
993 if (!empty($arrayfields[
'status'][
'checked'])) {
994 print
'<td class="right">';
995 if ($obj->cstatut == 0) {
997 print $contractstatic->LibStatut(0, 5);
999 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1003 $totalarray[
'nbfield']++;
1008 print
'<td class="nowrap center">';
1009 if ($massactionbutton || $massaction) {
1011 if (in_array($obj->rowid, $arrayofselected)) {
1014 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1018 $totalarray[
'nbfield']++;
1027include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1032 foreach ($arrayfields as $key => $val) {
1033 if (!empty($val[
'checked'])) {
1037 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1042$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1043$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1044print $hookmanager->resPrint;
1046print
'</table>'.
"\n";
1049print
'</form>'.
"\n";
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...)
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 a 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.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get 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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.