33require
"../main.inc.php";
34require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
35require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
36require_once DOL_DOCUMENT_ROOT.
"/societe/class/societe.class.php";
39$langs->loadLangs(array(
'products',
'contracts',
'companies'));
42$massaction =
GETPOST(
'massaction',
'alpha');
43$toselect =
GETPOST(
'toselect',
'array');
44$optioncss =
GETPOST(
'optioncss',
'aZ');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php')).$mode;
50$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
51$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
53if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
57$offset = $limit * $page;
61 $sortfield =
"c.rowid";
67$search_name =
GETPOST(
"search_name",
'alpha');
68$search_subprice =
GETPOST(
"search_subprice",
'alpha');
69$search_qty =
GETPOST(
"search_qty",
'alpha');
70$search_total_ht =
GETPOST(
"search_total_ht",
'alpha');
71$search_total_tva =
GETPOST(
"search_total_tva",
'alpha');
72$search_total_ttc =
GETPOST(
"search_total_ttc",
'alpha');
73$search_contract =
GETPOST(
"search_contract",
'alpha');
74$search_service =
GETPOST(
"search_service",
'alpha');
75$search_status =
GETPOST(
"search_status",
'alpha');
76$search_product_category =
GETPOSTINT(
'search_product_category');
80if ($search_status ==
'4&filter=notexpired') {
82 $filter =
'notexpired';
84if ($search_status ==
'4&filter=expired') {
91$opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
92$opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
93$opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
94$filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue');
99$filter_op1 =
GETPOST(
'filter_op1',
'alpha');
104$filter_op2 =
GETPOST(
'filter_op2',
'alpha');
106$opcloturemonth =
GETPOSTINT(
'opcloturemonth');
109$filter_opcloture =
GETPOST(
'filter_opcloture',
'alpha');
114$hookmanager->initHooks(array(
'contractservicelist'));
118$extrafields->fetch_name_optionals_label(
$object->table_element);
120$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
124if (!empty($user->socid)) {
125 $socid = $user->socid;
129$staticcontrat =
new Contrat($db);
131$companystatic =
new Societe($db);
134 'c.ref' => array(
'label' =>
"Contract",
'checked' => 1,
'position' => 80),
135 'p.description' => array(
'label' =>
"Service",
'checked' => 1,
'position' => 80),
136 's.nom' => array(
'label' =>
"ThirdParty",
'checked' => 1,
'position' => 90),
137 'cd.tva_tx' => array(
'label' =>
"VATRate",
'checked' => -1,
'position' => 100),
138 'cd.subprice' => array(
'label' =>
"PriceUHT",
'checked' => -1,
'position' => 105),
139 'cd.qty' => array(
'label' =>
"Qty",
'checked' => 1,
'position' => 108),
140 'cd.total_ht' => array(
'label' =>
"TotalHT",
'checked' => -1,
'position' => 109,
'isameasure' => 1),
141 'cd.total_tva' => array(
'label' =>
"TotalVAT",
'checked' => -1,
'position' => 110),
142 'cd.date_ouverture_prevue' => array(
'label' =>
"DateStartPlannedShort",
'checked' => 1,
'position' => 150),
143 'cd.date_ouverture' => array(
'label' =>
"DateStartRealShort",
'checked' => 1,
'position' => 160),
144 'cd.date_fin_validite' => array(
'label' =>
"DateEndPlannedShort",
'checked' => 1,
'position' => 170),
145 'cd.date_cloture' => array(
'label' =>
"DateEndRealShort",
'checked' => 1,
'position' => 180),
147 'cd.tms' => array(
'label' =>
"DateModificationShort",
'checked' => 0,
'position' => 500),
148 'status' => array(
'label' =>
"Status",
'checked' => 1,
'position' => 1000)
151include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
155'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
157$permissiontoread = $user->hasRight(
'contrat',
'lire');
158$permissiontoadd = $user->hasRight(
'contrat',
'creer');
159$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
168if (
GETPOST(
'cancel',
'alpha')) {
172if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
176$parameters = array(
'socid' => $socid);
177$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
182if (empty($reshook)) {
184 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
186 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
187 $search_product_category = 0;
189 $search_subprice =
"";
191 $search_total_ht =
"";
192 $search_total_tva =
"";
193 $search_total_ttc =
"";
194 $search_contract =
"";
195 $search_service =
"";
197 $opouvertureprevuemonth =
"";
198 $opouvertureprevueday =
"";
199 $opouvertureprevueyear =
"";
200 $filter_opouvertureprevue =
"";
209 $opcloturemonth =
"";
212 $filter_opcloture =
"";
215 $search_array_options = array();
224$form =
new Form($db);
228$title = $langs->trans(
"ListOfServices");
229if ($search_status ==
"0") {
230 $title = $langs->trans(
"ListOfInactiveServices");
232if ($search_status ==
"4" && $filter !=
"expired") {
233 $title = $langs->trans(
"ListOfRunningServices");
235if ($search_status ==
"4" && $filter ==
"expired") {
236 $title = $langs->trans(
"ListOfExpiredServices");
238if ($search_status ==
"5") {
239 $title = $langs->trans(
"ListOfClosedServices");
241$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
245$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
246$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
247$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
248$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,";
249if (!$user->hasRight(
'societe',
'client',
'voir')) {
250 $sql .=
" sc.fk_soc, sc.fk_user,";
252$sql .=
" cd.date_ouverture_prevue,";
253$sql .=
" cd.date_ouverture,";
254$sql .=
" cd.date_fin_validite,";
255$sql .=
" cd.date_cloture,";
257$sql .=
" cd.total_ht,";
258$sql .=
" cd.total_tva,";
259$sql .=
" cd.tva_tx,";
260$sql .=
" cd.subprice,";
262$sql .=
" cd.tms as date_modification";
264if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
265 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
266 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
270$parameters = array();
271$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
272$sql .= $hookmanager->resPrint;
273$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
274$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
275if (!$user->hasRight(
'societe',
'client',
'voir')) {
276 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
278$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
279if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
280 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
282$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
283if ($search_product_category > 0) {
284 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
286$sql .=
" WHERE c.entity IN (".getEntity(
$object->element).
")";
287$sql .=
" AND c.rowid = cd.fk_contrat";
288if ($search_product_category > 0) {
289 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
291$sql .=
" AND c.fk_soc = s.rowid";
292if (!$user->hasRight(
'societe',
'client',
'voir')) {
293 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
295if ($search_status ==
"0") {
296 $sql .=
" AND cd.statut = 0";
298if ($search_status ==
"4") {
299 $sql .=
" AND cd.statut = 4";
301if ($search_status ==
"4&filter=expired" || ($search_status ==
'4' && $filter ==
'expired')) {
302 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
304if ($search_status ==
"4&filter=notexpired" || ($search_status ==
'4' && $filter ==
'notexpired')) {
305 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
307if ($search_status ==
"5") {
308 $sql .=
" AND cd.statut = 5";
310if ($search_subprice) {
316if ($search_total_ht) {
319if ($search_total_tva) {
322if ($search_total_ttc) {
328if ($search_contract) {
331if ($search_service) {
332 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
335 $sql .=
" AND s.rowid = ".((int) $socid);
338$filter_dateouvertureprevue =
'';
341$filter_opcloture =
'';
343$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
344$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
345if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
346 $filter_opouvertureprevue =
' BETWEEN ';
349$filter_date1_start =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
350$filter_date1_end =
dol_mktime(23, 59, 59, $op1month, $op1day, $op1year);
351if ($filter_date1_start !=
'' && $filter_op1 == -1) {
352 $filter_op1 =
' BETWEEN ';
355$filter_date2_start =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
356$filter_date2_end =
dol_mktime(23, 59, 59, $op2month, $op2day, $op2year);
357if ($filter_date2_start !=
'' && $filter_op2 == -1) {
358 $filter_op2 =
' BETWEEN ';
361$filter_datecloture_start =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
362$filter_datecloture_end =
dol_mktime(23, 59, 59, $opcloturemonth, $opclotureday, $opclotureyear);
363if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
364 $filter_opcloture =
' BETWEEN ';
367if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
368 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
370if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
371 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
373if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
374 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
376if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
377 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
379if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
380 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
382if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
383 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
385if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
386 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
388if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
389 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
392include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
397$nbtotalofrecords =
'';
399 $result = $db->query($sql);
400 $nbtotalofrecords = $db->num_rows($result);
401 if (($page * $limit) > $nbtotalofrecords) {
408$sql .= $db->order($sortfield, $sortorder);
410 $sql .= $db->plimit($limit + 1, $offset);
414dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
415$resql = $db->query($sql);
421$num = $db->num_rows($resql);
436llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-list_services bodyforlist');
438$arrayofselected = is_array($toselect) ? $toselect : array();
442 $param .=
'&mode='.urlencode($mode);
444if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
445 $param .=
'&contextpage='.urlencode($contextpage);
447if ($limit > 0 && $limit != $conf->liste_limit) {
448 $param .=
'&limit='.((int) $limit);
450if ($optioncss !=
'') {
451 $param .=
'&optioncss='.urlencode($optioncss);
453if ($search_contract) {
454 $param .=
'&search_contract='.urlencode($search_contract);
457 $param .=
'&search_name='.urlencode($search_name);
459if ($search_subprice) {
460 $param .=
'&search_subprice='.urlencode($search_subprice);
463 $param .=
'&search_qty='.urlencode($search_qty);
465if ($search_total_ht) {
466 $param .=
'&search_total_ht='.urlencode($search_total_ht);
468if ($search_total_tva) {
469 $param .=
'&search_total_tva='.urlencode($search_total_tva);
471if ($search_total_ttc) {
472 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
474if ($search_service) {
475 $param .=
'&search_service='.urlencode($search_service);
478 $param .=
'&search_status='.urlencode($search_status);
480if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
481 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
483if (!empty($filter_op1) && $filter_op1 != -1) {
484 $param .=
'&filter_op1='.urlencode($filter_op1);
486if (!empty($filter_op2) && $filter_op2 != -1) {
487 $param .=
'&filter_op2='.urlencode($filter_op2);
489if (!empty($filter_opcloture) && $filter_opcloture != -1) {
490 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
492if ($filter_dateouvertureprevue_start !=
'') {
493 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
495if ($filter_date1_start !=
'') {
496 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
498if ($filter_date2_start !=
'') {
499 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
501if ($filter_datecloture_start !=
'') {
502 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
505include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
508$arrayofmassactions = array(
514$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
516print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
517if ($optioncss !=
'') {
518 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
520print
'<input type="hidden" name="token" value="'.newToken().
'">';
521print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
522print
'<input type="hidden" name="action" value="list">';
523print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
524print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
525print
'<input type="hidden" name="page" value="'.$page.
'">';
526print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
527print
'<input type="hidden" name="page_y" value="">';
528print
'<input type="hidden" name="mode" value="'.$mode.
'">';
533print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
536 $fieldstosearchall = array();
537 foreach ($fieldstosearchall as $key => $val) {
538 $fieldstosearchall[$key] = $langs->trans($val);
540 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
547if (isModEnabled(
'category') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
548 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
549 $moreforfilter .=
'<div class="divsearchfield">';
550 $tmptitle = $langs->trans(
'IncludingProductWithTag');
551 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
null,
'parent',
null,
null, 1);
552 $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);
553 $moreforfilter .=
'</div>';
556$parameters = array();
557$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
558if (empty($reshook)) {
559 $moreforfilter .= $hookmanager->resPrint;
561 $moreforfilter = $hookmanager->resPrint;
565if (!empty($moreforfilter)) {
566 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
567 print $moreforfilter;
568 $parameters = array();
569 $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
570 print $hookmanager->resPrint;
574$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
575$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
576$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
577$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
580print
'<div class="div-table-responsive">';
581print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
585print
'<tr class="liste_titre_filter">';
588 print
'<td class="liste_titre center maxwidthsearch">';
589 $searchpicto = $form->showFilterButtons(
'left');
593if (!empty($arrayfields[
'c.ref'][
'checked'])) {
594 print
'<td class="liste_titre">';
595 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
596 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
600if (!empty($arrayfields[
'p.description'][
'checked'])) {
601 print
'<td class="liste_titre">';
602 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
606if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
607 print
'<td class="liste_titre">';
610if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
611 print
'<td class="liste_titre right">';
612 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
615if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
616 print
'<td class="liste_titre right">';
617 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
620if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
621 print
'<td class="liste_titre right">';
622 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
625if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
626 print
'<td class="liste_titre right">';
627 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
631if (!empty($arrayfields[
's.nom'][
'checked'])) {
632 print
'<td class="liste_titre">';
633 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
637if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
638 print
'<td class="liste_titre center">';
639 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
640 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
642 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, $opouvertureprevuemonth, $opouvertureprevueday, $opouvertureprevueyear);
643 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
646if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
647 print
'<td class="liste_titre center">';
648 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
649 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
651 $filter_date1 =
dol_mktime(0, 0, 0, $op1month, $op1day, $op1year);
652 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
655if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
656 print
'<td class="liste_titre center">';
657 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
658 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
660 $filter_date2 =
dol_mktime(0, 0, 0, $op2month, $op2day, $op2year);
661 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
664if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
665 print
'<td class="liste_titre center">';
666 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
667 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
669 $filter_date_cloture =
dol_mktime(0, 0, 0, $opcloturemonth, $opclotureday, $opclotureyear);
670 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
674include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
677$parameters = array(
'arrayfields' => $arrayfields);
678$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
679print $hookmanager->resPrint;
680if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
682 print
'<td class="liste_titre">';
685if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
687 print
'<td class="liste_titre">';
690if (!empty($arrayfields[
'status'][
'checked'])) {
692 print
'<td class="liste_titre right parentonrightofpage">';
693 $arrayofstatus = array(
694 '0' => $langs->trans(
"ServiceStatusInitial"),
695 '4' => $langs->trans(
"ServiceStatusRunning"),
696 '4&filter=notexpired' => $langs->trans(
"ServiceStatusNotLate"),
697 '4&filter=expired' => $langs->trans(
"ServiceStatusLate"),
698 '5' => $langs->trans(
"ServiceStatusClosed")
700 $search_status_new =
GETPOST(
'search_status',
'alpha');
701 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
702 $search_status_new .=
'&filter=expired';
704 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
709 print
'<td class="liste_titre center maxwidthsearch">';
710 $searchpicto = $form->showFilterButtons();
716$totalarray = array();
717$totalarray[
'nbfield'] = 0;
721print
'<tr class="liste_titre">';
724 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
725 $totalarray[
'nbfield']++;
727if (!empty($arrayfields[
'c.ref'][
'checked'])) {
728 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
730if (!empty($arrayfields[
'p.description'][
'checked'])) {
731 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
733if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
734 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
736if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
737 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
739if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
740 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
742if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
743 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
745if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
746 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
748if (!empty($arrayfields[
's.nom'][
'checked'])) {
749 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
751if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
752 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
754if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
755 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
757if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
758 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
760if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
761 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
764include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
766$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
767$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
768print $hookmanager->resPrint;
769if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
770 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
772if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
773 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
775if (!empty($arrayfields[
'status'][
'checked'])) {
776 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
780 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
781 $totalarray[
'nbfield']++;
789$contractstatic =
new Contrat($db);
790$productstatic =
new Product($db);
793$savnbfield = $totalarray[
'nbfield'];
794$totalarray = array(
'nbfield' => 0,
'val' => array(
'cd.qty' => 0,
'cd.total_ht' => 0,
'cd.total_tva' => 0));
795$imaxinloop = ($limit ? min($num, $limit) : $num);
796while ($i < $imaxinloop) {
797 $obj = $db->fetch_object($resql);
802 $contractstatic->id = $obj->cid;
803 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
804 $contractstatic->ref_customer = $obj->ref_customer;
805 $contractstatic->ref_supplier = $obj->ref_supplier;
807 $companystatic->id = $obj->socid;
808 $companystatic->name = $obj->name;
809 $companystatic->email = $obj->email;
810 $companystatic->client = $obj->client;
811 $companystatic->fournisseur = $obj->fournisseur;
813 $productstatic->id = $obj->pid;
814 $productstatic->type = $obj->ptype;
815 $productstatic->ref = $obj->pref;
816 $productstatic->entity = $obj->pentity;
817 $productstatic->status = $obj->tosell;
818 $productstatic->status_buy = $obj->tobuy;
819 $productstatic->label = $obj->label;
820 $productstatic->description = $obj->description;
821 $productstatic->barcode = $obj->barcode;
823 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
827 print
'<td class="nowrap center">';
828 if ($massactionbutton || $massaction) {
830 if (in_array($obj->rowid, $arrayofselected)) {
833 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
837 $totalarray[
'nbfield']++;
841 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
842 print
'<td class="nowraponall">';
843 print $contractstatic->getNomUrl(1, 16);
846 $totalarray[
'nbfield']++;
850 if (!empty($arrayfields[
'p.description'][
'checked'])) {
851 print
'<td class="tdoverflowmax300">';
853 print $productstatic->getNomUrl(1,
'', 24);
854 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
856 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
859 if ($obj->type == 0) {
862 if ($obj->type == 1) {
868 $totalarray[
'nbfield']++;
872 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
873 print
'<td class="right nowraponall">';
877 $totalarray[
'nbfield']++;
880 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
881 print
'<td class="right nowraponall">';
882 print
price($obj->subprice);
885 $totalarray[
'nbfield']++;
888 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
889 print
'<td class="right nowraponall">';
893 $totalarray[
'nbfield']++;
896 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
898 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
900 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
901 print
'<td class="right nowraponall">';
902 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
905 $totalarray[
'nbfield']++;
908 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
910 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
912 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
913 print
'<td class="right nowraponall">';
914 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
917 $totalarray[
'nbfield']++;
920 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
922 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
926 if (!empty($arrayfields[
's.nom'][
'checked'])) {
927 print
'<td class="tdoverflowmax100">';
928 print $companystatic->getNomUrl(1,
'customer', 28);
931 $totalarray[
'nbfield']++;
936 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
937 print
'<td class="center nowraponall">';
938 print($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
939 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
940 print
' '.img_picto($langs->trans(
"Late"),
"warning");
942 print
' ';
946 $totalarray[
'nbfield']++;
949 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
950 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
952 $totalarray[
'nbfield']++;
956 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
957 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
958 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
959 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
960 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
963 print
' ';
967 $totalarray[
'nbfield']++;
971 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
972 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
974 $totalarray[
'nbfield']++;
979 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
981 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
982 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
983 print $hookmanager->resPrint;
985 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
986 print
'<td class="center">';
987 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
990 $totalarray[
'nbfield']++;
994 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
995 print
'<td class="center nowraponall">';
996 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
999 $totalarray[
'nbfield']++;
1003 if (!empty($arrayfields[
'status'][
'checked'])) {
1004 print
'<td class="right">';
1005 if ($obj->cstatut == 0) {
1008 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0,
'',
' - '.$langs->trans(
"Draft"));
1010 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1014 $totalarray[
'nbfield']++;
1019 print
'<td class="nowrap center">';
1020 if ($massactionbutton || $massaction) {
1022 if (in_array($obj->rowid, $arrayofselected)) {
1025 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1029 $totalarray[
'nbfield']++;
1038include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1043 foreach ($arrayfields as $key => $val) {
1044 if (!empty($val[
'checked'])) {
1048 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1053$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1054$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1055print $hookmanager->resPrint;
1057print
'</table>'.
"\n";
1060print
'</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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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.