dolibarr  16.0.5
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)) {
41  require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
42 }
43 if (isModEnabled('facture')) {
44  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
45 }
46 if (isModEnabled('facture')) {
47  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php';
48 }
49 if (!empty($conf->commande->enabled)) {
50  require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
51 }
52 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_invoice->enabled)) {
53  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
54 }
55 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
56  require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
57 }
58 if (!empty($conf->contrat->enabled)) {
59  require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
60 }
61 if (!empty($conf->ficheinter->enabled)) {
62  require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
63 }
64 if (!empty($conf->deplacement->enabled)) {
65  require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
66 }
67 if (isModEnabled('agenda')) {
68  require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
69 }
70 
71 
76 {
81  public $emetteur;
82 
87  public $phpmin = array(5, 6);
88 
93  public $version = 'dolibarr';
94 
95 
101  public function __construct($db)
102  {
103  global $conf, $langs, $mysoc;
104 
105  // Load traductions files required by page
106  $langs->loadLangs(array("companies", "main"));
107 
108  $this->db = $db;
109  $this->name = "ODT templates";
110  $this->description = $langs->trans("DocumentModelOdt");
111  $this->scandir = 'PROJECT_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
112 
113  // Page size for A4 format
114  $this->type = 'odt';
115  $this->page_largeur = 0;
116  $this->page_hauteur = 0;
117  $this->format = array($this->page_largeur, $this->page_hauteur);
118  $this->marge_gauche = 0;
119  $this->marge_droite = 0;
120  $this->marge_haute = 0;
121  $this->marge_basse = 0;
122 
123  $this->option_logo = 1; // Display logo
124  $this->option_tva = 0; // Manage the vat option COMMANDE_TVAOPTION
125  $this->option_modereg = 0; // Display payment mode
126  $this->option_condreg = 0; // Display payment terms
127  $this->option_multilang = 1; // Available in several languages
128  $this->option_escompte = 0; // Displays if there has been a discount
129  $this->option_credit_note = 0; // Support credit notes
130  $this->option_freetext = 1; // Support add of a personalised text
131  $this->option_draft_watermark = 0; // Support add of a watermark on drafts
132 
133  // Get source company
134  $this->emetteur = $mysoc;
135  if (!$this->emetteur->pays_code) {
136  $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
137  }
138  }
139 
140 
141  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
150  public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object')
151  {
152  // phpcs:enable
153  global $conf;
154 
155  $resarray = array(
156  $array_key.'_id'=>$object->id,
157  $array_key.'_ref'=>$object->ref,
158  $array_key.'_title'=>$object->title,
159  $array_key.'_description'=>$object->description,
160  $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'),
161  $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'),
162  $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'),
163  $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'),
164  $array_key.'_note_private'=>$object->note_private,
165  $array_key.'_note_public'=>$object->note_public,
166  $array_key.'_public'=>$object->public,
167  $array_key.'_statut'=>$object->getLibStatut()
168  );
169 
170  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
171  $extrafields = new ExtraFields($this->db);
172  $extrafields->fetch_name_optionals_label($object->table_element, true);
173  $object->fetch_optionals();
174 
175  $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs);
176 
177  return $resarray;
178  }
179 
180  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
188  public function get_substitutionarray_tasks(Task $task, $outputlangs)
189  {
190  // phpcs:enable
191  global $conf;
192 
193  $resarray = array(
194  'task_ref'=>$task->ref,
195  'task_fk_project'=>$task->fk_project,
196  'task_projectref'=>$task->projectref,
197  'task_projectlabel'=>$task->projectlabel,
198  'task_label'=>$task->label,
199  'task_description'=>$task->description,
200  'task_fk_parent'=>$task->fk_parent,
201  'task_duration'=>$task->duration,
202  'task_duration_hour'=>convertSecondToTime($task->duration, 'all'),
203  'task_progress'=>$task->progress,
204  'task_public'=>$task->public,
205  'task_date_start'=>dol_print_date($task->date_start, 'day'),
206  'task_date_end'=>dol_print_date($task->date_end, 'day'),
207  'task_note_private'=>$task->note_private,
208  'task_note_public'=>$task->note_public
209  );
210 
211  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
212  $extrafields = new ExtraFields($this->db);
213  $extrafields->fetch_name_optionals_label($task->table_element, true);
214  $task->fetch_optionals();
215 
216  $resarray = $this->fill_substitutionarray_with_extrafields($task, $resarray, $extrafields, 'task', $outputlangs);
217 
218  return $resarray;
219  }
220 
221  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
229  public function get_substitutionarray_project_contacts($contact, $outputlangs)
230  {
231  // phpcs:enable
232  global $conf;
233  $pc = 'projcontacts_'; // prefix to avoid typos
234 
235  $ret = array(
236  $pc.'id'=>$contact['id'],
237  $pc.'rowid'=>$contact['rowid'],
238  $pc.'role'=>$contact['libelle'],
239  $pc.'lastname'=>$contact['lastname'],
240  $pc.'firstname'=>$contact['firstname'],
241  $pc.'civility'=>$contact['civility'],
242  $pc.'fullcivname'=>$contact['fullname'],
243  $pc.'socname'=>$contact['socname'],
244  $pc.'email'=>$contact['email']
245  );
246 
247  if ($contact['source'] == 'external') {
248  $ret[$pc.'isInternal'] = ''; // not internal
249 
250  $ct = new Contact($this->db);
251  $ct->fetch($contact['id']);
252  $ret[$pc.'phone_pro'] = $ct->phone_pro;
253  $ret[$pc.'phone_perso'] = $ct->phone_perso;
254  $ret[$pc.'phone_mobile'] = $ct->phone_mobile;
255 
256  // fetch external user extrafields
257  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
258  $extrafields = new ExtraFields($this->db);
259  $extrafields->fetch_name_optionals_label($ct->table_element, true);
260  $extrafields_num = $ct->fetch_optionals();
261  //dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: ===== Number of Extrafields found: ".$extrafields_num, LOG_DEBUG);
262  foreach ($ct->array_options as $efkey => $efval) {
263  dol_syslog(get_class($this)."::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey." => ".$efval, LOG_DEBUG);
264  $ret[$pc.$efkey] = $efval; // add nothing else because it already comes as 'options_XX'
265  }
266  } elseif ($contact['source'] == 'internal') {
267  $ret[$pc.'isInternal'] = '1'; // this is an internal user
268 
269  $ct = new User($this->db);
270  $ct->fetch($contact['id']);
271  $ret[$pc.'phone_pro'] = $ct->office_phone;
272  $ret[$pc.'phone_perso'] = '';
273  $ret[$pc.'phone_mobile'] = $ct->user_mobile;
274  // do internal users have extrafields ?
275  }
276  return $ret;
277  }
278 
279  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
287  public function get_substitutionarray_project_file($file, $outputlangs)
288  {
289  // phpcs:enable
290  global $conf;
291 
292  return array(
293  'projfile_name'=>$file['name'],
294  'projfile_date'=>dol_print_date($file['date'], 'day'),
295  'projfile_size'=>$file['size']
296  );
297  }
298 
299  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
307  public function get_substitutionarray_project_reference($refdetail, $outputlangs)
308  {
309  // phpcs:enable
310  global $conf;
311 
312  return array(
313  'projref_type'=>$refdetail['type'],
314  'projref_ref'=>$refdetail['ref'],
315  'projref_date'=>dol_print_date($refdetail['date'], 'day'),
316  'projref_socname'=>$refdetail['socname'],
317  'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs),
318  'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs),
319  'projref_status'=>$refdetail['status']
320  );
321  }
322 
323  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
331  public function get_substitutionarray_tasksressource($taskressource, $outputlangs)
332  {
333  // phpcs:enable
334  global $conf;
335  //dol_syslog(get_class($this).'::get_substitutionarray_tasksressource taskressource='.var_export($taskressource,true),LOG_DEBUG);
336  return array(
337  'taskressource_rowid'=>$taskressource['rowid'],
338  'taskressource_role'=>$taskressource['libelle'],
339  'taskressource_lastname'=>$taskressource['lastname'],
340  'taskressource_firstname'=>$taskressource['firstname'],
341  'taskressource_fullcivname'=>$taskressource['fullname'],
342  'taskressource_socname'=>$taskressource['socname'],
343  'taskressource_email'=>$taskressource['email']
344  );
345  }
346 
347  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
355  public function get_substitutionarray_taskstime($tasktime, $outputlangs)
356  {
357  // phpcs:enable
358  global $conf;
359 
360  return array(
361  'tasktime_rowid'=>$tasktime['rowid'],
362  'tasktime_task_date'=>dol_print_date($tasktime['task_date'], 'day'),
363  'tasktime_task_duration_sec'=>$tasktime['task_duration'],
364  'tasktime_task_duration'=>convertSecondToTime($tasktime['task_duration'], 'all'),
365  'tasktime_note'=>$tasktime['note'],
366  'tasktime_fk_user'=>$tasktime['fk_user'],
367  'tasktime_user_name'=>$tasktime['name'],
368  'tasktime_user_first'=>$tasktime['firstname'],
369  'tasktime_fullcivname'=>$tasktime['fullcivname'],
370  'tasktime_amountht'=>$tasktime['amountht'],
371  'tasktime_amountttc'=>$tasktime['amountttc'],
372  'tasktime_thm'=>$tasktime['thm'],
373  );
374  }
375 
376  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
384  public function get_substitutionarray_task_file($file, $outputlangs)
385  {
386  // phpcs:enable
387  global $conf;
388 
389  return array(
390  'tasksfile_name'=>$file['name'],
391  'tasksfile_date'=>dol_print_date($file['date'], 'day'),
392  'tasksfile_size'=>$file['size']
393  );
394  }
395 
396 
403  public function info($langs)
404  {
405  global $conf, $langs;
406 
407  // Load translation files required by the page
408  $langs->loadLangs(array("companies", "errors"));
409 
410  $form = new Form($this->db);
411 
412  $texte = $this->description.".<br>\n";
413  $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
414  $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
415  $texte .= '<input type="hidden" name="page_y" value="">';
416  $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
417  $texte .= '<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
418  $texte .= '<table class="nobordernopadding" width="100%">';
419 
420  // List of directories area
421  $texte .= '<tr><td>';
422  $texttitle = $langs->trans("ListOfDirectories");
423  $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
424  $listoffiles = array();
425  foreach ($listofdir as $key => $tmpdir) {
426  $tmpdir = trim($tmpdir);
427  $tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
428  if (!$tmpdir) {
429  unset($listofdir[$key]);
430  continue;
431  }
432  if (!is_dir($tmpdir)) {
433  $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
434  } else {
435  $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
436  if (count($tmpfiles)) {
437  $listoffiles = array_merge($listoffiles, $tmpfiles);
438  }
439  }
440  }
441  $texthelp = $langs->trans("ListOfDirectoriesForModelGenODT");
442  // Add list of substitution keys
443  $texthelp .= '<br>'.$langs->trans("FollowingSubstitutionKeysCanBeUsed").'<br>';
444  $texthelp .= $langs->transnoentitiesnoconv("FullListOnOnlineDocumentation"); // This contains an url, we don't modify it
445 
446  $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
447  $texte .= '<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
448  $texte .= '<textarea class="flat" cols="60" name="value1">';
449  $texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
450  $texte .= '</textarea>';
451  $texte .= '</div><div style="display: inline-block; vertical-align: middle;">';
452  $texte .= '<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans("Modify").'">';
453  $texte .= '<br></div></div>';
454 
455  // Scan directories
456  $nbofiles = count($listoffiles);
457  if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) {
458  $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
459  //$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
460  $texte .= $nbofiles;
461  //$texte.=$nbofiles?'</a>':'';
462  $texte .= '</b>';
463  }
464 
465  if ($nbofiles) {
466  $texte .= '<div id="div_'.get_class($this).'" class="hiddenx">';
467  // Show list of found files
468  foreach ($listoffiles as $file) {
469  $texte .= '- '.$file['name'].' <a href="'.DOL_URL_ROOT.'/document.php?modulepart=doctemplates&file=projects/'.urlencode(basename($file['name'])).'">'.img_picto('', 'listlight').'</a><br>';
470  }
471  $texte .= '</div>';
472  }
473 
474  $texte .= '</td>';
475 
476  $texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';
477  $texte .= '<span class="opacitymedium">';
478  $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
479  $texte .= '</span>';
480  $texte .= '</td>';
481  $texte .= '</tr>';
482 
483  $texte .= '</table>';
484  $texte .= '</form>';
485 
486  return $texte;
487  }
488 
489  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
498  public function write_file($object, $outputlangs, $srctemplatepath)
499  {
500  // phpcs:enable
501  global $user, $langs, $conf, $mysoc, $hookmanager;
502 
503  if (empty($srctemplatepath)) {
504  dol_syslog("doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
505  return -1;
506  }
507 
508  // Add odtgeneration hook
509  if (!is_object($hookmanager)) {
510  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
511  $hookmanager = new HookManager($this->db);
512  }
513  $hookmanager->initHooks(array('odtgeneration'));
514  global $action;
515 
516  if (!is_object($outputlangs)) {
517  $outputlangs = $langs;
518  }
519  $sav_charset_output = $outputlangs->charset_output;
520  $outputlangs->charset_output = 'UTF-8';
521 
522  // Load translation files required by the page
523  $outputlangs->loadLangs(array("main", "dict", "companies", "projects"));
524 
525  if ($conf->project->dir_output) {
526  // If $object is id instead of object
527  if (!is_object($object)) {
528  $id = $object;
529  $object = new Project($this->db);
530  $result = $object->fetch($id);
531  if ($result < 0) {
532  dol_print_error($this->db, $object->error);
533  return -1;
534  }
535  }
536 
537  $object->fetch_thirdparty();
538 
539  $dir = $conf->project->dir_output;
540  $objectref = dol_sanitizeFileName($object->ref);
541  if (!preg_match('/specimen/i', $objectref)) {
542  $dir .= "/".$objectref;
543  }
544  $file = $dir."/".$objectref.".odt";
545 
546  if (!file_exists($dir)) {
547  if (dol_mkdir($dir) < 0) {
548  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
549  return -1;
550  }
551  }
552 
553  if (file_exists($dir)) {
554  //print "srctemplatepath=".$srctemplatepath; // Src filename
555  $newfile = basename($srctemplatepath);
556  $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
557  $newfiletmp = preg_replace('/template_/i', '', $newfiletmp);
558  $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp);
559  $newfiletmp = $objectref.'_'.$newfiletmp;
560  //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt';
561  // Get extension (ods or odt)
562  $newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
563  if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
564  $format = $conf->global->MAIN_DOC_USE_TIMING;
565  if ($format == '1') {
566  $format = '%Y%m%d%H%M%S';
567  }
568  $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
569  } else {
570  $filename = $newfiletmp.'.'.$newfileformat;
571  }
572  $file = $dir.'/'.$filename;
573  //print "newdir=".$dir;
574  //print "newfile=".$newfile;
575  //print "file=".$file;
576  //print "conf->societe->dir_temp=".$conf->societe->dir_temp;
577 
578  dol_mkdir($conf->project->dir_temp);
579  if (!is_writable($conf->project->dir_temp)) {
580  $this->error = "Failed to write in temp directory ".$conf->project->dir_temp;
581  dol_syslog('Error in write_file: '.$this->error, LOG_ERR);
582  return -1;
583  }
584 
585  // If PROJECTLEADER contact defined on project, we use it
586  $usecontact = false;
587  $arrayidcontact = $object->getIdContact('external', 'PROJECTLEADER');
588  if (count($arrayidcontact) > 0) {
589  $usecontact = true;
590  $result = $object->fetch_contact($arrayidcontact[0]);
591  }
592 
593  // Recipient name
594  $contactobject = null;
595  if (!empty($usecontact)) {
596  // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use
597  $contactobject = $object->contact;
598  }
599 
600  $socobject = $object->thirdparty;
601 
602  // Make substitution
603  $substitutionarray = array(
604  '__FROM_NAME__' => $this->emetteur->name,
605  '__FROM_EMAIL__' => $this->emetteur->email,
606  );
607  complete_substitutions_array($substitutionarray, $langs, $object);
608  // Call the ODTSubstitution hook
609  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$substitutionarray);
610  $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
611 
612  // Open and load template
613  require_once ODTPHP_PATH.'odf.php';
614  try {
615  $odfHandler = new odf(
616  $srctemplatepath,
617  array(
618  'PATH_TO_TMP' => $conf->project->dir_temp,
619  'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
620  'DELIMITER_LEFT' => '{',
621  'DELIMITER_RIGHT' => '}'
622  )
623  );
624  } catch (Exception $e) {
625  $this->error = $e->getMessage();
626  dol_syslog($e->getMessage(), LOG_INFO);
627  return -1;
628  }
629  // After construction $odfHandler->contentXml contains content and
630  // [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
631  // [!-- BEGIN lines --]*[!-- END lines --]
632  //print html_entity_decode($odfHandler->__toString());
633  //print exit;
634 
635 
636  // Define substitution array
637  $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
638  $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
639  $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
640  $array_user = $this->get_substitutionarray_user($user, $outputlangs);
641  $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
642  $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
643  $array_other = $this->get_substitutionarray_other($outputlangs);
644  // retrieve contact information for use in object as contact_xxx tags
645  $array_project_contact = array();
646  if ($usecontact && is_object($contactobject)) {
647  $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
648  }
649 
650  $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
651  complete_substitutions_array($tmparray, $outputlangs, $object);
652 
653  // Call the ODTSubstitution hook
654  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
655  $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
656 
657  foreach ($tmparray as $key => $value) {
658  try {
659  if (preg_match('/logo$/', $key)) { // Image
660  if (file_exists($value)) {
661  $odfHandler->setImage($key, $value);
662  } else {
663  $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
664  }
665  } else // Text
666  {
667  $odfHandler->setVars($key, $value, true, 'UTF-8');
668  }
669  } catch (OdfException $e) {
670  dol_syslog($e->getMessage(), LOG_INFO);
671  }
672  }
673 
674  // Replace tags of lines for tasks
675  try {
676  $listlines = $odfHandler->setSegment('tasks');
677 
678  $taskstatic = new Task($this->db);
679 
680  // Security check
681  $socid = 0;
682  if (!empty($object->fk_soc)) {
683  $socid = $object->fk_soc;
684  }
685 
686  $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
687 
688 
689  foreach ($tasksarray as $task) {
690  $tmparray = $this->get_substitutionarray_tasks($task, $outputlangs);
691  //complete_substitutions_array($tmparray, $outputlangs, $object, $task, "completesubstitutionarray_lines");
692  foreach ($tmparray as $key => $val) {
693  try {
694  $listlines->setVars($key, $val, true, 'UTF-8');
695  } catch (OdfException $e) {
696  dol_syslog($e->getMessage(), LOG_INFO);
697  } catch (SegmentException $e) {
698  dol_syslog($e->getMessage(), LOG_INFO);
699  }
700  }
701 
702  $taskobj = new Task($this->db);
703  $taskobj->fetch($task->id);
704 
705  // Replace tags of lines for contacts task
706  $sourcearray = array('internal', 'external');
707  $contact_arrray = array();
708  foreach ($sourcearray as $source) {
709  $contact_temp = $taskobj->liste_contact(-1, $source);
710  if ((is_array($contact_temp) && count($contact_temp) > 0)) {
711  $contact_arrray = array_merge($contact_arrray, $contact_temp);
712  }
713  }
714  if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
715  $listlinestaskres = $listlines->__get('tasksressources');
716 
717  foreach ($contact_arrray as $contact) {
718  if ($contact['source'] == 'internal') {
719  $objectdetail = new User($this->db);
720  $objectdetail->fetch($contact['id']);
721  $contact['socname'] = $mysoc->name;
722  } elseif ($contact['source'] == 'external') {
723  $objectdetail = new Contact($this->db);
724  $objectdetail->fetch($contact['id']);
725 
726  $soc = new Societe($this->db);
727  $soc->fetch($contact['socid']);
728  $contact['socname'] = $soc->name;
729  }
730  $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
731 
732  $tmparray = $this->get_substitutionarray_tasksressource($contact, $outputlangs);
733 
734  foreach ($tmparray as $key => $val) {
735  try {
736  $listlinestaskres->setVars($key, $val, true, 'UTF-8');
737  } catch (OdfException $e) {
738  dol_syslog($e->getMessage(), LOG_INFO);
739  } catch (SegmentException $e) {
740  dol_syslog($e->getMessage(), LOG_INFO);
741  }
742  }
743  $listlinestaskres->merge();
744  }
745  }
746 
747  //Time ressources
748  $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
749  $sql .= ", u.lastname, u.firstname, t.thm";
750  $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t";
751  $sql .= " , ".MAIN_DB_PREFIX."user as u";
752  $sql .= " WHERE t.fk_task =".((int) $task->id);
753  $sql .= " AND t.fk_user = u.rowid";
754  $sql .= " ORDER BY t.task_date DESC";
755 
756  $resql = $this->db->query($sql);
757  if ($resql) {
758  $num = $this->db->num_rows($resql);
759  $i = 0;
760  $tasks = array();
761  $row = array();
762  $listlinestasktime = $listlines->__get('taskstimes');
763  if (empty($num)) {
764  $row['rowid'] = '';
765  $row['task_date'] = '';
766  $row['task_duration'] = '';
767  $row['$tasktime'] = '';
768  $row['note'] = '';
769  $row['fk_user'] = '';
770  $row['name'] = '';
771  $row['firstname'] = '';
772  $row['fullcivname'] = '';
773  $row['amountht'] = '';
774  $row['amountttc'] = '';
775  $row['thm'] = '';
776  $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
777  foreach ($tmparray as $key => $val) {
778  try {
779  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
780  } catch (OdfException $e) {
781  dol_syslog($e->getMessage(), LOG_INFO);
782  } catch (SegmentException $e) {
783  dol_syslog($e->getMessage(), LOG_INFO);
784  }
785  }
786  $listlinestasktime->merge();
787  }
788  while ($i < $num) {
789  $row = $this->db->fetch_array($resql);
790  if (!empty($row['fk_user'])) {
791  $objectdetail = new User($this->db);
792  $objectdetail->fetch($row['fk_user']);
793  $row['fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
794  } else {
795  $row['fullcivname'] = '';
796  }
797 
798  if (!empty($row['thm'])) {
799  $row['amountht'] = ($row['task_duration'] / 3600) * $row['thm'];
800  $defaultvat = get_default_tva($mysoc, $mysoc);
801  $row['amountttc'] = price2num($row['amountht'] * (1 + ($defaultvat / 100)), 'MT');
802  } else {
803  $row['amountht'] = 0;
804  $row['amountttc'] = 0;
805  $row['thm'] = 0;
806  }
807 
808  $tmparray = $this->get_substitutionarray_taskstime($row, $outputlangs);
809 
810  foreach ($tmparray as $key => $val) {
811  try {
812  $listlinestasktime->setVars($key, $val, true, 'UTF-8');
813  } catch (OdfException $e) {
814  dol_syslog($e->getMessage(), LOG_INFO);
815  } catch (SegmentException $e) {
816  dol_syslog($e->getMessage(), LOG_INFO);
817  }
818  }
819  $listlinestasktime->merge();
820  $i++;
821  }
822  $this->db->free($resql);
823  }
824 
825 
826  // Replace tags of project files
827  $listtasksfiles = $listlines->__get('tasksfiles');
828 
829  $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref);
830  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
831 
832 
833  foreach ($filearray as $filedetail) {
834  $tmparray = $this->get_substitutionarray_task_file($filedetail, $outputlangs);
835  //dol_syslog(get_class($this).'::main $tmparray'.var_export($tmparray,true));
836  foreach ($tmparray as $key => $val) {
837  try {
838  $listtasksfiles->setVars($key, $val, true, 'UTF-8');
839  } catch (OdfException $e) {
840  dol_syslog($e->getMessage(), LOG_INFO);
841  } catch (SegmentException $e) {
842  dol_syslog($e->getMessage(), LOG_INFO);
843  }
844  }
845  $listtasksfiles->merge();
846  }
847  $listlines->merge();
848  }
849  $odfHandler->mergeSegment($listlines);
850  } catch (OdfException $e) {
851  $ExceptionTrace = $e->getTrace();
852  // no segment defined on ODT is not an error
853  if ($ExceptionTrace[0]['function'] != 'setSegment') {
854  $this->error = $e->getMessage();
855  dol_syslog($this->error, LOG_WARNING);
856  return -1;
857  }
858  }
859 
860  // Replace tags of project files
861  try {
862  $listlines = $odfHandler->setSegment('projectfiles');
863 
864  $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref);
865  $filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', 'name', SORT_ASC, 1);
866 
867  foreach ($filearray as $filedetail) {
868  //dol_syslog(get_class($this).'::main $filedetail'.var_export($filedetail,true));
869  $tmparray = $this->get_substitutionarray_project_file($filedetail, $outputlangs);
870 
871  foreach ($tmparray as $key => $val) {
872  try {
873  $listlines->setVars($key, $val, true, 'UTF-8');
874  } catch (OdfException $e) {
875  dol_syslog($e->getMessage(), LOG_INFO);
876  } catch (SegmentException $e) {
877  dol_syslog($e->getMessage(), LOG_INFO);
878  }
879  }
880  $listlines->merge();
881  }
882  $odfHandler->mergeSegment($listlines);
883  } catch (OdfException $e) {
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  $contact_arrray = array_merge($contact_arrray, $contact_temp);
896  }
897  }
898  if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
899  try {
900  $listlines = $odfHandler->setSegment('projectcontacts');
901 
902  foreach ($contact_arrray as $contact) {
903  if ($contact['source'] == 'internal') {
904  $objectdetail = new User($this->db);
905  $objectdetail->fetch($contact['id']);
906  $contact['socname'] = $mysoc->name;
907  } elseif ($contact['source'] == 'external') {
908  $objectdetail = new Contact($this->db);
909  $objectdetail->fetch($contact['id']);
910 
911  $soc = new Societe($this->db);
912  $soc->fetch($contact['socid']);
913  $contact['socname'] = $soc->name;
914  }
915  $contact['fullname'] = $objectdetail->getFullName($outputlangs, 1);
916 
917  $tmparray = $this->get_substitutionarray_project_contacts($contact, $outputlangs);
918  foreach ($tmparray as $key => $val) {
919  try {
920  $listlines->setVars($key, $val, true, 'UTF-8');
921  } catch (OdfException $e) {
922  dol_syslog($e->getMessage(), LOG_INFO);
923  } catch (SegmentException $e) {
924  dol_syslog($e->getMessage(), LOG_INFO);
925  }
926  }
927  $listlines->merge();
928  }
929  $odfHandler->mergeSegment($listlines);
930  } catch (OdfException $e) {
931  $this->error = $e->getMessage();
932  dol_syslog($this->error, LOG_WARNING);
933  return -1;
934  }
935  }
936 
937  //List of referent
938 
939  $listofreferent = array(
940  'propal' => array(
941  'title' => "ListProposalsAssociatedProject",
942  'class' => 'Propal',
943  'table' => 'propal',
944  'test' => $conf->propal->enabled && $user->rights->propale->lire
945  ),
946  'order' => array(
947  'title' => "ListOrdersAssociatedProject",
948  'class' => 'Commande',
949  'table' => 'commande',
950  'test' => $conf->commande->enabled && $user->rights->commande->lire
951  ),
952  'invoice' => array(
953  'title' => "ListInvoicesAssociatedProject",
954  'class' => 'Facture',
955  'table' => 'facture',
956  'test' => $conf->facture->enabled && $user->rights->facture->lire
957  ),
958  'invoice_predefined' => array(
959  'title' => "ListPredefinedInvoicesAssociatedProject",
960  'class' => 'FactureRec',
961  'table' => 'facture_rec',
962  'test' => $conf->facture->enabled && $user->rights->facture->lire
963  ),
964  'proposal_supplier' => array(
965  'title' => "ListSupplierProposalsAssociatedProject",
966  'class' => 'SupplierProposal',
967  'table' => 'supplier_proposal',
968  'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
969  ),
970  'order_supplier' => array(
971  'title' => "ListSupplierOrdersAssociatedProject",
972  'table' => 'commande_fournisseur',
973  'class' => 'CommandeFournisseur',
974  'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (!empty($conf->supplier_order->enabled) && $user->rights->supplier_order->lire)
975  ),
976  'invoice_supplier' => array(
977  'title' => "ListSupplierInvoicesAssociatedProject",
978  'table' => 'facture_fourn',
979  'class' => 'FactureFournisseur',
980  'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (!empty($conf->supplier_invoice->enabled) && $user->rights->supplier_invoice->lire)
981  ),
982  'contract' => array(
983  'title' => "ListContractAssociatedProject",
984  'class' => 'Contrat',
985  'table' => 'contrat',
986  'test' => $conf->contrat->enabled && $user->rights->contrat->lire
987  ),
988  'intervention' => array(
989  'title' => "ListFichinterAssociatedProject",
990  'class' => 'Fichinter',
991  'table' => 'fichinter',
992  'disableamount' => 1,
993  'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
994  ),
995  'shipping' => array(
996  'title' => "ListShippingAssociatedProject",
997  'class' => 'Expedition',
998  'table' => 'expedition',
999  'disableamount' => 1,
1000  'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1001  ),
1002  'trip' => array(
1003  'title' => "ListTripAssociatedProject",
1004  'class' => 'Deplacement',
1005  'table' => 'deplacement',
1006  'disableamount' => 1,
1007  'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1008  ),
1009  'expensereport' => array(
1010  'title' => "ListExpenseReportsAssociatedProject",
1011  'class' => 'ExpenseReportLine',
1012  'table' => 'expensereport_det',
1013  'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1014  ),
1015  'donation' => array(
1016  'title' => "ListDonationsAssociatedProject",
1017  'class' => 'Don',
1018  'table' => 'don',
1019  'test' => $conf->don->enabled && $user->rights->don->lire
1020  ),
1021  'loan' => array(
1022  'title' => "ListLoanAssociatedProject",
1023  'class' => 'Loan',
1024  'table' => 'loan',
1025  'test' => $conf->loan->enabled && $user->rights->loan->read
1026  ),
1027  'chargesociales' => array(
1028  'title' => "ListSocialContributionAssociatedProject",
1029  'class' => 'ChargeSociales',
1030  'table' => 'chargesociales',
1031  'urlnew' => DOL_URL_ROOT.'/compta/sociales/card.php?action=create&projectid='.$object->id,
1032  'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1033  ),
1034  'stock_mouvement' => array(
1035  'title' => "ListMouvementStockProject",
1036  'class' => 'MouvementStock',
1037  'table' => 'stock_mouvement',
1038  'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1039  ),
1040  'agenda' => array(
1041  'title' => "ListActionsAssociatedProject",
1042  'class' => 'ActionComm',
1043  'table' => 'actioncomm',
1044  'disableamount' => 1,
1045  'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1046  ),
1047  );
1048 
1049  //Insert reference
1050  try {
1051  $listlines = $odfHandler->setSegment('projectrefs');
1052 
1053  foreach ($listofreferent as $keyref => $valueref) {
1054  $title = $valueref['title'];
1055  $tablename = $valueref['table'];
1056  $classname = $valueref['class'];
1057  $qualified = $valueref['test'];
1058  if ($qualified) {
1059  $elementarray = $object->get_element_list($keyref, $tablename);
1060  if (count($elementarray) > 0 && is_array($elementarray)) {
1061  $total_ht = 0;
1062  $total_ttc = 0;
1063  $num = count($elementarray);
1064  for ($i = 0; $i < $num; $i++) {
1065  $ref_array = array();
1066  $ref_array['type'] = $langs->trans($classname);
1067 
1068  $element = new $classname($this->db);
1069  $element->fetch($elementarray[$i]);
1070  $element->fetch_thirdparty();
1071 
1072  //Ref object
1073  $ref_array['ref'] = $element->ref;
1074 
1075  //Date object
1076  $dateref = $element->date;
1077  if (empty($dateref)) {
1078  $dateref = $element->datep;
1079  }
1080  if (empty($dateref)) {
1081  $dateref = $element->date_contrat;
1082  }
1083  $ref_array['date'] = $dateref;
1084 
1085  //Soc object
1086  if (is_object($element->thirdparty)) {
1087  $ref_array['socname'] = $element->thirdparty->name;
1088  } else {
1089  $ref_array['socname'] = '';
1090  }
1091 
1092  //Amount object
1093  if (empty($valueref['disableamount'])) {
1094  if (!empty($element->total_ht)) {
1095  $ref_array['amountht'] = $element->total_ht;
1096  $ref_array['amountttc'] = $element->total_ttc;
1097  } else {
1098  $ref_array['amountht'] = 0;
1099  $ref_array['amountttc'] = 0;
1100  }
1101  } else {
1102  $ref_array['amountht'] = '';
1103  $ref_array['amountttc'] = '';
1104  }
1105 
1106  $ref_array['status'] = $element->getLibStatut(0);
1107 
1108  $tmparray = $this->get_substitutionarray_project_reference($ref_array, $outputlangs);
1109 
1110  foreach ($tmparray as $key => $val) {
1111  try {
1112  $listlines->setVars($key, $val, true, 'UTF-8');
1113  } catch (OdfException $e) {
1114  dol_syslog($e->getMessage(), LOG_INFO);
1115  } catch (SegmentException $e) {
1116  dol_syslog($e->getMessage(), LOG_INFO);
1117  }
1118  }
1119  $listlines->merge();
1120  }
1121  }
1122  }
1123  $odfHandler->mergeSegment($listlines);
1124  }
1125  } catch (OdfException $e) {
1126  $this->error = $e->getMessage();
1127  dol_syslog($this->error, LOG_WARNING);
1128  return -1;
1129  }
1130 
1131  // Replace labels translated
1132  $tmparray = $outputlangs->get_translations_for_substitutions();
1133  foreach ($tmparray as $key => $value) {
1134  try {
1135  $odfHandler->setVars($key, $value, true, 'UTF-8');
1136  } catch (OdfException $e) {
1137  dol_syslog($e->getMessage(), LOG_INFO);
1138  }
1139  }
1140 
1141  // Call the beforeODTSave hook
1142  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1143  $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1144 
1145 
1146  // Write new file
1147  if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1148  try {
1149  $odfHandler->exportAsAttachedPDF($file);
1150  } catch (Exception $e) {
1151  $this->error = $e->getMessage();
1152  return -1;
1153  }
1154  } else {
1155  try {
1156  $odfHandler->saveToDisk($file);
1157  } catch (Exception $e) {
1158  $this->error = $e->getMessage();
1159  dol_syslog($e->getMessage(), LOG_INFO);
1160  return -1;
1161  }
1162  }
1163  $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
1164  $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1165 
1166  if (!empty($conf->global->MAIN_UMASK)) {
1167  @chmod($file, octdec($conf->global->MAIN_UMASK));
1168  }
1169 
1170  $odfHandler = null; // Destroy object
1171 
1172  $this->result = array('fullpath'=>$file);
1173 
1174  return 1; // Success
1175  } else {
1176  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
1177  return -1;
1178  }
1179  }
1180 
1181  return -1;
1182  }
1183 }
doc_generic_project_odt\get_substitutionarray_project_reference
get_substitutionarray_project_reference($refdetail, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:307
Societe
Class to manage third parties objects (customers, suppliers, prospects...)
Definition: societe.class.php:48
db
$conf db
API class for accounts.
Definition: inc.php:41
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1212
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
Project
Class to manage projects.
Definition: project.class.php:35
doc_generic_project_odt\info
info($langs)
Return description of a module.
Definition: doc_generic_project_odt.modules.php:403
doc_generic_project_odt\get_substitutionarray_task_file
get_substitutionarray_task_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:384
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4830
CommonDocGenerator\get_substitutionarray_user
get_substitutionarray_user($user, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: commondocgenerator.class.php:108
img_warning
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
Definition: functions.lib.php:4507
doc_generic_project_odt\get_substitutionarray_project_contacts
get_substitutionarray_project_contacts($contact, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:229
Task
Class to manage tasks.
Definition: task.class.php:37
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
dol_dir_list
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
name
$conf db name
Definition: repair.php:122
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5647
doc_generic_project_odt\write_file
write_file($object, $outputlangs, $srctemplatepath)
Function to build a document on disk using the generic odt module.
Definition: doc_generic_project_odt.modules.php:498
convertSecondToTime
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:236
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2500
CommonDocGenerator\get_substitutionarray_contact
get_substitutionarray_contact($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
Definition: commondocgenerator.class.php:321
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3866
Exception
CommonDocGenerator\fill_substitutionarray_with_extrafields
fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
Fill array with couple extrafield key => extrafield value.
Definition: commondocgenerator.class.php:885
CommonDocGenerator\get_substitutionarray_thirdparty
get_substitutionarray_thirdparty($object, $outputlangs, $array_key='company')
Define array with couple substitution key => substitution value For example {company_name},...
Definition: commondocgenerator.class.php:256
CommonDocGenerator\get_substitutionarray_each_var_object
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=1)
Define array with couple substitution key => substitution value.
Definition: commondocgenerator.class.php:841
getCommonSubstitutionArray
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
Definition: functions.lib.php:7261
doc_generic_project_odt\__construct
__construct($db)
Constructor.
Definition: doc_generic_project_odt.modules.php:101
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1589
Contact
Class to manage contact/addresses.
Definition: contact.class.php:40
CommonDocGenerator\get_substitutionarray_mysoc
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: commondocgenerator.class.php:197
get_default_tva
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) VAT...
Definition: functions.lib.php:6290
doc_generic_project_odt
Class to build documents using ODF templates generator.
Definition: doc_generic_project_odt.modules.php:75
doc_generic_project_odt\get_substitutionarray_taskstime
get_substitutionarray_taskstime($tasktime, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:355
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
User
Class to manage Dolibarr users.
Definition: user.class.php:44
doc_generic_project_odt\get_substitutionarray_tasksressource
get_substitutionarray_tasksressource($taskressource, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:331
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2831
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
doc_generic_project_odt\get_substitutionarray_project_file
get_substitutionarray_project_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:287
price
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.
Definition: functions.lib.php:5527
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6589
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
ModelePDFProjects
Parent class for projects models.
Definition: modules_project.php:32
doc_generic_project_odt\get_substitutionarray_tasks
get_substitutionarray_tasks(Task $task, $outputlangs)
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:188
doc_generic_project_odt\get_substitutionarray_object
get_substitutionarray_object($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
Definition: doc_generic_project_odt.modules.php:150
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30
complete_substitutions_array
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...
Definition: functions.lib.php:7947
CommonDocGenerator\get_substitutionarray_other
get_substitutionarray_other($outputlangs)
Define array with couple substitution key => substitution value.
Definition: commondocgenerator.class.php:379