* Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2016-2018 Charlie Benke * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2024 William Mead * Copyright (C) 2024 MDW * * 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 . */ /** * \file htdocs/fichinter/card-rec.php * \ingroup intervention * \brief Page to show predefined fichinter */ // Load Dolibarr environment require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinterrec.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; if (isModEnabled('project')) { require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; } if (isModEnabled('contract')) { require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcontract.class.php'; } // Load translation files required by the page $langs->loadLangs(array("interventions", "admin", "compta", "bills")); // Security check $id = (GETPOSTINT('fichinterid') ? GETPOSTINT('fichinterid') : GETPOSTINT('id')); $ref = GETPOST('ref', 'alpha'); $date_next_execution = GETPOST('date_next_execution', 'alpha'); $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); $backtopage = GETPOST('backtopage', 'alpha'); $socid = GETPOSTINT('socid'); if ($user->socid) { $socid = $user->socid; } $objecttype = 'fichinter_rec'; if ($action == "create" || $action == "add") { $objecttype = ''; } // Load variable for pagination $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; } $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; $sortorder = GETPOST('sortorder', 'aZ09comma'); $sortfield = GETPOST('sortfield', 'aZ09comma'); if ($sortorder == "") { $sortorder = "DESC"; } if ($sortfield == "") { $sortfield = "f.datec"; } $object = new FichinterRec($db); $extrafields = new ExtraFields($db); $arrayfields = array( 'f.title' => array('label' => "Ref", 'checked' => 1), 's.nom' => array('label' => "ThirdParty", 'checked' => 1), 'f.fk_contrat' => array('label' => "Contract", 'checked' => 1), 'f.duree' => array('label' => "Duration", 'checked' => 1), 'f.total_ttc' => array('label' => "AmountTTC", 'checked' => 1), 'f.frequency' => array('label' => "RecurringInvoiceTemplate", 'checked' => 1), 'f.nb_gen_done' => array('label' => "NbOfGenerationDoneShort", 'checked' => 1), 'f.date_last_gen' => array('label' => "DateLastGeneration", 'checked' => 1), 'f.date_when' => array('label' => "NextDateToExecution", 'checked' => 1), 'f.datec' => array('label' => "DateCreation", 'checked' => 0, 'position' => 500), 'f.tms' => array('label' => "DateModificationShort", 'checked' => 0, 'position' => 500), ); $result = restrictedArea($user, 'ficheinter', $id, $objecttype); $permissiontoadd = $user->hasRight('ficheinter', 'creer'); $permissiontodelete = $user->hasRight('ficheinter', 'supprimer'); /* * Actions */ if ($cancel) { /*var_dump($cancel);var_dump($backtopage);var_dump($backtopageforcancel);exit;*/ if (!empty($backtopageforcancel)) { header("Location: ".$backtopageforcancel); exit; } elseif (!empty($backtopage)) { header("Location: ".$backtopage); exit; } $action = ''; } // Create predefined intervention if ($action == 'add' && $permissiontoadd) { if (!GETPOST('title')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Title")), null, 'errors'); $action = "create"; $error++; } if (!GETPOST('socid')) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Customer")), null, 'errors'); $action = "create"; $error++; } // gestion des fréquences et des échéances $frequency = GETPOSTINT('frequency'); $reyear = GETPOST('reyear'); $remonth = GETPOST('remonth'); $reday = GETPOST('reday'); $rehour = GETPOST('rehour'); $remin = GETPOST('remin'); $nb_gen_max = GETPOSTINT('nb_gen_max'); if ($frequency) { if (empty($reyear) || empty($remonth) || empty($reday)) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("Date")), null, 'errors'); $action = "create"; $error++; } else { $date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear); } if ($nb_gen_max === 0) { setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->trans("MaxPeriodNumber")), null, 'errors'); $action = "create"; $error++; } } if (!$error) { $object->id_origin = $id; $object->title = GETPOST('title', 'alpha'); $object->description = GETPOST('description', 'restricthtml'); $object->socid = GETPOSTINT('socid'); $object->fk_project = GETPOSTINT('projectid'); $object->fk_contrat = GETPOSTINT('contractid'); $object->frequency = $frequency; $object->unit_frequency = GETPOST('unit_frequency', 'alpha'); $object->nb_gen_max = $nb_gen_max; $object->auto_validate = GETPOSTINT('auto_validate'); $object->date_when = $date_next_execution; if ($object->create($user) > 0) { $id = $object->id; $action = ''; } else { setEventMessages($object->error, $object->errors, 'errors'); $action = "create"; } } } elseif ($action == 'createfrommodel' && $permissiontoadd) { $newinter = new Fichinter($db); // Fetch the stored data $object->fetch($id); $res = $object->fetch_lines(); // Transfer the data from one to the other if ($object->socid > 0) { $newinter->socid = $object->socid; $newinter->fk_project = $object->fk_project; $newinter->fk_contrat = $object->fk_contrat; } else { $newinter->socid = GETPOSTINT("socid"); } $newinter->entity = $object->entity; $newinter->duree = $object->duree; $newinter->description = $object->description; $newinter->note_private = $object->note_private; $newinter->note_public = $object->note_public; // on créer un nouvelle intervention $extrafields->fetch_name_optionals_label($newinter->table_element); $array_options = $extrafields->getOptionalsFromPost($newinter->table_element); $newinter->array_options = $array_options; $newfichinterid = $newinter->create($user); if ($newfichinterid > 0) { // Now we add line of details foreach ($object->lines as $line) { $newinter->addline($user, $newfichinterid, $line->desc, $line->datei, $line->duree, ''); } // on update le nombre d'inter crée à partir du modèle $object->updateNbGenDone(); //on redirige vers la fiche d'intervention nouvellement crée header('Location: '.DOL_URL_ROOT.'/fichinter/card.php?id='.$newfichinterid); exit; } else { setEventMessages($newinter->error, $newinter->errors, 'errors'); $action = ''; } } elseif ($action == 'delete' && $permissiontodelete) { // delete modele $object->fetch($id); $object->delete($user); $id = 0; header('Location: '.$_SERVER["PHP_SELF"]); exit; } elseif ($action == 'setfrequency' && $permissiontoadd) { // Set frequency and unit frequency $object->fetch($id); $object->setFrequencyAndUnit(GETPOST('frequency', 'int'), GETPOST('unit_frequency', 'alpha')); } elseif ($action == 'setdate_when' && $permissiontoadd) { // Set next date of execution $object->fetch($id); $date = dol_mktime(GETPOST('date_whenhour'), GETPOST('date_whenmin'), 0, GETPOST('date_whenmonth'), GETPOST('date_whenday'), GETPOST('date_whenyear')); if (!empty($date)) { $object->setNextDate($date); } } elseif ($action == 'setnb_gen_max' && $permissiontoadd) { // Set max period $object->fetch($id); $object->setMaxPeriod(GETPOSTINT('nb_gen_max')); } /* * View */ $help_url = ''; llxHeader('', $langs->trans("RepeatableIntervention"), $help_url, '', 0, 0, '', '', '', 'mod-fichinter page-card-rec'); $form = new Form($db); $companystatic = new Societe($db); if (isModEnabled('contract')) { $contratstatic = new Contrat($db); } if (isModEnabled('project')) { $projectstatic = new Project($db); } $now = dol_now(); $tmparray = dol_getdate($now); $today = dol_mktime(23, 59, 59, $tmparray['mon'], $tmparray['mday'], $tmparray['year']); // Today is last second of current day // Create mode if ($action == 'create') { print load_fiche_titre($langs->trans("CreateRepeatableIntervention"), '', 'intervention'); $object = new Fichinter($db); // Source invoice //$object = new Managementfichinter($db); // Source invoice if ($object->fetch($id, $ref) > 0) { print '
'; print ''; print ''; print ''; print ''; print dol_get_fiche_head(); $rowspan = 4; if (isModEnabled('project') && $object->fk_project > 0) { $rowspan++; } if (isModEnabled('contract') && $object->fk_contrat > 0) { $rowspan++; } print ''; $object->fetch_thirdparty(); // Third party print ''; // Title print ''; // Note print ''; // Author print ""; if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { // Duration print ''; print ''; print ''; } // Project if (isModEnabled('project')) { $formproject = new FormProjets($db); print ""; } // Contrat if (isModEnabled('contract')) { $formcontract = new FormContract($db); print ""; } print "
'.$langs->trans("Customer").''; print $form->select_company($object->thirdparty->id, 'socid', '', 0, 1); //.$object->thirdparty->getNomUrl(1,'customer'). print ''; print $langs->trans("Comment"); print '
'.$langs->trans("Title").''; print ''; print ''; print ''; print '
".$langs->trans("Author")."".$user->getFullName($langs)."
'.$langs->trans("TotalDuration").''.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'
".$langs->trans("Project").""; $projectid = GETPOST('projectid') ? GETPOST('projectid') : $object->fk_project; $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid, 'projectid', 0, 0, 1, 0, 0, 0, 0, '', 0, 0, ''); print '   '; print $langs->trans("AddProject").''; print "
".$langs->trans("Contract").""; $contractid = GETPOST('contractid') ? GETPOST('contractid') : (!empty($object->fk_contrat) ? $object->fk_contrat : 0) ; $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid, 'contracttid'); print "
"; print '

