dolibarr  9.0.0
card.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2018 Regis Houssin <regis.houssin@inodbox.com>
5  * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
6  * Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
7  * Copyright (C) 2014-2018 Ferran Marcet <fmarcet@2byte.es>
8  * Copyright (C) 2014-2018 Charlene Benke <charlies@patas-monkey.com>
9  * Copyright (C) 2015-2016 Abbes Bahfir <bafbes@gmail.com>
10  * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
32 require '../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
38 if (! empty($conf->projet->enabled))
39 {
40  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
41  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
42 }
43 if ($conf->contrat->enabled)
44 {
45  require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php";
46  require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
47 }
48 if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php"))
49 {
50  require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php';
51 }
52 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
53 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
54 
55 // Load translation files required by the page
56 $langs->loadLangs(array('bills', 'companies', 'interventions'));
57 
58 $id = GETPOST('id','int');
59 $ref = GETPOST('ref','alpha');
60 $socid = GETPOST('socid','int');
61 $contratid = GETPOST('contratid','int');
62 $action = GETPOST('action','alpha');
63 $cancel = GETPOST('cancel','alpha');
64 $confirm = GETPOST('confirm','alpha');
65 $mesg = GETPOST('msg','alpha');
66 $origin=GETPOST('origin','alpha');
67 $originid=(GETPOST('originid','int')?GETPOST('originid','int'):GETPOST('origin_id','int')); // For backward compatibility
68 $note_public = GETPOST('note_public','none');
69 $lineid = GETPOST('line_id','int');
70 
71 //PDF
72 $hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
73 $hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
74 $hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
75 
76 // Security check
77 if ($user->societe_id) $socid=$user->societe_id;
78 $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
79 
80 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
81 $hookmanager->initHooks(array('interventioncard','globalcard'));
82 
83 $object = new Fichinter($db);
84 $extrafields = new ExtraFields($db);
85 $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
86 
87 // Load object
88 if ($id > 0 || ! empty($ref))
89 {
90  $ret=$object->fetch($id, $ref);
91  if ($ret > 0) $ret=$object->fetch_thirdparty();
92  if ($ret < 0) dol_print_error('',$object->error);
93 }
94 
95 $permissionnote=$user->rights->ficheinter->creer; // Used by the include of actions_setnotes.inc.php
96 $permissiondellink=$user->rights->ficheinter->creer; // Used by the include of actions_dellink.inc.php
97 
98 
99 /*
100  * Actions
101  */
102 
103 $parameters=array('socid'=>$socid);
104 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
105 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
106 
107 if (empty($reshook))
108 {
109  if ($cancel)
110  {
111  if (! empty($backtopage))
112  {
113  header("Location: ".$backtopage);
114  exit;
115  }
116  $action='';
117  }
118 
119  include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
120 
121  include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
122 
123  // Action clone object
124  if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->ficheinter->creer)
125  {
126  if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
127  {
128  setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
129  }
130  else
131  {
132  if ($object->id > 0)
133  {
134  // Because createFromClone modifies the object, we must clone it so that we can restore it later
135  $orig = clone $object;
136 
137  $result=$object->createFromClone($socid);
138  if ($result > 0)
139  {
140  header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
141  exit;
142  }
143  else
144  {
145  setEventMessages($object->error, $object->errors, 'errors');
146  $object = $orig;
147  $action='';
148  }
149  }
150  }
151  }
152 
153  if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->ficheinter->creer)
154  {
155  $result = $object->setValid($user);
156 
157  if ($result >= 0)
158  {
159  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
160  {
161  // Define output language
162  $outputlangs = $langs;
163  $newlang='';
164  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
165  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
166  if (! empty($newlang))
167  {
168  $outputlangs = new Translate("",$conf);
169  $outputlangs->setDefaultLang($newlang);
170  }
171  $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->modelpdf:GETPOST('model','alpha'), $outputlangs);
172  }
173 
174  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
175  exit;
176  }
177  else
178  {
179  $mesg='<div class="error">'.$object->error.'</div>';
180  }
181  }
182 
183  else if ($action == 'confirm_modify' && $confirm == 'yes' && $user->rights->ficheinter->creer)
184  {
185  $result = $object->setDraft($user);
186  if ($result >= 0)
187  {
188  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
189  {
190  // Define output language
191  $outputlangs = $langs;
192  $newlang='';
193  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
194  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
195  if (! empty($newlang))
196  {
197  $outputlangs = new Translate("",$conf);
198  $outputlangs->setDefaultLang($newlang);
199  }
200  $result=fichinter_create($db, $object, (!GETPOST('model','alpha'))?$object->modelpdf:GETPOST('model','alpha'), $outputlangs);
201  }
202 
203  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
204  exit;
205  }
206  else
207  {
208  $mesg='<div class="error">'.$object->error.'</div>';
209  }
210  }
211 
212  else if ($action == 'add' && $user->rights->ficheinter->creer)
213  {
214  $object->socid = $socid;
215  $object->duration = GETPOST('duration','int');
216  $object->fk_project = GETPOST('projectid','int');
217  $object->fk_contrat = GETPOST('contratid','int');
218  $object->author = $user->id;
219  $object->description = GETPOST('description','none');
220  $object->ref = $ref;
221  $object->modelpdf = GETPOST('model','alpha');
222  $object->note_private = GETPOST('note_private','none');
223  $object->note_public = GETPOST('note_public','none');
224 
225  if ($object->socid > 0)
226  {
227  // If creation from another object of another module (Example: origin=propal, originid=1)
228  if (!empty($origin) && !empty($originid) )
229  {
230  // Parse element/subelement (ex: project_task)
231  $element = $subelement = $_POST['origin'];
232  if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs))
233  {
234  $element = $regs[1];
235  $subelement = $regs[2];
236  }
237 
238  // For compatibility
239  if ($element == 'order') {
240  $element = $subelement = 'commande';
241  }
242  if ($element == 'propal') {
243  $element = 'comm/propal'; $subelement = 'propal';
244  }
245  if ($element == 'contract') {
246  $element = $subelement = 'contrat';
247  }
248 
249  $object->origin = $origin;
250  $object->origin_id = $originid;
251 
252  // Possibility to add external linked objects with hooks
253  $object->linked_objects[$object->origin] = $object->origin_id;
254  if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects']))
255  {
256  $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
257  }
258 
259  // Extrafields
260  $extrafields = new ExtraFields($db);
261  $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
262  $array_options = $extrafields->getOptionalsFromPost($object->table_element);
263 
264  $object->array_options = $array_options;
265 
266  $id = $object->create($user);
267 
268  if ($id > 0)
269  {
270  dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
271 
272  $classname = ucfirst($subelement);
273  $srcobject = new $classname($db);
274 
275  dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
276  $result=$srcobject->fetch($object->origin_id);
277  if ($result > 0)
278  {
279  $srcobject->fetch_thirdparty();
280  $lines = $srcobject->lines;
281  if (empty($lines) && method_exists($srcobject,'fetch_lines'))
282  {
283  $srcobject->fetch_lines();
284  $lines = $srcobject->lines;
285  }
286 
287  $fk_parent_line=0;
288  $num=count($lines);
289 
290  for ($i=0; $i<$num; $i++)
291  {
292  $product_type=($lines[$i]->product_type?$lines[$i]->product_type:Product::TYPE_PRODUCT);
293 
294  if ($product_type == Product::TYPE_SERVICE || !empty($conf->global->FICHINTER_PRINT_PRODUCTS)) { //only services except if config includes products
295  $duration = 3600; // Default to one hour
296 
297  // Predefined products & services
298  if ($lines[$i]->fk_product > 0)
299  {
300  $prod = new Product($db);
301  $prod->id = $lines[$i]->fk_product;
302 
303  // Define output language
304  if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) {
305  $prod->getMultiLangs();
306  // We show if duration is present on service (so we get it)
307  $prod->fetch($lines[$i]->fk_product);
308  $outputlangs = $langs;
309  $newlang='';
310  if (empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
311  if (empty($newlang)) $newlang=$srcobject->thirdparty->default_lang;
312  if (! empty($newlang)) {
313  $outputlangs = new Translate("",$conf);
314  $outputlangs->setDefaultLang($newlang);
315  }
316  $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label;
317  } else {
318  $prod->fetch($lines[$i]->fk_product);
319  $label = $lines[$i]->product_label;
320  }
321 
322  if ($prod->duration_value && $conf->global->FICHINTER_USE_SERVICE_DURATION) {
323  switch ($prod->duration_unit) {
324  default:
325  case 'h':
326  $mult = 3600;
327  break;
328  case 'd':
329  $mult = 3600 * 24;
330  break;
331  case 'w':
332  $mult = 3600 * 24 * 7;
333  break;
334  case 'm':
335  $mult = (int) 3600 * 24 * (365 / 12); // Average month duration
336  break;
337  case 'y':
338  $mult = 3600 * 24 * 365;
339  break;
340  }
341  $duration = $prod->duration_value * $mult * $lines[$i]->qty;
342  }
343 
344  $desc = $lines[$i]->product_ref;
345  $desc .= ' - ';
346  $desc .= $label;
347  $desc .= '<br>';
348  }
349  // Common part (predefined or free line)
350  $desc .= dol_htmlentitiesbr($lines[$i]->desc);
351  $desc .= '<br>';
352  $desc .= ' (' . $langs->trans('Quantity') . ': ' . $lines[$i]->qty . ')';
353 
354  $timearray=dol_getdate(mktime());
355  $date_intervention=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']);
356 
357  if ($product_type == Product::TYPE_PRODUCT) {
358  $duration = 0;
359  }
360 
361  $predef = '';
362 
363  // Extrafields
364  $extrafieldsline = new ExtraFields($db);
365  $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
366  $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline, $predef);
367 
368  $result = $object->addline(
369  $user,
370  $id,
371  $desc,
372  $date_intervention,
373  $duration,
374  $array_options
375  );
376 
377  if ($result < 0)
378  {
379  $error++;
380  break;
381  }
382  }
383  }
384  }
385  else
386  {
387  $mesg=$srcobject->error;
388  $error++;
389  }
390  }
391  else
392  {
393  $mesg=$object->error;
394  $error++;
395  }
396  }
397  else
398  {
399  // Fill array 'array_options' with data from add form
400  $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
401  if ($ret < 0) {
402  $error ++;
403  $action = 'create';
404  }
405 
406  if (! $error)
407  {
408  // Extrafields
409  $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
410  $array_options = $extrafields->getOptionalsFromPost($object->table_element);
411 
412  $object->array_options = $array_options;
413 
414  $result = $object->create($user);
415  if ($result > 0)
416  {
417  $id=$result; // Force raffraichissement sur fiche venant d'etre cree
418  }
419  else
420  {
421  $langs->load("errors");
422  setEventMessages($object->error, $object->errors, 'errors');
423  $action = 'create';
424  }
425  }
426  }
427  }
428  else
429  {
430  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ThirdParty")).'</div>';
431  $action = 'create';
432  }
433  }
434 
435  else if ($action == 'update' && $user->rights->ficheinter->creer)
436  {
437  $object->socid = $socid;
438  $object->fk_project = GETPOST('projectid','int');
439  $object->fk_contrat = GETPOST('contratid','int');
440  $object->author = $user->id;
441  $object->description = GETPOST('description','alpha');
442  $object->ref = $ref;
443 
444  $result=$object->update($user);
445  if ($result<0) {
446  setEventMessages($object->error, $object->errors, 'errors');
447  }
448  }
449 
450  // Set into a project
451  else if ($action == 'classin' && $user->rights->ficheinter->creer)
452  {
453  $result=$object->setProject(GETPOST('projectid','int'));
454  if ($result < 0) dol_print_error($db,$object->error);
455  }
456 
457  // Set into a contract
458  else if ($action == 'setcontract' && $user->rights->contrat->creer)
459  {
460  $result=$object->set_contrat($user,GETPOST('contratid','int'));
461  if ($result < 0) dol_print_error($db,$object->error);
462  }
463 
464  else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
465  {
466  $result=$object->delete($user);
467  if ($result<0) {
468  setEventMessages($object->error, $object->errors, 'errors');
469  }
470 
471  header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter&restore_lastsearch_values=1');
472  exit;
473  }
474 
475  else if ($action == 'setdescription' && $user->rights->ficheinter->creer)
476  {
477  $result=$object->set_description($user,GETPOST('description'));
478  if ($result < 0) dol_print_error($db,$object->error);
479  }
480 
481  // Add line
482  else if ($action == "addline" && $user->rights->ficheinter->creer)
483  {
484  if (!GETPOST('np_desc','none') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC) )
485  {
486  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
487  $error++;
488  }
489  if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour','int') && !GETPOST('durationmin','int'))
490  {
491  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Duration")).'</div>';
492  $error++;
493  }
494  if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour','int') >= 24 && GETPOST('durationmin','int') > 0)
495  {
496  $mesg='<div class="error">'.$langs->trans("ErrorValueTooHigh").'</div>';
497  $error++;
498  }
499  if (! $error)
500  {
501  $db->begin();
502 
503  $desc=GETPOST('np_desc','none');
504  $date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
505  $duration = empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int')) : 0;
506 
507 
508  // Extrafields
509  $extrafieldsline = new ExtraFields($db);
510  $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
511  $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
512 
513  $result=$object->addline(
514  $user,
515  $id,
516  $desc,
517  $date_intervention,
518  $duration,
519  $array_options
520  );
521 
522  // Define output language
523  $outputlangs = $langs;
524  $newlang='';
525  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
526  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
527  if (! empty($newlang))
528  {
529  $outputlangs = new Translate("",$conf);
530  $outputlangs->setDefaultLang($newlang);
531  }
532 
533  if ($result >= 0)
534  {
535  $db->commit();
536 
537  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
538  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
539  exit;
540  }
541  else
542  {
543  $mesg=$object->error;
544  $db->rollback();
545  }
546  }
547  }
548 
549  // Classify Billed
550  else if ($action == 'classifybilled' && $user->rights->ficheinter->creer)
551  {
552  $result=$object->setStatut(2);
553  if ($result > 0)
554  {
555  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
556  exit;
557  }
558  else
559  {
560  setEventMessages($object->error, $object->errors, 'errors');
561  }
562  }
563 
564  // Classify unbilled
565  else if ($action == 'classifyunbilled' && $user->rights->ficheinter->creer)
566  {
567  $result=$object->setStatut(1);
568  if ($result > 0)
569  {
570  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
571  exit;
572  }
573  else
574  {
575  $mesg='<div class="error">'.$object->error.'</div>';
576  }
577  }
578 
579  // Classify Done
580  else if ($action == 'classifydone' && $user->rights->ficheinter->creer)
581  {
582  $result=$object->setStatut(3);
583  if ($result > 0)
584  {
585  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
586  exit;
587  }
588  else
589  {
590  setEventMessages($object->error, $object->errors, 'errors');
591  }
592  }
593 
594  /*
595  * Mise a jour d'une ligne d'intervention
596  */
597  else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save','alpha') == $langs->trans("Save"))
598  {
599  $objectline = new FichinterLigne($db);
600  if ($objectline->fetch($lineid) <= 0)
601  {
602  dol_print_error($db);
603  exit;
604  }
605 
606  if ($object->fetch($objectline->fk_fichinter) <= 0)
607  {
608  dol_print_error($db);
609  exit;
610  }
611  $object->fetch_thirdparty();
612 
613  $desc = GETPOST('np_desc');
614  $date_inter = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
615  $duration = convertTime2Seconds(GETPOST('durationhour','int'),GETPOST('durationmin','int'));
616 
617  $objectline->datei = $date_inter;
618  $objectline->desc = $desc;
619  $objectline->duration = $duration;
620 
621  // Extrafields
622  $extrafieldsline = new ExtraFields($db);
623  $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
624  $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
625  $objectline->array_options = $array_options;
626 
627  $result = $objectline->update($user);
628  if ($result < 0)
629  {
630  dol_print_error($db);
631  exit;
632  }
633 
634  // Define output language
635  $outputlangs = $langs;
636  $newlang='';
637  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
638  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
639  if (! empty($newlang))
640  {
641  $outputlangs = new Translate("",$conf);
642  $outputlangs->setDefaultLang($newlang);
643  }
644  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
645 
646  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
647  exit;
648  }
649 
650  /*
651  * Supprime une ligne d'intervention AVEC confirmation
652  */
653  else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer)
654  {
655  $objectline = new FichinterLigne($db);
656  if ($objectline->fetch($lineid) <= 0)
657  {
658  dol_print_error($db);
659  exit;
660  }
661  $result=$objectline->deleteline($user);
662 
663  if ($object->fetch($objectline->fk_fichinter) <= 0)
664  {
665  dol_print_error($db);
666  exit;
667  }
668 
669  // Define output language
670  $outputlangs = $langs;
671  $newlang='';
672  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
673  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
674  if (! empty($newlang))
675  {
676  $outputlangs = new Translate("",$conf);
677  $outputlangs->setDefaultLang($newlang);
678  }
679  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
680  }
681 
682  /*
683  * Ordonnancement des lignes
684  */
685 
686  else if ($action == 'up' && $user->rights->ficheinter->creer)
687  {
688  $object->line_up($lineid);
689 
690  // Define output language
691  $outputlangs = $langs;
692  $newlang='';
693  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
694  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
695  if (! empty($newlang))
696  {
697  $outputlangs = new Translate("",$conf);
698  $outputlangs->setDefaultLang($newlang);
699  }
700  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
701 
702  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
703  exit;
704  }
705 
706  else if ($action == 'down' && $user->rights->ficheinter->creer)
707  {
708  $object->line_down($lineid);
709 
710  // Define output language
711  $outputlangs = $langs;
712  $newlang='';
713  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
714  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
715  if (! empty($newlang))
716  {
717  $outputlangs = new Translate("",$conf);
718  $outputlangs->setDefaultLang($newlang);
719  }
720  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
721 
722  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
723  exit;
724  }
725 
726  // Actions when printing a doc from card
727  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
728 
729  // Actions to send emails
730  $trigger_name='FICHINTER_SENTBYMAIL';
731  $autocopy='MAIN_MAIL_AUTOCOPY_FICHINTER_TO';
732  $trackid='int'.$object->id;
733  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
734 
735  // Actions to build doc
736  $upload_dir = $conf->ficheinter->dir_output;
737  $permissioncreate = $user->rights->ficheinter->creer;
738  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
739 
740  if ($action == 'update_extras')
741  {
742  $object->oldcopy = dol_clone($object);
743 
744  // Fill array 'array_options' with data from update form
745  $extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
746  $ret = $extrafields->setOptionalsFromPost($extralabels,$object,GETPOST('attribute', 'none'));
747  if ($ret < 0) $error++;
748 
749  if (! $error)
750  {
751  // Actions on extra fields
752  $result=$object->insertExtraFields('INTERVENTION_MODIFY');
753  if ($result < 0)
754  {
755  $error++;
756  }
757  }
758 
759  if ($error) $action = 'edit_extras';
760  }
761 
762  if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer)
763  {
764  if ($action == 'addcontact')
765  {
766  if ($result > 0 && $id > 0)
767  {
768  $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
769  $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha'));
770  }
771 
772  if ($result >= 0)
773  {
774  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
775  exit;
776  }
777  else
778  {
779  if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
780  {
781  $langs->load("errors");
782  $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
783  }
784  else
785  {
786  $mesg = '<div class="error">'.$object->error.'</div>';
787  }
788  }
789  }
790 
791  // bascule du statut d'un contact
792  else if ($action == 'swapstatut')
793  {
794  $result=$object->swapContactStatus(GETPOST('ligne','int'));
795  }
796 
797  // Efface un contact
798  else if ($action == 'deletecontact')
799  {
800  $result = $object->delete_contact(GETPOST('lineid','int'));
801 
802  if ($result >= 0)
803  {
804  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
805  exit;
806  }
807  else {
808  dol_print_error($db);
809  }
810  }
811  }
812 }
813 
814 
815 /*
816  * View
817  */
818 
819 $form = new Form($db);
820 $formfile = new FormFile($db);
821 if ($conf->contrat->enabled) $formcontract = new FormContract($db);
822 if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
823 
824 llxHeader('',$langs->trans("Intervention"));
825 
826 if ($action == 'create')
827 {
828  /*
829  * Mode creation
830  * Creation d'une nouvelle fiche d'intervention
831  */
832 
833  $soc=new Societe($db);
834 
835  print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial');
836 
837  dol_htmloutput_mesg($mesg);
838 
839  if ($socid) $res=$soc->fetch($socid);
840 
841  if (GETPOST('origin') && GETPOST('originid'))
842  {
843  // Parse element/subelement (ex: project_task)
844  $element = $subelement = GETPOST('origin');
845  if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs))
846  {
847  $element = $regs[1];
848  $subelement = $regs[2];
849  }
850 
851  if ($element == 'project')
852  {
853  $projectid=GETPOST('originid');
854  }
855  else
856  {
857  // For compatibility
858  if ($element == 'order' || $element == 'commande') {
859  $element = $subelement = 'commande';
860  }
861  if ($element == 'propal') {
862  $element = 'comm/propal'; $subelement = 'propal';
863  }
864  if ($element == 'contract') {
865  $element = $subelement = 'contrat';
866  }
867 
868  dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
869 
870  $classname = ucfirst($subelement);
871  $objectsrc = new $classname($db);
872  $objectsrc->fetch(GETPOST('originid'));
873  if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))
874  {
875  $objectsrc->fetch_lines();
876  $lines = $objectsrc->lines;
877  }
878  $objectsrc->fetch_thirdparty();
879 
880  $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
881 
882  $soc = $objectsrc->thirdparty;
883 
884  $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private','none')));
885  $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public','none'));
886 
887  // Object source contacts list
888  $srccontactslist = $objectsrc->liste_contact(-1,'external',1);
889  }
890  }
891  else {
892  $projectid = GETPOST('projectid','int');
893  }
894 
895  if (! $conf->global->FICHEINTER_ADDON)
896  {
897  dol_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
898  exit;
899  }
900 
901  $object->date = dol_now();
902 
903  $obj = $conf->global->FICHEINTER_ADDON;
904  $obj = "mod_".$obj;
905 
906  //$modFicheinter = new $obj;
907  //$numpr = $modFicheinter->getNextValue($soc, $object);
908 
909  if ($socid > 0)
910  {
911  $soc=new Societe($db);
912  $soc->fetch($socid);
913 
914  print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
915  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
916 
917  dol_fiche_head('');
918 
919  print '<table class="border" width="100%">';
920 
921  print '<input type="hidden" name="socid" value='.$soc->id.'>';
922  print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
923 
924  print '<input type="hidden" name="action" value="add">';
925 
926  // Ref
927  print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
928 
929  // Description (must be a textarea and not html must be allowed (used in list view)
930  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
931  print '<td>';
932  print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
933  print '</td></tr>';
934 
935  // Project
936  if (! empty($conf->projet->enabled))
937  {
938  $formproject=new FormProjets($db);
939 
940  $langs->load("project");
941 
942  print '<tr><td>'.$langs->trans("Project").'</td><td>';
943  /* Fix: If a project must be linked to any companies (suppliers or not), project must be not be set as limited to customer but must be not linked to any particular thirdparty
944  if ($societe->fournisseur==1)
945  $numprojet=select_projects(-1,$_POST["projectid"],'projectid');
946  else
947  $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
948  */
949  $numprojet=$formproject->select_projects($soc->id,$projectid,'projectid');
950  if ($numprojet==0)
951  {
952  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
953  }
954  print '</td></tr>';
955  }
956 
957  // Contract
958  if ($conf->contrat->enabled)
959  {
960  $langs->load("contracts");
961  print '<tr><td>'.$langs->trans("Contract").'</td><td>';
962  $numcontrat=$formcontract->select_contract($soc->id,GETPOST('contratid','int'),'contratid',0,1);
963  if ($numcontrat==0)
964  {
965  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
966  }
967  print '</td></tr>';
968  }
969 
970  // Model
971  print '<tr>';
972  print '<td>'.$langs->trans("DefaultModel").'</td>';
973  print '<td colspan="2">';
975  print $form->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
976  print "</td></tr>";
977 
978  // Public note
979  print '<tr>';
980  print '<td tdtop">'.$langs->trans('NotePublic').'</td>';
981  print '<td colspan="2">';
982  $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
983  print $doleditor->Create(1);
984  //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
985  print '</td></tr>';
986 
987  // Private note
988  if (empty($user->societe_id))
989  {
990  print '<tr>';
991  print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
992  print '<td colspan="2">';
993  $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
994  print $doleditor->Create(1);
995  //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
996  print '</td></tr>';
997  }
998 
999  // Other attributes
1000  $parameters=array('colspan' => ' colspan="2"');
1001  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
1002  print $hookmanager->resPrint;
1003  if (empty($reshook))
1004  {
1005  print $object->showOptionals($extrafields,'edit');
1006  }
1007 
1008  // Show link to origin object
1009  if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
1010  {
1011  $newclassname=$classname;
1012  if ($newclassname=='Propal') $newclassname='CommercialProposal';
1013  print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
1014 
1015  // Amount
1016  /* Hide amount because we only copy services so amount may differ than source
1017  print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
1018  print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
1019  if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
1020  {
1021  print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
1022  }
1023 
1024  if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
1025  {
1026  print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
1027  }
1028 
1029  print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
1030 
1031  if (!empty($conf->multicurrency->enabled))
1032  {
1033  print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
1034  print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
1035  print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
1036  }
1037  */
1038  }
1039 
1040  print '</table>';
1041 
1042  if (is_object($objectsrc))
1043  {
1044  print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1045  print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1046  } elseif ($origin == 'project' && !empty($projectid)) {
1047  print '<input type="hidden" name="projectid" value="' . $projectid . '">';
1048  }
1049 
1050  dol_fiche_end();
1051 
1052  print '<div class="center">';
1053  print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
1054  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1055  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1056  print '</div>';
1057 
1058  print '</form>';
1059 
1060  // Show origin lines
1061  if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
1062  $title = $langs->trans('Services');
1063  print load_fiche_titre($title);
1064 
1065  print '<table class="noborder" width="100%">';
1066 
1067  $objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
1068 
1069  print '</table>';
1070  }
1071  }
1072  else
1073  {
1074  dol_fiche_head('');
1075 
1076  print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
1077  if (is_object($objectsrc))
1078  {
1079  print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1080  print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1081  } elseif ($origin == 'project' && !empty($projectid)) {
1082  print '<input type="hidden" name="projectid" value="' . $projectid . '">';
1083  }
1084  print '<table class="border" width="100%">';
1085  print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
1086  print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300');
1087  print '</td></tr>';
1088  print '</table>';
1089 
1090  dol_fiche_end();
1091 
1092  print '<div class="center">';
1093  print '<input type="hidden" name="action" value="create">';
1094  print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
1095  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1096  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1097  print '</div>';
1098 
1099  print '</form>';
1100  }
1101 }
1102 else if ($id > 0 || ! empty($ref))
1103 {
1104  /*
1105  * Affichage en mode visu
1106  */
1107 
1108  $object->fetch($id, $ref);
1109  $object->fetch_thirdparty();
1110 
1111  $soc=new Societe($db);
1112  $soc->fetch($object->socid);
1113 
1114  dol_htmloutput_mesg($mesg);
1115 
1116  $head = fichinter_prepare_head($object);
1117 
1118  dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, 'intervention');
1119 
1120  $formconfirm='';
1121 
1122  // Confirm deletion of intervention
1123  if ($action == 'delete')
1124  {
1125  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete','',0,1);
1126  }
1127 
1128  // Confirm validation
1129  if ($action == 'validate')
1130  {
1131  // on verifie si l'objet est en numerotation provisoire
1132  $ref = substr($object->ref, 1, 4);
1133  if ($ref == 'PROV')
1134  {
1135  $numref = $object->getNextNumRef($soc);
1136  if (empty($numref))
1137  {
1138  $error++;
1139  setEventMessages($object->error, $object->errors, 'errors');
1140  }
1141  }
1142  else
1143  {
1144  $numref = $object->ref;
1145  }
1146  $text=$langs->trans('ConfirmValidateIntervention',$numref);
1147 
1148  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',1,1);
1149  }
1150 
1151  // Confirm back to draft
1152  if ($action == 'modify')
1153  {
1154  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify','',0,1);
1155  }
1156 
1157  // Confirm deletion of line
1158  if ($action == 'ask_deleteline')
1159  {
1160  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1);
1161  }
1162 
1163  // Clone confirmation
1164  if ($action == 'clone') {
1165  // Create an array for form
1166  $formquestion = array(
1167  // 'text' => $langs->trans("ConfirmClone"),
1168  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
1169  // 1),
1170  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
1171  // => 1),
1172  array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '', '', 0, 0, null, 0, 'minwidth200')));
1173  // Paiement incomplet. On demande si motif = escompte ou autre
1174  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneIntervention'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
1175  }
1176 
1177  if (!$formconfirm)
1178  {
1179  $parameters=array('lineid'=>$lineid);
1180  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1181  if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
1182  elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
1183  }
1184 
1185  // Print form confirm
1186  print $formconfirm;
1187 
1188 
1189  // Intervention card
1190  $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
1191 
1192 
1193  $morehtmlref='<div class="refidno">';
1194  // Ref customer
1195  //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1);
1196  //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', null, null, '', 1);
1197  // Thirdparty
1198  $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
1199  // Project
1200  if (! empty($conf->projet->enabled))
1201  {
1202  $langs->load("projects");
1203  $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
1204  if ($user->rights->ficheinter->creer)
1205  {
1206  if ($action != 'classify')
1207  $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
1208  if ($action == 'classify') {
1209  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1210  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1211  $morehtmlref.='<input type="hidden" name="action" value="classin">';
1212  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1213  $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1214  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
1215  $morehtmlref.='</form>';
1216  } else {
1217  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1218  }
1219  } else {
1220  if (! empty($object->fk_project)) {
1221  $proj = new Project($db);
1222  $proj->fetch($object->fk_project);
1223  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
1224  $morehtmlref.=$proj->ref;
1225  $morehtmlref.='</a>';
1226  } else {
1227  $morehtmlref.='';
1228  }
1229  }
1230  }
1231  $morehtmlref.='</div>';
1232 
1233  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1234 
1235 
1236  print '<div class="fichecenter">';
1237  print '<div class="fichehalfleft">';
1238  print '<div class="underbanner clearboth"></div>';
1239 
1240  print '<table class="border" width="100%">';
1241 
1242  if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES))
1243  {
1244  // Date Start
1245  print '<tr><td class="titlefield">'.$langs->trans("Dateo").'</td>';
1246  print '<td>';
1247  print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;';
1248  print '</td>';
1249  print '</tr>';
1250 
1251  // Date End
1252  print '<tr><td>'.$langs->trans("Datee").'</td>';
1253  print '<td>';
1254  print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
1255  print '</td>';
1256  print '</tr>';
1257 
1258  // Date Terminate/close
1259  print '<tr><td>'.$langs->trans("Datet").'</td>';
1260  print '<td>';
1261  print $object->datet ? dol_print_date($object->datet, 'daytext') : '&nbsp;';
1262  print '</td>';
1263  print '</tr>';
1264  }
1265 
1266  // Description (must be a textarea and not html must be allowed (used in list view)
1267  print '<tr><td class="titlefield">';
1268  print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea');
1269  print '</td><td>';
1270  print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80');
1271  print '</td>';
1272  print '</tr>';
1273 
1274  // Contrat
1275  if ($conf->contrat->enabled)
1276  {
1277  $langs->load('contrat');
1278  print '<tr>';
1279  print '<td>';
1280 
1281  print '<table class="nobordernopadding" width="100%"><tr><td>';
1282  print $langs->trans('Contract');
1283  print '</td>';
1284  if ($action != 'contrat')
1285  {
1286  print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=contrat&amp;id='.$object->id.'">';
1287  print img_edit($langs->trans('SetContract'),1);
1288  print '</a></td>';
1289  }
1290  print '</tr></table>';
1291  print '</td><td>';
1292  if ($action == 'contrat')
1293  {
1294  $formcontract= new Formcontract($db);
1295  $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1);
1296  }
1297  else
1298  {
1299  if ($object->fk_contrat)
1300  {
1301  $contratstatic = new Contrat($db);
1302  $contratstatic->fetch($object->fk_contrat);
1303  //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
1304  print $contratstatic->getNomUrl(0,'',1);
1305  }
1306  else
1307  {
1308  print "&nbsp;";
1309  }
1310  }
1311  print '</td>';
1312  print '</tr>';
1313  }
1314 
1315  // Other attributes
1316  $cols = 2;
1317  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
1318 
1319  print '</table>';
1320 
1321  print '</div>';
1322  print '<div class="fichehalfright">';
1323  print '<div class="ficheaddleft">';
1324  print '<div class="underbanner clearboth"></div>';
1325 
1326  print '<table class="border centpercent">';
1327 
1328  if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
1329  {
1330  // Duration
1331  print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>';
1332  print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
1333  print '</tr>';
1334  }
1335 
1336  print "</table>";
1337 
1338  print '</div>';
1339  print '</div>';
1340  print '</div>';
1341 
1342  print '<div class="clearboth"></div><br>';
1343 
1344 
1345  if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
1346  {
1347  $blocname = 'contacts';
1348  $title = $langs->trans('ContactsAddresses');
1349  include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1350  }
1351 
1352  if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
1353  {
1354  $blocname = 'notes';
1355  $title = $langs->trans('Notes');
1356  include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1357  }
1358 
1359  // Line of interventions
1360  if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
1361  {
1362  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
1363  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1364  print '<input type="hidden" name="id" value="'.$object->id.'">';
1365  if ($action == 'editline')
1366  {
1367  print '<input type="hidden" name="action" value="updateline">';
1368  print '<input type="hidden" name="line_id" value="'.GETPOST('line_id','int').'">';
1369  }
1370  else
1371  {
1372  print '<input type="hidden" name="action" value="addline">';
1373  }
1374 
1375  // Intervention lines
1376  $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
1377  $sql.= ' ft.date as date_intervention';
1378  $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1379  $sql.= ' WHERE ft.fk_fichinter = '.$object->id;
1380  if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION))
1381  $sql.= ' AND ft.duree <> 0';
1382  $sql.= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
1383 
1384  $resql = $db->query($sql);
1385  if ($resql)
1386  {
1387  $num = $db->num_rows($resql);
1388  $i = 0;
1389 
1390  if ($num)
1391  {
1392  print '<br>';
1393  print '<table class="noborder" width="100%">';
1394 
1395  print '<tr class="liste_titre">';
1396  print '<td class="liste_titre">'.$langs->trans('Description').'</td>';
1397  print '<td class="liste_titre" align="center">'.$langs->trans('Date').'</td>';
1398  print '<td class="liste_titre" align="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').'</td>';
1399  print '<td class="liste_titre">&nbsp;</td>';
1400  print '<td class="liste_titre">&nbsp;</td>';
1401  print '<td class="liste_titre">&nbsp;</td>';
1402  print "</tr>\n";
1403  }
1404  while ($i < $num)
1405  {
1406  $objp = $db->fetch_object($resql);
1407 
1408 
1409  // Ligne en mode visu
1410  if ($action != 'editline' || GETPOST('line_id','int') != $objp->rowid)
1411  {
1412  print '<tr class="oddeven">';
1413  print '<td>';
1414  print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1415  print dol_htmlentitiesbr($objp->description);
1416 
1417  // Date
1418  print '<td align="center" width="150">'.(empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)?dol_print_date($db->jdate($objp->date_intervention),'dayhour'):dol_print_date($db->jdate($objp->date_intervention),'day')).'</td>';
1419 
1420  // Duration
1421  print '<td align="right" width="150">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertSecondToTime($objp->duree):'').'</td>';
1422 
1423  print "</td>\n";
1424 
1425 
1426  // Icone d'edition et suppression
1427  if ($object->statut == 0 && $user->rights->ficheinter->creer)
1428  {
1429  print '<td align="center">';
1430  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;line_id='.$objp->rowid.'#'.$objp->rowid.'">';
1431  print img_edit();
1432  print '</a>';
1433  print '</td>';
1434  print '<td align="center">';
1435  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=ask_deleteline&amp;line_id='.$objp->rowid.'">';
1436  print img_delete();
1437  print '</a></td>';
1438  print '<td align="center">';
1439  if ($num > 1)
1440  {
1441  if ($i > 0)
1442  {
1443  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=up&amp;line_id='.$objp->rowid.'">';
1444  print img_up();
1445  print '</a>';
1446  }
1447  if ($i < $num-1)
1448  {
1449  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=down&amp;line_id='.$objp->rowid.'">';
1450  print img_down();
1451  print '</a>';
1452  }
1453  }
1454  print '</td>';
1455  }
1456  else
1457  {
1458  print '<td colspan="3">&nbsp;</td>';
1459  }
1460 
1461  print '</tr>';
1462 
1463  $line = new FichinterLigne($db);
1464  $line->fetch($objp->rowid);
1465 
1466  $extrafieldsline = new ExtraFields($db);
1467  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
1468 
1469  $line->fetch_optionals();
1470 
1471  print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5));
1472  }
1473 
1474  // Line in update mode
1475  if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid)
1476  {
1477  print '<tr class="oddeven">';
1478  print '<td>';
1479  print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1480 
1481  // Editeur wysiwyg
1482  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1483  $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,'90%');
1484  $doleditor->Create();
1485  print '</td>';
1486 
1487  // Date d'intervention
1488  print '<td align="center" class="nowrap">';
1489  if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
1490  print $form->selectDate($db->jdate($objp->date_intervention),'di',0,0,0,"date_intervention");
1491  } else {
1492  print $form->selectDate($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention");
1493  }
1494  print '</td>';
1495 
1496  // Duration
1497  print '<td align="right">';
1498  if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
1499  $selectmode = 'select';
1500  if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION))
1501  $selectmode = 'text';
1502  $form->select_duration('duration', $objp->duree, 0, $selectmode);
1503  }
1504  print '</td>';
1505 
1506  print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
1507  print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
1508  print '</tr>' . "\n";
1509 
1510  $line = new FichinterLigne($db);
1511  $line->fetch($objp->rowid);
1512 
1513  $extrafieldsline = new ExtraFields($db);
1514  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
1515  $line->fetch_optionals();
1516 
1517  print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
1518  }
1519 
1520  $i++;
1521  }
1522 
1523  $db->free($resql);
1524 
1525  // Add new line
1526  if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS))
1527  {
1528  if (! $num)
1529  {
1530  print '<br><table class="noborder" width="100%">';
1531 
1532  print '<tr class="liste_titre">';
1533  print '<td>';
1534  print '<a name="add"></a>'; // ancre
1535  print $langs->trans('Description').'</td>';
1536  print '<td align="center">'.$langs->trans('Date').'</td>';
1537  print '<td align="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').'</td>';
1538  print '<td colspan="3">&nbsp;</td>';
1539  print "</tr>\n";
1540  }
1541 
1542  print '<tr class="oddeven">'."\n";
1543  print '<td>';
1544  // editeur wysiwyg
1545  if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) {
1546  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1547  $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%');
1548  $doleditor->Create();
1549  }
1550  print '</td>';
1551 
1552  // Date intervention
1553  print '<td align="center" class="nowrap">';
1554  $now=dol_now();
1555  $timearray=dol_getdate($now);
1556  if (! GETPOST('diday','int')) {
1557  $timewithnohour=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']);
1558  } else {
1559  $timewithnohour=dol_mktime(GETPOST('dihour','int'),GETPOST('dimin','int'), 0,GETPOST('dimonth','int'),GETPOST('diday','int'),GETPOST('diyear','int'));
1560  }
1561  if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) {
1562  print $form->selectDate($timewithnohour,'di',0,0,0,"addinter");
1563  } else {
1564  print $form->selectDate($timewithnohour,'di',1,1,0,"addinter");
1565  }
1566  print '</td>';
1567 
1568  // Duration
1569  print '<td align="right">';
1570  if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
1571  $selectmode = 'select';
1572  if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION)) {
1573  $selectmode = 'text';
1574  }
1575  $form->select_duration('duration', (!GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) ? 3600 : (60 * 60 * GETPOST('durationhour', 'int') + 60 * GETPOST('durationmin', 'int')), 0, $selectmode);
1576  }
1577  print '</td>';
1578 
1579  print '<td align="center" valign="middle" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
1580  print '</tr>';
1581 
1582  //Line extrafield
1583 
1584  $lineadd = new FichinterLigne($db);
1585 
1586  $extrafieldsline = new ExtraFields($db);
1587  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element);
1588 
1589  print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
1590 
1591  if (! $num) print '</table>';
1592  }
1593 
1594  if ($num) print '</table>';
1595  }
1596  else
1597  {
1598  dol_print_error($db);
1599  }
1600 
1601  print '</form>'."\n";
1602  }
1603 
1604  dol_fiche_end();
1605 
1606  print "\n";
1607 
1608 
1609  /*
1610  * Actions buttons
1611  */
1612 
1613  print '<div class="tabsAction">';
1614 
1615  $parameters = array();
1616  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1617  // modified by hook
1618  if (empty($reshook))
1619  {
1620  if ($user->societe_id == 0)
1621  {
1622  if ($action != 'editdescription' && ($action != 'presend')) {
1623  // Validate
1624  if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
1625  if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->validate)) {
1626  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&action=validate"';
1627  print '>' . $langs->trans("Validate") . '</a></div>';
1628  }
1629  }
1630 
1631  // Modify
1632  if ($object->statut == Fichinter::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->creer) || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->rights->ficheinter->ficheinter_advance->unvalidate)))
1633  {
1634  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
1635  if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
1636  else print $langs->trans("SetToDraft");
1637  print '</a></div>';
1638  }
1639 
1640  // Send
1641  if ($object->statut > Fichinter::STATUS_DRAFT)
1642  {
1643  if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
1644  {
1645  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendMail').'</a></div>';
1646  }
1647  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendMail').'</a></div>';
1648  }
1649 
1650  // create intervention model
1651  if ($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer && (count($object->lines) > 0)) {
1652  print '<div class="inline-block divButAction">';
1653  // This feature is not yet implemented
1654  //print '<a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card-rec.php?id='.$object->id.'&action=create">'.$langs->trans("ChangeIntoRepeatableIntervention").'</a>';
1655  print '<a class="butAction" title="'.$langs->trans("ChangeIntoRepeatableIntervention").'" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">'.$langs->trans("not yet implemented").'</a>';
1656  print '</div>';
1657  }
1658 
1659  // Proposal
1660  if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
1661  {
1662  $langs->load("propal");
1663  if ($object->statut < Fichinter::STATUS_BILLED)
1664  {
1665  if ($user->rights->propal->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/propal/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddProp").'</a></div>';
1666  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
1667  }
1668  }
1669 
1670  // Invoicing
1671  if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
1672  {
1673  $langs->load("bills");
1674  if ($object->statut < Fichinter::STATUS_BILLED)
1675  {
1676  if ($user->rights->facture->creer) print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a></div>';
1677  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>';
1678  }
1679 
1680  if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
1681  {
1682  if ($object->statut != Fichinter::STATUS_BILLED)
1683  {
1684  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
1685  }
1686  else
1687  {
1688  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyunbilled">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
1689  }
1690  }
1691  }
1692 
1693  // Done
1694  if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
1695  {
1696  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>';
1697  }
1698 
1699  // Clone
1700  if ($user->rights->ficheinter->creer) {
1701  print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&amp;socid=' . $object->socid . '&amp;action=clone&amp;object=ficheinter">' . $langs->trans("ToClone") . '</a></div>';
1702  }
1703 
1704  // Delete
1705  if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
1706  {
1707  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
1708  print '>'.$langs->trans('Delete').'</a></div>';
1709  }
1710  }
1711  }
1712  }
1713 
1714  print '</div>';
1715 
1716  if ($action != 'presend')
1717  {
1718  print '<div class="fichecenter"><div class="fichehalfleft">';
1719 
1720  /*
1721  * Built documents
1722  */
1723  $filename=dol_sanitizeFileName($object->ref);
1724  $filedir=$conf->ficheinter->dir_output . "/".$filename;
1725  $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
1726  $genallowed=$user->rights->ficheinter->lire;
1727  $delallowed=$user->rights->ficheinter->creer;
1728  print $formfile->showdocuments('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
1729 
1730  // Show links to link elements
1731  $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter'));
1732  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1733 
1734 
1735  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
1736 
1737  // List of actions on element
1738  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1739  $formactions=new FormActions($db);
1740  $somethingshown = $formactions->showactions($object,'fichinter',$socid,1);
1741 
1742  print '</div></div></div>';
1743  }
1744 
1745 
1746  // Select mail models is same action as presend
1747  if (GETPOST('modelselected')) {
1748  $action = 'presend';
1749  }
1750 
1751  // Presend form
1752  $modelmail='fichinter_send';
1753  $defaulttopic='SendInterventionRef';
1754  $diroutput = $conf->ficheinter->dir_output;
1755  $trackid = 'int'.$object->id;
1756 
1757  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1758 }
1759 
1760 
1761 llxFooter();
1762 
1763 $db->close();
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition: date.lib.php:180
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1053
Class to manage building of HTML components.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action=='set') else if($action=='specimen') else if($action=='setmodel') else if($action=='del') else if($action=='setdoc') $formactions
View.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
img_up($titlealt='default', $selected=0, $moreclass='')
Show top arrow logo.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
Show logo editer/modifier fiche.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Class to manage products or services.
Class to manage interventions.
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.
fichinter_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF.
Class to manage contracts.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for properties) With native = 0: P...
const STATUS_DRAFT
Draft status.
const TYPE_SERVICE
Service.
fichinter_prepare_head($object)
Prepare array with list of tabs.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
const TYPE_PRODUCT
Regular product.
const STATUS_VALIDATED
Validated status.
convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
Convert hours and minutes into seconds.
Definition: date.lib.php:153
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
img_down($titlealt='default', $selected=0, $moreclass='')
Show down arrow logo.
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage projects.
if(! function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
Class to manage building of HTML components.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
Class to manage translations.
dol_now($mode='gmt')
Return date for now.
const STATUS_CLOSED
Closed.
if($_POST["cancel"]==$langs->trans("Cancel") &&! $id) if($action=='add' && $_POST["cancel"]<> $langs->trans("Cancel")) if($action=='delete') if($id) $form
Actions.
Definition: card.php:153
Class to offer components to list and upload files.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage generation of HTML components for contract module.
Classe permettant la gestion des lignes d&#39;intervention.
const STATUS_BILLED
Billed.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Class to manage a WYSIWYG editor.
dol_getdate($timestamp, $fast=false)
Return an array with locale date info.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
$parameters
Actions.
Definition: card.php:114
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).