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: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$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';
165$permissiontoread = $user->hasRight(
'contrat',
'lire');
166$permissiontoadd = $user->hasRight(
'contrat',
'creer');
167$permissiontodelete = $user->hasRight(
'contrat',
'supprimer');
176if (
GETPOST(
'cancel',
'alpha')) {
180if (!
GETPOST(
'confirmmassaction',
'alpha') && $massaction !=
'presend' && $massaction !=
'confirm_presend') {
184$parameters = array(
'socid' => $socid);
185$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
190if (empty($reshook)) {
192 include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
194 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
195 $search_product_category = 0;
197 $search_subprice =
"";
199 $search_total_ht =
"";
200 $search_total_tva =
"";
201 $search_total_ttc =
"";
202 $search_contract =
"";
203 $search_service =
"";
206 $opouvertureprevuemonth =
"";
207 $opouvertureprevueday =
"";
208 $opouvertureprevueyear =
"";
209 $filter_opouvertureprevue =
"";
218 $opcloturemonth =
"";
221 $filter_opcloture =
"";
224 $search_array_options = array();
233$form =
new Form($db);
237$title = $langs->trans(
"ListOfServices");
238if ($search_status ==
"0") {
239 $title = $langs->trans(
"ListOfInactiveServices");
241if ($search_status ==
"4" && $filter !=
"expired") {
242 $title = $langs->trans(
"ListOfRunningServices");
244if ($search_status ==
"4" && $filter ==
"expired") {
245 $title = $langs->trans(
"ListOfExpiredServices");
247if ($search_status ==
"5") {
248 $title = $langs->trans(
"ListOfClosedServices");
250$help_url =
'EN:Module_Contracts|FR:Module_Contrat|ES:Contratos_de_servicio';
254$sql =
"SELECT c.rowid as cid, c.ref, c.statut as cstatut, c.ref_customer, c.ref_supplier,";
255$sql .=
" s.rowid as socid, s.nom as name, s.email, s.client, s.fournisseur,";
256$sql .=
" cd.rowid, cd.description, cd.statut, cd.product_type as type,";
257$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,";
258if (!$user->hasRight(
'societe',
'client',
'voir')) {
259 $sql .=
" sc.fk_soc, sc.fk_user,";
261$sql .=
" cd.date_ouverture_prevue,";
262$sql .=
" cd.date_ouverture,";
263$sql .=
" cd.date_fin_validite,";
264$sql .=
" cd.date_cloture,";
266$sql .=
" cd.total_ht,";
267$sql .=
" cd.total_tva,";
268$sql .=
" cd.tva_tx,";
269$sql .=
" cd.subprice,";
271$sql .=
" cd.tms as date_modification";
273if (!empty($extrafields->attributes[
$object->table_element][
'label'])) {
274 foreach ($extrafields->attributes[
$object->table_element][
'label'] as $key => $val) {
275 $sql .= ($extrafields->attributes[
$object->table_element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
279$parameters = array();
280$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, $object, $action);
281$sql .= $hookmanager->resPrint;
282$sql .=
" FROM ".MAIN_DB_PREFIX.
"contrat as c,";
283$sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
284if (!$user->hasRight(
'societe',
'client',
'voir')) {
285 $sql .=
" ".MAIN_DB_PREFIX.
"societe_commerciaux as sc,";
287$sql .=
" ".MAIN_DB_PREFIX.
"contratdet as cd";
288if (!empty($extrafields->attributes[
$object->table_element][
'label']) && is_array($extrafields->attributes[
$object->table_element][
'label']) && count($extrafields->attributes[
$object->table_element][
'label'])) {
289 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (cd.rowid = ef.fk_object)";
291$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON cd.fk_product = p.rowid";
292if ($search_product_category > 0) {
293 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'categorie_product as cp ON cp.fk_product=cd.fk_product';
295$sql .=
" WHERE c.entity IN (".getEntity(
$object->element).
")";
296$sql .=
" AND c.rowid = cd.fk_contrat";
297if ($search_product_category > 0) {
298 $sql .=
" AND cp.fk_categorie = ".((int) $search_product_category);
300$sql .=
" AND c.fk_soc = s.rowid";
301if (!$user->hasRight(
'societe',
'client',
'voir')) {
302 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
304if ($search_status ==
"0") {
305 $sql .=
" AND cd.statut = 0";
307if ($search_status ==
"4") {
308 $sql .=
" AND cd.statut = 4";
310if ($search_status ==
"4&filter=expired" || ($search_status ==
'4' && $filter ==
'expired')) {
311 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite < '".$db->idate($now).
"'";
313if ($search_status ==
"4&filter=notexpired" || ($search_status ==
'4' && $filter ==
'notexpired')) {
314 $sql .=
" AND cd.statut = 4 AND cd.date_fin_validite >= '".$db->idate($now).
"'";
316if ($search_status ==
"5") {
317 $sql .=
" AND cd.statut = 5";
319if ($search_option ==
'late' && $search_status !=
'0') {
320 $warning_date = $db->idate(
dol_now() - $conf->contract->services->expires->warning_delay);
321 $sql .=
" AND cd.date_fin_validite < '".addslashes($warning_date).
"'";
323if ($search_option ==
'late' && $search_status ==
'0') {
324 $warning_date = $db->idate(
dol_now() - $conf->contract->services->expires->warning_delay);
325 $sql .=
" AND (cd.date_ouverture_prevue < '".addslashes($warning_date).
"' OR cd.date_fin_validite < '".addslashes($warning_date).
"')";
327if ($search_subprice) {
333if ($search_total_ht) {
336if ($search_total_tva) {
339if ($search_total_ttc) {
345if ($search_contract) {
348if ($search_service) {
349 $sql .=
natural_search(array(
"p.ref",
"p.description",
"cd.description"), $search_service);
352 $sql .=
" AND s.rowid = ".((int) $socid);
355$filter_dateouvertureprevue =
'';
358$filter_opcloture =
'';
360$filter_dateouvertureprevue_start =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
361$filter_dateouvertureprevue_end =
dol_mktime(23, 59, 59, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
362if ($filter_dateouvertureprevue_start !=
'' && $filter_opouvertureprevue == -1) {
363 $filter_opouvertureprevue =
' BETWEEN ';
366$filter_date1_start =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
367$filter_date1_end =
dol_mktime(23, 59, 59, (
int) $op1month, (
int) $op1day, (
int) $op1year);
368if ($filter_date1_start !=
'' && $filter_op1 == -1) {
369 $filter_op1 =
' BETWEEN ';
372$filter_date2_start =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
373$filter_date2_end =
dol_mktime(23, 59, 59, (
int) $op2month, (
int) $op2day, (
int) $op2year);
374if ($filter_date2_start !=
'' && $filter_op2 == -1) {
375 $filter_op2 =
' BETWEEN ';
378$filter_datecloture_start =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
379$filter_datecloture_end =
dol_mktime(23, 59, 59, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
380if ($filter_datecloture_start !=
'' && $filter_opcloture == -1) {
381 $filter_opcloture =
' BETWEEN ';
384if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_opouvertureprevue !=
' BETWEEN ' && $filter_dateouvertureprevue_start !=
'') {
385 $sql .=
" AND cd.date_ouverture_prevue ".preg_replace(
'/[^<>]/',
'', $filter_opouvertureprevue).
" '".$db->idate($filter_dateouvertureprevue_start).
"'";
387if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue ==
' BETWEEN ') {
388 $sql .=
" AND cd.date_ouverture_prevue ".$db->sanitize($filter_opouvertureprevue).
" '".$db->idate($filter_dateouvertureprevue_start).
"' AND '".$db->idate($filter_dateouvertureprevue_end).
"'";
390if (!empty($filter_op1) && $filter_op1 != -1 && $filter_op1 !=
' BETWEEN ' && $filter_date1_start !=
'') {
391 $sql .=
" AND cd.date_ouverture ".preg_replace(
'/[^<>]/',
'', $filter_op1).
" '".$db->idate($filter_date1_start).
"'";
393if (!empty($filter_op1) && $filter_op1 ==
' BETWEEN ') {
394 $sql .=
" AND cd.date_ouverture ".$db->sanitize($filter_op1).
" '".$db->idate($filter_date1_start).
"' AND '".$db->idate($filter_date1_end).
"'";
396if (!empty($filter_op2) && $filter_op2 != -1 && $filter_op2 !=
' BETWEEN ' && $filter_date2_start !=
'') {
397 $sql .=
" AND cd.date_fin_validite ".preg_replace(
'/[^<>]/',
'', $filter_op2).
" '".$db->idate($filter_date2_start).
"'";
399if (!empty($filter_op2) && $filter_op2 ==
' BETWEEN ') {
400 $sql .=
" AND cd.date_fin_validite ".$db->sanitize($filter_op2).
" '".$db->idate($filter_date2_start).
"' AND '".$db->idate($filter_date2_end).
"'";
402if (!empty($filter_opcloture) && $filter_opcloture !=
' BETWEEN ' && $filter_opcloture != -1 && $filter_datecloture_start !=
'') {
403 $sql .=
" AND cd.date_cloture ".preg_replace(
'/[^<>]/',
'', $filter_opcloture).
" '".$db->idate($filter_datecloture_start).
"'";
405if (!empty($filter_opcloture) && $filter_opcloture ==
' BETWEEN ') {
406 $sql .=
" AND cd.date_cloture ".$db->sanitize($filter_opcloture).
" '".$db->idate($filter_datecloture_start).
"' AND '".$db->idate($filter_datecloture_end).
"'";
409include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
412$parameters = array();
413$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $object, $action);
414$sql .= $hookmanager->resPrint;
417$nbtotalofrecords =
'';
419 $result = $db->query($sql);
420 $nbtotalofrecords = $db->num_rows($result);
421 if (($page * $limit) > (
int) $nbtotalofrecords) {
428$sql .= $db->order($sortfield, $sortorder);
430 $sql .= $db->plimit($limit + 1, $offset);
434dol_syslog(
"contrat/services_list.php", LOG_DEBUG);
435$resql = $db->query($sql);
441$num = $db->num_rows($resql);
456llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-contrat page-list_services bodyforlist');
458$arrayofselected = is_array($toselect) ? $toselect : array();
462 $param .=
'&mode='.urlencode($mode);
464if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
465 $param .=
'&contextpage='.urlencode($contextpage);
467if ($limit > 0 && $limit != $conf->liste_limit) {
468 $param .=
'&limit='.((int) $limit);
470if ($optioncss !=
'') {
471 $param .=
'&optioncss='.urlencode($optioncss);
473if ($search_contract) {
474 $param .=
'&search_contract='.urlencode($search_contract);
477 $param .=
'&search_name='.urlencode($search_name);
479if ($search_subprice) {
480 $param .=
'&search_subprice='.urlencode($search_subprice);
483 $param .=
'&search_qty='.urlencode($search_qty);
485if ($search_total_ht) {
486 $param .=
'&search_total_ht='.urlencode($search_total_ht);
488if ($search_total_tva) {
489 $param .=
'&search_total_tva='.urlencode($search_total_tva);
491if ($search_total_ttc) {
492 $param .=
'&search_total_ttc='.urlencode($search_total_ttc);
494if ($search_service) {
495 $param .=
'&search_service='.urlencode($search_service);
497if ($search_status !=
'') {
498 if ($filter ==
'expired' || $filter ==
'notexpired') {
499 $param .=
'&search_status='.urlencode($search_status.
'&filter='.$filter);
501 $param .=
'&search_status='.urlencode($search_status);
505 $param .=
"&search_option=".urlencode($search_option);
507if (!empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) {
508 $param .=
'&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
510if (!empty($filter_op1) && $filter_op1 != -1) {
511 $param .=
'&filter_op1='.urlencode($filter_op1);
513if (!empty($filter_op2) && $filter_op2 != -1) {
514 $param .=
'&filter_op2='.urlencode($filter_op2);
516if (!empty($filter_opcloture) && $filter_opcloture != -1) {
517 $param .=
'&filter_opcloture='.urlencode($filter_opcloture);
519if ($filter_dateouvertureprevue_start !=
'') {
520 $param .=
'&opouvertureprevueday='.((int) $opouvertureprevueday).
'&opouvertureprevuemonth='.((int) $opouvertureprevuemonth).
'&opouvertureprevueyear='.((int) $opouvertureprevueyear);
522if ($filter_date1_start !=
'') {
523 $param .=
'&op1day='.((int) $op1day).
'&op1month='.((int) $op1month).
'&op1year='.((int) $op1year);
525if ($filter_date2_start !=
'') {
526 $param .=
'&op2day='.((int) $op2day).
'&op2month='.((int) $op2month).
'&op2year='.((int) $op2year);
528if ($filter_datecloture_start !=
'') {
529 $param .=
'&opclotureday='.((int) $op2day).
'&opcloturemonth='.((int) $op2month).
'&opclotureyear='.((int) $op2year);
532include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_param.tpl.php';
534$parameters = array();
535$reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, $object, $action);
536$param .= $hookmanager->resPrint;
539$arrayofmassactions = array(
545$massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
547print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">'.
"\n";
548if ($optioncss !=
'') {
549 print
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
551print
'<input type="hidden" name="token" value="'.newToken().
'">';
552print
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
553print
'<input type="hidden" name="action" value="list">';
554print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
555print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
556print
'<input type="hidden" name="page" value="'.$page.
'">';
557print
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
558print
'<input type="hidden" name="page_y" value="">';
559print
'<input type="hidden" name="mode" value="'.$mode.
'">';
564print_barre_liste($title, $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'contract', 0,
'',
'', $limit);
567 $fieldstosearchall = array();
568 foreach ($fieldstosearchall as $key => $val) {
569 $fieldstosearchall[$key] = $langs->trans($val);
571 print
'<div class="divsearchfieldfilter">'.$langs->trans(
"FilterOnInto", $sall).implode(
', ', $fieldstosearchall).
'</div>';
578if (
isModEnabled(
'category') && ($user->hasRight(
'produit',
'lire') || $user->hasRight(
'service',
'lire'))) {
579 include_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
580 $moreforfilter .=
'<div class="divsearchfield">';
581 $tmptitle = $langs->trans(
'IncludingProductWithTag');
582 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 0, 0, 1);
583 $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);
584 $moreforfilter .=
'</div>';
587$moreforfilter .=
'<div class="divsearchfield">';
588$moreforfilter .=
'<label for="search_option">'.$langs->trans(
'Alert').
'</label> <input type="checkbox" name="search_option" id="search_option" value="late"'.($search_option ==
'late' ?
' checked' :
'').
'>';
589$moreforfilter .=
'</div>';
591$parameters = array();
592$reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, $object, $action);
593if (empty($reshook)) {
594 $moreforfilter .= $hookmanager->resPrint;
596 $moreforfilter = $hookmanager->resPrint;
600if (!empty($moreforfilter)) {
601 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
602 print $moreforfilter;
606$varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
607$htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage,
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));
608$selectedfields = ($mode !=
'kanban' ? $htmlofselectarray :
'');
609$selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) :
'');
612print
'<div class="div-table-responsive">';
613print
'<table class="tagtable liste'.($moreforfilter ?
" listwithfilterbefore" :
"").
'">'.
"\n";
617print
'<tr class="liste_titre_filter">';
620 print
'<td class="liste_titre center maxwidthsearch">';
621 $searchpicto = $form->showFilterButtons(
'left');
625if (!empty($arrayfields[
'c.ref'][
'checked'])) {
626 print
'<td class="liste_titre">';
627 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
628 print
'<input type="text" class="flat maxwidth75" name="search_contract" value="'.dol_escape_htmltag($search_contract).
'">';
632if (!empty($arrayfields[
'p.description'][
'checked'])) {
633 print
'<td class="liste_titre">';
634 print
'<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).
'">';
638if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
639 print
'<td class="liste_titre">';
642if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
643 print
'<td class="liste_titre right">';
644 print
'<input type="text" class="flat maxwidth50 right" name="search_subprice" value="'.dol_escape_htmltag($search_subprice).
'">';
647if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
648 print
'<td class="liste_titre right">';
649 print
'<input type="text" class="flat maxwidth50 right" name="search_qty" value="'.dol_escape_htmltag($search_qty).
'">';
652if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
653 print
'<td class="liste_titre right">';
654 print
'<input type="text" class="flat maxwidth50" name="search_total_ht" value="'.dol_escape_htmltag($search_total_ht).
'">';
657if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
658 print
'<td class="liste_titre right">';
659 print
'<input type="text" class="flat maxwidth50" name="search_total_tva" value="'.dol_escape_htmltag($search_total_tva).
'">';
663if (!empty($arrayfields[
's.nom'][
'checked'])) {
664 print
'<td class="liste_titre">';
665 print
'<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).
'">';
669if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
670 print
'<td class="liste_titre center">';
671 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
672 print $form->selectarray(
'filter_opouvertureprevue', $arrayofoperators, $filter_opouvertureprevue, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
674 $filter_dateouvertureprevue =
dol_mktime(0, 0, 0, (
int) $opouvertureprevuemonth, (
int) $opouvertureprevueday, (
int) $opouvertureprevueyear);
675 print $form->selectDate($filter_dateouvertureprevue,
'opouvertureprevue', 0, 0, 1,
'', 1, 0);
678if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
679 print
'<td class="liste_titre center">';
680 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
681 print $form->selectarray(
'filter_op1', $arrayofoperators, $filter_op1, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
683 $filter_date1 =
dol_mktime(0, 0, 0, (
int) $op1month, (
int) $op1day, (
int) $op1year);
684 print $form->selectDate($filter_date1,
'op1', 0, 0, 1,
'', 1, 0);
687if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
688 print
'<td class="liste_titre center">';
689 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
690 print $form->selectarray(
'filter_op2', $arrayofoperators, $filter_op2, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
692 $filter_date2 =
dol_mktime(0, 0, 0, (
int) $op2month, (
int) $op2day, (
int) $op2year);
693 print $form->selectDate($filter_date2,
'op2', 0, 0, 1,
'', 1, 0);
696if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
697 print
'<td class="liste_titre center">';
698 $arrayofoperators = array(
'<' =>
'<',
'>' =>
'>');
699 print $form->selectarray(
'filter_opcloture', $arrayofoperators, $filter_opcloture, 1, 0, 0,
'', 0, 0, 0,
'',
'width50');
701 $filter_date_cloture =
dol_mktime(0, 0, 0, (
int) $opcloturemonth, (
int) $opclotureday, (
int) $opclotureyear);
702 print $form->selectDate($filter_date_cloture,
'opcloture', 0, 0, 1,
'', 1, 0);
706include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_input.tpl.php';
709$parameters = array(
'arrayfields' => $arrayfields);
710$reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, $object, $action);
711print $hookmanager->resPrint;
712if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
714 print
'<td class="liste_titre">';
717if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
719 print
'<td class="liste_titre">';
722if (!empty($arrayfields[
'status'][
'checked'])) {
724 print
'<td class="liste_titre right parentonrightofpage">';
725 $arrayofstatus = array(
726 '0' => $langs->trans(
"ServiceStatusInitial"),
727 '4' => $langs->trans(
"ServiceStatusRunning"),
728 '4&filter=notexpired' => $langs->trans(
"ServiceStatusNotLate"),
729 '4&filter=expired' => $langs->trans(
"ServiceStatusLate"),
730 '5' => $langs->trans(
"ServiceStatusClosed")
732 $search_status_new =
GETPOST(
'search_status',
'alpha');
733 if ($filter ==
'expired' && !preg_match(
'/expired/', $search_status_new)) {
734 $search_status_new .=
'&filter=expired';
736 print $form->selectarray(
'search_status', $arrayofstatus, (strstr($search_status_new,
',') ? -1 : $search_status_new), 1, 0, 0,
'', 0, 0, 0,
'',
'search_status width100 onrightofpage');
741 print
'<td class="liste_titre center maxwidthsearch">';
742 $searchpicto = $form->showFilterButtons();
753print
'<tr class="liste_titre">';
756 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
759if (!empty($arrayfields[
'c.ref'][
'checked'])) {
761 print_liste_field_titre($arrayfields[
'c.ref'][
'label'], $_SERVER[
"PHP_SELF"],
"c.ref",
"", $param,
"", $sortfield, $sortorder);
763if (!empty($arrayfields[
'p.description'][
'checked'])) {
764 print_liste_field_titre($arrayfields[
'p.description'][
'label'], $_SERVER[
"PHP_SELF"],
"p.description",
"", $param,
"", $sortfield, $sortorder);
766if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
767 print_liste_field_titre($arrayfields[
'cd.tva_tx'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tva_tx",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
769if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
770 print_liste_field_titre($arrayfields[
'cd.subprice'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.subprice",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
772if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
773 print_liste_field_titre($arrayfields[
'cd.qty'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.qty",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
775if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
776 print_liste_field_titre($arrayfields[
'cd.total_ht'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_ht",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
778if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
779 print_liste_field_titre($arrayfields[
'cd.total_tva'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.total_tva",
"", $param,
'', $sortfield, $sortorder,
'right nowrap ');
781if (!empty($arrayfields[
's.nom'][
'checked'])) {
782 print_liste_field_titre($arrayfields[
's.nom'][
'label'], $_SERVER[
"PHP_SELF"],
"s.nom",
"", $param,
"", $sortfield, $sortorder);
784if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
785 print_liste_field_titre($arrayfields[
'cd.date_ouverture_prevue'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture_prevue",
"", $param,
'', $sortfield, $sortorder,
'center ');
787if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
788 print_liste_field_titre($arrayfields[
'cd.date_ouverture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_ouverture",
"", $param,
'', $sortfield, $sortorder,
'center ');
790if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
791 print_liste_field_titre($arrayfields[
'cd.date_fin_validite'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_fin_validite",
"", $param,
'', $sortfield, $sortorder,
'center ');
793if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
794 print_liste_field_titre($arrayfields[
'cd.date_cloture'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.date_cloture",
"", $param,
'', $sortfield, $sortorder,
'center ');
797include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_title.tpl.php';
799$parameters = array(
'arrayfields' => $arrayfields,
'param' => $param,
'sortfield' => $sortfield,
'sortorder' => $sortorder);
800$reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $object, $action);
801print $hookmanager->resPrint;
802if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
803 print_liste_field_titre($arrayfields[
'cd.datec'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.datec",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
805if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
806 print_liste_field_titre($arrayfields[
'cd.tms'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.tms",
"", $param,
'', $sortfield, $sortorder,
'center nowrap ');
808if (!empty($arrayfields[
'status'][
'checked'])) {
809 print_liste_field_titre($arrayfields[
'status'][
'label'], $_SERVER[
"PHP_SELF"],
"cd.statut,c.statut",
"", $param,
'', $sortfield, $sortorder,
'right ');
813 print
getTitleFieldOfList($selectedfields, 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'', $sortfield, $sortorder,
'center maxwidthsearch ').
"\n";
822$contractstatic =
new Contrat($db);
823$productstatic =
new Product($db);
827$totalarray = array(
'nbfield' => 0,
'val' => array(
'cd.qty' => 0,
'cd.total_ht' => 0,
'cd.total_tva' => 0));
828$imaxinloop = ($limit ? min($num, $limit) : $num);
829while ($i < $imaxinloop) {
830 $obj = $db->fetch_object($resql);
835 $contractstatic->id = $obj->cid;
836 $contractstatic->ref = $obj->ref ? $obj->ref : $obj->cid;
837 $contractstatic->ref_customer = $obj->ref_customer;
838 $contractstatic->ref_supplier = $obj->ref_supplier;
840 $companystatic->id = $obj->socid;
841 $companystatic->name = $obj->name;
842 $companystatic->email = $obj->email;
843 $companystatic->client = $obj->client;
844 $companystatic->fournisseur = $obj->fournisseur;
846 $productstatic->id = $obj->pid;
847 $productstatic->type = $obj->ptype;
848 $productstatic->ref = $obj->pref;
849 $productstatic->entity = $obj->pentity;
850 $productstatic->status = $obj->tosell;
851 $productstatic->status_buy = $obj->tobuy;
852 $productstatic->label = $obj->label;
853 $productstatic->description = $obj->description;
854 $productstatic->barcode = $obj->barcode;
856 print
'<tr data-rowid="'.$object->id.
'" class="oddeven">';
860 print
'<td class="nowrap center">';
861 if ($massactionbutton || $massaction) {
863 if (in_array($obj->rowid, $arrayofselected)) {
866 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
874 if (!empty($arrayfields[
'c.ref'][
'checked'])) {
875 print
'<td class="nowraponall">';
876 print $contractstatic->getNomUrl(1, 16);
883 if (!empty($arrayfields[
'p.description'][
'checked'])) {
884 print
'<td class="tdoverflowmax300">';
886 print $productstatic->getNomUrl(1,
'', 24);
887 print $obj->label ?
' - '.dol_trunc($obj->label, 16) :
'';
889 print
'<br><div class="small lineheightsmall">'.dol_nl2br($obj->description).
'</div>';
892 if ($obj->type == 0) {
895 if ($obj->type == 1) {
905 if (!empty($arrayfields[
'cd.tva_tx'][
'checked'])) {
906 print
'<td class="right nowraponall">';
913 if (!empty($arrayfields[
'cd.subprice'][
'checked'])) {
914 print
'<td class="right nowraponall">';
915 print
price($obj->subprice);
921 if (!empty($arrayfields[
'cd.qty'][
'checked'])) {
922 print
'<td class="right nowraponall">';
933 if (!empty($arrayfields[
'cd.total_ht'][
'checked'])) {
934 print
'<td class="right nowraponall">';
935 print
'<span class="amount">'.price($obj->total_ht).
'</span>';
943 $totalarray[
'val'][
'cd.total_ht'] += $obj->total_ht;
945 if (!empty($arrayfields[
'cd.total_tva'][
'checked'])) {
946 print
'<td class="right nowraponall">';
947 print
'<span class="amount">'.price($obj->total_tva).
'</span>';
955 $totalarray[
'val'][
'cd.total_tva'] += $obj->total_tva;
959 if (!empty($arrayfields[
's.nom'][
'checked'])) {
960 print
'<td class="tdoverflowmax100">';
961 print $companystatic->getNomUrl(1,
'customer', 28);
969 if (!empty($arrayfields[
'cd.date_ouverture_prevue'][
'checked'])) {
970 print
'<td class="center nowraponall">';
971 print($obj->date_ouverture_prevue ?
dol_print_date($db->jdate($obj->date_ouverture_prevue),
'dayhour') :
' ');
972 if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0) {
973 print
' '.img_picto($langs->trans(
"Late"),
"warning");
975 print
' ';
982 if (!empty($arrayfields[
'cd.date_ouverture'][
'checked'])) {
983 print
'<td class="center nowraponall">'.($obj->date_ouverture ?
dol_print_date($db->jdate($obj->date_ouverture),
'dayhour') :
' ').
'</td>';
989 if (!empty($arrayfields[
'cd.date_fin_validite'][
'checked'])) {
990 print
'<td class="center nowraponall">'.($obj->date_fin_validite ?
dol_print_date($db->jdate($obj->date_fin_validite),
'dayhour') :
' ');
991 if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5) {
992 $warning_delay = $conf->contrat->services->expires->warning_delay / 3600 / 24;
993 $textlate = $langs->trans(
"Late").
' = '.$langs->trans(
"DateReference").
' > '.$langs->trans(
"DateToday").
' '.(ceil($warning_delay) >= 0 ?
'+' :
'').ceil($warning_delay).
' '.$langs->trans(
"days");
996 print
' ';
1004 if (!empty($arrayfields[
'cd.date_cloture'][
'checked'])) {
1005 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_cloture),
'dayhour').
'</td>';
1012 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_print_fields.tpl.php';
1014 $parameters = array(
'arrayfields' => $arrayfields,
'obj' => $obj,
'i' => $i,
'totalarray' => &$totalarray);
1015 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters);
1016 print $hookmanager->resPrint;
1018 if (!empty($arrayfields[
'cd.datec'][
'checked'])) {
1019 print
'<td class="center">';
1020 print
dol_print_date($db->jdate($obj->date_creation),
'dayhour',
'tzuser');
1027 if (!empty($arrayfields[
'cd.tms'][
'checked'])) {
1028 print
'<td class="center nowraponall">';
1029 print
dol_print_date($db->jdate($obj->date_modification),
'dayhour',
'tzuser');
1036 if (!empty($arrayfields[
'status'][
'checked'])) {
1037 print
'<td class="right">';
1038 if ($obj->cstatut == 0) {
1041 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0,
'',
' - '.$langs->trans(
"Draft"));
1043 print $staticcontratligne->LibStatut($obj->statut, 5, ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now) ? 1 : 0);
1052 print
'<td class="nowrap center">';
1053 if ($massactionbutton || $massaction) {
1055 if (in_array($obj->rowid, $arrayofselected)) {
1058 print
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1071include DOL_DOCUMENT_ROOT.
'/core/tpl/list_print_total.tpl.php';
1076 foreach ($arrayfields as $key => $val) {
1077 if (!empty($val[
'checked'])) {
1081 print
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1086$parameters = array(
'arrayfields' => $arrayfields,
'sql' => $sql);
1087$reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, $object, $action);
1088print $hookmanager->resPrint;
1090print
'</table>'.
"\n";
1093print
'</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...
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.
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 '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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...
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_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_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.
isModEnabled($module)
Is Dolibarr module enabled.
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.