'; /// frequency & duration // Autogeneration $title = $langs->trans("Recurrence"); print load_fiche_titre($title, '', 'calendar'); print ''; // Frequency print '"; // First date of execution for cron print ""; // Number max of generation print ""; print "
'; print $form->textwithpicto($langs->trans("Frequency"), $langs->transnoentitiesnoconv('toolTipFrequency')); print ""; print ' '; print $form->selectarray('unit_frequency', array('d' => $langs->trans('Day'), 'm' => $langs->trans('Month'), 'y' => $langs->trans('Year')), (GETPOST('unit_frequency') ? GETPOST('unit_frequency') : 'm')); print "
".$langs->trans('NextDateToExecution').""; if (empty($date_next_execution)) { $date_next_execution = (GETPOST('remonth') ? dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')) : -1); } print $form->selectDate($date_next_execution, '', 1, 1, 0, "add", 1, 1); print "
".$langs->trans("MaxPeriodNumber").""; print ''; print "
"; print '
'; $title = $langs->trans("ProductsAndServices"); if (!isModEnabled("service")) { $title = $langs->trans("Products"); } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } print load_fiche_titre($title, '', ''); /* * Fichinter lines */ print ''; print ''; print "
'; $sql = 'SELECT l.rowid, l.description, l.duree'; $sql .= " FROM ".MAIN_DB_PREFIX."fichinterdet as l"; $sql .= " WHERE l.fk_fichinter= ".((int) $object->id); //$sql.= " AND l.fk_product is null "; $sql .= " ORDER BY l.rang"; $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); $i = 0; $total = 0; echo ''; if ($num) { print ''; print ''; print ''; print "\n"; } while ($i < $num) { $objp = $db->fetch_object($result); print ''; // Show product and description print ''; print ""; $i++; } $db->free($result); } else { print $db->error(); } print "
'.$langs->trans("Description").''.$langs->trans("Duration").'
'; print ''; // ancre pour retourner sur la ligne $text = img_object($langs->trans('Service'), 'service'); print $text.' '.nl2br($objp->description); // Duration print ''.convertSecondToTime($objp->duree).'
"; print '
\n"; print dol_get_fiche_end(); print $form->buttonsSaveCancel("Create"); print "
\n"; } else { dol_print_error(null, "Error, no fichinter ".$object->id); } } elseif ($action == 'selsocforcreatefrommodel') { print load_fiche_titre($langs->trans("CreateRepeatableIntervention"), '', 'intervention'); print dol_get_fiche_head(''); print '
'; print ''; print ''; print '
'.$langs->trans("ThirdParty").''; print $form->select_company('', 'socid', '', 1, 1); print '
'; print dol_get_fiche_end(); print ''; print ''; print ''; print $form->buttonsSaveCancel("CreateDraftIntervention", ''); print '
'; } else { // View mode if ($id > 0) { if ($object->fetch($id) > 0) { $object->fetch_thirdparty(); $author = new User($db); $author->fetch($object->user_author); $head = fichinter_rec_prepare_head($object); print dol_get_fiche_head($head, 'card', $langs->trans("PredefinedInterventional"), 0, 'intervention'); // Intervention card $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = '
'; // Thirdparty $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1); // Project if (isModEnabled('project')) { $formproject = new FormProjets($db); $langs->load("projects"); $morehtmlref .= '
'.$langs->trans('Project').' '; if ($user->hasRight('ficheinter', 'creer')) { if ($action != 'classify') { $morehtmlref .= ''; $morehtmlref .= img_edit($langs->transnoentitiesnoconv('SetProject')).' : '; } if ($action == 'classify') { $morehtmlref .= '
'; $morehtmlref .= ''; $morehtmlref .= ''; $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); $morehtmlref .= ''; $morehtmlref .= '
'; } else { $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1, '', 'maxwidth300'); } } else { if (!empty($object->fk_project)) { $proj = new Project($db); $proj->fetch($object->fk_project); $morehtmlref .= ' : '.$proj->getNomUrl(1); if ($proj->title) { $morehtmlref .= ' - '.$proj->title; } } else { $morehtmlref .= ''; } } } $morehtmlref .= '
'; dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); print '
'; print '
'; print '
'; print ''; print ""; if (!getDolGlobalString('FICHINTER_DISABLE_DETAILS')) { // Duration print ''; print ''; } print '"; // Contract if (isModEnabled('contract')) { $langs->load('contracts'); print ''; print ''; print ''; } print "
".$langs->trans("Author").''.$author->getFullName($langs)."
'.$langs->trans("TotalDuration").''; print convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); print '
'.$langs->trans("Description").''.nl2br($object->description)."
'; print ''; if ($action != 'contrat') { print ''; } print '
'; print $langs->trans('Contract'); print 'id.'&token='.newToken().'">'; print img_edit($langs->trans('SetContract'), 1); print '
'; print '
'; if ($action == 'contrat') { $formcontract = new FormContract($db); $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1); } else { if ($object->fk_contrat) { $contratstatic = new Contrat($db); $contratstatic->fetch($object->fk_contrat); print $contratstatic->getNomUrl(0, '', 1); } else { print " "; } } print '
"; print '
'; print '
'; print '
'; $title = $langs->trans("Recurrence"); print load_fiche_titre($title, '', 'calendar'); print ''; // if "frequency" is empty or = 0, the recurrence is disabled print ''; // Date when print ''; print ''; // Max period / Rest period print ''; print ''; print '
'; print ''; if ($action != 'editfrequency' && $user->hasRight('ficheinter', 'creer')) { print ''; } print '
'; print $langs->trans('Frequency'); print ''; print img_edit($langs->trans('Edit'), 1).'
'; print '
'; if ($action == 'editfrequency') { print '
'; print ''; print ''; print ''; print ''; print ''; print '
'; print ' '; print $form->selectarray('unit_frequency', array('d' => $langs->trans('Day'), 'm' => $langs->trans('Month'), 'y' => $langs->trans('Year')), ($object->unit_frequency ? $object->unit_frequency : 'm')); print '
'; } else { if ($object->frequency > 0) { print $langs->trans('FrequencyPer_'.$object->unit_frequency, $object->frequency); } else { print $langs->trans("NotARecurringInterventionalTemplate"); } } print '
'; if ($user->hasRight('ficheinter', 'creer') && ($action == 'date_when' || $object->frequency > 0)) { print $form->editfieldkey($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->hasRight('facture', 'creer'), 'day'); } else { print $langs->trans("NextDateToExecution"); } print ''; if ($action == 'date_when' || $object->frequency > 0) { print $form->editfieldval($langs->trans("NextDateToExecution"), 'date_when', $object->date_when, $object, $user->hasRight('facture', 'creer'), 'day'); } print '
'; if ($user->hasRight('ficheinter', 'creer') && ($action == 'nb_gen_max' || $object->frequency > 0)) { print $form->editfieldkey($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max, $object, $user->hasRight('facture', 'creer')); } else { print $langs->trans("MaxPeriodNumber"); } print ''; if ($action == 'nb_gen_max' || $object->frequency > 0) { print $form->editfieldval($langs->trans("MaxPeriodNumber"), 'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max : '', $object, $user->hasRight('facture', 'creer')); } else { print ''; } print '
'; // Frequencry/Recurring section if ($object->frequency > 0) { print '
'; if (empty($conf->cron->enabled)) { $txtinfoadmin = $langs->trans("EnableAndSetupModuleCron", $langs->transnoentitiesnoconv("Module2300Name")); print info_admin($txtinfoadmin); } print '
'; print ''; // Nb of generation already done print ''; print ''; print ''; // Date last print ''; print ''; print '
'.$langs->trans("NbOfGenerationOfRecordDone").''; print $object->nb_gen_done ? $object->nb_gen_done : '0'; print '
'; print $langs->trans("DateLastGeneration"); print ''; print dol_print_date($object->date_last_gen, 'dayhour'); print '
'; print '
'; } print '
'; print '
'; print '

