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";
47$langs->loadLangs(array(
'products',
'contracts',
'companies'));
50$massaction =
GETPOST(
'massaction',
'alpha');
51$toselect =
GETPOST(
'toselect',
'array');
52$optioncss =
GETPOST(
'optioncss',
'aZ');
54$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') : str_replace(
'_',
'', basename(dirname(__FILE__)).basename(__FILE__,
'.php')).$mode;
58$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
59$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
61if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
65$offset = $limit * $page;
69 $sortfield =
"c.rowid";
75$search_name =
GETPOST(
"search_name",
'alpha');
76$search_subprice =
GETPOST(
"search_subprice",
'alpha');
77$search_qty =
GETPOST(
"search_qty",
'alpha');
78$search_total_ht =
GETPOST(
"search_total_ht",
'alpha');
79$search_total_tva =
GETPOST(
"search_total_tva",
'alpha');
80$search_total_ttc =
GETPOST(
"search_total_ttc",
'alpha');
81$search_contract =
GETPOST(
"search_contract",
'alpha');
82$search_service =
GETPOST(
"search_service",
'alpha');
83$search_status =
GETPOST(
"search_status",
'alpha');
84$search_option =
GETPOST(
'search_option',
'alpha');
85$search_product_category =
GETPOSTINT(
'search_product_category');
89if ($search_status ==
'4&filter=notexpired') {
91 $filter =
'notexpired';
93if ($search_status ==
'4&filter=expired') {
100$opouvertureprevuemonth =
GETPOST(
'opouvertureprevuemonth');
101$opouvertureprevueday =
GETPOST(
'opouvertureprevueday');
102$opouvertureprevueyear =
GETPOST(
'opouvertureprevueyear');
103$filter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue',
'alphawithlgt');
108$filter_op1 =
GETPOST(
'filter_op1',
'alphawithlgt');
113$filter_op2 =
GETPOST(
'filter_op2',
'alphawithlgt');
115$opcloturemonth =
GETPOSTINT(
'opcloturemonth');
118$filter_opcloture =
GETPOST(
'filter_opcloture',
'alphawithlgt');
123$hookmanager->initHooks(array(
'contractservicelist'));
127$extrafields->fetch_name_optionals_label(
$object->table_element);
129$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
133if (!empty($user->socid)) {
134 $socid = $user->socid;
138$staticcontrat =
new Contrat($db);
140$companystatic =
new Societe($db);
143 'c.ref' => array(
'label' =>
"Contract",
'checked' => 1,
'position' => 80),
144 'p.description' => array(
'label' =>
"Service",
'checked' => 1,
'position' => 80),
145 's.nom' => array(
'label' =>
"ThirdParty",
'checked' => 1,
'position' => 90),
146 'cd.tva_tx' => array(
'label' =>
"VATRate",
'checked' => -1,
'position' => 100),
147 'cd.subprice' => array(
'label' =>
"PriceUHT",
'checked' => -1,
'position' => 105),
148 'cd.qty' => array(
'label' =>
"Qty",
'checked' => 1,
'position' => 108),
149 'cd.total_ht' => array(
'label' =>
"TotalHT",
'checked' => -1,
'position' => 109,
'isameasure' => 1),
150 'cd.total_tva' => array(
'label' =>
"TotalVAT",
'checked' => -1,
'position' => 110),
151 'cd.date_ouverture_prevue' => array(
'label' =>
"DateStartPlannedShort",
'checked' => 1,
'position' => 150),
152 'cd.date_ouverture' => array(
'label' =>
"DateStartRealShort",
'checked' => 1,
'position' => 160),
153 'cd.date_fin_validite' => array(
'label' =>
"DateEndPlannedShort",
'checked' => 1,
'position' => 170),
154 'cd.date_cloture' => array(
'label' =>
"DateEndRealShort",
'checked' => 1,
'position' => 180),
156 'cd.tms' => array(
'label' =>
"DateModificationShort",
'checked' => 0,
'position' => 500),
157 'status' => array(
'label' =>
"Status",
'checked' => 1,
'position' => 1000)
160include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
164'@phan-var-force array<string,array{label:string,checked?:int<0,1>,position?:int,help?:string}> $arrayfields';
166$permissiontoread = $user->hasRight(
'contrat',
'lire');
167$permissiontoadd = $user->hasRight(
'contrat',
'creer');
168$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
177if (
GETPOST(
'cancel',
'alpha')) {
181if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
185$parameters = array(
'socid' => $socid);
186$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
191if (empty($reshook)) {
193 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
195 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
196 $search_product_category = 0;
198 $search_subprice =
"";
200 $search_total_ht =
"";
201 $search_total_tva =
"";
202 $search_total_ttc =
"";
203 $search_contract =
"";
204 $search_service =
"";
207 $opouvertureprevuemonth =
"";
208 $opouvertureprevueday =
"";
209 $opouvertureprevueyear =
"";
210 $filter_opouvertureprevue =
"";
219 $opcloturemonth =
"";
222 $filter_opcloture =
"";
225 $search_array_options = array();
234$form =
new Form($db);
238$title = $langs->trans(
"ListOfServices");
239if ($search_status ==
"0") {
240 $title = $langs->trans(
"ListOfInactiveServices");
242if ($search_status ==
"4" && $filter !=
"expired") {
243 $title = $langs->trans(
"ListOfRunningServices");
245if ($search_status ==
"4" && $filter ==
"expired") {
246 $title = $langs->trans(
"ListOfExpiredServices");
248if ($search_status ==
"5") {
249 $title = $langs->trans(
"ListOfClosedServices");
251$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
255$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
256$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
257$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
258$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,";
259if (!$user->hasRight(
'societe',
'client',
'voir')) {
260 $sql .=
" sc.fk_soc, sc.fk_user,";
262$sql .=
" cd.date_ouverture_prevue,";
263$sql .=
" cd.date_ouverture,";
264$sql .=
" cd.date_fin_validite,";
265$sql .=
" cd.date_cloture,";
267$sql .=
" cd.total_ht,";
268$sql .=
" cd.total_tva,";
269$sql .=
" cd.tva_tx,";
270$sql .=
" cd.subprice,";
272$sql .=
" cd.tms as date_modification";
274if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
275 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
276 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
280$parameters = array();
281$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
282$sql .= $hookmanager->resPrint;
283$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
284$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
285if (!$user->hasRight(
'societe',
'client',
'voir')) {
286 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
288$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
289if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
290 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
292$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
293if ($search_product_category > 0) {
294 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
296$sql .=
" WHERE c.entity IN (".getEntity(
$object->element).
")";
297$sql .=
" AND c.rowid = cd.fk_contrat";
298if ($search_product_category > 0) {
299 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
301$sql .=
" AND c.fk_soc = s.rowid";
302if (!$user->hasRight(
'societe',
'client',
'voir')) {
303 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
305if ($search_status ==
"0") {
306 $sql .=
" AND cd.statut = 0";
308if ($search_status ==
"4") {
309 $sql .=
" AND cd.statut = 4";
311if ($search_status ==
"4&filter=expired" || ($search_status ==
'4' && $filter ==
'expired')) {
312 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
314if ($search_status ==
"4&filter=notexpired" || ($search_status ==
'4' && $filter ==
'notexpired')) {
315 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
317if ($search_status ==
"5") {
318 $sql .=
" AND cd.statut = 5";
320if ($search_option ==
'late' && $search_status !=
'0') {
321 $warning_date = $db->idate(
dol_now() -
$conf->contract->services->expires->warning_delay);
322 $sql .=
" AND cd.date_fin_validite < '".addslashes($warning_date).
"'";
324if ($search_option ==
'late' && $search_status ==
'0') {
325 $warning_date = $db->idate(
dol_now() -
$conf->contract->services->expires->warning_delay);
326 $sql .=
" AND (cd.date_ouverture_prevue < '".addslashes($warning_date).
"' OR cd.date_fin_validite < '".addslashes($warning_date).
"')";
328if ($search_subprice) {
334if ($search_total_ht) {
337if ($search_total_tva) {
340if ($search_total_ttc) {
346if ($search_contract) {
349if ($search_service) {
350 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
353 $sql .=
" AND s.rowid = ".((int) $socid);
356$filter_dateouvertureprevue =
'';
359$filter_opcloture =
'';
361$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
362$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
363if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
364 $filter_opouvertureprevue =
' BETWEEN ';
367$filter_date1_start =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
368$filter_date1_end =
dol_mktime(23, 59, 59, (
int) $op1month, (
int) $op1day, (
int) $op1year);
369if ($filter_date1_start !=
'' && $filter_op1 == -1) {
370 $filter_op1 =
' BETWEEN ';
373$filter_date2_start =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
374$filter_date2_end =
dol_mktime(23, 59, 59, (
int) $op2month, (
int) $op2day, (
int) $op2year);
375if ($filter_date2_start !=
'' && $filter_op2 == -1) {
376 $filter_op2 =
' BETWEEN ';
379$filter_datecloture_start =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
380$filter_datecloture_end =
dol_mktime(23, 59, 59, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
381if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
382 $filter_opcloture =
' BETWEEN ';
385if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
386 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
388if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
389 $sql .=
" AND cd.date_ouverture_prevue ".$filter_opouvertureprevue.
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
391if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
392 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"'";
394if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
395 $sql .=
" AND cd.date_ouverture ".$filter_op1.
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
397if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
398 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"'";
400if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
401 $sql .=
" AND cd.date_fin_validite ".$filter_op2.
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
403if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
404 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"'";
406if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
407 $sql .=
" AND cd.date_cloture ".$filter_opcloture.
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
410include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
415$nbtotalofrecords =
'';
417 $result = $db->query($sql);
418 $nbtotalofrecords = $db->num_rows($result);
419 if (($page * $limit) > $nbtotalofrecords) {
426$sql .= $db->order($sortfield, $sortorder);
428 $sql .= $db->plimit($limit + 1, $offset);
432dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
433$resql = $db->query($sql);
439$num = $db->num_rows($resql);
454llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-list_services bodyforlist');
456$arrayofselected = is_array($toselect) ? $toselect : array();
460 $param .=
'&mode='.urlencode($mode);
462if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
463 $param .=
'&contextpage='.urlencode($contextpage);
465if ($limit > 0 && $limit !=
$conf->liste_limit) {
466 $param .=
'&limit='.((int) $limit);
468if ($optioncss !=
'') {
469 $param .=
'&optioncss='.urlencode($optioncss);
471if ($search_contract) {
472 $param .=
'&search_contract='.urlencode($search_contract);
475 $param .=
'&search_name='.urlencode($search_name);
477if ($search_subprice) {
478 $param .=
'&search_subprice='.urlencode($search_subprice);
481 $param .=
'&search_qty='.urlencode($search_qty);
483if ($search_total_ht) {
484 $param .=
'&search_total_ht='.urlencode($search_total_ht);
486if ($search_total_tva) {
487 $param .=
'&search_total_tva='.urlencode($search_total_tva);
489if ($search_total_ttc) {
490 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
492if ($search_service) {
493 $param .=
'&search_service='.urlencode($search_service);
496 $param .=
'&search_status='.urlencode($search_status);
499 $param .=
"&search_option=".urlencode($search_option);
501if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
502 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
504if (!empty($filter_op1) && $filter_op1 != -1) {
505 $param .=
'&filter_op1='.urlencode($filter_op1);
507if (!empty($filter_op2) && $filter_op2 != -1) {
508 $param .=
'&filter_op2='.urlencode($filter_op2);
510if (!empty($filter_opcloture) && $filter_opcloture != -1) {
511 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
513if ($filter_dateouvertureprevue_start !=
'') {
514 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
516if ($filter_date1_start !=
'') {
517 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
519if ($filter_date2_start !=
'') {
520 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
522if ($filter_datecloture_start !=
'') {
523 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
526include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
529$arrayofmassactions = array(
535$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
537print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
538if ($optioncss !=
'') {
539 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
541print
'<input type="hidden" name="token" value="'.newToken().
'">';
542print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
543print
'<input type="hidden" name="action" value="list">';
544print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
545print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
546print
'<input type="hidden" name="page" value="'.$page.
'">';
547print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
548print
'<input type="hidden" name="page_y" value="">';
549print
'<input type="hidden" name="mode" value="'.$mode.
'">';
554print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
557 $fieldstosearchall = array();
558 foreach ($fieldstosearchall as $key => $val) {
559 $fieldstosearchall[$key] = $langs->trans($val);
561 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
568if (isModEnabled(
'category') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
569 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
570 $moreforfilter .=
'<div class="divsearchfield">';
571 $tmptitle = $langs->trans(
'IncludingProductWithTag');
572 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
573 $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);
574 $moreforfilter .=
'</div>';
577$moreforfilter .=
'<div class="divsearchfield">';
578$moreforfilter .= $langs->trans(
'Alert').
' <input type="checkbox" name="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
579$moreforfilter .=
'</div>';
581$parameters = array();
582$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
583if (empty($reshook)) {
584 $moreforfilter .= $hookmanager->resPrint;
586 $moreforfilter = $hookmanager->resPrint;
590if (!empty($moreforfilter)) {
591 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
592 print $moreforfilter;
596$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
597$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
598$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
599$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
602print
'<div class="div-table-responsive">';
603print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
607print
'<tr class="liste_titre_filter">';
610 print
'<td class="liste_titre center maxwidthsearch">';
611 $searchpicto = $form->showFilterButtons(
'left');
615if (!empty($arrayfields[
'c.ref'][
'checked'])) {
616 print
'<td class="liste_titre">';
617 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
618 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
622if (!empty($arrayfields[
'p.description'][
'checked'])) {
623 print
'<td class="liste_titre">';
624 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
628if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
629 print
'<td class="liste_titre">';
632if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
633 print
'<td class="liste_titre right">';
634 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
637if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
638 print
'<td class="liste_titre right">';
639 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
642if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
643 print
'<td class="liste_titre right">';
644 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
647if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
648 print
'<td class="liste_titre right">';
649 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
653if (!empty($arrayfields[
's.nom'][
'checked'])) {
654 print
'<td class="liste_titre">';
655 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
659if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
660 print
'<td class="liste_titre center">';
661 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
662 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
664 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
665 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
668if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
669 print
'<td class="liste_titre center">';
670 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
671 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
673 $filter_date1 =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
674 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
677if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
678 print
'<td class="liste_titre center">';
679 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
680 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
682 $filter_date2 =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
683 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
686if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
687 print
'<td class="liste_titre center">';
688 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
689 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
691 $filter_date_cloture =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
692 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
696include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
699$parameters = array(
'arrayfields' => $arrayfields);
700$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
701print $hookmanager->resPrint;
702if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
704 print
'<td class="liste_titre">';
707if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
709 print
'<td class="liste_titre">';
712if (!empty($arrayfields[
'status'][
'checked'])) {
714 print
'<td class="liste_titre right parentonrightofpage">';
715 $arrayofstatus = array(
716 '0' => $langs->trans(
"ServiceStatusInitial"),
717 '4' => $langs->trans(
"ServiceStatusRunning"),
718 '4&filter=notexpired' => $langs->trans(
"ServiceStatusNotLate"),
719 '4&filter=expired' => $langs->trans(
"ServiceStatusLate"),
720 '5' => $langs->trans(
"ServiceStatusClosed")
722 $search_status_new =
GETPOST(
'search_status',
'alpha');
723 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
724 $search_status_new .=
'&filter=expired';
726 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
731 print
'<td class="liste_titre center maxwidthsearch">';
732 $searchpicto = $form->showFilterButtons();
738$totalarray = array();
739$totalarray[
'nbfield'] = 0;
743print
'<tr class="liste_titre">';
746 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
747 $totalarray[
'nbfield']++;
749if (!empty($arrayfields[
'c.ref'][
'checked'])) {
751 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
753if (!empty($arrayfields[
'p.description'][
'checked'])) {
754 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
756if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
757 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
759if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
760 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
762if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
763 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
765if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
766 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
768if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
769 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
771if (!empty($arrayfields[
's.nom'][
'checked'])) {
772 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
774if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
775 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
777if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
778 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
780if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
781 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
783if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
784 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
787include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
789$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
790$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
791print $hookmanager->resPrint;
792if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
793 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
795if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
796 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
798if (!empty($arrayfields[
'status'][
'checked'])) {
799 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
803 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
804 $totalarray[
'nbfield']++;
812$contractstatic =
new Contrat($db);
813$productstatic =
new Product($db);
816$savnbfield = $totalarray[
'nbfield'];
817$totalarray = array(
'nbfield' => 0,
'val' => array(
'cd.qty' => 0,
'cd.total_ht' => 0,
'cd.total_tva' => 0));
818$imaxinloop = ($limit ? min($num, $limit) : $num);
819while ($i < $imaxinloop) {
820 $obj = $db->fetch_object($resql);
825 $contractstatic->id = $obj->cid;
826 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
827 $contractstatic->ref_customer = $obj->ref_customer;
828 $contractstatic->ref_supplier = $obj->ref_supplier;
830 $companystatic->id = $obj->socid;
831 $companystatic->name = $obj->name;
832 $companystatic->email = $obj->email;
833 $companystatic->client = $obj->client;
834 $companystatic->fournisseur = $obj->fournisseur;
836 $productstatic->id = $obj->pid;
837 $productstatic->type = $obj->ptype;
838 $productstatic->ref = $obj->pref;
839 $productstatic->entity = $obj->pentity;
840 $productstatic->status = $obj->tosell;
841 $productstatic->status_buy = $obj->tobuy;
842 $productstatic->label = $obj->label;
843 $productstatic->description = $obj->description;
844 $productstatic->barcode = $obj->barcode;
846 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
850 print
'<td class="nowrap center">';
851 if ($massactionbutton || $massaction) {
853 if (in_array($obj->rowid, $arrayofselected)) {
856 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
860 $totalarray[
'nbfield']++;
864 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
865 print
'<td class="nowraponall">';
866 print $contractstatic->getNomUrl(1, 16);
869 $totalarray[
'nbfield']++;
873 if (!empty($arrayfields[
'p.description'][
'checked'])) {
874 print
'<td class="tdoverflowmax300">';
876 print $productstatic->getNomUrl(1,
'', 24);
877 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
879 print
'<br><span class="small">'.dol_nl2br($obj->description).
'</span>';
882 if ($obj->type == 0) {
885 if ($obj->type == 1) {
891 $totalarray[
'nbfield']++;
895 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
896 print
'<td class="right nowraponall">';
900 $totalarray[
'nbfield']++;
903 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
904 print
'<td class="right nowraponall">';
905 print
price($obj->subprice);
908 $totalarray[
'nbfield']++;
911 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
912 print
'<td class="right nowraponall">';
916 $totalarray[
'nbfield']++;
919 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.qty';
921 $totalarray[
'val'][
'cd.qty'] += $obj->qty;
923 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
924 print
'<td class="right nowraponall">';
925 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
928 $totalarray[
'nbfield']++;
931 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_ht';
933 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
935 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
936 print
'<td class="right nowraponall">';
937 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
940 $totalarray[
'nbfield']++;
943 $totalarray[
'pos'][$totalarray[
'nbfield']] =
'cd.total_tva';
945 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
949 if (!empty($arrayfields[
's.nom'][
'checked'])) {
950 print
'<td class="tdoverflowmax100">';
951 print $companystatic->getNomUrl(1,
'customer', 28);
954 $totalarray[
'nbfield']++;
959 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
960 print
'<td class="center nowraponall">';
961 print($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
962 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now -
$conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
963 print
' '.img_picto($langs->trans(
"Late"),
"warning");
965 print
' ';
969 $totalarray[
'nbfield']++;
972 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
973 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
975 $totalarray[
'nbfield']++;
979 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
980 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
981 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now -
$conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
982 $warning_delay =
$conf->contrat->services->expires->warning_delay / 3600 / 24;
983 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
986 print
' ';
990 $totalarray[
'nbfield']++;
994 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
995 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
997 $totalarray[
'nbfield']++;
1002 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1004 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1005 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1006 print $hookmanager->resPrint;
1008 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
1009 print
'<td class="center">';
1010 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1013 $totalarray[
'nbfield']++;
1017 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
1018 print
'<td class="center nowraponall">';
1019 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
1022 $totalarray[
'nbfield']++;
1026 if (!empty($arrayfields[
'status'][
'checked'])) {
1027 print
'<td class="right">';
1028 if ($obj->cstatut == 0) {
1031 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0,
'',
' - '.$langs->trans(
"Draft"));
1033 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1037 $totalarray[
'nbfield']++;
1042 print
'<td class="nowrap center">';
1043 if ($massactionbutton || $massaction) {
1045 if (in_array($obj->rowid, $arrayofselected)) {
1048 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1052 $totalarray[
'nbfield']++;
1061include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1066 foreach ($arrayfields as $key => $val) {
1067 if (!empty($val[
'checked'])) {
1071 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1076$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1077$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1078print $hookmanager->resPrint;
1080print
'</table>'.
"\n";
1083print
'</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 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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.