dolibarr  13.0.2
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 <https://www.gnu.org/licenses/>.
20  * or see https://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) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
45 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->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, 6);
68 
73  public $version = 'dolibarr';
74 
75 
81  public function __construct($db)
82  {
83  global $conf, $langs, $mysoc;
84 
85  // Load traductions files required 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  // Page size for A4 format
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.ScopeNotCamelCaps
129  public 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  $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.ScopeNotCamelCaps
167  public function get_substitutionarray_tasks(Task $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  $extrafields->fetch_name_optionals_label($task->table_element, true);
193  $task->fetch_optionals();
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.ScopeNotCamelCaps
208  public 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  $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.ScopeNotCamelCaps
266  public 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.ScopeNotCamelCaps
286  public 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.ScopeNotCamelCaps
310  public 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.ScopeNotCamelCaps
334  public 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.ScopeNotCamelCaps
363  public 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  public 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="'.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  $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
413  if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
414  }
415  }
416  $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
417  // Add list of substitution keys
418  $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
419  $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
420 
421  $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
422  $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
423  $texte .= '<textarea class="flat" cols="60" name="value1">';
424  $texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
425  $texte .= '</textarea>';
426  $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
427  $texte .= '<input type="submit" class="button" value="'.$langs->trans("Modify").'" name="Button">';
428  $texte .= '<br></div></div>';
429 
430  // Scan directories
431  $nbofiles = count($listoffiles);
432  if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH))
433  {
434  $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
435  //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
436  $texte .= $nbofiles;
437  //$texte.=$nbofiles?'</a>':'';
438  $texte .= '</b>';
439  }
440 
441  if ($nbofiles)
442  {
443  $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
444  // Show list of found files
445  foreach ($listoffiles as $file) {
446  $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=projects/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a><br>';
447  }
448  $texte .= '</div>';
449  }
450 
451  $texte .= '</td>';
452 
453  $texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';
454  $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
455  $texte .= '</td>';
456  $texte .= '</tr>';
457 
458  $texte .= '</table>';
459  $texte .= '</form>';
460 
461  return $texte;
462  }
463 
464  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
473  public function write_file($object, $outputlangs, $srctemplatepath)
474  {
475  // phpcs:enable
476  global $user, $langs, $conf, $mysoc, $hookmanager;
477 
478  if (empty($srctemplatepath))
479  {
480  dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
481  return -1;
482  }
483 
484  // Add odtgeneration hook
485  if (!is_object($hookmanager))
486  {
487  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
488  $hookmanager = new HookManager($this->db);
489  }
490  $hookmanager->initHooks(array('odtgeneration'));
491  global $action;
492 
493  if (!is_object($outputlangs)) $outputlangs = $langs;
494  $sav_charset_output = $outputlangs->charset_output;
495  $outputlangs->charset_output = 'UTF-8';
496 
497  // Load translation files required by the page
498  $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
499 
500  if ($conf->projet->dir_output)
501  {
502  // If $object is id instead of object
503  if (!is_object($object))
504  {
505  $id = $object;
506  $object = new Project($this->db);
507  $result = $object->fetch($id);
508  if ($result < 0)
509  {
510  dol_print_error($this->db, $object->error);
511  return -1;
512  }
513  }
514 
515  $object->fetch_thirdparty();
516 
517  $dir = $conf->projet->dir_output;
518  $objectref = dol_sanitizeFileName($object->ref);
519  if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
520  $file = $dir."/".$objectref.".odt";
521 
522  if (!file_exists($dir))
523  {
524  if (dol_mkdir($dir) < 0)
525  {
526  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
527  return -1;
528  }
529  }
530 
531  if (file_exists($dir))
532  {
533  //print "srctemplatepath=".$srctemplatepath; // Src filename
534  $newfile = basename($srctemplatepath);
535  $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
536  $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
537  $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
538  $newfiletmp = $objectref.'_'.$newfiletmp;
539  //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
540  // Get extension (ods or odt)
541  $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
542  if (!empty($conf->global->MAIN_DOC_USE_TIMING))
543  {
544  $format = $conf->global->MAIN_DOC_USE_TIMING;
545  if ($format == '1') $format = '%Y%m%d%H%M%S';
546  $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
547  } else {
548  $filename = $newfiletmp.'.'.$newfileformat;
549  }
550  $file = $dir.'/'.$filename;
551  //print "newdir=".$dir;
552  //print "newfile=".$newfile;
553  //print "file=".$file;
554  //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
555 
556  dol_mkdir($conf->projet->dir_temp);
557 
558  // If PROJECTLEADER contact defined on project, we use it
559  $usecontact = false;
560  $arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER');
561  if (count($arrayidcontact) > 0)
562  {
563  $usecontact = true;
564  $result = $object->fetch_contact($arrayidcontact[0]);
565  }
566 
567  // Recipient name
568  $contactobject = null;
569  if (!empty($usecontact))
570  {
571  // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
572  $contactobject = $object->contact;
573  }
574 
575  $socobject = $object->thirdparty;
576 
577  // Make substitution
578  $substitutionarray = array(
579  '__FROM_NAME__' => $this->emetteur->name,
580  '__FROM_EMAIL__' => $this->emetteur->email,
581  );
582  complete_substitutions_array($substitutionarray, $langs, $object);
583  // Call the ODTSubstitution hook
584  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
585  $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
586 
587  // Open and load template
588  require_once ODTPHP_PATH.'odf.php';
589  try {
590  $odfHandler = new odf(
591  $srctemplatepath,
592  array(
593  'PATH_TO_TMP' => $conf->projet->dir_temp,
594  'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
595  'DELIMITER_LEFT' => '{',
596  'DELIMITER_RIGHT' => '}'
597  )
598  );
599  } catch (Exception $e) {
600  $this->error = $e->getMessage();
601  dol_syslog($e->getMessage(), LOG_INFO);
602  return -1;
603  }
604  // After construction $odfHandler->contentXml contains content and
605  // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
606  // [!-- BEGIN lines --]*[!-- END lines --]
607  //print html_entity_decode($odfHandler->__toString());
608  //print exit;
609 
610 
611  // Define substitution array
612  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
613  $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
614  $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
615  $array_user = $this->get_substitutionarray_user($user, $outputlangs);
616  $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
617  $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
618  $array_other = $this->get_substitutionarray_other($outputlangs);
619  // retrieve contact information for use in object as contact_xxx tags
620  $array_project_contact = array();
621  if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
622 
623  $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
624  complete_substitutions_array($tmparray, $outputlangs, $object);
625 
626  // Call the ODTSubstitution hook
627  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
628  $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
629 
630  foreach ($tmparray as $key=>$value)
631  {
632  try {
633  if (preg_match('/logo$/', $key)) // Image
634  {
635  if (file_exists($value)) $odfHandler->setImage($key, $value);
636  else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
637  } else // Text
638  {
639  $odfHandler->setVars($key, $value, true, 'UTF-8');
640  }
641  } catch (OdfException $e)
642  {
643  dol_syslog($e->getMessage(), LOG_INFO);
644  }
645  }
646 
647  // Replace tags of lines for tasks
648  try {
649  $listlines = $odfHandler->setSegment('tasks');
650 
651  $taskstatic = new Task($this->db);
652 
653  // Security check
654  $socid = 0;
655  if (!empty($object->fk_soc)) $socid = $object->fk_soc;
656 
657  $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
658 
659 
660  foreach ($tasksarray as $task)
661  {
662  $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
663  //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
664  foreach ($tmparray as $key => $val)
665  {
666  try {
667  $listlines->setVars($key, $val, true, 'UTF-8');
668  } catch (OdfException $e)
669  {
670  dol_syslog($e->getMessage(), LOG_INFO);
671  } catch (SegmentException $e)
672  {
673  dol_syslog($e->getMessage(), LOG_INFO);
674  }
675  }
676 
677  $taskobj = new Task($this->db);
678  $taskobj->fetch($task->id);
679 
680  // Replace tags of lines for contacts task
681  $sourcearray = array('internal', 'external');
682  $contact_arrray = array();
683  foreach ($sourcearray as $source) {
684  $contact_temp = $taskobj->liste_contact(-1, $source);
685  if ((is_array($contact_temp) && count($contact_temp) > 0))
686  {
687  $contact_arrray = array_merge($contact_arrray, $contact_temp);
688  }
689  }
690  if ((is_array($contact_arrray) && count($contact_arrray) > 0))
691  {
692  $listlinestaskres = $listlines->__get('tasksressources');
693 
694  foreach ($contact_arrray as $contact)
695  {
696  if ($contact['source'] == 'internal') {
697  $objectdetail = new User($this->db);
698  $objectdetail->fetch($contact['id']);
699  $contact['socname'] = $mysoc->name;
700  } elseif ($contact['source'] == 'external') {
701  $objectdetail = new Contact($this->db);
702  $objectdetail->fetch($contact['id']);
703 
704  $soc = new Societe($this->db);
705  $soc->fetch($contact['socid']);
706  $contact['socname'] = $soc->name;
707  }
708  $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
709 
710  $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
711 
712  foreach ($tmparray as $key => $val)
713  {
714  try {
715  $listlinestaskres->setVars($key, $val, true, 'UTF-8');
716  } catch (OdfException $e)
717  {
718  dol_syslog($e->getMessage(), LOG_INFO);
719  } catch (SegmentException $e)
720  {
721  dol_syslog($e->getMessage(), LOG_INFO);
722  }
723  }
724  $listlinestaskres->merge();
725  }
726  }
727 
728  //Time ressources
729  $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
730  $sql .= ", u.lastname, u.firstname, t.thm";
731  $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
732  $sql .= " , ".MAIN_DB_PREFIX."user as u";
733  $sql .= " WHERE t.fk_task =".$task->id;
734  $sql .= " AND t.fk_user = u.rowid";
735  $sql .= " ORDER BY t.task_date DESC";
736 
737  $resql = $this->db->query($sql);
738  if ($resql)
739  {
740  $num = $this->db->num_rows($resql);
741  $i = 0;
742  $tasks = array();
743  $row = array();
744  $listlinestasktime = $listlines->__get('taskstimes');
745  if (empty($num)) {
746  $row['rowid'] = '';
747  $row['task_date'] = '';
748  $row['task_duration'] = '';
749  $row['$tasktime'] = '';
750  $row['note'] = '';
751  $row['fk_user'] = '';
752  $row['name'] = '';
753  $row['firstname'] = '';
754  $row['fullcivname'] = '';
755  $row['amountht'] = '';
756  $row['amountttc'] = '';
757  $row['thm'] = '';
758  $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
759  foreach ($tmparray as $key => $val)
760  {
761  try {
762  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
763  } catch (OdfException $e)
764  {
765  dol_syslog($e->getMessage(), LOG_INFO);
766  } catch (SegmentException $e)
767  {
768  dol_syslog($e->getMessage(), LOG_INFO);
769  }
770  }
771  $listlinestasktime->merge();
772  }
773  while ($i < $num)
774  {
775  $row = $this->db->fetch_array($resql);
776  if (!empty($row['fk_user'])) {
777  $objectdetail = new User($this->db);
778  $objectdetail->fetch($row['fk_user']);
779  $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
780  } else {
781  $row['fullcivname'] = '';
782  }
783 
784  if (!empty($row['thm'])) {
785  $row['amountht'] = ($row['task_duration'] / 3600) * $row['thm'];
786  $defaultvat = get_default_tva($mysoc, $mysoc);
787  $row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT');
788  } else {
789  $row['amountht'] = 0;
790  $row['amountttc'] = 0;
791  $row['thm'] = 0;
792  }
793 
794  $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
795 
796  foreach ($tmparray as $key => $val)
797  {
798  try {
799  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
800  } catch (OdfException $e)
801  {
802  dol_syslog($e->getMessage(), LOG_INFO);
803  } catch (SegmentException $e)
804  {
805  dol_syslog($e->getMessage(), LOG_INFO);
806  }
807  }
808  $listlinestasktime->merge();
809  $i++;
810  }
811  $this->db->free($resql);
812  }
813 
814 
815  // Replace tags of project files
816  $listtasksfiles = $listlines->__get('tasksfiles');
817 
818  $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
819  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
820 
821 
822  foreach ($filearray as $filedetail)
823  {
824  $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
825  //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
826  foreach ($tmparray as $key => $val)
827  {
828  try {
829  $listtasksfiles->setVars($key, $val, true, 'UTF-8');
830  } catch (OdfException $e)
831  {
832  dol_syslog($e->getMessage(), LOG_INFO);
833  } catch (SegmentException $e)
834  {
835  dol_syslog($e->getMessage(), LOG_INFO);
836  }
837  }
838  $listtasksfiles->merge();
839  }
840  $listlines->merge();
841  }
842  $odfHandler->mergeSegment($listlines);
843  } catch (OdfException $e)
844  {
845  $ExceptionTrace = $e->getTrace();
846  // no segment defined on ODT is not an error
847  if ($ExceptionTrace[0]['function'] != 'setSegment')
848  {
849  $this->error = $e->getMessage();
850  dol_syslog($this->error, LOG_WARNING);
851  return -1;
852  }
853  }
854 
855  // Replace tags of project files
856  try {
857  $listlines = $odfHandler->setSegment('projectfiles');
858 
859  $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
860  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
861 
862  foreach ($filearray as $filedetail)
863  {
864  //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
865  $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
866 
867  foreach ($tmparray as $key => $val)
868  {
869  try {
870  $listlines->setVars($key, $val, true, 'UTF-8');
871  } catch (OdfException $e)
872  {
873  dol_syslog($e->getMessage(), LOG_INFO);
874  } catch (SegmentException $e)
875  {
876  dol_syslog($e->getMessage(), LOG_INFO);
877  }
878  }
879  $listlines->merge();
880  }
881  $odfHandler->mergeSegment($listlines);
882  } catch (OdfException $e)
883  {
884  $this->error = $e->getMessage();
885  dol_syslog($this->error, LOG_WARNING);
886  return -1;
887  }
888 
889  // Replace tags of lines for contacts
890  $sourcearray = array('internal', 'external');
891  $contact_arrray = array();
892  foreach ($sourcearray as $source) {
893  $contact_temp = $object->liste_contact(-1, $source);
894  if ((is_array($contact_temp) && count($contact_temp) > 0))
895  {
896  $contact_arrray = array_merge($contact_arrray, $contact_temp);
897  }
898  }
899  if ((is_array($contact_arrray) && count($contact_arrray) > 0))
900  {
901  try {
902  $listlines = $odfHandler->setSegment('projectcontacts');
903 
904  foreach ($contact_arrray as $contact)
905  {
906  if ($contact['source'] == 'internal') {
907  $objectdetail = new User($this->db);
908  $objectdetail->fetch($contact['id']);
909  $contact['socname'] = $mysoc->name;
910  } elseif ($contact['source'] == 'external') {
911  $objectdetail = new Contact($this->db);
912  $objectdetail->fetch($contact['id']);
913 
914  $soc = new Societe($this->db);
915  $soc->fetch($contact['socid']);
916  $contact['socname'] = $soc->name;
917  }
918  $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
919 
920  $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
921  foreach ($tmparray as $key => $val)
922  {
923  try {
924  $listlines->setVars($key, $val, true, 'UTF-8');
925  } catch (OdfException $e)
926  {
927  dol_syslog($e->getMessage(), LOG_INFO);
928  } catch (SegmentException $e)
929  {
930  dol_syslog($e->getMessage(), LOG_INFO);
931  }
932  }
933  $listlines->merge();
934  }
935  $odfHandler->mergeSegment($listlines);
936  } catch (OdfException $e)
937  {
938  $this->error = $e->getMessage();
939  dol_syslog($this->error, LOG_WARNING);
940  return -1;
941  }
942  }
943 
944  //List of referent
945 
946  $listofreferent = array(
947  'propal' => array(
948  'title' => "ListProposalsAssociatedProject",
949  'class' => 'Propal',
950  'table' => 'propal',
951  'test' => $conf->propal->enabled && $user->rights->propale->lire
952  ),
953  'order' => array(
954  'title' => "ListOrdersAssociatedProject",
955  'class' => 'Commande',
956  'table' => 'commande',
957  'test' => $conf->commande->enabled && $user->rights->commande->lire
958  ),
959  'invoice' => array(
960  'title' => "ListInvoicesAssociatedProject",
961  'class' => 'Facture',
962  'table' => 'facture',
963  'test' => $conf->facture->enabled && $user->rights->facture->lire
964  ),
965  'invoice_predefined' => array(
966  'title' => "ListPredefinedInvoicesAssociatedProject",
967  'class' => 'FactureRec',
968  'table' => 'facture_rec',
969  'test' => $conf->facture->enabled && $user->rights->facture->lire
970  ),
971  'proposal_supplier' => array(
972  'title' => "ListSupplierProposalsAssociatedProject",
973  'class' => 'SupplierProposal',
974  'table' => 'supplier_proposal',
975  'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
976  ),
977  'order_supplier' => array(
978  'title' => "ListSupplierOrdersAssociatedProject",
979  'table' => 'commande_fournisseur',
980  'class' => 'CommandeFournisseur',
981  'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire
982  ),
983  'invoice_supplier' => array(
984  'title' => "ListSupplierInvoicesAssociatedProject",
985  'table' => 'facture_fourn',
986  'class' => 'FactureFournisseur',
987  'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire
988  ),
989  'contract' => array(
990  'title' => "ListContractAssociatedProject",
991  'class' => 'Contrat',
992  'table' => 'contrat',
993  'test' => $conf->contrat->enabled && $user->rights->contrat->lire
994  ),
995  'intervention' => array(
996  'title' => "ListFichinterAssociatedProject",
997  'class' => 'Fichinter',
998  'table' => 'fichinter',
999  'disableamount' => 1,
1000  'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1001  ),
1002  'shipping' => array(
1003  'title' => "ListShippingAssociatedProject",
1004  'class' => 'Expedition',
1005  'table' => 'expedition',
1006  'disableamount' => 1,
1007  'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1008  ),
1009  'trip' => array(
1010  'title' => "ListTripAssociatedProject",
1011  'class' => 'Deplacement',
1012  'table' => 'deplacement',
1013  'disableamount' => 1,
1014  'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1015  ),
1016  'expensereport' => array(
1017  'title' => "ListExpenseReportsAssociatedProject",
1018  'class' => 'ExpenseReportLine',
1019  'table' => 'expensereport_det',
1020  'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1021  ),
1022  'donation' => array(
1023  'title' => "ListDonationsAssociatedProject",
1024  'class' => 'Don',
1025  'table' => 'don',
1026  'test' => $conf->don->enabled && $user->rights->don->lire
1027  ),
1028  'loan' => array(
1029  'title' => "ListLoanAssociatedProject",
1030  'class' => 'Loan',
1031  'table' => 'loan',
1032  'test' => $conf->loan->enabled && $user->rights->loan->read
1033  ),
1034  'chargesociales' => array(
1035  'title' => "ListSocialContributionAssociatedProject",
1036  'class' => 'ChargeSociales',
1037  'table' => 'chargesociales',
1038  'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id,
1039  'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1040  ),
1041  'stock_mouvement' => array(
1042  'title' => "ListMouvementStockProject",
1043  'class' => 'MouvementStock',
1044  'table' => 'stock_mouvement',
1045  'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1046  ),
1047  'agenda' => array(
1048  'title' => "ListActionsAssociatedProject",
1049  'class' => 'ActionComm',
1050  'table' => 'actioncomm',
1051  'disableamount' => 1,
1052  'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1053  ),
1054  );
1055 
1056  //Insert reference
1057  try {
1058  $listlines = $odfHandler->setSegment('projectrefs');
1059 
1060  foreach ($listofreferent as $keyref => $valueref)
1061  {
1062  $title = $valueref['title'];
1063  $tablename = $valueref['table'];
1064  $classname = $valueref['class'];
1065  $qualified = $valueref['test'];
1066  if ($qualified)
1067  {
1068  $elementarray = $object->get_element_list($keyref, $tablename);
1069  if (count($elementarray) > 0 && is_array($elementarray))
1070  {
1071  $total_ht = 0;
1072  $total_ttc = 0;
1073  $num = count($elementarray);
1074  for ($i = 0; $i < $num; $i++)
1075  {
1076  $ref_array = array();
1077  $ref_array['type'] = $langs->trans($classname);
1078 
1079  $element = new $classname($this->db);
1080  $element->fetch($elementarray[$i]);
1081  $element->fetch_thirdparty();
1082 
1083  //Ref object
1084  $ref_array['ref'] = $element->ref;
1085 
1086  //Date object
1087  $dateref = $element->date;
1088  if (empty($dateref)) $dateref = $element->datep;
1089  if (empty($dateref)) $dateref = $element->date_contrat;
1090  $ref_array['date'] = $dateref;
1091 
1092  //Soc object
1093  if (is_object($element->thirdparty)) {
1094  $ref_array['socname'] = $element->thirdparty->name;
1095  } else {
1096  $ref_array['socname'] = '';
1097  }
1098 
1099  //Amount object
1100  if (empty($valueref['disableamount'])) {
1101  if (!empty($element->total_ht)) {
1102  $ref_array['amountht'] = $element->total_ht;
1103  $ref_array['amountttc'] = $element->total_ttc;
1104  } else {
1105  $ref_array['amountht'] = 0;
1106  $ref_array['amountttc'] = 0;
1107  }
1108  } else {
1109  $ref_array['amountht'] = '';
1110  $ref_array['amountttc'] = '';
1111  }
1112 
1113  $ref_array['status'] = $element->getLibStatut(0);
1114 
1115  $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs);
1116 
1117  foreach ($tmparray as $key => $val)
1118  {
1119  try {
1120  $listlines->setVars($key, $val, true, 'UTF-8');
1121  } catch (OdfException $e)
1122  {
1123  dol_syslog($e->getMessage(), LOG_INFO);
1124  } catch (SegmentException $e)
1125  {
1126  dol_syslog($e->getMessage(), LOG_INFO);
1127  }
1128  }
1129  $listlines->merge();
1130  }
1131  }
1132  }
1133  $odfHandler->mergeSegment($listlines);
1134  }
1135  } catch (OdfException $e) {
1136  $this->error = $e->getMessage();
1137  dol_syslog($this->error, LOG_WARNING);
1138  return -1;
1139  }
1140 
1141  // Replace labels translated
1142  $tmparray = $outputlangs->get_translations_for_substitutions();
1143  foreach ($tmparray as $key=>$value)
1144  {
1145  try {
1146  $odfHandler->setVars($key, $value, true, 'UTF-8');
1147  } catch (OdfException $e) {
1148  dol_syslog($e->getMessage(), LOG_INFO);
1149  }
1150  }
1151 
1152  // Call the beforeODTSave hook
1153  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1154  $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1155 
1156 
1157  // Write new file
1158  if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1159  try {
1160  $odfHandler->exportAsAttachedPDF($file);
1161  } catch (Exception $e) {
1162  $this->error = $e->getMessage();
1163  return -1;
1164  }
1165  } else {
1166  try {
1167  $odfHandler->saveToDisk($file);
1168  } catch (Exception $e) {
1169  $this->error = $e->getMessage();
1170  dol_syslog($e->getMessage(), LOG_INFO);
1171  return -1;
1172  }
1173  }
1174  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1175  $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1176 
1177  if (!empty($conf->global->MAIN_UMASK))
1178  @chmod($file, octdec($conf->global->MAIN_UMASK));
1179 
1180  $odfHandler = null; // Destroy object
1181 
1182  $this->result = array('fullpath'=>$file);
1183 
1184  return 1; // Success
1185  } else {
1186  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
1187  return -1;
1188  }
1189  }
1190 
1191  return -1;
1192  }
1193 }
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
Class to manage contact/addresses.
get_substitutionarray_project_reference($refdetail, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=true)
Define array with couple substitution key =&gt; substitution value.
dol_now($mode= 'auto')
Return date for now.
Class to build documents using ODF templates generator.
Class to manage Dolibarr users.
Definition: user.class.php:44
get_substitutionarray_user($user, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
get_substitutionarray_object($object, $outputlangs, $array_key= 'object')
Define array with couple substitution key =&gt; substitution value.
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition: repair.php:108
$conf db
API class for accounts.
Definition: inc.php:54
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
info($langs)
Return description of a module.
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...
get_substitutionarray_project_contacts($contact, $outputlangs)
Define array with couple substitution key =&gt; 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.
get_substitutionarray_contact($object, $outputlangs, $array_key= 'object')
Define array with couple substitution key =&gt; substitution value.
Class to manage generation of HTML components Only common components must be here.
get_substitutionarray_taskstime($tasktime, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
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 =&gt; substitution value.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
get_substitutionarray_thirdparty($object, $outputlangs, $array_key= 'company')
Define array with couple substitution key =&gt; substitution value.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
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:60
get_substitutionarray_project_file($file, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this-&gt;array_options This method is in most cases call...
Class to manage tasks.
Definition: task.class.php:35
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
Fill array with couple extrafield key =&gt; extrafield value.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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 substitution key =&gt; substitution value.
get_substitutionarray_task_file($file, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
get_substitutionarray_tasks(Task $task, $outputlangs)
Define array with couple substitution key =&gt; substitution value.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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
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 &quot;subst...