33require
"../main.inc.php";
42require_once DOL_DOCUMENT_ROOT.
"/contrat/class/contrat.class.php";
43require_once DOL_DOCUMENT_ROOT.
"/product/class/product.class.php";
44require_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:int');
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$sqlfilter_opouvertureprevue =
GETPOST(
'filter_opouvertureprevue',
'alphawithlgt');
108$sqlfilter_op1 =
GETPOST(
'filter_op1',
'alphawithlgt');
113$sqlfilter_op2 =
GETPOST(
'filter_op2',
'alphawithlgt');
115$opcloturemonth =
GETPOSTINT(
'opcloturemonth');
118$sqlfilter_opcloture =
GETPOST(
'filter_opcloture',
'alphawithlgt');
123$hookmanager->initHooks(array(
'contractservicelist'));
126$extrafields->fetch_name_optionals_label(
$object->table_element);
128$search_array_options = $extrafields->getOptionalsFromPost(
$object->table_element,
'',
'search_');
132if (!empty($user->socid)) {
133 $socid = $user->socid;
142 'c.ref' => array(
'label' =>
"Contract",
'checked' =>
'1',
'position' => 80),
143 'p.description' => array(
'label' =>
"Service",
'checked' =>
'1',
'position' => 80),
144 's.nom' => array(
'label' =>
"ThirdParty",
'checked' =>
'1',
'position' => 90),
145 'cd.tva_tx' => array(
'label' =>
"VATRate",
'checked' =>
'-1',
'position' => 100),
146 'cd.subprice' => array(
'label' =>
"PriceUHT",
'checked' =>
'-1',
'position' => 105),
147 'cd.qty' => array(
'label' =>
"Qty",
'checked' =>
'1',
'position' => 108),
148 'cd.total_ht' => array(
'label' =>
"TotalHT",
'checked' =>
'-1',
'position' => 109,
'isameasure' => 1),
149 'cd.total_tva' => array(
'label' =>
"TotalVAT",
'checked' =>
'-1',
'position' => 110),
150 'cd.date_ouverture_prevue' => array(
'label' =>
"DateStartPlannedShort",
'checked' =>
'1',
'position' => 150),
151 'cd.date_ouverture' => array(
'label' =>
"DateStartRealShort",
'checked' =>
'1',
'position' => 160),
152 'cd.date_fin_validite' => array(
'label' =>
"DateEndPlannedShort",
'checked' =>
'1',
'position' => 170),
153 'cd.date_cloture' => array(
'label' =>
"DateEndRealShort",
'checked' =>
'1',
'position' => 180),
155 'cd.tms' => array(
'label' =>
"DateModificationShort",
'checked' =>
'0',
'position' => 500),
156 'status' => array(
'label' =>
"Status",
'checked' =>
'1',
'position' => 1000)
159include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_array_fields.tpl.php';
161$parameters = array(
'arrayfields' => &$arrayfields);
162$reshook = $hookmanager->executeHooks(
'completeArrayFields', $parameters, $object, $action);
167$permissiontoread = $user->hasRight(
'contrat',
'lire');
168$permissiontoadd = $user->hasRight(
'contrat',
'creer');
169$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
178if (
GETPOST(
'cancel',
'alpha')) {
182if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
186$parameters = array(
'socid' => $socid);
187$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
192if (empty($reshook)) {
194 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
196 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
197 $search_product_category = 0;
199 $search_subprice =
"";
201 $search_total_ht =
"";
202 $search_total_tva =
"";
203 $search_total_ttc =
"";
204 $search_contract =
"";
205 $search_service =
"";
208 $opouvertureprevuemonth =
"";
209 $opouvertureprevueday =
"";
210 $opouvertureprevueyear =
"";
211 $sqlfilter_opouvertureprevue =
"";
220 $opcloturemonth =
"";
223 $sqlfilter_opcloture =
"";
226 $search_array_options = array();
239$title = $langs->trans(
"ListOfServices");
240if ($search_status ==
"0") {
241 $title = $langs->trans(
"ListOfInactiveServices");
243if ($search_status ==
"4" && $filter !=
"expired") {
244 $title = $langs->trans(
"ListOfRunningServices");
246if ($search_status ==
"4" && $filter ==
"expired") {
247 $title = $langs->trans(
"ListOfExpiredServices");
249if ($search_status ==
"5") {
250 $title = $langs->trans(
"ListOfClosedServices");
252$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
256$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
257$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
258$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
259$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,";
260if (!$user->hasRight(
'societe',
'client',
'voir')) {
261 $sql .=
" sc.fk_soc, sc.fk_user,";
263$sql .=
" cd.date_ouverture_prevue,";
264$sql .=
" cd.date_ouverture,";
265$sql .=
" cd.date_fin_validite,";
266$sql .=
" cd.date_cloture,";
268$sql .=
" cd.total_ht,";
269$sql .=
" cd.total_tva,";
270$sql .=
" cd.tva_tx,";
271$sql .=
" cd.subprice,";
273$sql .=
" cd.tms as date_modification";
275if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
276 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
277 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
281$parameters = array();
282$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
283$sql .= $hookmanager->resPrint;
284$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
285$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
286if (!$user->hasRight(
'societe',
'client',
'voir')) {
287 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
289$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
290if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
291 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
293$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
294if ($search_product_category > 0) {
295 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
297$sql .=
" WHERE c.entity IN (".getEntity(
$object->element).
")";
298$sql .=
" AND c.rowid = cd.fk_contrat";
299if ($search_product_category > 0) {
300 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
302$sql .=
" AND c.fk_soc = s.rowid";
303if (!$user->hasRight(
'societe',
'client',
'voir')) {
304 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
306if ($search_status ==
"0") {
307 $sql .=
" AND cd.statut = 0";
309if ($search_status ==
"4") {
310 $sql .=
" AND cd.statut = 4";
312if ($search_status ==
"4&filter=expired" || ($search_status ==
'4' && $filter ==
'expired')) {
313 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
315if ($search_status ==
"4&filter=notexpired" || ($search_status ==
'4' && $filter ==
'notexpired')) {
316 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
318if ($search_status ==
"5") {
319 $sql .=
" AND cd.statut = 5";
321if ($search_option ==
'late' && $search_status !=
'0') {
322 $warning_date =
$db->idate(
dol_now() - (
int)
$conf->contract->services->expires->warning_delay);
323 $sql .=
" AND cd.date_fin_validite < '".$db->escape($warning_date).
"'";
325if ($search_option ==
'late' && $search_status ==
'0') {
326 $warning_date =
$db->idate(
dol_now() - (
int)
$conf->contract->services->expires->warning_delay);
327 $sql .=
" AND (cd.date_ouverture_prevue < '".$db->escape($warning_date).
"' OR cd.date_fin_validite < '".
$db->escape($warning_date).
"')";
329if ($search_subprice) {
335if ($search_total_ht) {
338if ($search_total_tva) {
341if ($search_total_ttc) {
347if ($search_contract) {
350if ($search_service) {
351 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
354 $sql .=
" AND s.rowid = ".((int) $socid);
357$filter_dateouvertureprevue =
'';
360$sqlfilter_opcloture =
'';
362$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
363$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
364if ($filter_dateouvertureprevue_start !=
'' && $sqlfilter_opouvertureprevue == -1) {
365 $sqlfilter_opouvertureprevue =
' BETWEEN ';
368$filter_date1_start =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
369$filter_date1_end =
dol_mktime(23, 59, 59, (
int) $op1month, (
int) $op1day, (
int) $op1year);
370if ($filter_date1_start !=
'' && $sqlfilter_op1 == -1) {
371 $sqlfilter_op1 =
' BETWEEN ';
374$filter_date2_start =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
375$filter_date2_end =
dol_mktime(23, 59, 59, (
int) $op2month, (
int) $op2day, (
int) $op2year);
376if ($filter_date2_start !=
'' && $sqlfilter_op2 == -1) {
377 $sqlfilter_op2 =
' BETWEEN ';
380$filter_datecloture_start =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
381$filter_datecloture_end =
dol_mktime(23, 59, 59, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
382if ($filter_datecloture_start !=
'' && $sqlfilter_opcloture == -1) {
383 $sqlfilter_opcloture =
' BETWEEN ';
386if (!empty($sqlfilter_opouvertureprevue) && $sqlfilter_opouvertureprevue != -1 && $sqlfilter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
387 $sql .=
" AND cd.date_ouverture_prevue ".preg_replace(
'/[^<>]/',
'', $sqlfilter_opouvertureprevue).
" '".
$db->idate($filter_dateouvertureprevue_start).
"'";
389if (!empty($sqlfilter_opouvertureprevue) && $sqlfilter_opouvertureprevue ==
' BETWEEN ') {
390 $sql .=
" AND cd.date_ouverture_prevue ".$db->sanitize($sqlfilter_opouvertureprevue).
" '".
$db->idate($filter_dateouvertureprevue_start).
"' AND '".
$db->idate($filter_dateouvertureprevue_end).
"'";
392if (!empty($sqlfilter_op1) && $sqlfilter_op1 != -1 && $sqlfilter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
393 $sql .=
" AND cd.date_ouverture ".preg_replace(
'/[^<>]/',
'', $sqlfilter_op1).
" '".
$db->idate($filter_date1_start).
"'";
395if (!empty($sqlfilter_op1) && $sqlfilter_op1 ==
' BETWEEN ') {
396 $sql .=
" AND cd.date_ouverture ".$db->sanitize($sqlfilter_op1).
" '".
$db->idate($filter_date1_start).
"' AND '".
$db->idate($filter_date1_end).
"'";
398if (!empty($sqlfilter_op2) && $sqlfilter_op2 != -1 && $sqlfilter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
399 $sql .=
" AND cd.date_fin_validite ".preg_replace(
'/[^<>]/',
'', $sqlfilter_op2).
" '".
$db->idate($filter_date2_start).
"'";
401if (!empty($sqlfilter_op2) && $sqlfilter_op2 ==
' BETWEEN ') {
402 $sql .=
" AND cd.date_fin_validite ".$db->sanitize($sqlfilter_op2).
" '".
$db->idate($filter_date2_start).
"' AND '".
$db->idate($filter_date2_end).
"'";
404if (!empty($sqlfilter_opcloture) && $sqlfilter_opcloture !=
' BETWEEN ' && $sqlfilter_opcloture != -1 && $filter_datecloture_start !=
'') {
405 $sql .=
" AND cd.date_cloture ".preg_replace(
'/[^<>]/',
'', $sqlfilter_opcloture).
" '".
$db->idate($filter_datecloture_start).
"'";
407if (!empty($sqlfilter_opcloture) && $sqlfilter_opcloture ==
' BETWEEN ') {
408 $sql .=
" AND cd.date_cloture ".$db->sanitize($sqlfilter_opcloture).
" '".
$db->idate($filter_datecloture_start).
"' AND '".
$db->idate($filter_datecloture_end).
"'";
411include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
414$parameters = array();
415$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
416$sql .= $hookmanager->resPrint;
419$nbtotalofrecords =
'';
421 $result =
$db->query($sql);
422 $nbtotalofrecords =
$db->num_rows($result);
423 if (($page * $limit) > (
int) $nbtotalofrecords) {
430$sql .=
$db->order($sortfield, $sortorder);
432 $sql .=
$db->plimit($limit + 1, $offset);
436dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
437$resql =
$db->query($sql);
443$num =
$db->num_rows($resql);
458llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-list_services bodyforlist');
460$arrayofselected = is_array($toselect) ? $toselect : array();
464 $param .=
'&mode='.urlencode($mode);
466if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
467 $param .=
'&contextpage='.urlencode($contextpage);
469if ($limit > 0 && $limit !=
$conf->liste_limit) {
470 $param .=
'&limit='.((int) $limit);
472if ($optioncss !=
'') {
473 $param .=
'&optioncss='.urlencode($optioncss);
475if ($search_contract) {
476 $param .=
'&search_contract='.urlencode($search_contract);
479 $param .=
'&search_name='.urlencode($search_name);
481if ($search_subprice) {
482 $param .=
'&search_subprice='.urlencode($search_subprice);
485 $param .=
'&search_qty='.urlencode($search_qty);
487if ($search_total_ht) {
488 $param .=
'&search_total_ht='.urlencode($search_total_ht);
490if ($search_total_tva) {
491 $param .=
'&search_total_tva='.urlencode($search_total_tva);
493if ($search_total_ttc) {
494 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
496if ($search_service) {
497 $param .=
'&search_service='.urlencode($search_service);
499if ($search_status !=
'') {
500 if ($filter ==
'expired' || $filter ==
'notexpired') {
501 $param .=
'&search_status='.urlencode($search_status.
'&filter='.$filter);
503 $param .=
'&search_status='.urlencode($search_status);
507 $param .=
"&search_option=".urlencode($search_option);
509if (!empty($sqlfilter_opouvertureprevue) && $sqlfilter_opouvertureprevue != -1) {
510 $param .=
'&filter_opouvertureprevue='.urlencode($sqlfilter_opouvertureprevue);
512if (!empty($sqlfilter_op1) && $sqlfilter_op1 != -1) {
513 $param .=
'&filter_op1='.urlencode($sqlfilter_op1);
515if (!empty($sqlfilter_op2) && $sqlfilter_op2 != -1) {
516 $param .=
'&filter_op2='.urlencode($sqlfilter_op2);
518if (!empty($sqlfilter_opcloture) && $sqlfilter_opcloture != -1) {
519 $param .=
'&filter_opcloture='.urlencode($sqlfilter_opcloture);
521if ($filter_dateouvertureprevue_start !=
'') {
522 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
524if ($filter_date1_start !=
'') {
525 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
527if ($filter_date2_start !=
'') {
528 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
530if ($filter_datecloture_start !=
'') {
531 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
534include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
536$parameters = array();
537$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
538$param .= $hookmanager->resPrint;
541$arrayofmassactions = array(
547$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
549print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
550if ($optioncss !=
'') {
551 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
553print
'<input type="hidden" name="token" value="'.newToken().
'">';
554print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
555print
'<input type="hidden" name="action" value="list">';
556print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
557print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
558print
'<input type="hidden" name="page" value="'.$page.
'">';
559print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
560print
'<input type="hidden" name="page_y" value="">';
561print
'<input type="hidden" name="mode" value="'.$mode.
'">';
566print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
569 $fieldstosearchall = array();
570 foreach ($fieldstosearchall as $key => $val) {
571 $fieldstosearchall[$key] = $langs->trans($val);
573 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
580if (
isModEnabled(
'category') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
581 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
582 $moreforfilter .=
'<div class="divsearchfield">';
583 $tmptitle = $langs->trans(
'IncludingProductWithTag');
584 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
585 $moreforfilter .=
img_picto($tmptitle,
'category',
'class="pictofixedwidth"').$form->selectarray(
'search_product_category', $cate_arbo, $search_product_category, $tmptitle, 0, 0,
'', 0, 0, 0,
'',
'widthcentpercentminusx maxwidth300', 1);
586 $moreforfilter .=
'</div>';
589$moreforfilter .=
'<div class="divsearchfield">';
590$moreforfilter .=
'<label for="search_option">'.$langs->trans(
'Alert').
'</label> <input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
591$moreforfilter .=
'</div>';
593$parameters = array();
594$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
595if (empty($reshook)) {
596 $moreforfilter .= $hookmanager->resPrint;
598 $moreforfilter = $hookmanager->resPrint;
602if (!empty($moreforfilter)) {
603 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
604 print $moreforfilter;
608$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
609$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
$conf->main_checkbox_left_column);
610$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
611$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
614print
'<div class="div-table-responsive">';
615print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
619print
'<tr class="liste_titre_filter">';
621if (
$conf->main_checkbox_left_column) {
622 print
'<td class="liste_titre center maxwidthsearch">';
623 $searchpicto = $form->showFilterButtons(
'left');
627if (!empty($arrayfields[
'c.ref'][
'checked'])) {
628 print
'<td class="liste_titre">';
629 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
630 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
634if (!empty($arrayfields[
'p.description'][
'checked'])) {
635 print
'<td class="liste_titre">';
636 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
640if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
641 print
'<td class="liste_titre">';
644if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
645 print
'<td class="liste_titre right">';
646 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
649if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
650 print
'<td class="liste_titre right">';
651 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
654if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
655 print
'<td class="liste_titre right">';
656 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
659if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
660 print
'<td class="liste_titre right">';
661 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
665if (!empty($arrayfields[
's.nom'][
'checked'])) {
666 print
'<td class="liste_titre">';
667 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
671if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
672 print
'<td class="liste_titre center">';
673 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
674 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $sqlfilter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
676 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
677 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
680if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
681 print
'<td class="liste_titre center">';
682 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
683 print $form->selectarray(
'filter_op1', $arrayofoperators, $sqlfilter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
685 $filter_date1 =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
686 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
689if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
690 print
'<td class="liste_titre center">';
691 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
692 print $form->selectarray(
'filter_op2', $arrayofoperators, $sqlfilter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
694 $filter_date2 =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
695 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
698if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
699 print
'<td class="liste_titre center">';
700 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
701 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $sqlfilter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
703 $filter_date_cloture =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
704 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
708include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
711$parameters = array(
'arrayfields' => $arrayfields);
712$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
713print $hookmanager->resPrint;
714if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
716 print
'<td class="liste_titre">';
719if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
721 print
'<td class="liste_titre">';
724if (!empty($arrayfields[
'status'][
'checked'])) {
726 print
'<td class="liste_titre right parentonrightofpage">';
727 $arrayofstatus = array(
728 '0' => $langs->trans(
"ServiceStatusInitial"),
729 '4' => $langs->trans(
"ServiceStatusRunning"),
730 '4&filter=notexpired' => $langs->trans(
"ServiceStatusNotLate"),
731 '4&filter=expired' => $langs->trans(
"ServiceStatusLate"),
732 '5' => $langs->trans(
"ServiceStatusClosed")
734 $search_status_new =
GETPOST(
'search_status',
'alpha');
735 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
736 $search_status_new .=
'&filter=expired';
738 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
742if (!
$conf->main_checkbox_left_column) {
743 print
'<td class="liste_titre center maxwidthsearch">';
744 $searchpicto = $form->showFilterButtons();
755print
'<tr class="liste_titre">';
757if (
$conf->main_checkbox_left_column) {
758 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
761if (!empty($arrayfields[
'c.ref'][
'checked'])) {
763 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
765if (!empty($arrayfields[
'p.description'][
'checked'])) {
766 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
768if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
769 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
771if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
772 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
774if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
775 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
777if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
778 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
780if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
781 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
783if (!empty($arrayfields[
's.nom'][
'checked'])) {
784 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
786if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
787 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
789if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
790 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
792if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
793 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
795if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
796 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
799include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
801$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
802$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
803print $hookmanager->resPrint;
804if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
805 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
807if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
808 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
810if (!empty($arrayfields[
'status'][
'checked'])) {
811 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
814if (!
$conf->main_checkbox_left_column) {
815 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
829$totalarray = array(
'nbfield' => 0,
'val' => array(
'cd.qty' => 0,
'cd.total_ht' => 0,
'cd.total_tva' => 0));
830$imaxinloop = ($limit ? min($num, $limit) : $num);
831while ($i < $imaxinloop) {
832 $obj =
$db->fetch_object($resql);
837 $contractstatic->id = $obj->cid;
838 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
839 $contractstatic->ref_customer = $obj->ref_customer;
840 $contractstatic->ref_supplier = $obj->ref_supplier;
842 $companystatic->id = $obj->socid;
843 $companystatic->name = $obj->name;
844 $companystatic->email = $obj->email;
845 $companystatic->client = $obj->client;
846 $companystatic->fournisseur = $obj->fournisseur;
848 $productstatic->id = $obj->pid;
849 $productstatic->type = $obj->ptype;
850 $productstatic->ref = $obj->pref;
851 $productstatic->entity = $obj->pentity;
852 $productstatic->status = $obj->tosell;
853 $productstatic->status_buy = $obj->tobuy;
854 $productstatic->label = $obj->label;
855 $productstatic->description = $obj->description;
856 $productstatic->barcode = $obj->barcode;
858 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
861 if (
$conf->main_checkbox_left_column) {
862 print
'<td class="nowrap center">';
863 if ($massactionbutton || $massaction) {
865 if (in_array($obj->rowid, $arrayofselected)) {
868 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
876 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
877 print
'<td class="nowraponall">';
878 print $contractstatic->getNomUrl(1, 16);
885 if (!empty($arrayfields[
'p.description'][
'checked'])) {
886 print
'<td class="tdoverflowmax300">';
888 print $productstatic->getNomUrl(1,
'', 24);
889 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
891 print
'<br><div class="small lineheightsmall">'.dol_nl2br($obj->description).
'</div>';
894 if ($obj->type == 0) {
897 if ($obj->type == 1) {
907 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
908 print
'<td class="right nowraponall">';
915 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
916 print
'<td class="right nowraponall">';
917 print
price($obj->subprice);
923 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
924 print
'<td class="right nowraponall">';
935 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
936 print
'<td class="right nowraponall">';
937 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
945 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
947 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
948 print
'<td class="right nowraponall">';
949 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
957 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
961 if (!empty($arrayfields[
's.nom'][
'checked'])) {
962 print
'<td class="tdoverflowmax100">';
963 print $companystatic->getNomUrl(1,
'customer', 28);
971 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
972 print
'<td class="center nowraponall">';
973 print($obj->date_ouverture_prevue ?
dol_print_date(
$db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
974 if (
$db->jdate($obj->date_ouverture_prevue) && (
$db->jdate($obj->date_ouverture_prevue) < ($now -
$conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
975 print
' '.img_picto($langs->trans(
"Late"),
"warning");
977 print
' ';
984 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
985 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date(
$db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
991 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
992 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date(
$db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
993 if ($obj->date_fin_validite &&
$db->jdate($obj->date_fin_validite) < ($now -
$conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
994 $warning_delay =
$conf->contrat->services->expires->warning_delay / 3600 / 24;
995 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
998 print
' ';
1006 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
1007 print
'<td class="center nowraponall">'.dol_print_date(
$db->jdate($obj->date_cloture),
'dayhour').
'</td>';
1014 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1016 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1017 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1018 print $hookmanager->resPrint;
1020 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
1021 print
'<td class="center">';
1029 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
1030 print
'<td class="center nowraponall">';
1038 if (!empty($arrayfields[
'status'][
'checked'])) {
1039 print
'<td class="right">';
1040 if ($obj->cstatut == 0) {
1043 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite &&
$db->jdate($obj->date_fin_validite) < $now) ? 1 : 0,
'',
' - '.$langs->trans(
"Draft"));
1045 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite &&
$db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1053 if (!
$conf->main_checkbox_left_column) {
1054 print
'<td class="nowrap center">';
1055 if ($massactionbutton || $massaction) {
1057 if (in_array($obj->rowid, $arrayofselected)) {
1060 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1073include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1078 foreach ($arrayfields as $key => $val) {
1079 if (!empty($val[
'checked'])) {
1083 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1088$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1089$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1090print $hookmanager->resPrint;
1092print
'</table>'.
"\n";
1095print
'</form>'.
"\n";
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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_now($mode='gmt')
Return date for now.
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...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
natural_search($fields, $value, $mode=0, $nofirstand=0, $sqltoadd='')
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.