dolibarr  7.0.0-beta
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-2015 Regis Houssin <regis.houssin@capnetworks.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-2015 Charlie Benke <charlies@patas-monkey.com>
9  * Copyright (C) 2015-2016 Abbes Bahfir <bafbes@gmail.com>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 
31 require '../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/core/modules/fichinter/modules_fichinter.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/fichinter.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
37 if (! empty($conf->projet->enabled))
38 {
39  require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
40  require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
41 }
42 if ($conf->contrat->enabled)
43 {
44  require_once DOL_DOCUMENT_ROOT."/core/class/html.formcontract.class.php";
45  require_once DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php";
46 }
47 if (! empty($conf->global->FICHEINTER_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.".php"))
48 {
49  require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/mod_".$conf->global->FICHEINTER_ADDON.'.php';
50 }
51 require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
52 require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
53 
54 $langs->load("bills");
55 $langs->load("companies");
56 $langs->load("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($extralabels);
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 
386  }
387  else
388  {
389  $mesg=$srcobject->error;
390  $error++;
391  }
392  }
393  else
394  {
395  $mesg=$object->error;
396  $error++;
397  }
398  }
399  else
400  {
401  // Fill array 'array_options' with data from add form
402  $ret = $extrafields->setOptionalsFromPost($extralabels, $object);
403  if ($ret < 0) {
404  $error ++;
405  $action = 'create';
406  }
407 
408  if (! $error)
409  {
410  // Extrafields
411  $extralabels = $extrafields->fetch_name_optionals_label($object->table_element);
412  $array_options = $extrafields->getOptionalsFromPost($extralabels);
413 
414  $object->array_options = $array_options;
415 
416  $result = $object->create($user);
417  if ($result > 0)
418  {
419  $id=$result; // Force raffraichissement sur fiche venant d'etre cree
420  }
421  else
422  {
423  $langs->load("errors");
424  setEventMessages($object->error, $object->errors, 'errors');
425  $action = 'create';
426  }
427  }
428  }
429  }
430  else
431  {
432  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("ThirdParty")).'</div>';
433  $action = 'create';
434  }
435  }
436 
437  else if ($action == 'update' && $user->rights->ficheinter->creer)
438  {
439  $object->socid = $socid;
440  $object->fk_project = GETPOST('projectid','int');
441  $object->fk_contrat = GETPOST('contratid','int');
442  $object->author = $user->id;
443  $object->description = GETPOST('description','alpha');
444  $object->ref = $ref;
445 
446  $result=$object->update($user);
447  if ($result<0) {
448  setEventMessages($object->error, $object->errors, 'errors');
449  }
450  }
451 
452  // Set into a project
453  else if ($action == 'classin' && $user->rights->ficheinter->creer)
454  {
455  $result=$object->setProject(GETPOST('projectid','int'));
456  if ($result < 0) dol_print_error($db,$object->error);
457  }
458 
459  // Set into a contract
460  else if ($action == 'setcontract' && $user->rights->contrat->creer)
461  {
462  $result=$object->set_contrat($user,GETPOST('contratid','int'));
463  if ($result < 0) dol_print_error($db,$object->error);
464  }
465 
466  else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
467  {
468  $result=$object->delete($user);
469  if ($result<0) {
470  setEventMessages($object->error, $object->errors, 'errors');
471  }
472 
473  header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');
474  exit;
475  }
476 
477  else if ($action == 'setdescription' && $user->rights->ficheinter->creer)
478  {
479  $result=$object->set_description($user,GETPOST('description'));
480  if ($result < 0) dol_print_error($db,$object->error);
481  }
482 
483  // Add line
484  else if ($action == "addline" && $user->rights->ficheinter->creer)
485  {
486  if (!GETPOST('np_desc','none') && empty($conf->global->FICHINTER_EMPTY_LINE_DESC) )
487  {
488  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Description")).'</div>';
489  $error++;
490  }
491  if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && !GETPOST('durationhour','int') && !GETPOST('durationmin','int'))
492  {
493  $mesg='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Duration")).'</div>';
494  $error++;
495  }
496  if (empty($conf->global->FICHINTER_WITHOUT_DURATION) && GETPOST('durationhour','int') >= 24 && GETPOST('durationmin','int') > 0)
497  {
498  $mesg='<div class="error">'.$langs->trans("ErrorValueTooHigh").'</div>';
499  $error++;
500  }
501  if (! $error)
502  {
503  $db->begin();
504 
505  $desc=GETPOST('np_desc','none');
506  $date_intervention = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
507  $duration = empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertTime2Seconds(GETPOST('durationhour','int'), GETPOST('durationmin','int')) : 0;
508 
509 
510  // Extrafields
511  $extrafieldsline = new ExtraFields($db);
512  $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
513  $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
514 
515  $result=$object->addline(
516  $user,
517  $id,
518  $desc,
519  $date_intervention,
520  $duration,
521  $array_options
522  );
523 
524  // Define output language
525  $outputlangs = $langs;
526  $newlang='';
527  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
528  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
529  if (! empty($newlang))
530  {
531  $outputlangs = new Translate("",$conf);
532  $outputlangs->setDefaultLang($newlang);
533  }
534 
535  if ($result >= 0)
536  {
537  $db->commit();
538 
539  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
540  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
541  exit;
542  }
543  else
544  {
545  $mesg=$object->error;
546  $db->rollback();
547  }
548  }
549  }
550 
551  // Classify Billed
552  else if ($action == 'classifybilled' && $user->rights->ficheinter->creer)
553  {
554  $result=$object->setStatut(2);
555  if ($result > 0)
556  {
557  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
558  exit;
559  }
560  else
561  {
562  setEventMessages($object->error, $object->errors, 'errors');
563  }
564  }
565 
566  // Classify unbilled
567  else if ($action == 'classifyunbilled' && $user->rights->ficheinter->creer)
568  {
569  $result=$object->setStatut(1);
570  if ($result > 0)
571  {
572  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
573  exit;
574  }
575  else
576  {
577  $mesg='<div class="error">'.$object->error.'</div>';
578  }
579  }
580 
581  // Classify Done
582  else if ($action == 'classifydone' && $user->rights->ficheinter->creer)
583  {
584  $result=$object->setStatut(3);
585  if ($result > 0)
586  {
587  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
588  exit;
589  }
590  else
591  {
592  setEventMessages($object->error, $object->errors, 'errors');
593  }
594  }
595 
596  /*
597  * Mise a jour d'une ligne d'intervention
598  */
599  else if ($action == 'updateline' && $user->rights->ficheinter->creer && GETPOST('save','alpha') == $langs->trans("Save"))
600  {
601  $objectline = new FichinterLigne($db);
602  if ($objectline->fetch($lineid) <= 0)
603  {
604  dol_print_error($db);
605  exit;
606  }
607 
608  if ($object->fetch($objectline->fk_fichinter) <= 0)
609  {
610  dol_print_error($db);
611  exit;
612  }
613  $object->fetch_thirdparty();
614 
615  $desc = GETPOST('np_desc');
616  $date_inter = dol_mktime(GETPOST('dihour','int'), GETPOST('dimin','int'), 0, GETPOST('dimonth','int'), GETPOST('diday','int'), GETPOST('diyear','int'));
617  $duration = convertTime2Seconds(GETPOST('durationhour','int'),GETPOST('durationmin','int'));
618 
619  $objectline->datei = $date_inter;
620  $objectline->desc = $desc;
621  $objectline->duration = $duration;
622 
623  // Extrafields
624  $extrafieldsline = new ExtraFields($db);
625  $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
626  $array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
627  $objectline->array_options = $array_options;
628 
629  $result = $objectline->update($user);
630  if ($result < 0)
631  {
632  dol_print_error($db);
633  exit;
634  }
635 
636  // Define output language
637  $outputlangs = $langs;
638  $newlang='';
639  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
640  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
641  if (! empty($newlang))
642  {
643  $outputlangs = new Translate("",$conf);
644  $outputlangs->setDefaultLang($newlang);
645  }
646  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
647 
648  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
649  exit;
650  }
651 
652  /*
653  * Supprime une ligne d'intervention AVEC confirmation
654  */
655  else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->ficheinter->creer)
656  {
657  $objectline = new FichinterLigne($db);
658  if ($objectline->fetch($lineid) <= 0)
659  {
660  dol_print_error($db);
661  exit;
662  }
663  $result=$objectline->deleteline($user);
664 
665  if ($object->fetch($objectline->fk_fichinter) <= 0)
666  {
667  dol_print_error($db);
668  exit;
669  }
670 
671  // Define output language
672  $outputlangs = $langs;
673  $newlang='';
674  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
675  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
676  if (! empty($newlang))
677  {
678  $outputlangs = new Translate("",$conf);
679  $outputlangs->setDefaultLang($newlang);
680  }
681  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
682  }
683 
684  /*
685  * Ordonnancement des lignes
686  */
687 
688  else if ($action == 'up' && $user->rights->ficheinter->creer)
689  {
690  $object->line_up($lineid);
691 
692  // Define output language
693  $outputlangs = $langs;
694  $newlang='';
695  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
696  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
697  if (! empty($newlang))
698  {
699  $outputlangs = new Translate("",$conf);
700  $outputlangs->setDefaultLang($newlang);
701  }
702  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
703 
704  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
705  exit;
706  }
707 
708  else if ($action == 'down' && $user->rights->ficheinter->creer)
709  {
710  $object->line_down($lineid);
711 
712  // Define output language
713  $outputlangs = $langs;
714  $newlang='';
715  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','aZ09')) $newlang=GETPOST('lang_id','aZ09');
716  if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
717  if (! empty($newlang))
718  {
719  $outputlangs = new Translate("",$conf);
720  $outputlangs->setDefaultLang($newlang);
721  }
722  if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) fichinter_create($db, $object, $object->modelpdf, $outputlangs);
723 
724  header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.'#'.$lineid);
725  exit;
726  }
727 
728  // Actions when printing a doc from card
729  include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
730 
731  // Actions to send emails
732  $trigger_name='FICHINTER_SENTBYMAIL';
733  $autocopy='MAIN_MAIL_AUTOCOPY_FICHINTER_TO';
734  $trackid='int'.$object->id;
735  include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php';
736 
737  // Actions to build doc
738  $upload_dir = $conf->ficheinter->dir_output;
739  $permissioncreate = $user->rights->ficheinter->creer;
740  include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
741 
742  if ($action == 'update_extras')
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'));
747  if ($ret < 0) $error++;
748 
749  if (! $error)
750  {
751  // Actions on extra fields (by external module or standard code)
752  // TODO le hook fait double emploi avec le trigger !!
753  $hookmanager->initHooks(array('interventiondao'));
754  $parameters=array('id'=>$object->id);
755  $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
756  if (empty($reshook))
757  {
758  $result=$object->insertExtraFields();
759  if ($result < 0)
760  {
761  $error++;
762  }
763  }
764  else if ($reshook < 0) $error++;
765  }
766 
767  if ($error) $action = 'edit_extras';
768  }
769 
770  if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->ficheinter->creer)
771  {
772  if ($action == 'addcontact')
773  {
774  if ($result > 0 && $id > 0)
775  {
776  $contactid = (GETPOST('userid','int') ? GETPOST('userid','int') : GETPOST('contactid','int'));
777  $result = $object->add_contact($contactid, GETPOST('type','int'), GETPOST('source','alpha'));
778  }
779 
780  if ($result >= 0)
781  {
782  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
783  exit;
784  }
785  else
786  {
787  if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
788  {
789  $langs->load("errors");
790  $mesg = '<div class="error">'.$langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType").'</div>';
791  }
792  else
793  {
794  $mesg = '<div class="error">'.$object->error.'</div>';
795  }
796  }
797  }
798 
799  // bascule du statut d'un contact
800  else if ($action == 'swapstatut')
801  {
802  $result=$object->swapContactStatus(GETPOST('ligne','int'));
803  }
804 
805  // Efface un contact
806  else if ($action == 'deletecontact')
807  {
808  $result = $object->delete_contact(GETPOST('lineid','int'));
809 
810  if ($result >= 0)
811  {
812  header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
813  exit;
814  }
815  else {
816  dol_print_error($db);
817  }
818  }
819  }
820 }
821 
822 
823 /*
824  * View
825  */
826 
827 $form = new Form($db);
828 $formfile = new FormFile($db);
829 if ($conf->contrat->enabled) $formcontract = new FormContract($db);
830 if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
831 
832 llxHeader('',$langs->trans("Intervention"));
833 
834 if ($action == 'create')
835 {
836  /*
837  * Mode creation
838  * Creation d'une nouvelle fiche d'intervention
839  */
840 
841  $soc=new Societe($db);
842 
843  print load_fiche_titre($langs->trans("AddIntervention"), '', 'title_commercial');
844 
845  dol_htmloutput_mesg($mesg);
846 
847  if ($socid) $res=$soc->fetch($socid);
848 
849  if (GETPOST('origin') && GETPOST('originid'))
850  {
851  // Parse element/subelement (ex: project_task)
852  $element = $subelement = GETPOST('origin');
853  if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs))
854  {
855  $element = $regs[1];
856  $subelement = $regs[2];
857  }
858 
859  if ($element == 'project')
860  {
861  $projectid=GETPOST('originid');
862  }
863  else
864  {
865  // For compatibility
866  if ($element == 'order' || $element == 'commande') {
867  $element = $subelement = 'commande';
868  }
869  if ($element == 'propal') {
870  $element = 'comm/propal'; $subelement = 'propal';
871  }
872  if ($element == 'contract') {
873  $element = $subelement = 'contrat';
874  }
875 
876  dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
877 
878  $classname = ucfirst($subelement);
879  $objectsrc = new $classname($db);
880  $objectsrc->fetch(GETPOST('originid'));
881  if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines'))
882  {
883  $objectsrc->fetch_lines();
884  $lines = $objectsrc->lines;
885  }
886  $objectsrc->fetch_thirdparty();
887 
888  $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:'');
889 
890  $soc = $objectsrc->thirdparty;
891 
892  $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : GETPOST('note_private','none')));
893  $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : GETPOST('note_public','none'));
894 
895  // Object source contacts list
896  $srccontactslist = $objectsrc->liste_contact(-1,'external',1);
897  }
898  }
899  else {
900  $projectid = GETPOST('projectid','int');
901  }
902 
903  if (! $conf->global->FICHEINTER_ADDON)
904  {
905  dol_print_error($db,$langs->trans("Error")." ".$langs->trans("Error_FICHEINTER_ADDON_NotDefined"));
906  exit;
907  }
908 
909  $object->date = dol_now();
910 
911  $obj = $conf->global->FICHEINTER_ADDON;
912  $obj = "mod_".$obj;
913 
914  //$modFicheinter = new $obj;
915  //$numpr = $modFicheinter->getNextValue($soc, $object);
916 
917  if ($socid > 0)
918  {
919  $soc=new Societe($db);
920  $soc->fetch($socid);
921 
922  print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
923  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
924 
925  dol_fiche_head('');
926 
927  print '<table class="border" width="100%">';
928 
929  print '<input type="hidden" name="socid" value='.$soc->id.'>';
930  print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("ThirdParty").'</td><td>'.$soc->getNomUrl(1).'</td></tr>';
931 
932  print '<input type="hidden" name="action" value="add">';
933 
934  // Ref
935  print '<tr><td class="fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans("Draft").'</td></tr>';
936 
937  // Description (must be a textarea and not html must be allowed (used in list view)
938  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td>';
939  print '<td>';
940  print '<textarea name="description" class="quatrevingtpercent" rows="'.ROWS_3.'">'.GETPOST('description').'</textarea>';
941  print '</td></tr>';
942 
943  // Project
944  if (! empty($conf->projet->enabled))
945  {
946  $formproject=new FormProjets($db);
947 
948  $langs->load("project");
949 
950  print '<tr><td>'.$langs->trans("Project").'</td><td>';
951  /* 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
952  if ($societe->fournisseur==1)
953  $numprojet=select_projects(-1,$_POST["projectid"],'projectid');
954  else
955  $numprojet=select_projects($societe->id,$_POST["projectid"],'projectid');
956  */
957  $numprojet=$formproject->select_projects($soc->id,$projectid,'projectid');
958  if ($numprojet==0)
959  {
960  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
961  }
962  print '</td></tr>';
963  }
964 
965  // Contract
966  if ($conf->contrat->enabled)
967  {
968  $langs->load("contracts");
969  print '<tr><td>'.$langs->trans("Contract").'</td><td>';
970  $numcontrat=$formcontract->select_contract($soc->id,GETPOST('contratid','int'),'contratid',0,1);
971  if ($numcontrat==0)
972  {
973  print ' &nbsp; <a href="'.DOL_URL_ROOT.'/contrat/card.php?socid='.$soc->id.'&action=create">'.$langs->trans("AddContract").'</a>';
974  }
975  print '</td></tr>';
976  }
977 
978  // Model
979  print '<tr>';
980  print '<td>'.$langs->trans("DefaultModel").'</td>';
981  print '<td colspan="2">';
983  print $form->selectarray('model',$liste,$conf->global->FICHEINTER_ADDON_PDF);
984  print "</td></tr>";
985 
986  // Public note
987  print '<tr>';
988  print '<td tdtop">'.$langs->trans('NotePublic').'</td>';
989  print '<td colspan="2">';
990  $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
991  print $doleditor->Create(1);
992  //print '<textarea name="note_public" cols="80" rows="'.ROWS_3.'">'.$note_public.'</textarea>';
993  print '</td></tr>';
994 
995  // Private note
996  if (empty($user->societe_id))
997  {
998  print '<tr>';
999  print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
1000  print '<td colspan="2">';
1001  $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
1002  print $doleditor->Create(1);
1003  //print '<textarea name="note_private" cols="80" rows="'.ROWS_3.'">'.$note_private.'</textarea>';
1004  print '</td></tr>';
1005  }
1006 
1007  // Other attributes
1008  $parameters=array('colspan' => ' colspan="2"');
1009  $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
1010  print $hookmanager->resPrint;
1011  if (empty($reshook) && ! empty($extrafields->attribute_label))
1012  {
1013  print $object->showOptionals($extrafields,'edit');
1014  }
1015 
1016  // Show link to origin object
1017  if (! empty($origin) && ! empty($originid) && is_object($objectsrc))
1018  {
1019  $newclassname=$classname;
1020  if ($newclassname=='Propal') $newclassname='CommercialProposal';
1021  print '<tr><td>'.$langs->trans($newclassname).'</td><td colspan="2">'.$objectsrc->getNomUrl(1).'</td></tr>';
1022 
1023  // Amount
1024  /* Hide amount because we only copy services so amount may differ than source
1025  print '<tr><td>' . $langs->trans('TotalHT') . '</td><td>' . price($objectsrc->total_ht) . '</td></tr>';
1026  print '<tr><td>' . $langs->trans('TotalVAT') . '</td><td>' . price($objectsrc->total_tva) . "</td></tr>";
1027  if ($mysoc->localtax1_assuj == "1" || $objectsrc->total_localtax1 != 0) // Localtax1 RE
1028  {
1029  print '<tr><td>' . $langs->transcountry("AmountLT1", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax1) . "</td></tr>";
1030  }
1031 
1032  if ($mysoc->localtax2_assuj == "1" || $objectsrc->total_localtax2 != 0) // Localtax2 IRPF
1033  {
1034  print '<tr><td>' . $langs->transcountry("AmountLT2", $mysoc->country_code) . '</td><td>' . price($objectsrc->total_localtax2) . "</td></tr>";
1035  }
1036 
1037  print '<tr><td>' . $langs->trans('TotalTTC') . '</td><td>' . price($objectsrc->total_ttc) . "</td></tr>";
1038 
1039  if (!empty($conf->multicurrency->enabled))
1040  {
1041  print '<tr><td>' . $langs->trans('MulticurrencyTotalHT') . '</td><td>' . price($objectsrc->multicurrency_total_ht) . '</td></tr>';
1042  print '<tr><td>' . $langs->trans('MulticurrencyTotalVAT') . '</td><td>' . price($objectsrc->multicurrency_total_tva) . "</td></tr>";
1043  print '<tr><td>' . $langs->trans('MulticurrencyTotalTTC') . '</td><td>' . price($objectsrc->multicurrency_total_ttc) . "</td></tr>";
1044  }
1045  */
1046  }
1047 
1048  print '</table>';
1049 
1050  if (is_object($objectsrc))
1051  {
1052  print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1053  print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1054  } elseif ($origin == 'project' && !empty($projectid)) {
1055  print '<input type="hidden" name="projectid" value="' . $projectid . '">';
1056  }
1057 
1058  dol_fiche_end();
1059 
1060  print '<div class="center">';
1061  print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
1062  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1063  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1064  print '</div>';
1065 
1066  print '</form>';
1067 
1068  // Show origin lines
1069  if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) {
1070  $title = $langs->trans('Services');
1072 
1073  print '<table class="noborder" width="100%">';
1074 
1075  $objectsrc->printOriginLinesList(empty($conf->global->FICHINTER_PRINT_PRODUCTS)?'services':''); // Show only service, except if option FICHINTER_PRINT_PRODUCTS is on
1076 
1077  print '</table>';
1078  }
1079  }
1080  else
1081  {
1082  dol_fiche_head('');
1083 
1084  print '<form name="fichinter" action="'.$_SERVER['PHP_SELF'].'" method="POST">';
1085  if (is_object($objectsrc))
1086  {
1087  print '<input type="hidden" name="origin" value="'.$objectsrc->element.'">';
1088  print '<input type="hidden" name="originid" value="'.$objectsrc->id.'">';
1089  } elseif ($origin == 'project' && !empty($projectid)) {
1090  print '<input type="hidden" name="projectid" value="' . $projectid . '">';
1091  }
1092  print '<table class="border" width="100%">';
1093  print '<tr><td class="fieldrequired">'.$langs->trans("ThirdParty").'</td><td>';
1094  print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, null, 0, 'minwidth300');
1095  print '</td></tr>';
1096  print '</table>';
1097 
1098  dol_fiche_end();
1099 
1100  print '<div class="center">';
1101  print '<input type="hidden" name="action" value="create">';
1102  print '<input type="submit" class="button" value="'.$langs->trans("CreateDraftIntervention").'">';
1103  print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
1104  print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
1105  print '</div>';
1106 
1107  print '</form>';
1108  }
1109 
1110 }
1111 else if ($id > 0 || ! empty($ref))
1112 {
1113  /*
1114  * Affichage en mode visu
1115  */
1116 
1117  $object->fetch($id, $ref);
1118  $object->fetch_thirdparty();
1119 
1120  $soc=new Societe($db);
1121  $soc->fetch($object->socid);
1122 
1123  dol_htmloutput_mesg($mesg);
1124 
1125  $head = fichinter_prepare_head($object);
1126 
1127  dol_fiche_head($head, 'card', $langs->trans("InterventionCard"), -1, 'intervention');
1128 
1129  $formconfirm='';
1130 
1131  // Confirm deletion of intervention
1132  if ($action == 'delete')
1133  {
1134  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteIntervention'), $langs->trans('ConfirmDeleteIntervention'), 'confirm_delete','',0,1);
1135  }
1136 
1137  // Confirm validation
1138  if ($action == 'validate')
1139  {
1140  // on verifie si l'objet est en numerotation provisoire
1141  $ref = substr($object->ref, 1, 4);
1142  if ($ref == 'PROV')
1143  {
1144  $numref = $object->getNextNumRef($soc);
1145  if (empty($numref))
1146  {
1147  $error++;
1148  setEventMessages($object->error, $object->errors, 'errors');
1149  }
1150  }
1151  else
1152  {
1153  $numref = $object->ref;
1154  }
1155  $text=$langs->trans('ConfirmValidateIntervention',$numref);
1156 
1157  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateIntervention'), $text, 'confirm_validate','',1,1);
1158  }
1159 
1160  // Confirm back to draft
1161  if ($action == 'modify')
1162  {
1163  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ModifyIntervention'), $langs->trans('ConfirmModifyIntervention'), 'confirm_modify','',0,1);
1164  }
1165 
1166  // Confirm deletion of line
1167  if ($action == 'ask_deleteline')
1168  {
1169  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&line_id='.$lineid, $langs->trans('DeleteInterventionLine'), $langs->trans('ConfirmDeleteInterventionLine'), 'confirm_deleteline','',0,1);
1170  }
1171 
1172  // Clone confirmation
1173  if ($action == 'clone') {
1174  // Create an array for form
1175  $formquestion = array(
1176  // 'text' => $langs->trans("ConfirmClone"),
1177  // array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' =>
1178  // 1),
1179  // array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value'
1180  // => 1),
1181  array('type' => 'other','name' => 'socid','label' => $langs->trans("SelectThirdParty"),'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '', '', 0, 0, null, 0, 'minwidth200')));
1182  // Paiement incomplet. On demande si motif = escompte ou autre
1183  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('CloneIntervention'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
1184  }
1185 
1186  if (!$formconfirm)
1187  {
1188  $parameters=array('lineid'=>$lineid);
1189  $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
1190  if (empty($reshook)) $formconfirm.=$hookmanager->resPrint;
1191  elseif ($reshook > 0) $formconfirm=$hookmanager->resPrint;
1192  }
1193 
1194  // Print form confirm
1195  print $formconfirm;
1196 
1197 
1198  // Intervention card
1199  $linkback = '<a href="'.DOL_URL_ROOT.'/fichinter/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
1200 
1201 
1202  $morehtmlref='<div class="refidno">';
1203  // Ref customer
1204  //$morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', 0, 1);
1205  //$morehtmlref.=$form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $user->rights->fichinter->creer, 'string', '', null, null, '', 1);
1206  // Thirdparty
1207  $morehtmlref.=$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
1208  // Project
1209  if (! empty($conf->projet->enabled))
1210  {
1211  $langs->load("projects");
1212  $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
1213  if ($user->rights->ficheinter->creer)
1214  {
1215  if ($action != 'classify')
1216  $morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
1217  if ($action == 'classify') {
1218  //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
1219  $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
1220  $morehtmlref.='<input type="hidden" name="action" value="classin">';
1221  $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1222  $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
1223  $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
1224  $morehtmlref.='</form>';
1225  } else {
1226  $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
1227  }
1228  } else {
1229  if (! empty($object->fk_project)) {
1230  $proj = new Project($db);
1231  $proj->fetch($object->fk_project);
1232  $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
1233  $morehtmlref.=$proj->ref;
1234  $morehtmlref.='</a>';
1235  } else {
1236  $morehtmlref.='';
1237  }
1238  }
1239  }
1240  $morehtmlref.='</div>';
1241 
1242  dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
1243 
1244 
1245  print '<div class="fichecenter">';
1246  print '<div class="fichehalfleft">';
1247  print '<div class="underbanner clearboth"></div>';
1248 
1249  print '<table class="border" width="100%">';
1250 
1251  if (! empty($conf->global->FICHINTER_USE_PLANNED_AND_DONE_DATES))
1252  {
1253  // Date Start
1254  print '<tr><td class="titlefield">'.$langs->trans("Dateo").'</td>';
1255  print '<td>';
1256  print $object->dateo ? dol_print_date($object->dateo, 'daytext') : '&nbsp;';
1257  print '</td>';
1258  print '</tr>';
1259 
1260  // Date End
1261  print '<tr><td>'.$langs->trans("Datee").'</td>';
1262  print '<td>';
1263  print $object->datee ? dol_print_date($object->datee, 'daytext') : '&nbsp;';
1264  print '</td>';
1265  print '</tr>';
1266 
1267  // Date Terminate/close
1268  print '<tr><td>'.$langs->trans("Datet").'</td>';
1269  print '<td>';
1270  print $object->datet ? dol_print_date($object->datet, 'daytext') : '&nbsp;';
1271  print '</td>';
1272  print '</tr>';
1273  }
1274 
1275  // Description (must be a textarea and not html must be allowed (used in list view)
1276  print '<tr><td class="titlefield">';
1277  print $form->editfieldkey("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea');
1278  print '</td><td>';
1279  print $form->editfieldval("Description",'description',$object->description,$object,$user->rights->ficheinter->creer,'textarea:8:80');
1280  print '</td>';
1281  print '</tr>';
1282 
1283  // Contrat
1284  if ($conf->contrat->enabled)
1285  {
1286  $langs->load('contrat');
1287  print '<tr>';
1288  print '<td>';
1289 
1290  print '<table class="nobordernopadding" width="100%"><tr><td>';
1291  print $langs->trans('Contract');
1292  print '</td>';
1293  if ($action != 'contrat')
1294  {
1295  print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=contrat&amp;id='.$object->id.'">';
1296  print img_edit($langs->trans('SetContract'),1);
1297  print '</a></td>';
1298  }
1299  print '</tr></table>';
1300  print '</td><td>';
1301  if ($action == 'contrat')
1302  {
1303  $formcontract= new Formcontract($db);
1304  $formcontract->formSelectContract($_SERVER["PHP_SELF"].'?id='.$object->id, $object->socid, $object->fk_contrat, 'contratid', 0, 1);
1305  }
1306  else
1307  {
1308  if ($object->fk_contrat)
1309  {
1310  $contratstatic = new Contrat($db);
1311  $contratstatic->fetch($object->fk_contrat);
1312  //print '<a href="'.DOL_URL_ROOT.'/projet/card.php?id='.$selected.'">'.$projet->title.'</a>';
1313  print $contratstatic->getNomUrl(0,'',1);
1314  }
1315  else
1316  {
1317  print "&nbsp;";
1318  }
1319  }
1320  print '</td>';
1321  print '</tr>';
1322  }
1323 
1324  // Other attributes
1325  $cols = 2;
1326  include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
1327 
1328  print '</table>';
1329 
1330  print '</div>';
1331  print '<div class="fichehalfright">';
1332  print '<div class="ficheaddleft">';
1333  print '<div class="underbanner clearboth"></div>';
1334 
1335  print '<table class="border centpercent">';
1336 
1337  if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
1338  {
1339  // Duration
1340  print '<tr><td class="titlefield">'.$langs->trans("TotalDuration").'</td>';
1341  print '<td>'.convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY).'</td>';
1342  print '</tr>';
1343  }
1344 
1345  print "</table>";
1346 
1347  print '</div>';
1348  print '</div>';
1349  print '</div>';
1350 
1351  print '<div class="clearboth"></div><br>';
1352 
1353 
1354  if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
1355  {
1356  $blocname = 'contacts';
1357  $title = $langs->trans('ContactsAddresses');
1358  include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1359  }
1360 
1361  if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB))
1362  {
1363  $blocname = 'notes';
1364  $title = $langs->trans('Notes');
1365  include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
1366  }
1367 
1368  // Line of interventions
1369  if (empty($conf->global->FICHINTER_DISABLE_DETAILS))
1370  {
1371  print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'" name="addinter" method="post">';
1372  print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
1373  print '<input type="hidden" name="id" value="'.$object->id.'">';
1374  if ($action == 'editline')
1375  {
1376  print '<input type="hidden" name="action" value="updateline">';
1377  print '<input type="hidden" name="line_id" value="'.GETPOST('line_id','int').'">';
1378  }
1379  else
1380  {
1381  print '<input type="hidden" name="action" value="addline">';
1382  }
1383 
1384  // Intervention lines
1385  $sql = 'SELECT ft.rowid, ft.description, ft.fk_fichinter, ft.duree, ft.rang,';
1386  $sql.= ' ft.date as date_intervention';
1387  $sql.= ' FROM '.MAIN_DB_PREFIX.'fichinterdet as ft';
1388  $sql.= ' WHERE ft.fk_fichinter = '.$object->id;
1389  if (!empty($conf->global->FICHINTER_HIDE_EMPTY_DURATION))
1390  $sql.= ' AND ft.duree <> 0';
1391  $sql.= ' ORDER BY ft.rang ASC, ft.date ASC, ft.rowid';
1392 
1393  $resql = $db->query($sql);
1394  if ($resql)
1395  {
1396  $num = $db->num_rows($resql);
1397  $i = 0;
1398 
1399  if ($num)
1400  {
1401  print '<br>';
1402  print '<table class="noborder" width="100%">';
1403 
1404  print '<tr class="liste_titre">';
1405  print '<td class="liste_titre">'.$langs->trans('Description').'</td>';
1406  print '<td class="liste_titre" align="center">'.$langs->trans('Date').'</td>';
1407  print '<td class="liste_titre" align="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').'</td>';
1408  print '<td class="liste_titre">&nbsp;</td>';
1409  print '<td class="liste_titre">&nbsp;</td>';
1410  print '<td class="liste_titre">&nbsp;</td>';
1411  print "</tr>\n";
1412  }
1413  $var=true;
1414  while ($i < $num)
1415  {
1416  $objp = $db->fetch_object($resql);
1417 
1418 
1419  // Ligne en mode visu
1420  if ($action != 'editline' || GETPOST('line_id','int') != $objp->rowid)
1421  {
1422  print '<tr class="oddeven">';
1423  print '<td>';
1424  print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1425  print dol_htmlentitiesbr($objp->description);
1426 
1427  // Date
1428  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>';
1429 
1430  // Duration
1431  print '<td align="right" width="150">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?convertSecondToTime($objp->duree):'').'</td>';
1432 
1433  print "</td>\n";
1434 
1435 
1436  // Icone d'edition et suppression
1437  if ($object->statut == 0 && $user->rights->ficheinter->creer)
1438  {
1439  print '<td align="center">';
1440  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=editline&amp;line_id='.$objp->rowid.'#'.$objp->rowid.'">';
1441  print img_edit();
1442  print '</a>';
1443  print '</td>';
1444  print '<td align="center">';
1445  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=ask_deleteline&amp;line_id='.$objp->rowid.'">';
1446  print img_delete();
1447  print '</a></td>';
1448  print '<td align="center">';
1449  if ($num > 1)
1450  {
1451  if ($i > 0)
1452  {
1453  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=up&amp;line_id='.$objp->rowid.'">';
1454  print img_up();
1455  print '</a>';
1456  }
1457  if ($i < $num-1)
1458  {
1459  print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=down&amp;line_id='.$objp->rowid.'">';
1460  print img_down();
1461  print '</a>';
1462  }
1463  }
1464  print '</td>';
1465  }
1466  else
1467  {
1468  print '<td colspan="3">&nbsp;</td>';
1469  }
1470 
1471  print '</tr>';
1472 
1473  $line = new FichinterLigne($db);
1474  $line->fetch($objp->rowid);
1475 
1476  $extrafieldsline = new ExtraFields($db);
1477  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
1478 
1479  $line->fetch_optionals($line->rowid, $extralabelslines);
1480 
1481  print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>5));
1482 
1483 
1484  }
1485 
1486  // Line in update mode
1487  if ($object->statut == 0 && $action == 'editline' && $user->rights->ficheinter->creer && GETPOST('line_id','int') == $objp->rowid)
1488  {
1489  print '<tr class="oddeven">';
1490  print '<td>';
1491  print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
1492 
1493  // Editeur wysiwyg
1494  require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1495  $doleditor=new DolEditor('np_desc',$objp->description,'',164,'dolibarr_details','',false,true,$conf->global->FCKEDITOR_ENABLE_DETAILS,ROWS_2,'90%');
1496  $doleditor->Create();
1497  print '</td>';
1498 
1499  // Date d'intervention
1500  print '<td align="center" class="nowrap">';
1501  if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) $form->select_date($db->jdate($objp->date_intervention),'di',0,0,0,"date_intervention");
1502  else $form->select_date($db->jdate($objp->date_intervention),'di',1,1,0,"date_intervention");
1503  print '</td>';
1504 
1505  // Duration
1506  print '<td align="right">';
1507  if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
1508  $selectmode = 'select';
1509  if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION))
1510  $selectmode = 'text';
1511  $form->select_duration('duration', $objp->duree, 0, $selectmode);
1512  }
1513  print '</td>';
1514 
1515  print '<td align="center" colspan="5" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
1516  print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
1517  print '</tr>' . "\n";
1518 
1519  $line = new FichinterLigne($db);
1520  $line->fetch($objp->rowid);
1521 
1522  $extrafieldsline = new ExtraFields($db);
1523  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($line->table_element);
1524  $line->fetch_optionals($line->rowid, $extralabelslines);
1525 
1526  print $line->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
1527 
1528 
1529  }
1530 
1531  $i++;
1532  }
1533 
1534  $db->free($resql);
1535 
1536  // Add new line
1537  if ($object->statut == 0 && $user->rights->ficheinter->creer && $action <> 'editline' && empty($conf->global->FICHINTER_DISABLE_DETAILS))
1538  {
1539  if (! $num)
1540  {
1541  print '<br><table class="noborder" width="100%">';
1542 
1543  print '<tr class="liste_titre">';
1544  print '<td>';
1545  print '<a name="add"></a>'; // ancre
1546  print $langs->trans('Description').'</td>';
1547  print '<td align="center">'.$langs->trans('Date').'</td>';
1548  print '<td align="right">'.(empty($conf->global->FICHINTER_WITHOUT_DURATION)?$langs->trans('Duration'):'').'</td>';
1549  print '<td colspan="3">&nbsp;</td>';
1550  print "</tr>\n";
1551  }
1552 
1553  print '<tr class="oddeven">'."\n";
1554  print '<td>';
1555  // editeur wysiwyg
1556  if (empty($conf->global->FICHINTER_EMPTY_LINE_DESC)) {
1557  require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1558  $doleditor = new DolEditor('np_desc', GETPOST('np_desc', 'alpha'), '', 100, 'dolibarr_details', '', false, true, $conf->global->FCKEDITOR_ENABLE_DETAILS, ROWS_2, '90%');
1559  $doleditor->Create();
1560  }
1561  print '</td>';
1562 
1563  // Date intervention
1564  print '<td align="center" class="nowrap">';
1565  $now=dol_now();
1566  $timearray=dol_getdate($now);
1567  if (! GETPOST('diday','int')) $timewithnohour=dol_mktime(0,0,0,$timearray['mon'],$timearray['mday'],$timearray['year']);
1568  else $timewithnohour=dol_mktime(GETPOST('dihour','int'),GETPOST('dimin','int'), 0,GETPOST('dimonth','int'),GETPOST('diday','int'),GETPOST('diyear','int'));
1569  if (!empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) $form->select_date($timewithnohour,'di',0,0,0,"addinter");
1570  else $form->select_date($timewithnohour,'di',1,1,0,"addinter");
1571  print '</td>';
1572 
1573  // Duration
1574  print '<td align="right">';
1575  if (empty($conf->global->FICHINTER_WITHOUT_DURATION)) {
1576  $selectmode = 'select';
1577  if (!empty($conf->global->INTERVENTION_ADDLINE_FREEDUREATION))
1578  $selectmode = 'text';
1579  $form->select_duration('duration', (!GETPOST('durationhour', 'int') && !GETPOST('durationmin', 'int')) ? 3600 : (60 * 60 * GETPOST('durationhour', 'int') + 60 * GETPOST('durationmin', 'int')), 0, $selectmode);
1580  }
1581  print '</td>';
1582 
1583  print '<td align="center" valign="middle" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addline"></td>';
1584  print '</tr>';
1585 
1586  //Line extrafield
1587 
1588  $lineadd = new FichinterLigne($db);
1589 
1590  $extrafieldsline = new ExtraFields($db);
1591  $extralabelslines=$extrafieldsline->fetch_name_optionals_label($lineadd->table_element);
1592 
1593  print $lineadd->showOptionals($extrafieldsline, 'edit', array('style'=>$bc[$var], 'colspan'=>5));
1594 
1595  if (! $num) print '</table>';
1596  }
1597 
1598  if ($num) print '</table>';
1599  }
1600  else
1601  {
1602  dol_print_error($db);
1603  }
1604 
1605  print '</form>'."\n";
1606  }
1607 
1608  dol_fiche_end();
1609 
1610  print "\n";
1611 
1612 
1613  /*
1614  * Actions buttons
1615  */
1616 
1617  print '<div class="tabsAction">';
1618 
1619  $parameters = array();
1620  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
1621  // modified by hook
1622  if (empty($reshook))
1623  {
1624  if ($user->societe_id == 0)
1625  {
1626  if ($action != 'editdescription' && ($action != 'presend')) {
1627  // Validate
1628  if ($object->statut == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || !empty($conf->global->FICHINTER_DISABLE_DETAILS))) {
1629  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)) {
1630  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id=' . $object->id . '&action=validate"';
1631  print '>' . $langs->trans("Validate") . '</a></div>';
1632  }
1633  }
1634 
1635  // Modify
1636  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)))
1637  {
1638  print '<div class="inline-block divButAction"><a class="butAction" href="card.php?id='.$object->id.'&action=modify">';
1639  if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) print $langs->trans("Modify");
1640  else print $langs->trans("SetToDraft");
1641  print '</a></div>';
1642  }
1643 
1644  // Send
1645  if ($object->statut > Fichinter::STATUS_DRAFT)
1646  {
1647  if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->ficheinter->ficheinter_advance->send)
1648  {
1649  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init#formmailbeforetitle">'.$langs->trans('SendByMail').'</a></div>';
1650  }
1651  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans('SendByMail').'</a></div>';
1652  }
1653 
1654  // Proposal
1655  if ($conf->service->enabled && ! empty($conf->propal->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
1656  {
1657  $langs->load("propal");
1658  if ($object->statut < Fichinter::STATUS_BILLED)
1659  {
1660  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>';
1661  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddProp").'</a></div>';
1662  }
1663  }
1664 
1665  // Invoicing
1666  if (! empty($conf->facture->enabled) && $object->statut > Fichinter::STATUS_DRAFT)
1667  {
1668  $langs->load("bills");
1669  if ($object->statut < Fichinter::STATUS_BILLED)
1670  {
1671  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>';
1672  else print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="'.$langs->trans("NotEnoughPermissions").'">'.$langs->trans("AddBill").'</a></div>';
1673  }
1674 
1675  if (! empty($conf->global->FICHINTER_CLASSIFY_BILLED)) // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1
1676  {
1677  if ($object->statut != Fichinter::STATUS_BILLED)
1678  {
1679  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifybilled">'.$langs->trans("InterventionClassifyBilled").'</a></div>';
1680  }
1681  else
1682  {
1683  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifyunbilled">'.$langs->trans("InterventionClassifyUnBilled").'</a></div>';
1684  }
1685  }
1686  }
1687 
1688  // Done
1689  if (empty($conf->global->FICHINTER_CLASSIFY_BILLED) && $object->statut > Fichinter::STATUS_DRAFT && $object->statut < Fichinter::STATUS_CLOSED)
1690  {
1691  print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=classifydone">'.$langs->trans("InterventionClassifyDone").'</a></div>';
1692  }
1693 
1694  // Clone
1695  if ($user->rights->ficheinter->creer) {
1696  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>';
1697  }
1698 
1699  // Delete
1700  if (($object->statut == Fichinter::STATUS_DRAFT && $user->rights->ficheinter->creer) || $user->rights->ficheinter->supprimer)
1701  {
1702  print '<div class="inline-block divButAction"><a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete"';
1703  print '>'.$langs->trans('Delete').'</a></div>';
1704  }
1705 
1706  }
1707  }
1708  }
1709 
1710  print '</div>';
1711 
1712  if ($action != 'presend')
1713  {
1714  print '<div class="fichecenter"><div class="fichehalfleft">';
1715 
1716  /*
1717  * Built documents
1718  */
1719  $filename=dol_sanitizeFileName($object->ref);
1720  $filedir=$conf->ficheinter->dir_output . "/".$filename;
1721  $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id;
1722  $genallowed=$user->rights->ficheinter->lire;
1723  $delallowed=$user->rights->ficheinter->creer;
1724  print $formfile->showdocuments('ficheinter',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'','','',$soc->default_lang);
1725 
1726  // Show links to link elements
1727  $linktoelem = $form->showLinkToObjectBlock($object, null, array('fichinter'));
1728  $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
1729 
1730 
1731  print '</div><div class="fichehalfright"><div class="ficheaddleft">';
1732 
1733  // List of actions on element
1734  include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
1735  $formactions=new FormActions($db);
1736  $somethingshown = $formactions->showactions($object,'fichinter',$socid,1);
1737 
1738  print '</div></div></div>';
1739  }
1740 
1741 
1742  // Select mail models is same action as presend
1743  if (GETPOST('modelselected')) {
1744  $action = 'presend';
1745  }
1746 
1747  // Presend form
1748  $modelmail='fichinter_send';
1749  $defaulttopic='SendInterventionRef';
1750  $diroutput = $conf->ficheinter->dir_output;
1751  $trackid = 'int'.$object->id;
1752 
1753  include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
1754 }
1755 
1756 
1757 llxFooter();
1758 
1759 $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:171
llxFooter()
Empty footer.
Definition: wrapper.php:58
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
Class to manage building of HTML components.
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...
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
static liste_modeles($db, $maxfilenamelength=0)
Return list of active generation modules.
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.
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.
if(empty($reshook)) $form
View.
Definition: perms.php:103
const STATUS_VALIDATED
Validated status.
dol_htmloutput_mesg($mesgstring='', $mesgarray='', $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
convertTime2Seconds($iHours=0, $iMinutes=0, $iSeconds=0)
Convert hours and minutes into seconds.
Definition: date.lib.php:153
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
img_up($titlealt= 'default', $selected=0, $moreclass='')
Show top arrow logo.
Class to manage building of HTML components.
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
Class to manage translations.
dol_now($mode='gmt')
Return date for now.
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
const STATUS_CLOSED
Closed.
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.
print
Draft customers invoices.
Definition: index.php:91
Classe permettant la gestion des lignes d'intervention.
const STATUS_BILLED
Billed.
if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg)) if($action== 'set') else if($action== 'specimen') else if($action== 'setmodel') else if($action== 'del') else if($action== 'setdoc' $formactions)
View.
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:1013
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Return a prefix to use for this Dolibarr instance, for session/cookie names or email id...
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.
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $objcanvas=null)
Check permissions of a user to show a page and an object.
$parameters
Actions.
Definition: card.php:112