33 require
'../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinterrec.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/fichinter.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
40 if (!empty($conf->project->enabled)) {
41 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
42 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
44 if (!empty($conf->contrat->enabled)) {
45 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcontract.class.php';
50 $langs->loadLangs(array(
"interventions",
"admin",
"compta",
"bills"));
54 $action =
GETPOST(
'action',
'aZ09');
56 $socid = $user->socid;
58 $objecttype =
'fichinter_rec';
59 if ($action ==
"create" || $action ==
"add") {
68 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
69 $offset = $limit * $page;
71 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
72 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
73 if ($sortorder ==
"") {
77 if ($sortfield ==
"") {
78 $sortfield =
"f.datec";
86 'f.titre'=>array(
'label'=>
"Ref",
'checked'=>1),
87 's.nom'=>array(
'label'=>
"ThirdParty",
'checked'=>1),
88 'f.fk_contrat'=>array(
'label'=>
"Contract",
'checked'=>1),
89 'f.duree'=>array(
'label'=>
"Duration",
'checked'=>1),
90 'f.total_ttc'=>array(
'label'=>
"AmountTTC",
'checked'=>1),
91 'f.frequency'=>array(
'label'=>
"RecurringInvoiceTemplate",
'checked'=>1),
92 'f.nb_gen_done'=>array(
'label'=>
"NbOfGenerationDoneShort",
'checked'=>1),
93 'f.date_last_gen'=>array(
'label'=>
"DateLastGeneration",
'checked'=>1),
94 'f.date_when'=>array(
'label'=>
"NextDateToExecution",
'checked'=>1),
95 'f.datec'=>array(
'label'=>
"DateCreation",
'checked'=>0,
'position'=>500),
96 'f.tms'=>array(
'label'=>
"DateModificationShort",
'checked'=>0,
'position'=>500),
106 if ($action ==
'add') {
108 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Title")),
null,
'errors');
114 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Customer")),
null,
'errors');
120 $frequency =
GETPOST(
'frequency',
'int');
126 $nb_gen_max = (
GETPOST(
'nb_gen_max',
'int') ?
GETPOST(
'nb_gen_max',
'int') : 0);
128 if (empty($reyear) || empty($remonth) || empty($reday)) {
129 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"Date")),
null,
'errors');
133 if ($nb_gen_max ===
'') {
134 setEventMessages($langs->transnoentities(
"ErrorFieldRequired", $langs->trans(
"MaxPeriodNumber")),
null,
'errors');
141 $object->id_origin = $id;
142 $object->title =
GETPOST(
'titre',
'alpha');
143 $object->description =
GETPOST(
'description',
'restricthtml');
144 $object->socid =
GETPOST(
'socid',
'alpha');
145 $object->fk_project =
GETPOST(
'projectid',
'int');
146 $object->fk_contract =
GETPOST(
'contractid',
'int');
148 $object->frequency = $frequency;
149 $object->unit_frequency =
GETPOST(
'unit_frequency',
'alpha');
150 $object->nb_gen_max = $nb_gen_max;
151 $object->auto_validate =
GETPOST(
'auto_validate',
'int');
153 $date_next_execution =
dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
154 $object->date_when = $date_next_execution;
156 if ($object->create($user) > 0) {
164 } elseif ($action ==
'createfrommodel') {
169 $res = $object->fetch_lines();
171 if ($object->socid > 0) {
172 $newinter->socid = $object->socid;
173 $newinter->fk_project = $object->fk_project;
174 $newinter->fk_contrat = $object->fk_contrat;
176 $newinter->socid =
GETPOST(
"socid");
179 $newinter->entity = $object->entity;
180 $newinter->duree = $object->duree;
182 $newinter->description = $object->description;
183 $newinter->note_private = $object->note_private;
184 $newinter->note_public = $object->note_public;
187 $extrafields->fetch_name_optionals_label($newinter->table_element);
189 $array_options = $extrafields->getOptionalsFromPost($newinter->table_element);
190 $newinter->array_options = $array_options;
192 $newfichinterid = $newinter->create($user);
194 if ($newfichinterid > 0) {
196 foreach ($object->lines as $line) {
197 $newinter->addline($user, $newfichinterid, $line->desc, $line->datei, $line->duree,
'');
201 $object->updateNbGenDone();
203 header(
'Location: '.DOL_URL_ROOT.
'/fichinter/card.php?id='.$newfichinterid);
209 } elseif ($action ==
'delete' && $user->rights->ficheinter->supprimer) {
214 header(
'Location: '.$_SERVER[
"PHP_SELF"]);
216 } elseif ($action ==
'setfrequency' && $user->rights->ficheinter->creer) {
219 $object->setFrequencyAndUnit(
GETPOST(
'frequency',
'int'),
GETPOST(
'unit_frequency',
'alpha'));
220 } elseif ($action ==
'setdate_when' && $user->rights->ficheinter->creer) {
225 $object->setNextDate($date);
227 } elseif ($action ==
'setnb_gen_max' && $user->rights->ficheinter->creer) {
230 $object->setMaxPeriod(
GETPOST(
'nb_gen_max',
'int'));
243 $companystatic =
new Societe($db);
244 if (!empty($conf->contrat->enabled)) {
245 $contratstatic =
new Contrat($db);
247 if (!empty($conf->project->enabled)) {
248 $projectstatic =
new Project($db);
253 $today =
dol_mktime(23, 59, 59, $tmparray[
'mon'], $tmparray[
'mday'], $tmparray[
'year']);
260 if ($action ==
'create') {
261 print
load_fiche_titre($langs->trans(
"CreateRepeatableIntervention"),
'',
'intervention');
266 if ($object->fetch($id, $ref) > 0) {
267 print
'<form action="card-rec.php" method="post">';
268 print
'<input type="hidden" name="token" value="'.newToken().
'">';
269 print
'<input type="hidden" name="action" value="add">';
270 print
'<input type="hidden" name="fichinterid" value="'.$object->id.
'">';
275 if (!empty($conf->project->enabled) && $object->fk_project > 0) {
278 if (!empty($conf->contrat->enabled) && $object->fk_contrat > 0) {
282 print
'<table class="border centpercent">';
284 $object->fetch_thirdparty();
287 print
'<tr><td>'.$langs->trans(
"Customer").
'</td><td>';
288 print
$form->select_company($object->thirdparty->id,
'socid',
'', 0, 1);
292 print $langs->trans(
"Comment");
296 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Title").
'</td><td>';
297 print
'<input class="flat quatrevingtpercent" type="text" name="titre" value="'.dol_escape_htmltag(
GETPOST(
"titre",
"alphanohtml")).
'">';
301 print
'<td rowspan="'.$rowspan.
'" valign="top">';
302 print
'<textarea class="flat" name="description" wrap="soft" cols="60" rows="'.ROWS_4.
'">';
303 print $object->description.
'</textarea>';
307 print
"<tr><td>".$langs->trans(
"Author").
"</td><td>".$user->getFullName($langs).
"</td></tr>";
309 if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
311 print
'<tr><td>'.$langs->trans(
"TotalDuration").
'</td>';
312 print
'<td colspan="3">'.convertSecondToTime($object->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY).
'</td>';
317 if (!empty($conf->project->enabled)) {
319 print
"<tr><td>".$langs->trans(
"Project").
"</td><td>";
320 $projectid =
GETPOST(
'projectid') ?
GETPOST(
'projectid') : $object->fk_project;
322 $numprojet = $formproject->select_projects($object->thirdparty->id, $projectid,
'projectid', 0, 0, 1, 0, 0, 0, 0,
'', 0, 0,
'');
323 print
' <a href="'.DOL_URL_ROOT.
'/projet/card.php?socid='.$object->thirdparty->id;
324 print
'&action=create&status=1&backtopage='.urlencode($_SERVER[
"PHP_SELF"]).
'?action=create';
325 print
'&socid='.$object->thirdparty->id.(!empty($id) ?
'&id='.$id :
'').
'">';
326 print $langs->trans(
"AddProject").
'</a>';
331 if (!empty($conf->contrat->enabled)) {
333 print
"<tr><td>".$langs->trans(
"Contract").
"</td><td>";
334 $contractid =
GETPOST(
'contractid') ?
GETPOST(
'contractid') : $object->fk_contract;
335 $numcontract = $formcontract->select_contract($object->thirdparty->id, $contractid,
'contracttid');
344 $title = $langs->trans(
"Recurrence");
347 print
'<table class="border centpercent">';
350 print
'<tr><td class="titlefieldcreate">';
351 print
$form->textwithpicto($langs->trans(
"Frequency"), $langs->transnoentitiesnoconv(
'toolTipFrequency'));
353 print
'<input type="text" name="frequency" value="'.GETPOST(
'frequency',
'int').
'" size="4"> ';
354 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'));
358 print
"<tr><td>".$langs->trans(
'NextDateToExecution').
"</td><td>";
359 if ($date_next_execution !=
"") {
362 print
$form->selectDate($date_next_execution,
'', 1, 1,
'',
"add", 1, 1);
366 print
"<tr><td>".$langs->trans(
"MaxPeriodNumber").
"</td><td>";
367 print
'<input type="text" name="nb_gen_max" value="'.GETPOST(
'nb_gen_max',
'int').
'" size="5">';
374 $title = $langs->trans(
"ProductsAndServices");
375 if (empty($conf->service->enabled)) {
376 $title = $langs->trans(
"Products");
377 } elseif (empty($conf->product->enabled)) {
378 $title = $langs->trans(
"Services");
386 print
'<table class="notopnoleftnoright" width="100%">';
387 print
'<tr><td colspan="3">';
389 $sql =
'SELECT l.rowid, l.description, l.duree';
390 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinterdet as l";
391 $sql .=
" WHERE l.fk_fichinter= ".((int) $object->id);
393 $sql .=
" ORDER BY l.rang";
395 $result = $db->query($sql);
397 $num = $db->num_rows($result);
401 echo
'<table class="noborder centpercent">';
403 print
'<tr class="liste_titre">';
404 print
'<td>'.$langs->trans(
"Description").
'</td>';
405 print
'<td class="center">'.$langs->trans(
"Duration").
'</td>';
409 $objp = $db->fetch_object($result);
410 print
'<tr class="oddeven">';
415 print
'<a name="'.$objp->rowid.
'"></a>';
417 $text =
img_object($langs->trans(
'Service'),
'service');
419 print $text.
' '.nl2br($objp->description);
422 print
'<td class="center">'.convertSecondToTime($objp->duree).
'</td>';
439 print
$form->buttonsSaveCancel(
"Create");
445 } elseif ($action ==
'selsocforcreatefrommodel') {
446 print
load_fiche_titre($langs->trans(
"CreateRepeatableIntervention"),
'',
'intervention');
449 print
'<form name="fichinter" action="'.$_SERVER[
'PHP_SELF'].
'" method="POST">';
450 print
'<table class="border centpercent">';
451 print
'<tr><td class="fieldrequired">'.$langs->trans(
"ThirdParty").
'</td><td>';
452 print
$form->select_company(
'',
'socid',
'', 1, 1);
458 print
'<input type="hidden" name="action" value="createfrommodel">';
459 print
'<input type="hidden" name="id" value="'.$id.
'">';
460 print
$form->buttonsSaveCancel(
"CreateDraftIntervention",
'');
469 if ($object->fetch($id) > 0) {
470 $object->fetch_thirdparty();
472 $author =
new User($db);
473 $author->fetch($object->user_author);
477 print
dol_get_fiche_head($head,
'card', $langs->trans(
"PredefinedInterventional"), 0,
'intervention');
480 $linkback =
'<a href="card-rec.php">'.$langs->trans(
"BackToList").
'</a>';
482 $morehtmlref =
'<div class="refidno">';
485 $morehtmlref .= $langs->trans(
'ThirdParty').
' : '.$object->thirdparty->getNomUrl(1);
487 if (!empty($conf->project->enabled)) {
489 $langs->load(
"projects");
490 $morehtmlref .=
'<br>'.$langs->trans(
'Project').
' ';
491 if ($user->rights->ficheinter->creer) {
492 if ($action !=
'classify') {
493 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.$object->id.
'">';
494 $morehtmlref .=
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> : ';
496 if ($action ==
'classify') {
497 $morehtmlref .=
'<form method="post" action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'">';
498 $morehtmlref .=
'<input type="hidden" name="action" value="classin">';
499 $morehtmlref .=
'<input type="hidden" name="token" value="'.newToken().
'">';
500 $morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project,
'projectid', $maxlength, 0, 1, 0, 1, 0, 0,
'', 1);
501 $morehtmlref .=
'<input type="submit" class="button valignmiddle" value="'.$langs->trans(
"Modify").
'">';
502 $morehtmlref .=
'</form>';
504 $morehtmlref .=
$form->form_project($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->socid, $object->fk_project,
'none', 0, 0, 0, 1);
507 if (!empty($object->fk_project)) {
509 $proj->fetch($object->fk_project);
510 $morehtmlref .=
' : '.$proj->getNomUrl(1);
512 $morehtmlref .=
' - '.$proj->title;
519 $morehtmlref .=
'</div>';
521 dol_banner_tab($object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref);
523 print
'<div class="fichecenter">';
524 print
'<div class="fichehalfleft">';
525 print
'<div class="underbanner clearboth"></div>';
527 print
'<table class="border centpercent">';
529 print
"<tr><td>".$langs->trans(
"Author").
'</td><td colspan="3">'.$author->getFullName($langs).
"</td></tr>";
531 if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) {
533 print
'<tr><td class="titlefield">'.$langs->trans(
"TotalDuration").
'</td>';
534 print
'<td colspan="3">';
535 print
convertSecondToTime($object->duration,
'all', $conf->global->MAIN_DURATION_OF_WORKDAY);
539 print
'<tr><td>'.$langs->trans(
"Description").
'</td><td colspan="3">'.nl2br($object->description).
"</td></tr>";
542 if (!empty($conf->contrat->enabled)) {
543 $langs->load(
'contracts');
547 print
'<table class="nobordernopadding" width="100%"><tr><td>';
548 print $langs->trans(
'Contract');
550 if ($action !=
'contrat') {
551 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=contrat&id='.$object->id.
'">';
552 print
img_edit($langs->trans(
'SetContract'), 1);
555 print
'</tr></table>';
557 if ($action ==
'contrat') {
558 $formcontract =
new Formcontract($db);
559 $formcontract->formSelectContract($_SERVER[
"PHP_SELF"].
'?id='.$object->id, $object->socid, $object->fk_contrat,
'contratid', 0, 1);
561 if ($object->fk_contrat) {
562 $contratstatic =
new Contrat($db);
563 $contratstatic->fetch($object->fk_contrat);
564 print $contratstatic->getNomUrl(0,
'', 1);
575 print
'<div class="fichehalfright">';
576 print
'<div class="underbanner clearboth"></div>';
578 $title = $langs->trans(
"Recurrence");
581 print
'<table class="border centpercent">';
584 print
'<tr><td class="titlefield">';
585 print
'<table class="nobordernopadding" width="100%"><tr><td>';
586 print $langs->trans(
'Frequency');
588 if ($action !=
'editfrequency' && $user->rights->ficheinter->creer) {
589 print
'<td class="right"><a href="'.$_SERVER[
"PHP_SELF"].
'?action=editfrequency&token='.
newToken().
'&id='.$id.
'">';
590 print
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
592 print
'</tr></table>';
594 if ($action ==
'editfrequency') {
595 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
596 print
'<input type="hidden" name="action" value="setfrequency">';
597 print
'<input type="hidden" name="token" value="'.newToken().
'">';
598 print
'<table class="nobordernopadding">';
600 print
'<input type="text" name="frequency" value="'.$object->frequency.
'" size="5"> ';
601 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'));
603 print
'<td class="left"><input type="submit" class="button button-edit" value="'.$langs->trans(
"Modify").
'"></td>';
604 print
'</tr></table></form>';
606 if ($object->frequency > 0) {
607 print $langs->trans(
'FrequencyPer_'.$object->unit_frequency, $object->frequency);
609 print $langs->trans(
"NotARecurringInterventionalTemplate");
616 if ($user->rights->ficheinter->creer && ($action ==
'date_when' || $object->frequency > 0)) {
617 print
$form->editfieldkey($langs->trans(
"NextDateToExecution"),
'date_when', $object->date_when, $object, $user->rights->facture->creer,
'day');
619 print $langs->trans(
"NextDateToExecution");
622 if ($action ==
'date_when' || $object->frequency > 0) {
623 print
$form->editfieldval($langs->trans(
"NextDateToExecution"),
'date_when', $object->date_when, $object, $user->rights->facture->creer,
'day');
630 if ($user->rights->ficheinter->creer && ($action ==
'nb_gen_max' || $object->frequency > 0)) {
631 print
$form->editfieldkey($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', $object->nb_gen_max, $object, $user->rights->facture->creer);
633 print $langs->trans(
"MaxPeriodNumber");
637 if ($action ==
'nb_gen_max' || $object->frequency > 0) {
638 print
$form->editfieldval($langs->trans(
"MaxPeriodNumber"),
'nb_gen_max', $object->nb_gen_max ? $object->nb_gen_max :
'', $object, $user->rights->facture->creer);
649 if ($object->frequency > 0) {
651 if (empty($conf->cron->enabled)) {
652 $txtinfoadmin = $langs->trans(
"EnableAndSetupModuleCron", $langs->transnoentitiesnoconv(
"Module2300Name"));
655 print
'<div class="underbanner clearboth"></div>';
656 print
'<table class="border centpercent">';
659 print
'<tr><td class="titlefield">'.$langs->trans(
"NbOfGenerationOfRecordDone").
'</td>';
661 print $object->nb_gen_done ? $object->nb_gen_done :
'0';
667 print $langs->trans(
"DateLastGeneration");
679 print
'<div class="clearboth"></div><br>';
685 $title = $langs->trans(
"ProductsAndServices");
686 if (empty($conf->service->enabled)) {
687 $title = $langs->trans(
"Products");
688 } elseif (empty($conf->product->enabled)) {
689 $title = $langs->trans(
"Services");
694 print
'<table class="noborder centpercent">';
695 print
'<tr class="liste_titre">';
696 print
'<td>'.$langs->trans(
"Description").
'</td>';
697 print
'<td class="center">'.$langs->trans(
"Duration").
'</td>';
700 $num = count($object->lines);
704 if (isset($object->lines[$i]->product_type)) {
705 $type = $object->lines[$i]->product_type;
707 $object->lines[$i]->fk_product_type;
711 if (!empty($objp->date_start)) {
714 if (!empty($objp->date_end)) {
719 print
'<tr class="oddeven">';
721 $text =
img_object($langs->trans(
'Service'),
'service');
722 print $text.
' '.nl2br($object->lines[$i]->desc);
725 print
'<td class="center">'.convertSecondToTime($object->lines[$i]->duree).
'</td>';
734 print
'<div class="tabsAction">';
736 if ($user->rights->ficheinter->creer) {
737 print
'<div class="inline-block divButAction">';
738 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=createfrommodel&token='.
newToken().
'';
739 print
'&socid='.$object->thirdparty->id.
'&id='.$object->id.
'">';
740 print $langs->trans(
"AddIntervention").
'</a></div>';
743 if ($user->rights->ficheinter->supprimer) {
744 print
'<div class="inline-block divButAction">';
745 print
'<a class="butActionDelete" href="'.$_SERVER[
'PHP_SELF'].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'">';
746 print $langs->trans(
'Delete').
'</a></div>';
750 print $langs->trans(
"ErrorRecordNotFound");
756 $sql =
"SELECT f.rowid as fich_rec, s.nom as name, s.rowid as socid, f.rowid as facid, f.titre as title,";
757 $sql .=
" f.duree, f.fk_contrat, f.fk_projet as fk_project, f.frequency, f.nb_gen_done, f.nb_gen_max,";
758 $sql .=
" f.date_last_gen, f.date_when, f.datec";
760 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinter_rec as f";
761 $sql .=
" , ".MAIN_DB_PREFIX.
"societe as s ";
762 if (empty($user->rights->societe->client->voir) && !$socid) {
763 $sql .=
" , ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
765 $sql .=
" WHERE f.fk_soc = s.rowid";
766 $sql .=
" AND f.entity = ".$conf->entity;
768 $sql .=
" AND s.rowid = ".((int) $socid);
770 if (empty($user->rights->societe->client->voir) && !$socid) {
771 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
776 if ($search_societe) {
779 if ($search_frequency ==
'1') {
780 $sql .=
' AND f.frequency > 0';
782 if ($search_frequency ==
'0') {
783 $sql .=
' AND (f.frequency IS NULL or f.frequency = 0)';
790 $resql = $db->query($sql);
792 $num = $db->num_rows(
$resql);
794 print_barre_liste($langs->trans(
"RepeatableIntervention"), $page, $_SERVER[
'PHP_SELF'],
"&socid=$socid", $sortfield, $sortorder,
'', $num,
'',
'intervention');
796 print
'<span class="opacitymedium">'.$langs->trans(
"ToCreateAPredefinedIntervention").
'</span><br><br>';
799 print
'<table class="noborder centpercent">';
800 print
'<tr class="liste_titre">';
801 print_liste_field_titre(
"Ref", $_SERVER[
'PHP_SELF'],
"f.titre",
"",
"",
'width="200px"', $sortfield, $sortorder,
'left ');
802 print_liste_field_titre(
"Company", $_SERVER[
'PHP_SELF'],
"s.nom",
"",
"",
'width="200px"', $sortfield, $sortorder,
'left ');
803 if (!empty($conf->contrat->enabled)) {
804 print_liste_field_titre(
"Contract", $_SERVER[
'PHP_SELF'],
"f.fk_contrat",
"",
"",
'width="100px"', $sortfield, $sortorder,
'left ');
806 if (!empty($conf->project->enabled)) {
807 print_liste_field_titre(
"Project", $_SERVER[
'PHP_SELF'],
"f.fk_project",
"",
"",
'width="100px"', $sortfield, $sortorder,
'left ');
809 print_liste_field_titre(
"Duration", $_SERVER[
'PHP_SELF'],
'f.duree',
'',
'',
'width="50px"', $sortfield, $sortorder,
'right ');
811 print_liste_field_titre(
"Frequency", $_SERVER[
'PHP_SELF'],
"f.frequency",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
812 print_liste_field_titre(
"NbOfGenerationDoneShort", $_SERVER[
'PHP_SELF'],
"f.nb_gen_done",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
813 print_liste_field_titre(
"DateLastGeneration", $_SERVER[
'PHP_SELF'],
"f.date_last_gen",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
814 print_liste_field_titre(
"NextDateToIntervention", $_SERVER[
'PHP_SELF'],
"f.date_when",
"",
"",
'width="100px"', $sortfield, $sortorder,
'center ');
815 print
'<th width="100px"></th>';
822 while ($i < min($num, $limit)) {
823 $objp = $db->fetch_object(
$resql);
825 print
'<tr class="oddeven">';
826 print
'<td><a href="'.$_SERVER[
'PHP_SELF'].
'?id='.$objp->fich_rec.
'">';
827 print
img_object($langs->trans(
"ShowIntervention"),
"intervention").
' '.$objp->title;
830 $companystatic->id = $objp->socid;
831 $companystatic->name = $objp->name;
832 print
'<td>'.$companystatic->getNomUrl(1,
'customer').
'</td>';
834 print
'<td>'.$langs->trans(
"None").
'</td>';
837 if (!empty($conf->contrat->enabled)) {
839 if ($objp->fk_contrat > 0) {
840 $contratstatic->fetch($objp->fk_contrat);
841 print $contratstatic->getNomUrl(1);
845 if (!empty($conf->project->enabled)) {
847 if ($objp->fk_project > 0) {
848 $projectstatic->fetch($objp->fk_project);
849 print $projectstatic->getNomUrl(1);
854 print
'<td class=right>'.convertSecondToTime($objp->duree).
'</td>';
856 print
'<td class="center">'.yn($objp->frequency ? 1 : 0).
'</td>';
858 print
'<td class="center">';
859 if ($objp->frequency) {
860 print $objp->nb_gen_done.($objp->nb_gen_max > 0 ?
' / '.$objp->nb_gen_max :
'');
863 print
'<td class="center">';
867 print
'<td class="center">';
871 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
873 print
'<td class="center">';
874 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
876 print
'<td class="center">';
877 print
'<span class="opacitymedium">'.$langs->trans(
'NA').
'</span>';
881 if ($user->rights->ficheinter->creer) {
883 print
'<td class="center">';
884 if ($user->rights->ficheinter->creer) {
885 if (empty($objp->frequency) || $db->jdate($objp->date_when) <= $today) {
886 print
'<a class="butAction" href="'.$_SERVER[
'PHP_SELF'].
'?action=createfrommodel';
887 print
'&socid='.$objp->socid.
'&id='.$objp->fich_rec.
'">';
888 print $langs->trans(
"CreateFichInter").
'</a>';
890 print $langs->trans(
"DateIsNotEnough");
903 print
'<tr class="oddeven"><td colspan="10"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';