'; /* * Lines */ $title = $langs->trans("ProductsAndServices"); if (!isModEnabled("service")) { $title = $langs->trans("Products"); } elseif (!isModEnabled("product")) { $title = $langs->trans("Services"); } print load_fiche_titre($title); print ''; print ''; print ''; print ''; print ''; $num = count($object->lines); $i = 0; while ($i < $num) { // Show product and description if (isset($object->lines[$i]->product_type)) { $type = $object->lines[$i]->product_type; } // else { $object->lines[$i]->fk_product_type; } // Try to enhance type detection using date_start and date_end for free lines when type // was not saved. if (!empty($objp->date_start)) { $type = 1; } if (!empty($objp->date_end)) { $type = 1; } // Show line print ''; print ''; print ''; print "\n"; $i++; } print '
'.$langs->trans("Description").''.$langs->trans("Duration").'
'; $text = img_object($langs->trans('Service'), 'service'); print $text.' '.nl2br($object->lines[$i]->desc); print ''.convertSecondToTime($object->lines[$i]->duree).'
'; // Action bar print '
'; if ($user->hasRight('ficheinter', 'creer')) { print ''; } // Delete print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $user->hasRight('ficheinter', 'supprimer')); print '
'; } else { print $langs->trans("ErrorRecordNotFound"); } } else { // List mode $sql = "SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.title,"; $sql .= " f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,"; $sql .= " f.date_last_gen, f.date_when, f.datec, f.status"; $sql .= " FROM ".MAIN_DB_PREFIX."fichinter_rec as f"; $sql .= " , ".MAIN_DB_PREFIX."societe as s "; if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity = ".$conf->entity; if (!empty($socid)) { $sql .= " AND s.rowid = ".((int) $socid); } if (!$user->hasRight('societe', 'client', 'voir')) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id); } /* if (!empty($search_ref)) { $sql .= natural_search('f.title', $search_ref); } */ if (!empty($search_societe)) { $sql .= natural_search('s.nom', $search_societe); } if (!empty($search_frequency) && $search_frequency == '1') { $sql .= ' AND f.frequency > 0'; } if (isset($search_frequency) && (string) $search_frequency == '0') { $sql .= ' AND (f.frequency IS NULL or f.frequency = 0)'; } //$sql .= " ORDER BY $sortfield $sortorder, rowid DESC "; // $sql .= $db->plimit($limit + 1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); print_barre_liste($langs->trans("RepeatableIntervention"), $page, $_SERVER['PHP_SELF'], "&socid=$socid", $sortfield, $sortorder, '', $num, '', 'intervention'); print ''.$langs->trans("ToCreateAPredefinedIntervention").'

