34require
'../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinterrec.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/fichinter.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
41if (isModEnabled(
'project')) {
42 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
43 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
45if (isModEnabled(
'contrat')) {
46 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcontract.class.php';
51$langs->loadLangs(array(
"interventions",
"admin",
"compta",
"bills"));
56$date_next_execution =
GETPOST(
'date_next_execution',
'alpha');
57$action =
GETPOST(
'action',
'aZ09');
58$cancel =
GETPOST(
'cancel',
'aZ09');
59$backtopage =
GETPOST(
'backtopage',
'alpha');
60$socid =
GETPOST(
'socid',
'int');
62 $socid = $user->socid;
64$objecttype =
'fichinter_rec';
65if ($action ==
"create" || $action ==
"add") {
71$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
72$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
74$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
75if (empty($page) || $page < 0 ||
GETPOST(
'button_search',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
79$offset = $limit * $page;
84$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
85$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
86if ($sortorder ==
"") {
90if ($sortfield ==
"") {
91 $sortfield =
"f.datec";
99 'f.titre'=>array(
'label'=>
"Ref",
'checked'=>1),
100 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
101 'f.fk_contrat'=>array(
'label'=>
"Contract",
'checked'=>1),
102 'f.duree'=>array(
'label'=>
"Duration",
'checked'=>1),
103 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>1),
104 'f.frequency'=>array(
'label'=>
"RecurringInvoiceTemplate",
'checked'=>1),
105 'f.nb_gen_done'=>array(
'label'=>
"NbOfGenerationDoneShort",
'checked'=>1),
106 'f.date_last_gen'=>array(
'label'=>
"DateLastGeneration",
'checked'=>1),
107 'f.date_when'=>array(
'label'=>
"NextDateToExecution",
'checked'=>1),
108 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
109 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
119 if (!empty($backtopageforcancel)) {
120 header(
"Location: ".$backtopageforcancel);
122 } elseif (!empty($backtopage)) {
123 header(
"Location: ".$backtopage);
130if ($action ==
'add') {
132 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
138 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Customer")),
null,
'errors');
144 $frequency =
GETPOST(
'frequency',
'int');
150 $nb_gen_max = (
GETPOST(
'nb_gen_max',
'int') ?
GETPOST(
'nb_gen_max',
'int') : 0);
152 if (empty($reyear) || empty($remonth) || empty($reday)) {
153 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
157 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
159 if ($nb_gen_max ===
'') {
160 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"MaxPeriodNumber")),
null,
'errors');
167 $object->id_origin = $id;
168 $object->title =
GETPOST(
'titre',
'alpha');
169 $object->description =
GETPOST(
'description',
'restricthtml');
170 $object->socid =
GETPOST(
'socid',
'alpha');
171 $object->fk_project =
GETPOST(
'projectid',
'int');
172 $object->fk_contract =
GETPOST(
'contractid',
'int');
174 $object->frequency = $frequency;
175 $object->unit_frequency =
GETPOST(
'unit_frequency',
'alpha');
176 $object->nb_gen_max = $nb_gen_max;
177 $object->auto_validate =
GETPOST(
'auto_validate',
'int');
179 $object->date_when = $date_next_execution;
181 if ($object->create($user) > 0) {
189} elseif ($action ==
'createfrommodel') {
194 $res = $object->fetch_lines();
196 if ($object->socid > 0) {
197 $newinter->socid = $object->socid;
198 $newinter->fk_project = $object->fk_project;
199 $newinter->fk_contrat = $object->fk_contrat;
201 $newinter->socid =
GETPOST(
"socid");
204 $newinter->entity = $object->entity;
205 $newinter->duree = $object->duree;
207 $newinter->description = $object->description;
208 $newinter->note_private = $object->note_private;
209 $newinter->note_public = $object->note_public;
212 $extrafields->fetch_name_optionals_label($newinter->table_element);
214 $array_options = $extrafields->getOptionalsFromPost($newinter->table_element);
215 $newinter->array_options = $array_options;
217 $newfichinterid = $newinter->create($user);
219 if ($newfichinterid > 0) {
221 foreach ($object->lines as $line) {
222 $newinter->addline($user, $newfichinterid, $line->desc, $line->datei, $line->duree,
'');
226 $object->updateNbGenDone();
228 header(
'Location: '.DOL_URL_ROOT.
'/fichinter/card.php?id='.$newfichinterid);
234} elseif ($action ==
'delete' && $user->hasRight(
'ficheinter',
'supprimer')) {
237 $object->delete($user);
239 header(
'Location: '.$_SERVER[
"PHP_SELF"]);
241} elseif ($action ==
'setfrequency' && $user->hasRight(
'ficheinter',
'creer')) {
244 $object->setFrequencyAndUnit(
GETPOST(
'frequency',
'int'),
GETPOST(
'unit_frequency',
'alpha'));
245} elseif ($action ==
'setdate_when' && $user->hasRight(
'ficheinter',
'creer')) {
250 $object->setNextDate($date);
252} elseif ($action ==
'setnb_gen_max' && $user->hasRight(
'ficheinter',
'creer')) {
255 $object->setMaxPeriod(
GETPOST(
'nb_gen_max',
'int'));
265llxHeader(
'', $langs->trans(
"RepeatableIntervention"), $help_url);
267$form =
new Form($db);
268$companystatic =
new Societe($db);
269if (isModEnabled(
'contrat')) {
270 $contratstatic =
new Contrat($db);
272if (isModEnabled(
'project')) {
273 $projectstatic =
new Project($db);
278$today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
285if ($action ==
'create') {
286 print
load_fiche_titre($langs->trans(
"CreateRepeatableIntervention"),
'',
'intervention');
291 if ($object->fetch($id, $ref) > 0) {
292 print
'<form action="card-rec.php" method="post">';
293 print
'<input type="hidden" name="token" value="'.newToken().
'">';
294 print
'<input type="hidden" name="action" value="add">';
295 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
296 print
'<input type="hidden" name="fichinterid" value="'.$object->id.
'">';
301 if (isModEnabled(
'project') && $object->fk_project > 0) {
304 if (isModEnabled(
'contrat') && $object->fk_contrat > 0) {
308 print
'<table class="border centpercent">';
310 $object->fetch_thirdparty();
313 print
'<tr><td>'.$langs->trans(
"Customer").
'</td><td>';
314 print $form->select_company($object->thirdparty->id,
'socid',
'', 0, 1);
318 print $langs->trans(
"Comment");
322 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
323 print
'<input class="flat quatrevingtpercent" type="text" name="titre" value="'.dol_escape_htmltag(
GETPOST(
"titre",
"alphanohtml")).
'">';
327 print
'<td rowspan="'.$rowspan.
'" valign="top">';
328 print
'<textarea class="flat" name="description" wrap="soft" cols="60" rows="'.ROWS_4.
'">';
329 print $object->description.
'</textarea>';
333 print
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
337 print
'<tr><td>'.$langs->trans(
"TotalDuration").
'</td>';
338 print
'<td colspan="3">'.convertSecondToTime($object->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
343 if (isModEnabled(
'project')) {
345 print
"<tr><td>".$langs->trans(
"Project").
"</td><td>";
346 $projectid =
GETPOST(
'projectid') ?
GETPOST(
'projectid') : $object->fk_project;
348 $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
349 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$object->thirdparty->id;
350 print
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?action=create';
351 print
'&socid='.$object->thirdparty->id.(!empty($id) ?
'&id='.$id :
'').
'">';
352 print $langs->trans(
"AddProject").
'</a>';
357 if (isModEnabled(
'contrat')) {
359 print
"<tr><td>".$langs->trans(
"Contract").
"</td><td>";
360 $contractid =
GETPOST(
'contractid') ?
GETPOST(
'contractid') : (!empty($object->fk_contract) ? $object->fk_contract : 0) ;
361 $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid,
'contracttid');
370 $title = $langs->trans(
"Recurrence");
373 print
'<table class="border centpercent">';
376 print
'<tr><td class="titlefieldcreate">';
377 print $form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency'));
379 print
'<input type="text" name="frequency" value="'.GETPOST(
'frequency',
'int').
'" size="4"> ';
380 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'));
384 print
"<tr><td>".$langs->trans(
'NextDateToExecution').
"</td><td>";
385 if (empty($date_next_execution)) {
388 print $form->selectDate($date_next_execution,
'', 1, 1,
'',
"add", 1, 1);
392 print
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
393 print
'<input type="text" name="nb_gen_max" value="'.GETPOST(
'nb_gen_max',
'int').
'" size="5">';
400 $title = $langs->trans(
"ProductsAndServices");
401 if (!isModEnabled(
"service")) {
402 $title = $langs->trans(
"Products");
403 } elseif (!isModEnabled(
"product")) {
404 $title = $langs->trans(
"Services");
412 print
'<table class="notopnoleftnoright" width="100%">';
413 print
'<tr><td colspan="3">';
415 $sql =
'SELECT l.rowid, l.description, l.duree';
416 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinterdet as l";
417 $sql .=
" WHERE l.fk_fichinter= ".((int) $object->id);
419 $sql .=
" ORDER BY l.rang";
421 $result = $db->query($sql);
423 $num = $db->num_rows($result);
427 echo
'<table class="noborder centpercent">';
429 print
'<tr class="liste_titre">';
430 print
'<td>'.$langs->trans(
"Description").
'</td>';
431 print
'<td class="center">'.$langs->trans(
"Duration").
'</td>';
435 $objp = $db->fetch_object($result);
436 print
'<tr class="oddeven">';
441 print
'<a name="'.$objp->rowid.
'"></a>';
443 $text =
img_object($langs->trans(
'Service'),
'service');
445 print $text.
' '.nl2br($objp->description);
448 print
'<td class="center">'.convertSecondToTime($objp->duree).
'</td>';
465 print $form->buttonsSaveCancel(
"Create");
471} elseif ($action ==
'selsocforcreatefrommodel') {
472 print
load_fiche_titre($langs->trans(
"CreateRepeatableIntervention"),
'',
'intervention');
475 print
'<form name="fichinter" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
476 print
'<table class="border centpercent">';
477 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ThirdParty").
'</td><td>';
478 print $form->select_company(
'',
'socid',
'', 1, 1);
484 print
'<input type="hidden" name="action" value="createfrommodel">';
485 print
'<input type="hidden" name="id" value="'.$id.
'">';
486 print $form->buttonsSaveCancel(
"CreateDraftIntervention",
'');
495 if ($object->fetch($id) > 0) {
496 $object->fetch_thirdparty();
498 $author =
new User($db);
499 $author->fetch($object->user_author);
503 print
dol_get_fiche_head($head,
'card', $langs->trans(
"PredefinedInterventional"), 0,
'intervention');
506 $linkback =
'<a href="card-rec.php">'.$langs->trans(
"BackToList").
'</a>';
508 $morehtmlref =
'<div class="refidno">';
511 $morehtmlref .= $langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
513 if (isModEnabled(
'project')) {
515 $langs->load(
"projects");
516 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
517 if ($user->hasRight(
'ficheinter',
'creer')) {
518 if ($action !=
'classify') {
519 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.newToken().
'&id='.$object->id.
'">';
520 $morehtmlref .=
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
522 if ($action ==
'classify') {
523 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
524 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
525 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
526 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
527 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
528 $morehtmlref .=
'</form>';
530 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1,
'',
'maxwidth300');
533 if (!empty($object->fk_project)) {
535 $proj->fetch($object->fk_project);
536 $morehtmlref .=
' : '.$proj->getNomUrl(1);
538 $morehtmlref .=
' - '.$proj->title;
545 $morehtmlref .=
'</div>';
547 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
549 print
'<div class="fichecenter">';
550 print
'<div class="fichehalfleft">';
551 print
'<div class="underbanner clearboth"></div>';
553 print
'<table class="border centpercent">';
555 print
"<tr><td>".$langs->trans(
"Author").
'</td><td colspan="3">'.$author->getFullName($langs).
"</td></tr>";
559 print
'<tr><td class="titlefield">'.$langs->trans(
"TotalDuration").
'</td>';
560 print
'<td colspan="3">';
561 print
convertSecondToTime($object->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
565 print
'<tr><td>'.$langs->trans(
"Description").
'</td><td colspan="3">'.nl2br($object->description).
"</td></tr>";
568 if (isModEnabled(
'contrat')) {
569 $langs->load(
'contracts');
573 print
'<table class="nobordernopadding" width="100%"><tr><td>';
574 print $langs->trans(
'Contract');
576 if ($action !=
'contrat') {
577 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=contrat&id='.$object->id.
'">';
578 print
img_edit($langs->trans(
'SetContract'), 1);
581 print
'</tr></table>';
583 if ($action ==
'contrat') {
585 $formcontract->formSelectContract($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $object->socid, $object->fk_contrat,
'contratid', 0, 1);
587 if ($object->fk_contrat) {
588 $contratstatic =
new Contrat($db);
589 $contratstatic->fetch($object->fk_contrat);
590 print $contratstatic->getNomUrl(0,
'', 1);
601 print
'<div class="fichehalfright">';
602 print
'<div class="underbanner clearboth"></div>';
604 $title = $langs->trans(
"Recurrence");
607 print
'<table class="border centpercent">';
610 print
'<tr><td class="titlefield">';
611 print
'<table class="nobordernopadding" width="100%"><tr><td>';
612 print $langs->trans(
'Frequency');
614 if ($action !=
'editfrequency' && $user->hasRight(
'ficheinter',
'creer')) {
615 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editfrequency&token='.newToken().
'&id='.$id.
'">';
616 print
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
618 print
'</tr></table>';
620 if ($action ==
'editfrequency') {
621 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
622 print
'<input type="hidden" name="action" value="setfrequency">';
623 print
'<input type="hidden" name="token" value="'.newToken().
'">';
624 print
'<table class="nobordernopadding">';
626 print
'<input type="text" name="frequency" value="'.$object->frequency.
'" size="5"> ';
627 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'));
629 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
630 print
'</tr></table></form>';
632 if ($object->frequency > 0) {
633 print $langs->trans(
'FrequencyPer_'.$object->unit_frequency, $object->frequency);
635 print $langs->trans(
"NotARecurringInterventionalTemplate");
642 if ($user->hasRight(
'ficheinter',
'creer') && ($action ==
'date_when' || $object->frequency > 0)) {
643 print $form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when', $object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day');
645 print $langs->trans(
"NextDateToExecution");
648 if ($action ==
'date_when' || $object->frequency > 0) {
649 print $form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when', $object->date_when, $object, $user->hasRight(
'facture',
'creer'),
'day');
656 if ($user->hasRight(
'ficheinter',
'creer') && ($action ==
'nb_gen_max' || $object->frequency > 0)) {
657 print $form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', $object->nb_gen_max, $object, $user->hasRight(
'facture',
'creer'));
659 print $langs->trans(
"MaxPeriodNumber");
663 if ($action ==
'nb_gen_max' || $object->frequency > 0) {
664 print $form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max :
'', $object, $user->hasRight(
'facture',
'creer'));
675 if ($object->frequency > 0) {
677 if (empty($conf->cron->enabled)) {
678 $txtinfoadmin = $langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name"));
681 print
'<div class="underbanner clearboth"></div>';
682 print
'<table class="border centpercent">';
685 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfGenerationOfRecordDone").
'</td>';
687 print $object->nb_gen_done ? $object->nb_gen_done :
'0';
693 print $langs->trans(
"DateLastGeneration");
705 print
'<div class="clearboth"></div><br>';
711 $title = $langs->trans(
"ProductsAndServices");
712 if (!isModEnabled(
"service")) {
713 $title = $langs->trans(
"Products");
714 } elseif (!isModEnabled(
"product")) {
715 $title = $langs->trans(
"Services");
720 print
'<table class="noborder centpercent">';
721 print
'<tr class="liste_titre">';
722 print
'<td>'.$langs->trans(
"Description").
'</td>';
723 print
'<td class="center">'.$langs->trans(
"Duration").
'</td>';
726 $num = count($object->lines);
730 if (isset($object->lines[$i]->product_type)) {
731 $type = $object->lines[$i]->product_type;
733 $object->lines[$i]->fk_product_type;
737 if (!empty($objp->date_start)) {
740 if (!empty($objp->date_end)) {
745 print
'<tr class="oddeven">';
747 $text =
img_object($langs->trans(
'Service'),
'service');
748 print $text.
' '.nl2br($object->lines[$i]->desc);
751 print
'<td class="center">'.convertSecondToTime($object->lines[$i]->duree).
'</td>';
760 print
'<div class="tabsAction">';
762 if ($user->hasRight(
'ficheinter',
'creer')) {
763 print
'<div class="inline-block divButAction">';
764 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=createfrommodel&token='.newToken();
765 print
'&socid='.$object->thirdparty->id.
'&id='.$object->id.
'">';
766 print $langs->trans(
"AddIntervention").
'</a></div>';
770 print
dolGetButtonAction($langs->trans(
"Delete"),
'',
'delete', $_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.newToken(),
'delete', $user->hasRight(
'ficheinter',
'supprimer'));
774 print $langs->trans(
"ErrorRecordNotFound");
780 $sql =
"SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title,";
781 $sql .=
" f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,";
782 $sql .=
" f.date_last_gen, f.date_when, f.datec";
784 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter_rec as f";
785 $sql .=
" , ".MAIN_DB_PREFIX.
"societe as s ";
786 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
787 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
789 $sql .=
" WHERE f.fk_soc = s.rowid";
790 $sql .=
" AND f.entity = ".$conf->entity;
791 if (!empty($socid)) {
792 $sql .=
" AND s.rowid = ".((int) $socid);
794 if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
795 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
797 if (!empty($search_ref)) {
800 if (!empty($search_societe)) {
803 if (!empty($search_frequency) && $search_frequency ==
'1') {
804 $sql .=
' AND f.frequency > 0';
806 if (isset($search_frequency) && (
string) $search_frequency ==
'0') {
807 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
814 $resql = $db->query($sql);
816 $num = $db->num_rows($resql);
818 print_barre_liste($langs->trans(
"RepeatableIntervention"), $page, $_SERVER[
'PHP_SELF'],
"&socid=$socid", $sortfield, $sortorder,
'', $num,
'',
'intervention');
820 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedIntervention").
'</span><br><br>';
823 print
'<table class="noborder centpercent">';
824 print
'<tr class="liste_titre">';
825 print_liste_field_titre(
"Ref", $_SERVER[
'PHP_SELF'],
"f.titre",
"",
"",
'width="200px"', $sortfield, $sortorder,
'left ');
826 print_liste_field_titre(
"Company", $_SERVER[
'PHP_SELF'],
"s.nom",
"",
"",
'width="200px"', $sortfield, $sortorder,
'left ');
827 if (isModEnabled(
'contrat')) {
828 print_liste_field_titre(
"Contract", $_SERVER[
'PHP_SELF'],
"f.fk_contrat",
"",
"",
'width="100px"', $sortfield, $sortorder,
'left ');
830 if (isModEnabled(
'project')) {
831 print_liste_field_titre(
"Project", $_SERVER[
'PHP_SELF'],
"f.fk_project",
"",
"",
'width="100px"', $sortfield, $sortorder,
'left ');
833 print_liste_field_titre(
"Duration", $_SERVER[
'PHP_SELF'],
'f.duree',
'',
'',
'width="50px"', $sortfield, $sortorder,
'right ');
835 print_liste_field_titre(
"Frequency", $_SERVER[
'PHP_SELF'],
"f.frequency",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
836 print_liste_field_titre(
"NbOfGenerationDoneShort", $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
837 print_liste_field_titre(
"DateLastGeneration", $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
838 print_liste_field_titre(
"NextDateToIntervention", $_SERVER[
'PHP_SELF'],
"f.date_when",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
839 print
'<th width="100px"></th>';
846 while ($i < min($num, $limit)) {
847 $objp = $db->fetch_object($resql);
849 print
'<tr class="oddeven">';
850 print
'<td><a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$objp->fich_rec.
'">';
851 print
img_object($langs->trans(
"ShowIntervention"),
"intervention").
' '.$objp->title;
854 $companystatic->id = $objp->socid;
855 $companystatic->name = $objp->name;
856 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
858 print
'<td>'.$langs->trans(
"None").
'</td>';
861 if (isModEnabled(
'contrat')) {
863 if ($objp->fk_contrat > 0) {
864 $contratstatic->fetch($objp->fk_contrat);
865 print $contratstatic->getNomUrl(1);
869 if (isModEnabled(
'project')) {
871 if ($objp->fk_project > 0) {
872 $projectstatic->fetch($objp->fk_project);
873 print $projectstatic->getNomUrl(1);
878 print
'<td class=right>'.convertSecondToTime($objp->duree).
'</td>';
880 print
'<td class="center">'.yn($objp->frequency ? 1 : 0).
'</td>';
882 print
'<td class="center">';
883 if ($objp->frequency) {
884 print $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'');
887 print
'<td class="center">';
891 print
'<td class="center">';
895 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
897 print
'<td class="center">';
898 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
900 print
'<td class="center">';
901 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
905 if ($user->hasRight(
'ficheinter',
'creer')) {
907 print
'<td class="center">';
908 if ($user->hasRight(
'ficheinter',
'creer')) {
909 if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
910 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=createfrommodel';
911 print
'&socid='.$objp->socid.
'&id='.$objp->fich_rec.
'">';
912 print $langs->trans(
"CreateFichInter").
'</a>';
914 print $langs->trans(
"DateIsNotEnough");
927 print
'<tr class="oddeven"><td colspan="10"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage contracts.
Class to manage interventions.
Classe de gestion des factures recurrentes/Modeles.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
fichinter_rec_prepare_head($object)
Prepare array with list of tabs.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_get_fiche_end($notab=0)
Return tab footer of a card.
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show 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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
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.