diff --git a/htdocs/contrat/services.php b/htdocs/contrat/services.php index e4a18e1599a..4fc2f9f53c3 100644 --- a/htdocs/contrat/services.php +++ b/htdocs/contrat/services.php @@ -33,17 +33,18 @@ $langs->load("products"); $langs->load("contracts"); $langs->load("companies"); -$mode = GETPOST("mode"); +$limit = GETPOST("limit")?GETPOST("limit","int"):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); -if ($page == -1) { $page = 0 ; } -$limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; -$offset = $limit * $page ; - +if ($page == -1) { $page = 0; } +$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"); @@ -73,6 +74,17 @@ $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; @@ -100,39 +112,74 @@ $staticcontrat=new Contrat($db); $staticcontratligne=new ContratLigne($db); $companystatic=new Societe($db); -$arrayfields=array(); +$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("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +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)) { - $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=''; + // 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 */ @@ -141,8 +188,6 @@ $now=dol_now(); $form=new Form($db); -llxHeader(); - $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,"; @@ -151,11 +196,20 @@ if (!$user->rights->societe->client->voir && !$socid) $sql .= " sc.fk_soc, sc.fk $sql.= " cd.date_ouverture_prevue,"; $sql.= " cd.date_ouverture,"; $sql.= " cd.date_fin_validite,"; -$sql.= " cd.date_cloture"; +$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; @@ -180,169 +234,263 @@ if (! empty($filter_opouvertureprevue) && $filter_opouvertureprevue != -1 && $fi 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)."'"; -$totalnboflines=0; -$result=$db->query($sql); -if ($result) -{ - $totalnboflines = $db->num_rows($result); -} $sql .= $db->order($sortfield,$sortorder); + +$nbtotalofrecords = -1; +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) +if (! $resql) { - $num = $db->num_rows($resql); - $i = 0; + dol_print_error($db); + exit; +} - $param=''; - 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='.$mode; - if ($filter) $param.='&filter='.$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; - - // 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 '
'; -} -else -{ - dol_print_error($db); -} llxFooter(); diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php index e6ee4e5cc40..45e6e06fb68 100644 --- a/htdocs/projet/tasks/list.php +++ b/htdocs/projet/tasks/list.php @@ -567,7 +567,7 @@ print '