32require
"../main.inc.php";
33require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
34require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
35require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
38$langs->loadLangs(array(
'products',
'contracts',
'companies'));
41$massaction =
GETPOST(
'massaction',
'alpha');
42$toselect =
GETPOST(
'toselect',
'array');
43$optioncss =
GETPOST(
'optioncss',
'aZ');
45$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php')).$mode;
49$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
50$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
52if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
56$offset = $limit * $page;
60 $sortfield =
"c.rowid";
66$search_name =
GETPOST(
"search_name",
'alpha');
67$search_subprice =
GETPOST(
"search_subprice",
'alpha');
68$search_qty =
GETPOST(
"search_qty",
'alpha');
69$search_total_ht =
GETPOST(
"search_total_ht",
'alpha');
70$search_total_tva =
GETPOST(
"search_total_tva",
'alpha');
71$search_total_ttc =
GETPOST(
"search_total_ttc",
'alpha');
72$search_contract =
GETPOST(
"search_contract",
'alpha');
73$search_service =
GETPOST(
"search_service",
'alpha');
74$search_status =
GETPOST(
"search_status",
'alpha');
75$search_product_category =
GETPOSTINT(
'search_product_category');
79if ($search_status ==
'4&filter=notexpired') {
81 $filter =
'notexpired';
83if ($search_status ==
'4&filter=expired') {
90$opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
91$opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
92$opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
93$filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue',
'alphawithlgt');
98$filter_op1 =
GETPOST(
'filter_op1',
'alphawithlgt');
103$filter_op2 =
GETPOST(
'filter_op2',
'alphawithlgt');
105$opcloturemonth =
GETPOSTINT(
'opcloturemonth');
108$filter_opcloture =
GETPOST(
'filter_opcloture',
'alphawithlgt');
113$hookmanager->initHooks(array(
'contractservicelist'));
117$extrafields->fetch_name_optionals_label(
$object->table_element);
119$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
123if (!empty($user->socid)) {
124 $socid = $user->socid;
128$staticcontrat =
new Contrat($db);
130$companystatic =
new Societe($db);
133 'c.ref' => array(
'label' =>
"Contract",
'checked' => 1,
'position' => 80),
134 'p.description' => array(
'label' =>
"Service",
'checked' => 1,
'position' => 80),
135 's.nom' => array(
'label' =>
"ThirdParty",
'checked' => 1,
'position' => 90),
136 'cd.tva_tx' => array(
'label' =>
"VATRate",
'checked' => -1,
'position' => 100),
137 'cd.subprice' => array(
'label' =>
"PriceUHT",
'checked' => -1,
'position' => 105),
138 'cd.qty' => array(
'label' =>
"Qty",
'checked' => 1,
'position' => 108),
139 'cd.total_ht' => array(
'label' =>
"TotalHT",
'checked' => -1,
'position' => 109,
'isameasure' => 1),
140 'cd.total_tva' => array(
'label' =>
"TotalVAT",
'checked' => -1,
'position' => 110),
141 'cd.date_ouverture_prevue' => array(
'label' =>
"DateStartPlannedShort",
'checked' => 1,
'position' => 150),
142 'cd.date_ouverture' => array(
'label' =>
"DateStartRealShort",
'checked' => 1,
'position' => 160),
143 'cd.date_fin_validite' => array(
'label' =>
"DateEndPlannedShort",
'checked' => 1,
'position' => 170),
144 'cd.date_cloture' => array(
'label' =>
"DateEndRealShort",
'checked' => 1,
'position' => 180),
146 'cd.tms' => array(
'label' =>
"DateModificationShort",
'checked' => 0,
'position' => 500),
147 'status' => array(
'label' =>
"Status",
'checked' => 1,
'position' => 1000)
150include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
154'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
156$permissiontoread = $user->hasRight(
'contrat',
'lire');
157$permissiontoadd = $user->hasRight(
'contrat',
'creer');
158$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
167if (
GETPOST(
'cancel',
'alpha')) {
171if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
175$parameters = array(
'socid' => $socid);
176$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
181if (empty($reshook)) {
183 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
185 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
186 $search_product_category = 0;
188 $search_subprice =
"";
190 $search_total_ht =
"";
191 $search_total_tva =
"";
192 $search_total_ttc =
"";
193 $search_contract =
"";
194 $search_service =
"";
196 $opouvertureprevuemonth =
"";
197 $opouvertureprevueday =
"";
198 $opouvertureprevueyear =
"";
199 $filter_opouvertureprevue =
"";
208 $opcloturemonth =
"";
211 $filter_opcloture =
"";
214 $search_array_options = array();
223$form =
new Form($db);
227$title = $langs->trans(
"ListOfServices");
228if ($search_status ==
"0") {
229 $title = $langs->trans(
"ListOfInactiveServices");
231if ($search_status ==
"4" && $filter !=
"expired") {
232 $title = $langs->trans(
"ListOfRunningServices");
234if ($search_status ==
"4" && $filter ==
"expired") {
235 $title = $langs->trans(
"ListOfExpiredServices");
237if ($search_status ==
"5") {
238 $title = $langs->trans(
"ListOfClosedServices");
244$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
245$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
246$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
247$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,";
248if (!$user->hasRight(
'societe',
'client',
'voir')) {
249 $sql .=
" sc.fk_soc, sc.fk_user,";
251$sql .=
" cd.date_ouverture_prevue,";
252$sql .=
" cd.date_ouverture,";
253$sql .=
" cd.date_fin_validite,";
254$sql .=
" cd.date_cloture,";
256$sql .=
" cd.total_ht,";
257$sql .=
" cd.total_tva,";
258$sql .=
" cd.tva_tx,";
259$sql .=
" cd.subprice,";
261$sql .=
" cd.tms as date_modification";
263if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
264 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
265 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
269$parameters = array();
270$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
271$sql .= $hookmanager->resPrint;
272$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
273$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
274if (!$user->hasRight(
'societe',
'client',
'voir')) {
275 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
277$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
278if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
279 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
281$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
282if ($search_product_category > 0) {
283 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
285$sql .=
" WHERE c.entity IN (".getEntity(
$object->element).
")";
286$sql .=
" AND c.rowid = cd.fk_contrat";
287if ($search_product_category > 0) {
288 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
290$sql .=
" AND c.fk_soc = s.rowid";
291if (!$user->hasRight(
'societe',
'client',
'voir')) {
292 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
294if ($search_status ==
"0") {
295 $sql .=
" AND cd.statut = 0";
297if ($search_status ==
"4") {
298 $sql .=
" AND cd.statut = 4";
300if ($search_status ==
"4&filter=expired" || ($search_status ==
'4' && $filter ==
'expired')) {
301 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
303if ($search_status ==
"4&filter=notexpired" || ($search_status ==
'4' && $filter ==
'notexpired')) {
304 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
306if ($search_status ==
"5") {
307 $sql .=
" AND cd.statut = 5";
309if ($search_subprice) {
315if ($search_total_ht) {
318if ($search_total_tva) {
321if ($search_total_ttc) {
327if ($search_contract) {
330if ($search_service) {
331 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
334 $sql .=
" AND s.rowid = ".((int) $socid);
337$filter_dateouvertureprevue =
'';
340$filter_opcloture =
'';
342$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
343$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
344if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
345 $filter_opouvertureprevue =
' BETWEEN ';
348$filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
349$filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
350if ($filter_date1_start !=
'' && $filter_op1 == -1) {
351 $filter_op1 =
' BETWEEN ';
354$filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
355$filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
356if ($filter_date2_start !=
'' && $filter_op2 == -1) {
357 $filter_op2 =
' BETWEEN ';
360$filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
361$filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
362if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
363 $filter_opcloture =
' BETWEEN ';
366if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
367 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
369if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
370 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
372if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
373 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
375if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
376 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
378if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
379 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
381if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
382 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
384if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
385 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
387if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
388 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
391include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
394$parameters = array();
395$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
396$sql .= $hookmanager->resPrint;
399$nbtotalofrecords =
'';
401 $result = $db->query($sql);
402 $nbtotalofrecords = $db->num_rows($result);
403 if (($page * $limit) > $nbtotalofrecords) {
410$sql .= $db->order($sortfield, $sortorder);
412 $sql .= $db->plimit($limit + 1, $offset);
416dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
417$resql = $db->query($sql);
423$num = $db->num_rows($resql);
440$arrayofselected = is_array($toselect) ? $toselect : array();
444 $param .=
'&mode='.urlencode($mode);
446if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
447 $param .=
'&contextpage='.urlencode($contextpage);
449if ($limit > 0 && $limit != $conf->liste_limit) {
450 $param .=
'&limit='.((int) $limit);
452if ($optioncss !=
'') {
453 $param .=
'&optioncss='.urlencode($optioncss);
455if ($search_contract) {
456 $param .=
'&search_contract='.urlencode($search_contract);
459 $param .=
'&search_name='.urlencode($search_name);
461if ($search_subprice) {
462 $param .=
'&search_subprice='.urlencode($search_subprice);
465 $param .=
'&search_qty='.urlencode($search_qty);
467if ($search_total_ht) {
468 $param .=
'&search_total_ht='.urlencode($search_total_ht);
470if ($search_total_tva) {
471 $param .=
'&search_total_tva='.urlencode($search_total_tva);
473if ($search_total_ttc) {
474 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
476if ($search_service) {
477 $param .=
'&search_service='.urlencode($search_service);
480 $param .=
'&search_status='.urlencode($search_status);
482if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
483 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
485if (!empty($filter_op1) && $filter_op1 != -1) {
486 $param .=
'&filter_op1='.urlencode($filter_op1);
488if (!empty($filter_op2) && $filter_op2 != -1) {
489 $param .=
'&filter_op2='.urlencode($filter_op2);
491if (!empty($filter_opcloture) && $filter_opcloture != -1) {
492 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
494if ($filter_dateouvertureprevue_start !=
'') {
495 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
497if ($filter_date1_start !=
'') {
498 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
500if ($filter_date2_start !=
'') {
501 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
503if ($filter_datecloture_start !=
'') {
504 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
507include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
509$parameters = array();
510$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
511$param .= $hookmanager->resPrint;
514$arrayofmassactions = array(
520$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
522print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
523if ($optioncss !=
'') {
524 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
526print
'<input type="hidden" name="token" value="'.newToken().
'">';
527print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
528print
'<input type="hidden" name="action" value="list">';
529print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
530print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
531print
'<input type="hidden" name="page" value="'.$page.
'">';
532print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
533print
'<input type="hidden" name="page_y" value="">';
534print
'<input type="hidden" name="mode" value="'.$mode.
'">';
539print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
542 $fieldstosearchall = array();
543 foreach ($fieldstosearchall as $key => $val) {
544 $fieldstosearchall[$key] = $langs->trans($val);
546 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
553if (isModEnabled(
'category') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
554 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
555 $moreforfilter .=
'<div class="divsearchfield">';
556 $tmptitle = $langs->trans(
'IncludingProductWithTag');
557 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
558 $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);
559 $moreforfilter .=
'</div>';
562$parameters = array();
563$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
564if (empty($reshook)) {
565 $moreforfilter .= $hookmanager->resPrint;
567 $moreforfilter = $hookmanager->resPrint;
571if (!empty($moreforfilter)) {
572 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
573 print $moreforfilter;
577$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
578$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
579$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
580$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
583print
'<div class="div-table-responsive">';
584print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
588print
'<tr class="liste_titre_filter">';
591 print
'<td class="liste_titre center maxwidthsearch">';
592 $searchpicto = $form->showFilterButtons(
'left');
596if (!empty($arrayfields[
'c.ref'][
'checked'])) {
597 print
'<td class="liste_titre">';
598 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
599 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
603if (!empty($arrayfields[
'p.description'][
'checked'])) {
604 print
'<td class="liste_titre">';
605 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
609if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
610 print
'<td class="liste_titre">';
613if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
614 print
'<td class="liste_titre right">';
615 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
618if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
619 print
'<td class="liste_titre right">';
620 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
623if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
624 print
'<td class="liste_titre right">';
625 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
628if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
629 print
'<td class="liste_titre right">';
630 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
634if (!empty($arrayfields[
's.nom'][
'checked'])) {
635 print
'<td class="liste_titre">';
636 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
640if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
641 print
'<td class="liste_titre center">';
642 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
643 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
645 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
646 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
649if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
650 print
'<td class="liste_titre center">';
651 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
652 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
654 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
655 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
658if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
659 print
'<td class="liste_titre center">';
660 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
661 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
663 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
664 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
667if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
668 print
'<td class="liste_titre center">';
669 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
670 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
672 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
673 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
677include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
680$parameters = array(
'arrayfields' => $arrayfields);
681$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
682print $hookmanager->resPrint;
683if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
685 print
'<td class="liste_titre">';
688if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
690 print
'<td class="liste_titre">';
693if (!empty($arrayfields[
'status'][
'checked'])) {
695 print
'<td class="liste_titre right parentonrightofpage">';
696 $arrayofstatus = array(
697 '0' => $langs->trans(
"ServiceStatusInitial"),
698 '4' => $langs->trans(
"ServiceStatusRunning"),
699 '4&filter=notexpired' => $langs->trans(
"ServiceStatusNotLate"),
700 '4&filter=expired' => $langs->trans(
"ServiceStatusLate"),
701 '5' => $langs->trans(
"ServiceStatusClosed")
703 $search_status_new =
GETPOST(
'search_status',
'alpha');
704 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
705 $search_status_new .=
'&filter=expired';
707 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
712 print
'<td class="liste_titre center maxwidthsearch">';
713 $searchpicto = $form->showFilterButtons();
719$totalarray = array();
720$totalarray[
'nbfield'] = 0;
724print
'<tr class="liste_titre">';
727 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
728 $totalarray[
'nbfield']++;
730if (!empty($arrayfields[
'c.ref'][
'checked'])) {
731 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
733if (!empty($arrayfields[
'p.description'][
'checked'])) {
734 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
736if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
737 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
739if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
740 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
742if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
743 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
745if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
746 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
748if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
749 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
751if (!empty($arrayfields[
's.nom'][
'checked'])) {
752 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
754if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
755 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
757if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
758 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
760if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
761 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
763if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
764 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
767include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
769$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
770$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
771print $hookmanager->resPrint;
772if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
773 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
775if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
776 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
778if (!empty($arrayfields[
'status'][
'checked'])) {
779 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
783 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
784 $totalarray[
'nbfield']++;
792$contractstatic =
new Contrat($db);
793$productstatic =
new Product($db);
796$savnbfield = $totalarray[
'nbfield'];
797$totalarray = array(
'nbfield' => 0,
'val' => array(
'cd.qty' => 0,
'cd.total_ht' => 0,
'cd.total_tva' => 0));
798$imaxinloop = ($limit ? min($num, $limit) : $num);
799while ($i < $imaxinloop) {
800 $obj = $db->fetch_object($resql);
805 $contractstatic->id = $obj->cid;
806 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
807 $contractstatic->ref_customer = $obj->ref_customer;
808 $contractstatic->ref_supplier = $obj->ref_supplier;
810 $companystatic->id = $obj->socid;
811 $companystatic->name = $obj->name;
812 $companystatic->email = $obj->email;
813 $companystatic->client = $obj->client;
814 $companystatic->fournisseur = $obj->fournisseur;
816 $productstatic->id = $obj->pid;
817 $productstatic->type = $obj->ptype;
818 $productstatic->ref = $obj->pref;
819 $productstatic->entity = $obj->pentity;
820 $productstatic->status = $obj->tosell;
821 $productstatic->status_buy = $obj->tobuy;
822 $productstatic->label = $obj->label;
823 $productstatic->description = $obj->description;
824 $productstatic->barcode = $obj->barcode;
826 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
830 print
'<td class="nowrap center">';
831 if ($massactionbutton || $massaction) {
833 if (in_array($obj->rowid, $arrayofselected)) {
836 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
840 $totalarray[
'nbfield']++;
844 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
845 print
'<td class="nowraponall">';
846 print $contractstatic->getNomUrl(1, 16);
849 $totalarray[
'nbfield']++;
853 if (!empty($arrayfields[
'p.description'][
'checked'])) {
854 print
'<td class="tdoverflowmax300">';
856 print $productstatic->getNomUrl(1,
'', 24);
857 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
859 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
862 if ($obj->type == 0) {
865 if ($obj->type == 1) {
871 $totalarray[
'nbfield']++;
875 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
876 print
'<td class="right nowraponall">';
880 $totalarray[
'nbfield']++;
883 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
884 print
'<td class="right nowraponall">';
885 print
price($obj->subprice);
888 $totalarray[
'nbfield']++;
891 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
892 print
'<td class="right nowraponall">';
896 $totalarray[
'nbfield']++;
899 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
901 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
903 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
904 print
'<td class="right nowraponall">';
905 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
908 $totalarray[
'nbfield']++;
911 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
913 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
915 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
916 print
'<td class="right nowraponall">';
917 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
920 $totalarray[
'nbfield']++;
923 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
925 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
929 if (!empty($arrayfields[
's.nom'][
'checked'])) {
930 print
'<td class="tdoverflowmax100">';
931 print $companystatic->getNomUrl(1,
'customer', 28);
934 $totalarray[
'nbfield']++;
939 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
940 print
'<td class="center nowraponall">';
941 print($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
942 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
943 print
' '.img_picto($langs->trans(
"Late"),
"warning");
945 print
' ';
949 $totalarray[
'nbfield']++;
952 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
953 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
955 $totalarray[
'nbfield']++;
959 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
960 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
961 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
962 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
963 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
966 print
' ';
970 $totalarray[
'nbfield']++;
974 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
975 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
977 $totalarray[
'nbfield']++;
982 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
984 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
985 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
986 print $hookmanager->resPrint;
988 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
989 print
'<td class="center">';
990 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
993 $totalarray[
'nbfield']++;
997 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
998 print
'<td class="center nowraponall">';
999 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
1002 $totalarray[
'nbfield']++;
1006 if (!empty($arrayfields[
'status'][
'checked'])) {
1007 print
'<td class="right">';
1008 if ($obj->cstatut == 0) {
1011 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0,
'',
' - '.$langs->trans(
"Draft"));
1013 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1017 $totalarray[
'nbfield']++;
1022 print
'<td class="nowrap center">';
1023 if ($massactionbutton || $massaction) {
1025 if (in_array($obj->rowid, $arrayofselected)) {
1028 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1032 $totalarray[
'nbfield']++;
1041include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1046 foreach ($arrayfields as $key => $val) {
1047 if (!empty($val[
'checked'])) {
1051 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1056$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1057$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1058print $hookmanager->resPrint;
1060print
'</table>'.
"\n";
1063print
'</form>'.
"\n";
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 information (by default a local PHP server timestamp) Rep...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_sort_array(&$array, $index, $order='asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by the value of a given key, which produces ascending (default) or descending out...
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.
print_barre_liste($title, $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.
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
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.