dolibarr  9.0.0
doc_generic_project_odt.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2013 Florian Henry <florian.henry@ope-concept.pro>
5  * Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
6  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  * or see http://www.gnu.org/
21  */
22 
29 require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
30 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/lib/doc.lib.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
40 if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
41 if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
42 if (! empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
43 if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
44 if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45 if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
46 if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
47 if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
48 if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
49 if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
50 
51 
56 {
61  public $emetteur;
62 
67  public $phpmin = array(5, 4);
68 
73  public $version = 'dolibarr';
74 
75 
81  function __construct($db)
82  {
83  global $conf, $langs, $mysoc;
84 
85  // Load traductions files requiredby by page
86  $langs->loadLangs(array("companies", "main"));
87 
88  $this->db = $db;
89  $this->name = "ODT templates";
90  $this->description = $langs->trans("DocumentModelOdt");
91  $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
92 
93  // Dimension page pour format A4
94  $this->type = 'odt';
95  $this->page_largeur = 0;
96  $this->page_hauteur = 0;
97  $this->format = array($this->page_largeur,$this->page_hauteur);
98  $this->marge_gauche=0;
99  $this->marge_droite=0;
100  $this->marge_haute=0;
101  $this->marge_basse=0;
102 
103  $this->option_logo = 1; // Affiche logo
104  $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
105  $this->option_modereg = 0; // Affiche mode reglement
106  $this->option_condreg = 0; // Affiche conditions reglement
107  $this->option_codeproduitservice = 0; // Affiche code produit-service
108  $this->option_multilang = 1; // Dispo en plusieurs langues
109  $this->option_escompte = 0; // Affiche si il y a eu escompte
110  $this->option_credit_note = 0; // Support credit notes
111  $this->option_freetext = 1; // Support add of a personalised text
112  $this->option_draft_watermark = 0; // Support add of a watermark on drafts
113 
114  // Recupere emetteur
115  $this->emetteur=$mysoc;
116  if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'etait pas defini
117  }
118 
119 
120  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
129  function get_substitutionarray_object($object,$outputlangs,$array_key='object')
130  {
131  // phpcs:enable
132  global $conf;
133 
134  $resarray=array(
135  $array_key.'_id'=>$object->id,
136  $array_key.'_ref'=>$object->ref,
137  $array_key.'_title'=>$object->title,
138  $array_key.'_description'=>$object->description,
139  $array_key.'_date_creation'=>dol_print_date($object->date_c,'day'),
140  $array_key.'_date_modification'=>dol_print_date($object->date_m,'day'),
141  $array_key.'_date_start'=>dol_print_date($object->date_start,'day'),
142  $array_key.'_date_end'=>dol_print_date($object->date_end,'day'),
143  $array_key.'_note_private'=>$object->note_private,
144  $array_key.'_note_public'=>$object->note_public,
145  $array_key.'_public'=>$object->public,
146  $array_key.'_statut'=>$object->getLibStatut()
147  );
148 
149  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
150  $extrafields = new ExtraFields($this->db);
151  $extralabels = $extrafields->fetch_name_optionals_label($object->table_element,true);
152  $object->fetch_optionals();
153 
154  $resarray = $this->fill_substitutionarray_with_extrafields($object,$resarray,$extrafields,$array_key,$outputlangs);
155 
156  return $resarray;
157  }
158 
159  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
167  function get_substitutionarray_tasks($task,$outputlangs)
168  {
169  // phpcs:enable
170  global $conf;
171 
172  $resarray = array(
173  'task_ref'=>$task->ref,
174  'task_fk_project'=>$task->fk_project,
175  'task_projectref'=>$task->projectref,
176  'task_projectlabel'=>$task->projectlabel,
177  'task_label'=>$task->label,
178  'task_description'=>$task->description,
179  'task_fk_parent'=>$task->fk_parent,
180  'task_duration'=>$task->duration,
181  'task_duration_hour'=>convertSecondToTime($task->duration,'all'),
182  'task_progress'=>$task->progress,
183  'task_public'=>$task->public,
184  'task_date_start'=>dol_print_date($task->date_start,'day'),
185  'task_date_end'=>dol_print_date($task->date_end,'day'),
186  'task_note_private'=>$task->note_private,
187  'task_note_public'=>$task->note_public
188  );
189 
190  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
191  $extrafields = new ExtraFields($this->db);
192  $extralabels = $extrafields->fetch_name_optionals_label($task->table_element,true);
193  $task->fetch_optionals($task->id,$extralabels);
194 
195  $resarray = $this->fill_substitutionarray_with_extrafields($task,$resarray,$extrafields,'task',$outputlangs);
196 
197  return $resarray;
198  }
199 
200  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
208  function get_substitutionarray_project_contacts($contact,$outputlangs)
209  {
210  // phpcs:enable
211  global $conf;
212  $pc='projcontacts_'; // prefix to avoid typos
213 
214  $ret = array(
215  $pc.'id'=>$contact['id'],
216  $pc.'rowid'=>$contact['rowid'],
217  $pc.'role'=>$contact['libelle'],
218  $pc.'lastname'=>$contact['lastname'],
219  $pc.'firstname'=>$contact['firstname'],
220  $pc.'civility'=>$contact['civility'],
221  $pc.'fullcivname'=>$contact['fullname'],
222  $pc.'socname'=>$contact['socname'],
223  $pc.'email'=>$contact['email']
224  );
225 
226  if ($contact['source']=='external') {
227  $ret[$pc.'isInternal'] = ''; // not internal
228 
229  $ct = new Contact($this->db);
230  $ct->fetch($contact['id']);
231  $ret[$pc.'phone_pro'] = $ct->phone_pro;
232  $ret[$pc.'phone_perso'] = $ct->phone_perso;
233  $ret[$pc.'phone_mobile'] = $ct->phone_mobile;
234 
235  // fetch external user extrafields
236  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
237  $extrafields=new ExtraFields($this->db);
238  $extralabels=$extrafields->fetch_name_optionals_label($ct->table_element, true);
239  $extrafields_num = $ct->fetch_optionals();
240  //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
241  foreach($ct->array_options as $efkey => $efval) {
242  dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
243  $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
244  }
245  } elseif ($contact['source']=='internal') {
246  $ret[$pc.'isInternal'] = '1'; // this is an internal user
247 
248  $ct = new User($this->db);
249  $ct->fetch($contact['id']);
250  $ret[$pc.'phone_pro'] = $ct->office_phone;
251  $ret[$pc.'phone_perso'] = '';
252  $ret[$pc.'phone_mobile'] = $ct->user_mobile;
253  // do internal users have extrafields ?
254  }
255  return $ret;
256  }
257 
258  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
266  function get_substitutionarray_project_file($file,$outputlangs)
267  {
268  // phpcs:enable
269  global $conf;
270 
271  return array(
272  'projfile_name'=>$file['name'],
273  'projfile_date'=>dol_print_date($file['date'],'day'),
274  'projfile_size'=>$file['size']
275  );
276  }
277 
278  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
286  function get_substitutionarray_project_reference($refdetail,$outputlangs)
287  {
288  // phpcs:enable
289  global $conf;
290 
291  return array(
292  'projref_type'=>$refdetail['type'],
293  'projref_ref'=>$refdetail['ref'],
294  'projref_date'=>dol_print_date($refdetail['date'],'day'),
295  'projref_socname'=>$refdetail['socname'],
296  'projref_amountht'=>price($refdetail['amountht'],0,$outputlangs),
297  'projref_amountttc'=>price($refdetail['amountttc'],0,$outputlangs),
298  'projref_status'=>$refdetail['status']
299  );
300  }
301 
302  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
310  function get_substitutionarray_tasksressource($taskressource,$outputlangs)
311  {
312  // phpcs:enable
313  global $conf;
314  //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
315  return array(
316  'taskressource_rowid'=>$taskressource['rowid'],
317  'taskressource_role'=>$taskressource['libelle'],
318  'taskressource_lastname'=>$taskressource['lastname'],
319  'taskressource_firstname'=>$taskressource['firstname'],
320  'taskressource_fullcivname'=>$taskressource['fullname'],
321  'taskressource_socname'=>$taskressource['socname'],
322  'taskressource_email'=>$taskressource['email']
323  );
324  }
325 
326  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
334  function get_substitutionarray_taskstime($tasktime,$outputlangs)
335  {
336  // phpcs:enable
337  global $conf;
338 
339  return array(
340  'tasktime_rowid'=>$tasktime['rowid'],
341  'tasktime_task_date'=>dol_print_date($tasktime['task_date'],'day'),
342  'tasktime_task_duration_sec'=>$tasktime['task_duration'],
343  'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'],'all'),
344  'tasktime_note'=>$tasktime['note'],
345  'tasktime_fk_user'=>$tasktime['fk_user'],
346  'tasktime_user_name'=>$tasktime['name'],
347  'tasktime_user_first'=>$tasktime['firstname'],
348  'tasktime_fullcivname'=>$tasktime['fullcivname'],
349  'tasktime_amountht'=>$tasktime['amountht'],
350  'tasktime_amountttc'=>$tasktime['amountttc'],
351  'tasktime_thm'=>$tasktime['thm'],
352  );
353  }
354 
355  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
363  function get_substitutionarray_task_file($file,$outputlangs)
364  {
365  // phpcs:enable
366  global $conf;
367 
368  return array(
369  'tasksfile_name'=>$file['name'],
370  'tasksfile_date'=>dol_print_date($file['date'],'day'),
371  'tasksfile_size'=>$file['size']
372  );
373  }
374 
375 
382  function info($langs)
383  {
384  global $conf,$langs;
385 
386  // Load translation files required by the page
387  $langs->loadLangs(array("companies","errors"));
388 
389  $form = new Form($this->db);
390 
391  $texte = $this->description.".<br>\n";
392  $texte.= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
393  $texte.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
394  $texte.= '<input type="hidden" name="action" value="setModuleOptions">';
395  $texte.= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
396  $texte.= '<table class="nobordernopadding" width="100%">';
397 
398  // List of directories area
399  $texte.= '<tr><td>';
400  $texttitle=$langs->trans("ListOfDirectories");
401  $listofdir=explode(',',preg_replace('/[\r\n]+/',',',trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
402  $listoffiles=array();
403  foreach($listofdir as $key=>$tmpdir)
404  {
405  $tmpdir=trim($tmpdir);
406  $tmpdir=preg_replace('/DOL_DATA_ROOT/',DOL_DATA_ROOT,$tmpdir);
407  if (! $tmpdir) {
408  unset($listofdir[$key]); continue;
409  }
410  if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0);
411  else
412  {
413  $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)');
414  if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles);
415  }
416  }
417  $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT");
418  // Add list of substitution keys
419  $texthelp.='<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
420  $texthelp.=$langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
421 
422  $texte.= $form->textwithpicto($texttitle,$texthelp,1,'help','',1);
423  $texte.= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
424  $texte.= '<textarea class="flat" cols="60" name="value1">';
425  $texte.=$conf->global->PROJECT_ADDON_PDF_ODT_PATH;
426  $texte.= '</textarea>';
427  $texte.= '</div><div style="display: inline-block; vertical-align: middle;">';
428  $texte.= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
429  $texte.= '<br></div></div>';
430 
431  // Scan directories
432  $nbofiles=count($listoffiles);
433  if (! empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
434  {
435  $texte.=$langs->trans("NumberOfModelFilesFound").': <b>';
436  //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
437  $texte.=$nbofiles;
438  //$texte.=$nbofiles?'</a>':'';
439  $texte.='</b>';
440  }
441 
442  if ($nbofiles)
443  {
444  $texte.='<div id="div_'.get_class($this).'" class="hidden">';
445  foreach($listoffiles as $file)
446  {
447  $texte.=$file['name'].'<br>';
448  }
449  $texte.='<div id="div_'.get_class($this).'">';
450  }
451 
452  $texte.= '</td>';
453 
454  $texte.= '<td valign="top" rowspan="2" class="hideonsmartphone">';
455  $texte.= $langs->trans("ExampleOfDirectoriesForModelGen");
456  $texte.= '</td>';
457  $texte.= '</tr>';
458 
459  $texte.= '</table>';
460  $texte.= '</form>';
461 
462  return $texte;
463  }
464 
465  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
474  function write_file($object,$outputlangs,$srctemplatepath)
475  {
476  // phpcs:enable
477  global $user,$langs,$conf,$mysoc,$hookmanager;
478 
479  if (empty($srctemplatepath))
480  {
481  dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
482  return -1;
483  }
484 
485  // Add odtgeneration hook
486  if (! is_object($hookmanager))
487  {
488  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
489  $hookmanager=new HookManager($this->db);
490  }
491  $hookmanager->initHooks(array('odtgeneration'));
492  global $action;
493 
494  if (! is_object($outputlangs)) $outputlangs=$langs;
495  $sav_charset_output=$outputlangs->charset_output;
496  $outputlangs->charset_output='UTF-8';
497 
498  // Load translation files required by the page
499  $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
500 
501  if ($conf->projet->dir_output)
502  {
503  // If $object is id instead of object
504  if (! is_object($object))
505  {
506  $id = $object;
507  $object = new Project($this->db);
508  $result=$object->fetch($id);
509  if ($result < 0)
510  {
511  dol_print_error($this->db,$object->error);
512  return -1;
513  }
514  }
515 
516  $dir = $conf->projet->dir_output;
517  $objectref = dol_sanitizeFileName($object->ref);
518  if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref;
519  $file = $dir . "/" . $objectref . ".odt";
520 
521  if (! file_exists($dir))
522  {
523  if (dol_mkdir($dir) < 0)
524  {
525  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
526  return -1;
527  }
528  }
529 
530  if (file_exists($dir))
531  {
532  //print "srctemplatepath=".$srctemplatepath; // Src filename
533  $newfile=basename($srctemplatepath);
534  $newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
535  $newfiletmp=preg_replace('/template_/i','',$newfiletmp);
536  $newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
537  $newfiletmp=$objectref.'_'.$newfiletmp;
538  //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
539  // Get extension (ods or odt)
540  $newfileformat=substr($newfile, strrpos($newfile, '.')+1);
541  if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
542  {
543  $format=$conf->global->MAIN_DOC_USE_TIMING;
544  if ($format == '1') $format='%Y%m%d%H%M%S';
545  $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat;
546  }
547  else
548  {
549  $filename=$newfiletmp.'.'.$newfileformat;
550  }
551  $file=$dir.'/'.$filename;
552  //print "newdir=".$dir;
553  //print "newfile=".$newfile;
554  //print "file=".$file;
555  //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
556 
557  dol_mkdir($conf->projet->dir_temp);
558 
559  // If PROJECTLEADER contact defined on project, we use it
560  $usecontact=false;
561  $arrayidcontact=$object->getIdContact('external','PROJECTLEADER');
562  if (count($arrayidcontact) > 0)
563  {
564  $usecontact=true;
565  $result=$object->fetch_contact($arrayidcontact[0]);
566  }
567 
568  // Recipient name
569  $contactobject=null;
570  if (! empty($usecontact))
571  {
572  // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
573  $contactobject = $object->contact;
574  }
575 
576  $socobject=$object->thirdparty;
577 
578  // Make substitution
579  $substitutionarray=array(
580  '__FROM_NAME__' => $this->emetteur->name,
581  '__FROM_EMAIL__' => $this->emetteur->email,
582  );
583  complete_substitutions_array($substitutionarray, $langs, $object);
584  // Call the ODTSubstitution hook
585  $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
586  $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
587 
588  // Open and load template
589  require_once ODTPHP_PATH.'odf.php';
590  try {
591  $odfHandler = new odf(
592  $srctemplatepath,
593  array(
594  'PATH_TO_TMP' => $conf->projet->dir_temp,
595  'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
596  'DELIMITER_LEFT' => '{',
597  'DELIMITER_RIGHT' => '}'
598  )
599  );
600  } catch (Exception $e) {
601  $this->error=$e->getMessage();
602  dol_syslog($e->getMessage(), LOG_INFO);
603  return -1;
604  }
605  // After construction $odfHandler->contentXml contains content and
606  // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
607  // [!-- BEGIN lines --]*[!-- END lines --]
608  //print html_entity_decode($odfHandler->__toString());
609  //print exit;
610 
611 
612  // Define substitution array
613  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
614  $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
615  $array_objet=$this->get_substitutionarray_object($object,$outputlangs);
616  $array_user=$this->get_substitutionarray_user($user,$outputlangs);
617  $array_soc=$this->get_substitutionarray_mysoc($mysoc,$outputlangs);
618  $array_thirdparty=$this->get_substitutionarray_thirdparty($socobject,$outputlangs);
619  $array_other=$this->get_substitutionarray_other($outputlangs);
620  // retrieve contact information for use in object as contact_xxx tags
621  $array_project_contact = array();
622  if ($usecontact && is_object($contactobject)) $array_project_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact');
623 
624  $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_project_contact);
625  complete_substitutions_array($tmparray, $outputlangs, $object);
626 
627  // Call the ODTSubstitution hook
628  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
629  $reshook=$hookmanager->executeHooks('ODTSubstitution',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
630 
631  foreach($tmparray as $key=>$value)
632  {
633  try {
634  if (preg_match('/logo$/',$key)) // Image
635  {
636  if (file_exists($value)) $odfHandler->setImage($key, $value);
637  else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
638  }
639  else // Text
640  {
641  $odfHandler->setVars($key, $value, true, 'UTF-8');
642  }
643  }
644  catch (OdfException $e)
645  {
646  dol_syslog($e->getMessage(), LOG_INFO);
647  }
648  }
649 
650  // Replace tags of lines for tasks
651  try
652  {
653  $listlines = $odfHandler->setSegment('tasks');
654 
655  $taskstatic = new Task($this->db);
656 
657  // Security check
658  $socid=0;
659  if (!empty($object->fk_soc)) $socid = $object->fk_soc;
660 
661  $tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
662 
663 
664  foreach ($tasksarray as $task)
665  {
666  $tmparray=$this->get_substitutionarray_tasks($task,$outputlangs);
667  //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
668  foreach($tmparray as $key => $val)
669  {
670  try
671  {
672  $listlines->setVars($key, $val, true, 'UTF-8');
673  }
674  catch(OdfException $e)
675  {
676  dol_syslog($e->getMessage(), LOG_INFO);
677  }
678  catch(SegmentException $e)
679  {
680  dol_syslog($e->getMessage(), LOG_INFO);
681  }
682  }
683 
684  $taskobj=new Task($this->db);
685  $taskobj->fetch($task->id);
686 
687  // Replace tags of lines for contacts task
688  $sourcearray=array('internal','external');
689  $contact_arrray=array();
690  foreach ($sourcearray as $source) {
691  $contact_temp=$taskobj->liste_contact(-1,$source);
692  if ((is_array($contact_temp) && count($contact_temp) > 0))
693  {
694  $contact_arrray=array_merge($contact_arrray,$contact_temp);
695  }
696  }
697  if ((is_array($contact_arrray) && count($contact_arrray) > 0))
698  {
699  $listlinestaskres = $listlines->__get('tasksressources');
700 
701  foreach ($contact_arrray as $contact)
702  {
703  if ($contact['source']=='internal') {
704  $objectdetail=new User($this->db);
705  $objectdetail->fetch($contact['id']);
706  $contact['socname']=$mysoc->name;
707  } elseif ($contact['source']=='external') {
708  $objectdetail=new Contact($this->db);
709  $objectdetail->fetch($contact['id']);
710 
711  $soc=new Societe($this->db);
712  $soc->fetch($contact['socid']);
713  $contact['socname']=$soc->name;
714  }
715  $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
716 
717  $tmparray=$this->get_substitutionarray_tasksressource($contact,$outputlangs);
718 
719  foreach($tmparray as $key => $val)
720  {
721  try
722  {
723  $listlinestaskres->setVars($key, $val, true, 'UTF-8');
724  }
725  catch(OdfException $e)
726  {
727  dol_syslog($e->getMessage(), LOG_INFO);
728  }
729  catch(SegmentException $e)
730  {
731  dol_syslog($e->getMessage(), LOG_INFO);
732  }
733  }
734  $listlinestaskres->merge();
735  }
736  }
737 
738  //Time ressources
739  $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
740  $sql.= ", u.lastname, u.firstname, t.thm";
741  $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
742  $sql .= " , ".MAIN_DB_PREFIX."user as u";
743  $sql .= " WHERE t.fk_task =".$task->id;
744  $sql .= " AND t.fk_user = u.rowid";
745  $sql .= " ORDER BY t.task_date DESC";
746 
747  $resql = $this->db->query($sql);
748  if ($resql)
749  {
750  $num = $this->db->num_rows($resql);
751  $i = 0;
752  $tasks = array();
753  $listlinestasktime = $listlines->__get('taskstimes');
754  if (empty($num)) {
755  $row['rowid']='';
756  $row['task_date']='';
757  $row['task_duration']='';
758  $row['$tasktime']='';
759  $row['note']='';
760  $row['fk_user']='';
761  $row['name']='';
762  $row['firstname']='';
763  $row['fullcivname']='';
764  $row['amountht']='';
765  $row['amountttc']='';
766  $row['thm']='';
767  $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
768  foreach($tmparray as $key => $val)
769  {
770  try
771  {
772  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
773  }
774  catch(OdfException $e)
775  {
776  dol_syslog($e->getMessage(), LOG_INFO);
777  }
778  catch(SegmentException $e)
779  {
780  dol_syslog($e->getMessage(), LOG_INFO);
781  }
782  }
783  $listlinestasktime->merge();
784  }
785  while ($i < $num)
786  {
787  $row = $this->db->fetch_array($resql);
788  if (!empty($row['fk_user'])) {
789  $objectdetail=new User($this->db);
790  $objectdetail->fetch($row['fk_user']);
791  $row['fullcivname']=$objectdetail->getFullName($outputlangs,1);
792  } else {
793  $row['fullcivname']='';
794  }
795 
796  if (!empty($row['thm'])) {
797  $row['amountht']=($row['task_duration'] / 3600) * $row['thm'];
798  $defaultvat = get_default_tva($mysoc, $mysoc);
799  $row['amountttc']=price2num($row['amountht'] * (1 + ($defaultvat / 100)),'MT');
800  } else {
801  $row['amountht']=0;
802  $row['amountttc']=0;
803  $row['thm']=0;
804  }
805 
806  $tmparray=$this->get_substitutionarray_taskstime($row,$outputlangs);
807 
808  foreach($tmparray as $key => $val)
809  {
810  try
811  {
812  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
813  }
814  catch(OdfException $e)
815  {
816  dol_syslog($e->getMessage(), LOG_INFO);
817  }
818  catch(SegmentException $e)
819  {
820  dol_syslog($e->getMessage(), LOG_INFO);
821  }
822  }
823  $listlinestasktime->merge();
824  $i++;
825  }
826  $this->db->free($resql);
827  }
828 
829 
830  // Replace tags of project files
831  $listtasksfiles = $listlines->__get('tasksfiles');
832 
833  $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
834  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
835 
836 
837  foreach ($filearray as $filedetail)
838  {
839  $tmparray=$this->get_substitutionarray_task_file($filedetail,$outputlangs);
840  //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
841  foreach($tmparray as $key => $val)
842  {
843  try
844  {
845  $listtasksfiles->setVars($key, $val, true, 'UTF-8');
846  }
847  catch (OdfException $e)
848  {
849  dol_syslog($e->getMessage(), LOG_INFO);
850  }
851  catch (SegmentException $e)
852  {
853  dol_syslog($e->getMessage(), LOG_INFO);
854  }
855  }
856  $listtasksfiles->merge();
857  }
858  $listlines->merge();
859  }
860  $odfHandler->mergeSegment($listlines);
861  }
862  catch(OdfException $e)
863  {
864  $ExceptionTrace=$e->getTrace();
865  // no segment defined on ODT is not an error
866  if($ExceptionTrace[0]['function'] != 'setSegment')
867  {
868  $this->error=$e->getMessage();
869  dol_syslog($this->error, LOG_WARNING);
870  return -1;
871  }
872  }
873 
874  // Replace tags of project files
875  try
876  {
877  $listlines = $odfHandler->setSegment('projectfiles');
878 
879  $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
880  $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$','name',SORT_ASC,1);
881 
882  foreach ($filearray as $filedetail)
883  {
884  //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
885  $tmparray=$this->get_substitutionarray_project_file($filedetail,$outputlangs);
886 
887  foreach($tmparray as $key => $val)
888  {
889  try
890  {
891  $listlines->setVars($key, $val, true, 'UTF-8');
892  }
893  catch(OdfException $e)
894  {
895  dol_syslog($e->getMessage(), LOG_INFO);
896  }
897  catch(SegmentException $e)
898  {
899  dol_syslog($e->getMessage(), LOG_INFO);
900  }
901  }
902  $listlines->merge();
903  }
904  $odfHandler->mergeSegment($listlines);
905  }
906  catch(OdfException $e)
907  {
908  $this->error=$e->getMessage();
909  dol_syslog($this->error, LOG_WARNING);
910  return -1;
911  }
912 
913  // Replace tags of lines for contacts
914  $sourcearray=array('internal','external');
915  $contact_arrray=array();
916  foreach ($sourcearray as $source) {
917  $contact_temp=$object->liste_contact(-1,$source);
918  if ((is_array($contact_temp) && count($contact_temp) > 0))
919  {
920  $contact_arrray=array_merge($contact_arrray,$contact_temp);
921  }
922  }
923  if ((is_array($contact_arrray) && count($contact_arrray) > 0))
924  {
925  try
926  {
927  $listlines = $odfHandler->setSegment('projectcontacts');
928 
929  foreach ($contact_arrray as $contact)
930  {
931  if ($contact['source']=='internal') {
932  $objectdetail=new User($this->db);
933  $objectdetail->fetch($contact['id']);
934  $contact['socname']=$mysoc->name;
935  } elseif ($contact['source']=='external') {
936  $objectdetail=new Contact($this->db);
937  $objectdetail->fetch($contact['id']);
938 
939  $soc=new Societe($this->db);
940  $soc->fetch($contact['socid']);
941  $contact['socname']=$soc->name;
942  }
943  $contact['fullname']=$objectdetail->getFullName($outputlangs,1);
944 
945  $tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
946  foreach($tmparray as $key => $val)
947  {
948  try
949  {
950  $listlines->setVars($key, $val, true, 'UTF-8');
951  }
952  catch(OdfException $e)
953  {
954  dol_syslog($e->getMessage(), LOG_INFO);
955  }
956  catch(SegmentException $e)
957  {
958  dol_syslog($e->getMessage(), LOG_INFO);
959  }
960  }
961  $listlines->merge();
962  }
963  $odfHandler->mergeSegment($listlines);
964  }
965  catch(OdfException $e)
966  {
967  $this->error=$e->getMessage();
968  dol_syslog($this->error, LOG_WARNING);
969  return -1;
970  }
971  }
972 
973  //List of referent
974 
975  $listofreferent = array(
976  'propal' => array(
977  'title' => "ListProposalsAssociatedProject",
978  'class' => 'Propal',
979  'table' => 'propal',
980  'test' => $conf->propal->enabled && $user->rights->propale->lire
981  ),
982  'order' => array(
983  'title' => "ListOrdersAssociatedProject",
984  'class' => 'Commande',
985  'table' => 'commande',
986  'test' => $conf->commande->enabled && $user->rights->commande->lire
987  ),
988  'invoice' => array(
989  'title' => "ListInvoicesAssociatedProject",
990  'class' => 'Facture',
991  'table' => 'facture',
992  'test' => $conf->facture->enabled && $user->rights->facture->lire
993  ),
994  'invoice_predefined' => array(
995  'title' => "ListPredefinedInvoicesAssociatedProject",
996  'class' => 'FactureRec',
997  'table' => 'facture_rec',
998  'test' => $conf->facture->enabled && $user->rights->facture->lire
999  ),
1000  'proposal_supplier' => array(
1001  'title' => "ListSupplierProposalsAssociatedProject",
1002  'class' => 'SupplierProposal',
1003  'table' => 'supplier_proposal',
1004  'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
1005  ),
1006  'order_supplier' => array(
1007  'title' => "ListSupplierOrdersAssociatedProject",
1008  'table' => 'commande_fournisseur',
1009  'class' => 'CommandeFournisseur',
1010  'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire
1011  ),
1012  'invoice_supplier' => array(
1013  'title' => "ListSupplierInvoicesAssociatedProject",
1014  'table' => 'facture_fourn',
1015  'class' => 'FactureFournisseur',
1016  'test' => $conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire
1017  ),
1018  'contract' => array(
1019  'title' => "ListContractAssociatedProject",
1020  'class' => 'Contrat',
1021  'table' => 'contrat',
1022  'test' => $conf->contrat->enabled && $user->rights->contrat->lire
1023  ),
1024  'intervention' => array(
1025  'title' => "ListFichinterAssociatedProject",
1026  'class' => 'Fichinter',
1027  'table' => 'fichinter',
1028  'disableamount' => 1,
1029  'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1030  ),
1031  'shipping' => array(
1032  'title' => "ListShippingAssociatedProject",
1033  'class' => 'Expedition',
1034  'table' => 'expedition',
1035  'disableamount' => 1,
1036  'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1037  ),
1038  'trip' => array(
1039  'title' => "ListTripAssociatedProject",
1040  'class' => 'Deplacement',
1041  'table' => 'deplacement',
1042  'disableamount' => 1,
1043  'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1044  ),
1045  'expensereport' => array(
1046  'title' => "ListExpenseReportsAssociatedProject",
1047  'class' => 'ExpenseReportLine',
1048  'table' => 'expensereport_det',
1049  'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1050  ),
1051  'donation' => array(
1052  'title' => "ListDonationsAssociatedProject",
1053  'class' => 'Don',
1054  'table' => 'don',
1055  'test' => $conf->don->enabled && $user->rights->don->lire
1056  ),
1057  'loan' => array(
1058  'title' => "ListLoanAssociatedProject",
1059  'class' => 'Loan',
1060  'table' => 'loan',
1061  'test' => $conf->loan->enabled && $user->rights->loan->read
1062  ),
1063  'chargesociales' => array(
1064  'title' => "ListSocialContributionAssociatedProject",
1065  'class' => 'ChargeSociales',
1066  'table' => 'chargesociales',
1067  'urlnew' => DOL_URL_ROOT . '/compta/sociales/card.php?action=create&projectid=' . $id,
1068  'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1069  ),
1070  'stock_mouvement' => array(
1071  'title' => "ListMouvementStockProject",
1072  'class' => 'MouvementStock',
1073  'table' => 'stock_mouvement',
1074  'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && ! empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1075  ),
1076  'agenda' => array(
1077  'title' => "ListActionsAssociatedProject",
1078  'class' => 'ActionComm',
1079  'table' => 'actioncomm',
1080  'disableamount' => 1,
1081  'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1082  ),
1083  );
1084 
1085  //Insert reference
1086  try
1087  {
1088  $listlines = $odfHandler->setSegment('projectrefs');
1089 
1090  foreach ($listofreferent as $keyref => $valueref)
1091  {
1092  $title=$valueref['title'];
1093  $tablename=$valueref['table'];
1094  $classname=$valueref['class'];
1095  $qualified=$valueref['test'];
1096  if ($qualified)
1097  {
1098  $elementarray = $object->get_element_list($keyref, $tablename);
1099  if (count($elementarray)>0 && is_array($elementarray))
1100  {
1101  $total_ht = 0;
1102  $total_ttc = 0;
1103  $num=count($elementarray);
1104  for ($i = 0; $i < $num; $i++)
1105  {
1106  $ref_array=array();
1107  $ref_array['type']=$langs->trans($classname);
1108 
1109  $element = new $classname($this->db);
1110  $element->fetch($elementarray[$i]);
1111  $element->fetch_thirdparty();
1112 
1113  //Ref object
1114  $ref_array['ref']=$element->ref;
1115 
1116  //Date object
1117  $dateref=$element->date;
1118  if (empty($dateref)) $dateref=$element->datep;
1119  if (empty($dateref)) $dateref=$element->date_contrat;
1120  $ref_array['date']=$dateref;
1121 
1122  //Soc object
1123  if (is_object($element->thirdparty)) {
1124  $ref_array['socname']=$element->thirdparty->name;
1125  } else {
1126  $ref_array['socname']='';
1127  }
1128 
1129  //Amount object
1130  if (empty($valueref['disableamount'])) {
1131  if (!empty($element->total_ht)) {
1132  $ref_array['amountht']=$element->total_ht;
1133  $ref_array['amountttc']=$element->total_ttc;
1134  } else {
1135  $ref_array['amountht']=0;
1136  $ref_array['amountttc']=0;
1137  }
1138  } else {
1139  $ref_array['amountht']='';
1140  $ref_array['amountttc']='';
1141  }
1142 
1143  $ref_array['status']=$element->getLibStatut(0);
1144 
1145  $tmparray=$this->get_substitutionarray_project_reference($ref_array,$outputlangs);
1146 
1147  foreach($tmparray as $key => $val)
1148  {
1149  try
1150  {
1151  $listlines->setVars($key, $val, true, 'UTF-8');
1152  }
1153  catch(OdfException $e)
1154  {
1155  dol_syslog($e->getMessage(), LOG_INFO);
1156  }
1157  catch(SegmentException $e)
1158  {
1159  dol_syslog($e->getMessage(), LOG_INFO);
1160  }
1161  }
1162  $listlines->merge();
1163  }
1164  }
1165  }
1166  $odfHandler->mergeSegment($listlines);
1167  }
1168  } catch(OdfException $e) {
1169  $this->error=$e->getMessage();
1170  dol_syslog($this->error, LOG_WARNING);
1171  return -1;
1172  }
1173 
1174  // Replace labels translated
1175  $tmparray=$outputlangs->get_translations_for_substitutions();
1176  foreach($tmparray as $key=>$value)
1177  {
1178  try {
1179  $odfHandler->setVars($key, $value, true, 'UTF-8');
1180  } catch (OdfException $e) {
1181  dol_syslog($e->getMessage(), LOG_INFO);
1182  }
1183  }
1184 
1185  // Call the beforeODTSave hook
1186  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1187  $reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
1188 
1189 
1190  // Write new file
1191  if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1192  try {
1193  $odfHandler->exportAsAttachedPDF($file);
1194  } catch (Exception $e) {
1195  $this->error=$e->getMessage();
1196  return -1;
1197  }
1198  } else {
1199  try {
1200  $odfHandler->saveToDisk($file);
1201  } catch (Exception $e){
1202  $this->error=$e->getMessage();
1203  dol_syslog($e->getMessage(), LOG_INFO);
1204  return -1;
1205  }
1206  }
1207  $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray);
1208  $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
1209 
1210  if (! empty($conf->global->MAIN_UMASK))
1211  @chmod($file, octdec($conf->global->MAIN_UMASK));
1212 
1213  $odfHandler=null; // Destroy object
1214 
1215  $this->result = array('fullpath'=>$file);
1216 
1217  return 1; // Success
1218  }
1219  else
1220  {
1221  $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
1222  return -1;
1223  }
1224  }
1225 
1226  return -1;
1227  }
1228 }
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
img_warning($titlealt='default', $moreatt='')
Show warning logo.
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
</td >< td class="liste_titre" align="right"></td ></tr >< tr class="liste_titre">< input type="checkbox" onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< tr class="oddeven">< td >< input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td >< td >< input type="checkbox" class="check" name="choose'.$i.'"></td >< td class="nowrap"></td >< td >< input type="hidden" name="desc' . $i . '" value="' . dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:573
Class to manage contact/addresses.
get_substitutionarray_project_reference($refdetail, $outputlangs)
Define array with couple substitution key => substitution value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=true)
Define array with couple subtitution key => subtitution value.
get_substitutionarray_tasks($task, $outputlangs)
Define array with couple substitution key => substitution value.
Class to build documents using ODF templates generator.
Class to manage Dolibarr users.
Definition: user.class.php:41
get_substitutionarray_user($user, $outputlangs)
Define array with couple subtitution key => subtitution value.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:103
info($langs)
Return description of a module.
get_substitutionarray_project_contacts($contact, $outputlangs)
Define array with couple substitution key => substitution value.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Class to manage standard extra fields.
Class to manage hooks.
Class to manage generation of HTML components Only common components must be here.
get_substitutionarray_taskstime($tasktime, $outputlangs)
Define array with couple substitution key => substitution value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
type
Definition: viewcat.php:284
Class to manage third parties objects (customers, suppliers, prospects...)
Parent class for projects models.
Class to manage projects.
write_file($object, $outputlangs, $srctemplatepath)
Function to build a document on disk using the generic odt module.
get_substitutionarray_tasksressource($taskressource, $outputlangs)
Define array with couple substitution key => substitution value.
$version
Dolibarr version of the loaded document string.
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple subtitution key => subtitution value.
get_substitutionarray_object($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:59
dol_now($mode='gmt')
Return date for now.
get_substitutionarray_project_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
get_substitutionarray_contact($object, $outputlangs, $array_key='object')
Define array with couple subtitution key => subtitution value.
Class to manage tasks.
Definition: task.class.php:33
get_substitutionarray_thirdparty($object, $outputlangs)
Define array with couple subtitution key => subtitution value.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
Fill array with couple extrafield key => extrafield value.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
get_substitutionarray_other($outputlangs)
Define array with couple subtitution key => subtitution value.
get_substitutionarray_task_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
price2num($amount, $rounding='', $alreadysqlnb=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...