123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- <?php
- /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
- * Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /**
- * \file htdocs/contrat/services.php
- * \ingroup contrat
- * \brief Page to list services in contracts
- */
- require ("../main.inc.php");
- require_once (DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php");
- require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
- require_once (DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
- $langs->load("products");
- $langs->load("contracts");
- $langs->load("companies");
- $limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit;
- $sortfield = GETPOST("sortfield",'alpha');
- $sortorder = GETPOST("sortorder",'alpha');
- $page = GETPOST("page",'int');
- if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
- $offset = $limit * $page;
- $pageprev = $page - 1;
- $pagenext = $page + 1;
- if (! $sortfield) $sortfield="c.rowid";
- if (! $sortorder) $sortorder="ASC";
- $mode = GETPOST("mode");
- $filter=GETPOST("filter");
- $search_name=GETPOST("search_name");
- $search_contract=GETPOST("search_contract");
- $search_service=GETPOST("search_service");
- $search_status=GETPOST("search_status","alpha");
- $statut=GETPOST('statut')?GETPOST('statut'):1;
- $search_product_category=GETPOST('search_product_category','int');
- $socid=GETPOST('socid','int');
- $opouvertureprevuemonth=GETPOST('opouvertureprevuemonth');
- $opouvertureprevueday=GETPOST('opouvertureprevueday');
- $opouvertureprevueyear=GETPOST('opouvertureprevueyear');
- $filter_opouvertureprevue=GETPOST('filter_opouvertureprevue');
- $op1month=GETPOST('op1month');
- $op1day=GETPOST('op1day');
- $op1year=GETPOST('op1year');
- $filter_op1=GETPOST('filter_op1');
- $op2month=GETPOST('op2month');
- $op2day=GETPOST('op2day');
- $op2year=GETPOST('op2year');
- $filter_op2=GETPOST('filter_op2');
- $opcloturemonth=GETPOST('opcloturemonth');
- $opclotureday=GETPOST('opclotureday');
- $opclotureyear=GETPOST('opclotureyear');
- $filter_opcloture=GETPOST('filter_opcloture');
- // Initialize context for list
- $contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'servicelist'.$mode;
- // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
- $hookmanager->initHooks(array($contextpage));
- $extrafields = new ExtraFields($db);
- // fetch optionals attributes and labels
- $extralabels = $extrafields->fetch_name_optionals_label('contratdet');
- $search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_');
- // Security check
- $contratid = GETPOST('id','int');
- if (! empty($user->societe_id)) $socid=$user->societe_id;
- $result = restrictedArea($user, 'contrat',$contratid);
- if ($search_status != '')
- {
- $tmp=explode('&', $search_status);
- $mode=$tmp[0];
- if (empty($tmp[1])) $filter='';
- else
- {
- if ($tmp[1] == 'filter=notexpired') $filter='notexpired';
- if ($tmp[1] == 'filter=expired') $filter='expired';
- }
- }
- else
- {
- $search_status = $mode;
- if ($filter == 'expired') $search_status.='&filter=expired';
- if ($filter == 'notexpired') $search_status.='&filter=notexpired';
- }
- $staticcontrat=new Contrat($db);
- $staticcontratligne=new ContratLigne($db);
- $companystatic=new Societe($db);
- $arrayfields=array(
- 'c.ref'=>array('label'=>$langs->trans("Contract"), 'checked'=>1, 'position'=>80),
- 'p.description'=>array('label'=>$langs->trans("Service"), 'checked'=>1, 'position'=>80),
- 's.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1, 'position'=>100),
- 'cd.date_ouverture_prevue'=>array('label'=>$langs->trans("DateStartPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode == "0")),
- 'cd.date_ouverture'=>array('label'=>$langs->trans("DateStartRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode > 0)),
- 'cd.date_fin_validite'=>array('label'=>$langs->trans("DateEndPlannedShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode < 5)),
- 'cd.date_cloture'=>array('label'=>$langs->trans("DateEndRealShort"), 'checked'=>(($mode == "" || $mode == -1) || $mode >= 5)),
- 'status'=>array('label'=>$langs->trans("Status"), 'checked'=>1),
- //'cd.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
- 'cd.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500)
- );
- // Extra fields
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
- {
- foreach($extrafields->attribute_label as $key => $val)
- {
- $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
- }
- }
- /*
- * Actions
- */
- if (GETPOST('cancel')) { $action='list'; $massaction=''; }
- if (! GETPOST('confirmmassaction') && $massaction != 'presend' && $massaction != 'confirm_presend' && $massaction != 'confirm_createbills') { $massaction=''; }
- $parameters=array('socid'=>$socid);
- $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- if (empty($reshook))
- {
- // Selection of new fields
- include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
- if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
- {
- $search_name="";
- $search_contract="";
- $search_service="";
- $search_status=-1;
- $opouvertureprevuemonth="";
- $opouvertureprevueday="";
- $opouvertureprevueyear="";
- $filter_opouvertureprevue="";
- $op1month="";
- $op1day="";
- $op1year="";
- $filter_op1="";
- $op2month="";
- $op2day="";
- $op2year="";
- $filter_op2="";
- $opcloturemonth="";
- $opclotureday="";
- $opclotureyear="";
- $filter_opcloture="";
- $mode='';
- $filter='';
- }
- }
- /*
- * View
- */
- $now=dol_now();
- $form=new Form($db);
- $sql = "SELECT c.rowid as cid, c.ref, c.statut as cstatut,";
- $sql.= " s.rowid as socid, s.nom as name,";
- $sql.= " cd.rowid, cd.description, cd.statut,";
- $sql.= " p.rowid as pid, p.ref as pref, p.label as label, p.fk_product_type as ptype, p.entity as pentity,";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk_user,";
- $sql.= " cd.date_ouverture_prevue,";
- $sql.= " cd.date_ouverture,";
- $sql.= " cd.date_fin_validite,";
- $sql.= " cd.date_cloture,";
- //$sql.= " cd.date_c as date_creation,";
- $sql.= " cd.tms as date_update";
- // Add fields from extrafields
- foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
- // Add fields from hooks
- $parameters=array();
- $reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook
- $sql.=$hookmanager->resPrint;
- $sql.= " FROM ".MAIN_DB_PREFIX."contrat as c,";
- $sql.= " ".MAIN_DB_PREFIX."societe as s,";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
- $sql.= " ".MAIN_DB_PREFIX."contratdet as cd";
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."contratdet_extrafields as ef on (cd.rowid = ef.fk_object)";
- $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON cd.fk_product = p.rowid";
- if ($search_product_category > 0) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_product as cp ON cp.fk_product=cd.fk_product';
- $sql.= " WHERE c.entity = ".$conf->entity;
- $sql.= " AND c.rowid = cd.fk_contrat";
- if ($search_product_category > 0) $sql.=" AND cp.fk_categorie = ".$search_product_category;
- $sql.= " AND c.fk_soc = s.rowid";
- if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
- if ($mode == "0") $sql.= " AND cd.statut = 0";
- if ($mode == "4") $sql.= " AND cd.statut = 4";
- if ($mode == "5") $sql.= " AND cd.statut = 5";
- if ($filter == "expired") $sql.= " AND cd.date_fin_validite < '".$db->idate($now)."'";
- if ($filter == "notexpired") $sql.= " AND cd.date_fin_validite >= '".$db->idate($now)."'";
- if ($search_name) $sql.= " AND s.nom LIKE '%".$db->escape($search_name)."%'";
- if ($search_contract) $sql.= " AND c.rowid = '".$db->escape($search_contract)."'";
- if ($search_service) $sql.= " AND (p.ref LIKE '%".$db->escape($search_service)."%' OR p.description LIKE '%".$db->escape($search_service)."%' OR cd.description LIKE '%".$db->escape($search_service)."%')";
- if ($socid > 0) $sql.= " AND s.rowid = ".$socid;
- $filter_dateouvertureprevue=dol_mktime(0,0,0,$opouvertureprevuemonth,$opouvertureprevueday,$opouvertureprevueyear);
- $filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
- $filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
- $filter_datecloture=dol_mktime(0,0,0,$opcloturemonth,$opclotureday,$opclotureyear);
- if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $filter_dateouvertureprevue != '') $sql.= " AND cd.date_ouverture_prevue ".$filter_opouvertureprevue." '".$db->idate($filter_dateouvertureprevue)."'";
- if (! empty($filter_op1) && $filter_op1 != -1 && $filter_date1 != '') $sql.= " AND cd.date_ouverture ".$filter_op1." '".$db->idate($filter_date1)."'";
- if (! empty($filter_op2) && $filter_op2 != -1 && $filter_date2 != '') $sql.= " AND cd.date_fin_validite ".$filter_op2." '".$db->idate($filter_date2)."'";
- if (! empty($filter_opcloture) && $filter_opcloture != -1 && $filter_datecloture != '') $sql.= " AND cd.date_cloture ".$filter_opcloture." '".$db->idate($filter_datecloture)."'";
- $sql .= $db->order($sortfield,$sortorder);
- $nbtotalofrecords = '';
- if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
- {
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
- }
- $sql .= $db->plimit($limit + 1, $offset);
- //print $sql;
- dol_syslog("contrat/services.php", LOG_DEBUG);
- $resql=$db->query($sql);
- if (! $resql)
- {
- dol_print_error($db);
- exit;
- }
- $num = $db->num_rows($resql);
- /*
- if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
- {
- $obj = $db->fetch_object($resql);
- $id = $obj->id;
- header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
- exit;
- }*/
- llxHeader(null, $langs->trans("Services"));
- $param='';
- if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
- if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
- if ($search_contract) $param.='&search_contract='.urlencode($search_contract);
- if ($search_name) $param.='&search_name='.urlencode($search_name);
- if ($search_service) $param.='&search_service='.urlencode($search_service);
- if ($mode) $param.='&mode='.urlencode($mode);
- if ($filter) $param.='&filter='.urlencode($filter);
- if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1) $param.='&filter_opouvertureprevue='.urlencode($filter_opouvertureprevue);
- if (! empty($filter_op1) && $filter_op1 != -1) $param.='&filter_op1='.urlencode($filter_op1);
- if (! empty($filter_op2) && $filter_op2 != -1) $param.='&filter_op2='.urlencode($filter_op2);
- if (! empty($filter_opcloture) && $filter_opcloture != -1) $param.='&filter_opcloture='.urlencode($filter_opcloture);
- if ($filter_dateouvertureprevue != '') $param.='&opouvertureprevueday='.$opouvertureprevueday.'&opouvertureprevuemonth='.$opouvertureprevuemonth.'&opouvertureprevueyear='.$opouvertureprevueyear;
- if ($filter_date1 != '') $param.='&op1day='.$op1day.'&op1month='.$op1month.'&op1year='.$op1year;
- if ($filter_date2 != '') $param.='&op2day='.$op2day.'&op2month='.$op2month.'&op2year='.$op2year;
- if ($filter_datecloture != '') $param.='&opclotureday='.$op2day.'&opcloturemonth='.$op2month.'&opclotureyear='.$op2year;
- if ($optioncss != '') $param.='&optioncss='.$optioncss;
- // Add $param from extra fields
- foreach ($search_array_options as $key => $val)
- {
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
- }
- // List of mass actions available
- $arrayofmassactions = array(
- //'presend'=>$langs->trans("SendByMail"),
- //'builddoc'=>$langs->trans("PDFMerge"),
- );
- //if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
- //if ($massaction == 'presend') $arrayofmassactions=array();
- $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
- print '<form method="POST" action="'. $_SERVER["PHP_SELF"] .'">';
- if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
- print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
- print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
- print '<input type="hidden" name="action" value="list">';
- print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
- print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
- print '<input type="hidden" name="page" value="'.$page.'">';
- $title=$langs->trans("ListOfServices");
- if ($mode == "0") $title=$langs->trans("ListOfInactiveServices"); // Must use == "0"
- if ($mode == "4" && $filter != "expired") $title=$langs->trans("ListOfRunningServices");
- if ($mode == "4" && $filter == "expired") $title=$langs->trans("ListOfExpiredServices");
- if ($mode == "5") $title=$langs->trans("ListOfClosedServices");
- print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);
- if ($sall)
- {
- foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
- print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
- }
- $morefilter = '';
- // If the user can view categories of products
- if ($conf->categorie->enabled && ($user->rights->produit->lire || $user->rights->service->lire))
- {
- include_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
- $moreforfilter.='<div class="divsearchfield">';
- $moreforfilter.=$langs->trans('IncludingProductWithTag'). ': ';
- $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT, null, 'parent', null, null, 1);
- $moreforfilter.=$form->selectarray('search_product_category', $cate_arbo, $search_product_category, 1, 0, 0, '', 0, 0, 0, 0, '', 1);
- $moreforfilter.='</div>';
- }
- $parameters=array();
- $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook
- if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
- else $moreforfilter = $hookmanager->resPrint;
- if (! empty($moreforfilter))
- {
- print '<div class="liste_titre liste_titre_bydiv centpercent">';
- print $moreforfilter;
- print '</div>';
- }
- $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
- $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
- print '<div class="div-table-responsive">';
- print '<table class="tagtable liste'.($moreforfilter?" listwithfilterbefore":"").'">'."\n";
- print '<tr class="liste_titre">';
- if (! empty($arrayfields['c.ref']['checked'])) print_liste_field_titre($arrayfields['c.ref']['label'],$_SERVER["PHP_SELF"],"c.ref","",$param,"",$sortfield,$sortorder);
- if (! empty($arrayfields['p.description']['checked'])) print_liste_field_titre($arrayfields['p.description']['label'],$_SERVER["PHP_SELF"],"p.description","",$param,"",$sortfield,$sortorder);
- if (! empty($arrayfields['s.nom']['checked'])) print_liste_field_titre($arrayfields['s.nom']['label'],$_SERVER["PHP_SELF"],"s.nom","",$param,"",$sortfield,$sortorder);
- if (! empty($arrayfields['cd.date_ouverture_prevue']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture_prevue']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture_prevue","",$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['cd.date_ouverture']['checked'])) print_liste_field_titre($arrayfields['cd.date_ouverture']['label'],$_SERVER["PHP_SELF"],"cd.date_ouverture","",$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['cd.date_fin_validite']['checked'])) print_liste_field_titre($arrayfields['cd.date_fin_validite']['label'],$_SERVER["PHP_SELF"],"cd.date_fin_validite","",$param,'align="center"',$sortfield,$sortorder);
- if (! empty($arrayfields['cd.date_cloture']['checked'])) print_liste_field_titre($arrayfields['cd.date_cloture']['label'],$_SERVER["PHP_SELF"],"cd.date_cloture","",$param,'align="center"',$sortfield,$sortorder);
- // Extra fields
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
- {
- foreach($extrafields->attribute_label as $key => $val)
- {
- if (! empty($arrayfields["ef.".$key]['checked']))
- {
- $align=$extrafields->getAlignFlag($key);
- print_liste_field_titre($langs->trans($extralabels[$key]),$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder);
- }
- }
- }
- // Hook fields
- $parameters=array('arrayfields'=>$arrayfields);
- $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- if (! empty($arrayfields['cd.datec']['checked'])) print_liste_field_titre($arrayfields['cd.datec']['label'],$_SERVER["PHP_SELF"],"cd.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
- if (! empty($arrayfields['cd.tms']['checked'])) print_liste_field_titre($arrayfields['cd.tms']['label'],$_SERVER["PHP_SELF"],"cd.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder);
- if (! empty($arrayfields['status']['checked'])) print_liste_field_titre($arrayfields['status']['label'],$_SERVER["PHP_SELF"],"cd.statut,c.statut","",$param,'align="right"',$sortfield,$sortorder);
- print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch ');
- print "</tr>\n";
- print '<tr class="liste_titre">';
- if (! empty($arrayfields['c.ref']['checked']))
- {
- print '<td class="liste_titre">';
- print '<input type="hidden" name="filter" value="'.$filter.'">';
- print '<input type="hidden" name="mode" value="'.$mode.'">';
- print '<input type="text" class="flat" size="3" name="search_contract" value="'.dol_escape_htmltag($search_contract).'">';
- print '</td>';
- }
- // Service label
- if (! empty($arrayfields['p.description']['checked']))
- {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat maxwidth100" name="search_service" value="'.dol_escape_htmltag($search_service).'">';
- print '</td>';
- }
- // Third party
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '<td class="liste_titre">';
- print '<input type="text" class="flat maxwidth100" name="search_name" value="'.dol_escape_htmltag($search_name).'">';
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_ouverture_prevue']['checked']))
- {
- print '<td class="liste_titre" align="center">';
- $arrayofoperators=array('<'=>'<','>'=>'>');
- print $form->selectarray('filter_opouvertureprevue',$arrayofoperators,$filter_opouvertureprevue,1);
- print ' ';
- $filter_dateouvertureprevue=dol_mktime(0,0,0,$opouvertureprevuemonth,$opouvertureprevueday,$opouvertureprevueyear);
- print $form->select_date($filter_dateouvertureprevue,'opouvertureprevue',0,0,1,'',1,0,1);
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_ouverture']['checked']))
- {
- print '<td class="liste_titre" align="center">';
- $arrayofoperators=array('<'=>'<','>'=>'>');
- print $form->selectarray('filter_op1',$arrayofoperators,$filter_op1,1);
- print ' ';
- $filter_date1=dol_mktime(0,0,0,$op1month,$op1day,$op1year);
- print $form->select_date($filter_date1,'op1',0,0,1,'',1,0,1);
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_fin_validite']['checked']))
- {
- print '<td class="liste_titre" align="center">';
- $arrayofoperators=array('<'=>'<','>'=>'>');
- print $form->selectarray('filter_op2',$arrayofoperators,$filter_op2,1);
- print ' ';
- $filter_date2=dol_mktime(0,0,0,$op2month,$op2day,$op2year);
- print $form->select_date($filter_date2,'op2',0,0,1,'',1,0,1);
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_cloture']['checked']))
- {
- print '<td class="liste_titre" align="center">';
- $arrayofoperators=array('<'=>'<','>'=>'>');
- print $form->selectarray('filter_opcloture',$arrayofoperators,$filter_opcloture,1);
- print ' ';
- $filter_date_cloture=dol_mktime(0,0,0,$opcloturemonth,$opclotureday,$opclotureyear);
- print $form->select_date($filter_date_cloture,'opcloture',0,0,1,'',1,0,1);
- print '</td>';
- }
- // Extra fields
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
- {
- foreach($extrafields->attribute_label as $key => $val)
- {
- if (! empty($arrayfields["ef.".$key]['checked']))
- {
- $align=$extrafields->getAlignFlag($key);
- $typeofextrafield=$extrafields->attribute_type[$key];
- print '<td class="liste_titre'.($align?' '.$align:'').'">';
- if (in_array($typeofextrafield, array('varchar', 'int', 'double', 'select')))
- {
- $crit=$val;
- $tmpkey=preg_replace('/search_options_/','',$key);
- $searchclass='';
- if (in_array($typeofextrafield, array('varchar', 'select'))) $searchclass='searchstring';
- if (in_array($typeofextrafield, array('int', 'double'))) $searchclass='searchnum';
- print '<input class="flat'.($searchclass?' '.$searchclass:'').'" size="4" type="text" name="search_options_'.$tmpkey.'" value="'.dol_escape_htmltag($search_array_options['search_options_'.$tmpkey]).'">';
- }
- print '</td>';
- }
- }
- }
- // Fields from hook
- $parameters=array('arrayfields'=>$arrayfields);
- $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- if (! empty($arrayfields['cd.datec']['checked']))
- {
- // Date creation
- print '<td class="liste_titre">';
- print '</td>';
- }
- if (! empty($arrayfields['cd.tms']['checked']))
- {
- // Date modification
- print '<td class="liste_titre">';
- print '</td>';
- }
- if (! empty($arrayfields['status']['checked']))
- {
- // Status
- print '<td class="liste_titre" align="right">';
- $arrayofstatus=array(
- '0'=>$langs->trans("ServiceStatusInitial"),
- '4'=>$langs->trans("ServiceStatusRunning"),
- '4&filter=notexpired'=>$langs->trans("ServiceStatusNotLate"),
- '4&filter=expired'=>$langs->trans("ServiceStatusLate"),
- '5'=>$langs->trans("ServiceStatusClosed")
- );
- print $form->selectarray('search_status', $arrayofstatus, (strstr($search_status, ',')?-1:$search_status), 1, 0, '', 0, 0, 0, '', 'maxwidth100onsmartphone');
- print '</td>';
- }
- // Action column
- print '<td class="liste_titre" align="right">';
- $searchpicto=$form->showFilterAndCheckAddButtons(0);
- print $searchpicto;
- print '</td>';
- print "</tr>\n";
- $contractstatic=new Contrat($db);
- $productstatic=new Product($db);
- $var=True; $i=0;
- while ($i < min($num,$limit))
- {
- $obj = $db->fetch_object($resql);
-
- $contractstatic->id=$obj->cid;
- $contractstatic->ref=$obj->ref?$obj->ref:$obj->cid;
-
-
- print '<tr class="oddeven">';
-
- // Ref
- if (! empty($arrayfields['c.ref']['checked']))
- {
- print '<td>';
- print $contractstatic->getNomUrl(1,16);
- print '</td>';
- }
- // Service
- if (! empty($arrayfields['p.description']['checked']))
- {
- print '<td>';
- if ($obj->pid)
- {
- $productstatic->id=$obj->pid;
- $productstatic->type=$obj->ptype;
- $productstatic->ref=$obj->pref;
- $productstatic->entity=$obj->pentity;
- print $productstatic->getNomUrl(1,'',24);
- print $obj->label?' - '.dol_trunc($obj->label,16):'';
- if (! empty($obj->description) && ! empty($conf->global->PRODUCT_DESC_IN_LIST)) print '<br>'.dol_nl2br($obj->description);
- }
- else
- {
- if ($obj->type == 0) print img_object($obj->description,'product').' '.dol_trunc($obj->description,24);
- if ($obj->type == 1) print img_object($obj->description,'service').' '.dol_trunc($obj->description,24);
- }
- print '</td>';
- }
-
- // Third party
- if (! empty($arrayfields['s.nom']['checked']))
- {
- print '<td>';
- $companystatic->id=$obj->socid;
- $companystatic->name=$obj->name;
- $companystatic->client=1;
- print $companystatic->getNomUrl(1,'customer',28);
- print '</td>';
- }
-
- // Start date
- if (! empty($arrayfields['cd.date_ouverture_prevue']['checked']))
- {
- print '<td align="center">';
- print ($obj->date_ouverture_prevue?dol_print_date($db->jdate($obj->date_ouverture_prevue)):' ');
- if ($db->jdate($obj->date_ouverture_prevue) && ($db->jdate($obj->date_ouverture_prevue) < ($now - $conf->contrat->services->inactifs->warning_delay)) && $obj->statut == 0)
- print ' '.img_picto($langs->trans("Late"),"warning");
- else print ' ';
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_ouverture']['checked']))
- {
- print '<td align="center">'.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture)):' ').'</td>';
- }
- // End date
- if (! empty($arrayfields['cd.date_fin_validite']['checked']))
- {
- print '<td align="center">'.($obj->date_fin_validite?dol_print_date($db->jdate($obj->date_fin_validite)):' ');
- if ($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < ($now - $conf->contrat->services->expires->warning_delay) && $obj->statut < 5)
- {
- $warning_delay=$conf->contrat->services->expires->warning_delay / 3600 / 24;
- $textlate = $langs->trans("Late").' = '.$langs->trans("DateReference").' > '.$langs->trans("DateToday").' '.(ceil($warning_delay) >= 0 ? '+' : '').ceil($warning_delay).' '.$langs->trans("days");
- print img_warning($textlate);
- }
- else print ' ';
- print '</td>';
- }
- if (! empty($arrayfields['cd.date_cloture']['checked']))
- {
- print '<td align="center">'.dol_print_date($db->jdate($obj->date_cloture)).'</td>';
- }
- // Extra fields
- if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
- {
- foreach($extrafields->attribute_label as $key => $val)
- {
- if (! empty($arrayfields["ef.".$key]['checked']))
- {
- print '<td';
- $align=$extrafields->getAlignFlag($key);
- if ($align) print ' align="'.$align.'"';
- print '>';
- $tmpkey='options_'.$key;
- print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
- print '</td>';
- if (! $i) $totalarray['nbfield']++;
- }
- }
- }
- // Fields from hook
- $parameters=array('arrayfields'=>$arrayfields, 'obj'=>$obj);
- $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- // Date creation
- if (! empty($arrayfields['cd.datec']['checked']))
- {
- print '<td align="center">';
- print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
- print '</td>';
- if (! $i) $totalarray['nbfield']++;
- }
- // Date modification
- if (! empty($arrayfields['cd.tms']['checked']))
- {
- print '<td align="center">';
- print dol_print_date($db->jdate($obj->date_update), 'dayhour');
- print '</td>';
- if (! $i) $totalarray['nbfield']++;
- }
- // Status
- if (! empty($arrayfields['status']['checked']))
- {
- print '<td align="right">';
- if ($obj->cstatut == 0) // If contract is draft, we say line is also draft
- {
- print $contractstatic->LibStatut(0,5,($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now));
- }
- else
- {
- print $staticcontratligne->LibStatut($obj->statut,5,($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0);
- }
- print '</td>';
- }
- // Action column
- print '<td class="nowrap" align="center">';
- if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- {
- $selected=0;
- if (in_array($obj->rowid, $arrayofselected)) $selected=1;
- print '<input id="cb'.$obj->rowid.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected?' checked="checked"':'').'>';
- }
- print '</td>';
- if (! $i) $totalarray['nbfield']++;
-
- print "</tr>\n";
- $i++;
- }
- $db->free($resql);
- $parameters=array('sql' => $sql);
- $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
- print '</table>';
- print '</div>';
- print '</form>';
- llxFooter();
- $db->close();
|