'; $i = 0; print ''; print ''; print_liste_field_titre("Ref", $_SERVER['PHP_SELF'], "f.title", "", "", 'width="200px"', $sortfield, $sortorder, 'left '); print_liste_field_titre("Company", $_SERVER['PHP_SELF'], "s.nom", "", "", 'width="200px"', $sortfield, $sortorder, 'left '); if (isModEnabled('contract')) { print_liste_field_titre("Contract", $_SERVER['PHP_SELF'], "f.fk_contrat", "", "", 'width="100px"', $sortfield, $sortorder, 'left '); } if (isModEnabled('project')) { print_liste_field_titre("Project", $_SERVER['PHP_SELF'], "f.fk_project", "", "", 'width="100px"', $sortfield, $sortorder, 'left '); } print_liste_field_titre("Duration", $_SERVER['PHP_SELF'], 'f.duree', '', '', 'width="50px"', $sortfield, $sortorder, 'right '); // Recurring or not print_liste_field_titre("Frequency", $_SERVER['PHP_SELF'], "f.frequency", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print_liste_field_titre("NbOfGenerationDoneShort", $_SERVER['PHP_SELF'], "f.nb_gen_done", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print_liste_field_titre("DateLastGeneration", $_SERVER['PHP_SELF'], "f.date_last_gen", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print_liste_field_titre("NextDateToIntervention", $_SERVER['PHP_SELF'], "f.date_when", "", "", 'width="100px"', $sortfield, $sortorder, 'center '); print ''; print "\n"; // les filtres à faire ensuite if ($num > 0) { while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); print ''; print '\n"; if ($objp->socid) { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; print ''; } else { print ''; } if (isModEnabled('contract')) { print ''; } if (isModEnabled('project')) { print ''; } print ''; print ''; print ''; print ''; print ''; } else { print ''.$langs->trans('NA').''; print ''; print ''; print ''; } if ($user->hasRight('ficheinter', 'creer')) { // Action column print '"; print "\n"; $i++; } } } else { print ''; } print "
'; print img_object($langs->trans("ShowIntervention"), "intervention").' '.$objp->title; print "'.$companystatic->getNomUrl(1, 'customer').''.$langs->trans("None").''; if ($objp->fk_contrat > 0) { $contratstatic->fetch($objp->fk_contrat); print $contratstatic->getNomUrl(1); } print ''; if ($objp->fk_project > 0) { $projectstatic->fetch($objp->fk_project); print $projectstatic->getNomUrl(1); } print ''.convertSecondToTime($objp->duree).''.yn($objp->frequency ? 1 : 0).''; if ($objp->frequency) { print $objp->nb_gen_done.($objp->nb_gen_max > 0 ? ' / '.$objp->nb_gen_max : ''); print ''; print dol_print_date($db->jdate($objp->date_last_gen), 'day'); print ''; print dol_print_date($db->jdate($objp->date_when), 'day'); print ''; print ''.$langs->trans('NA').''; print ''; print ''.$langs->trans('NA').''; print ''; if ($user->hasRight('ficheinter', 'creer')) { if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) { print ''; print $langs->trans("NewIntervention").''; } else { print $langs->trans("DateIsNotEnough"); } } else { print " "; } print "
'.$langs->trans("None").'
"; $db->free($resql); } else { dol_print_error($db); } } } llxFooter(); $db->close();