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';
41 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
44 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
52 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_invoice")) {
53 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
55 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
56 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
59 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
62 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
65 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
71 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
89 public $phpmin = array(7, 0);
95 public $version =
'dolibarr';
105 global $conf, $langs, $mysoc;
108 $langs->loadLangs(array(
"companies",
"main"));
111 $this->
name =
"ODT templates";
112 $this->
description = $langs->trans(
"DocumentModelOdt");
113 $this->scandir =
'PROJECT_ADDON_PDF_ODT_PATH';
117 $this->page_largeur = 0;
118 $this->page_hauteur = 0;
119 $this->format = array($this->page_largeur, $this->page_hauteur);
120 $this->marge_gauche = 0;
121 $this->marge_droite = 0;
122 $this->marge_haute = 0;
123 $this->marge_basse = 0;
125 $this->option_logo = 1;
126 $this->option_tva = 0;
127 $this->option_modereg = 0;
128 $this->option_condreg = 0;
129 $this->option_multilang = 1;
130 $this->option_escompte = 0;
131 $this->option_credit_note = 0;
132 $this->option_freetext = 1;
133 $this->option_draft_watermark = 0;
136 $this->emetteur = $mysoc;
137 if (!$this->emetteur->country_code) {
138 $this->emetteur->country_code = substr($langs->defaultlang, -2);
158 $array_key.
'_id'=>$object->id,
159 $array_key.
'_ref'=>$object->ref,
160 $array_key.
'_title'=>$object->title,
161 $array_key.
'_description'=>$object->description,
162 $array_key.
'_date_creation'=>
dol_print_date($object->date_c,
'day'),
163 $array_key.
'_date_modification'=>
dol_print_date($object->date_m,
'day'),
164 $array_key.
'_date_start'=>
dol_print_date($object->date_start,
'day'),
166 $array_key.
'_note_private'=>$object->note_private,
167 $array_key.
'_note_public'=>$object->note_public,
168 $array_key.
'_public'=>$object->public,
169 $array_key.
'_statut'=>$object->getLibStatut()
172 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
174 $extrafields->fetch_name_optionals_label($object->table_element,
true);
175 $object->fetch_optionals();
196 'task_ref'=>$task->ref,
197 'task_fk_project'=>$task->fk_project,
198 'task_projectref'=>$task->projectref,
199 'task_projectlabel'=>$task->projectlabel,
200 'task_label'=>$task->label,
201 'task_description'=>$task->description,
202 'task_fk_parent'=>$task->fk_parent,
203 'task_duration'=>$task->duration,
205 'task_progress'=>$task->progress,
206 'task_public'=>$task->public,
209 'task_note_private'=>$task->note_private,
210 'task_note_public'=>$task->note_public
213 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
215 $extrafields->fetch_name_optionals_label($task->table_element,
true);
216 $task->fetch_optionals();
235 $pc =
'projcontacts_';
238 $pc.
'id'=>$contact[
'id'],
239 $pc.
'rowid'=>$contact[
'rowid'],
240 $pc.
'role'=>$contact[
'libelle'],
241 $pc.
'lastname'=>$contact[
'lastname'],
242 $pc.
'firstname'=>$contact[
'firstname'],
243 $pc.
'civility'=>$contact[
'civility'],
244 $pc.
'fullcivname'=>$contact[
'fullname'],
245 $pc.
'socname'=>$contact[
'socname'],
246 $pc.
'email'=>$contact[
'email']
249 if ($contact[
'source'] ==
'external') {
250 $ret[$pc.
'isInternal'] =
'';
253 $ct->fetch($contact[
'id']);
254 $ret[$pc.
'phone_pro'] = $ct->phone_pro;
255 $ret[$pc.
'phone_perso'] = $ct->phone_perso;
256 $ret[$pc.
'phone_mobile'] = $ct->phone_mobile;
259 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
261 $extrafields->fetch_name_optionals_label($ct->table_element,
true);
262 $extrafields_num = $ct->fetch_optionals();
264 foreach ($ct->array_options as $efkey => $efval) {
265 dol_syslog(get_class($this).
"::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey.
" => ".$efval, LOG_DEBUG);
266 $ret[$pc.$efkey] = $efval;
268 } elseif ($contact[
'source'] ==
'internal') {
269 $ret[$pc.
'isInternal'] =
'1';
271 $ct =
new User($this->
db);
272 $ct->fetch($contact[
'id']);
273 $ret[$pc.
'phone_pro'] = $ct->office_phone;
274 $ret[$pc.
'phone_perso'] =
'';
275 $ret[$pc.
'phone_mobile'] = $ct->user_mobile;
295 'projfile_name'=>$file[
'name'],
297 'projfile_size'=>$file[
'size']
315 'projref_type'=>$refdetail[
'type'],
316 'projref_ref'=>$refdetail[
'ref'],
318 'projref_socname'=>$refdetail[
'socname'],
319 'projref_amountht'=>
price($refdetail[
'amountht'], 0, $outputlangs),
320 'projref_amountttc'=>
price($refdetail[
'amountttc'], 0, $outputlangs),
321 'projref_status'=>$refdetail[
'status']
339 'taskressource_rowid'=>$taskressource[
'rowid'],
340 'taskressource_role'=>$taskressource[
'libelle'],
341 'taskressource_lastname'=>$taskressource[
'lastname'],
342 'taskressource_firstname'=>$taskressource[
'firstname'],
343 'taskressource_fullcivname'=>$taskressource[
'fullname'],
344 'taskressource_socname'=>$taskressource[
'socname'],
345 'taskressource_email'=>$taskressource[
'email']
363 'tasktime_rowid'=>$tasktime[
'rowid'],
364 'tasktime_task_date'=>
dol_print_date($tasktime[
'task_date'],
'day'),
365 'tasktime_task_duration_sec'=>$tasktime[
'task_duration'],
367 'tasktime_note'=>$tasktime[
'note'],
368 'tasktime_fk_user'=>$tasktime[
'fk_user'],
369 'tasktime_user_name'=>$tasktime[
'name'],
370 'tasktime_user_first'=>$tasktime[
'firstname'],
371 'tasktime_fullcivname'=>$tasktime[
'fullcivname'],
372 'tasktime_amountht'=>$tasktime[
'amountht'],
373 'tasktime_amountttc'=>$tasktime[
'amountttc'],
374 'tasktime_thm'=>$tasktime[
'thm'],
392 'tasksfile_name'=>$file[
'name'],
394 'tasksfile_size'=>$file[
'size']
407 global $conf, $langs;
410 $langs->loadLangs(array(
"companies",
"errors"));
415 $texte .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
416 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
417 $texte .=
'<input type="hidden" name="page_y" value="">';
418 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
419 $texte .=
'<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
420 $texte .=
'<table class="nobordernopadding" width="100%">';
423 $texte .=
'<tr><td>';
424 $texttitle = $langs->trans(
"ListOfDirectories");
425 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
426 $listoffiles = array();
427 foreach ($listofdir as $key => $tmpdir) {
428 $tmpdir = trim($tmpdir);
429 $tmpdir = preg_replace(
'/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
431 unset($listofdir[$key]);
434 if (!is_dir($tmpdir)) {
435 $texttitle .=
img_warning($langs->trans(
"ErrorDirNotFound", $tmpdir), 0);
437 $tmpfiles =
dol_dir_list($tmpdir,
'files', 0,
'\.(ods|odt)');
438 if (count($tmpfiles)) {
439 $listoffiles = array_merge($listoffiles, $tmpfiles);
443 $texthelp = $langs->trans(
"ListOfDirectoriesForModelGenODT");
445 $texthelp .=
'<br>'.$langs->trans(
"FollowingSubstitutionKeysCanBeUsed").
'<br>';
446 $texthelp .= $langs->transnoentitiesnoconv(
"FullListOnOnlineDocumentation");
448 $texte .=
$form->textwithpicto($texttitle, $texthelp, 1,
'help',
'', 1);
449 $texte .=
'<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
450 $texte .=
'<textarea class="flat" cols="60" name="value1">';
451 $texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
452 $texte .=
'</textarea>';
453 $texte .=
'</div><div style="display: inline-block; vertical-align: middle;">';
454 $texte .=
'<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans(
"Modify").
'">';
455 $texte .=
'<br></div></div>';
458 $nbofiles = count($listoffiles);
459 if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) {
460 $texte .= $langs->trans(
"NumberOfModelFilesFound").
': <b>';
468 $texte .=
'<div id="div_'.get_class($this).
'" class="hiddenx">';
470 foreach ($listoffiles as $file) {
471 $texte .=
'- '.$file[
'name'].
' <a href="'.DOL_URL_ROOT.
'/document.php?modulepart=doctemplates&file=projects/'.urlencode(basename($file[
'name'])).
'">'.
img_picto(
'',
'listlight').
'</a>';
472 $texte .=
' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?modulepart=doctemplates&keyforuploaddir=PROJECT_ADDON_PDF_ODT_PATH&action=deletefile&token='.
newToken().
'&file='.urlencode(basename($file[
'name'])).
'">'.
img_picto(
'',
'delete').
'</a>';
480 $texte .=
'<td rowspan="2" class="tdtop hideonsmartphone">';
481 $texte .=
'<span class="opacitymedium">';
482 $texte .= $langs->trans(
"ExampleOfDirectoriesForModelGen");
487 $texte .=
'</table>';
502 public function write_file($object, $outputlangs, $srctemplatepath)
505 global $user, $langs, $conf, $mysoc, $hookmanager;
507 if (empty($srctemplatepath)) {
508 dol_syslog(
"doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
513 if (!is_object($hookmanager)) {
514 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
517 $hookmanager->initHooks(array(
'odtgeneration'));
520 if (!is_object($outputlangs)) {
521 $outputlangs = $langs;
523 $sav_charset_output = $outputlangs->charset_output;
524 $outputlangs->charset_output =
'UTF-8';
527 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"projects"));
529 if ($conf->project->dir_output) {
531 if (!is_object($object)) {
534 $result = $object->fetch($id);
541 $object->fetch_thirdparty();
543 $dir = $conf->project->dir_output;
545 if (!preg_match(
'/specimen/i', $objectref)) {
546 $dir .=
"/".$objectref;
548 $file = $dir.
"/".$objectref.
".odt";
550 if (!file_exists($dir)) {
552 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
557 if (file_exists($dir)) {
559 $newfile = basename($srctemplatepath);
560 $newfiletmp = preg_replace(
'/\.od[ts]/i',
'', $newfile);
561 $newfiletmp = preg_replace(
'/template_/i',
'', $newfiletmp);
562 $newfiletmp = preg_replace(
'/modele_/i',
'', $newfiletmp);
563 $newfiletmp = $objectref .
'_' . $newfiletmp;
566 $newfileformat = substr($newfile, strrpos($newfile,
'.') + 1);
567 if (!empty($conf->global->MAIN_DOC_USE_TIMING)) {
568 $format = $conf->global->MAIN_DOC_USE_TIMING;
569 if ($format ==
'1') {
570 $format =
'%Y%m%d%H%M%S';
574 $filename = $newfiletmp .
'.' . $newfileformat;
576 $file = $dir .
'/' . $filename;
583 if (!is_writable($conf->project->dir_temp)) {
584 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp);
585 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
591 $arrayidcontact = $object->getIdContact(
'external',
'PROJECTLEADER');
592 if (count($arrayidcontact) > 0) {
594 $result = $object->fetch_contact($arrayidcontact[0]);
598 $contactobject =
null;
599 if (!empty($usecontact)) {
601 $contactobject = $object->contact;
604 $socobject = $object->thirdparty;
607 $substitutionarray = array(
608 '__FROM_NAME__' => $this->emetteur->name,
609 '__FROM_EMAIL__' => $this->emetteur->email,
613 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$substitutionarray);
614 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
617 require_once ODTPHP_PATH.
'odf.php';
619 $odfHandler =
new odf(
622 'PATH_TO_TMP' => $conf->project->dir_temp,
623 'ZIP_PROXY' =>
'PclZipProxy',
624 'DELIMITER_LEFT' =>
'{',
625 'DELIMITER_RIGHT' =>
'}'
629 $this->error = $e->getMessage();
649 $array_project_contact = array();
650 if ($usecontact && is_object($contactobject)) {
654 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
658 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
659 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
661 foreach ($tmparray as $key => $value) {
663 if (preg_match(
'/logo$/', $key)) {
664 if (file_exists($value)) {
665 $odfHandler->setImage($key, $value);
667 $odfHandler->setVars($key,
'ErrorFileNotFound',
true,
'UTF-8');
671 $odfHandler->setVars($key, $value,
true,
'UTF-8');
673 }
catch (OdfException $e) {
680 $listlines = $odfHandler->setSegment(
'tasks');
682 $taskstatic =
new Task($this->
db);
686 if (!empty($object->fk_soc)) {
687 $socid = $object->fk_soc;
690 $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
693 foreach ($tasksarray as $task) {
696 foreach ($tmparray as $key => $val) {
698 $listlines->setVars($key, $val,
true,
'UTF-8');
699 }
catch (OdfException $e) {
701 }
catch (SegmentException $e) {
706 $taskobj =
new Task($this->
db);
707 $taskobj->fetch($task->id);
710 $sourcearray = array(
'internal',
'external');
711 $contact_arrray = array();
712 foreach ($sourcearray as $source) {
713 $contact_temp = $taskobj->liste_contact(-1, $source);
714 if ((is_array($contact_temp) && count($contact_temp) > 0)) {
715 $contact_arrray = array_merge($contact_arrray, $contact_temp);
718 if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
719 $listlinestaskres = $listlines->__get(
'tasksressources');
721 foreach ($contact_arrray as $contact) {
722 if ($contact[
'source'] ==
'internal') {
723 $objectdetail =
new User($this->
db);
724 $objectdetail->fetch($contact[
'id']);
725 $contact[
'socname'] = $mysoc->name;
726 } elseif ($contact[
'source'] ==
'external') {
728 $objectdetail->fetch($contact[
'id']);
731 $soc->fetch($contact[
'socid']);
732 $contact[
'socname'] = $soc->name;
734 $contact[
'fullname'] = $objectdetail->getFullName($outputlangs, 1);
738 foreach ($tmparray as $key => $val) {
740 $listlinestaskres->setVars($key, $val,
true,
'UTF-8');
741 }
catch (OdfException $e) {
743 }
catch (SegmentException $e) {
747 $listlinestaskres->merge();
752 $sql =
"SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note";
753 $sql .=
", u.lastname, u.firstname, t.thm";
754 $sql .=
" FROM ".MAIN_DB_PREFIX.
"projet_task_time as t";
755 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
756 $sql .=
" WHERE t.fk_task =".((int) $task->id);
757 $sql .=
" AND t.fk_user = u.rowid";
758 $sql .=
" ORDER BY t.task_date DESC";
766 $listlinestasktime = $listlines->__get(
'taskstimes');
769 $row[
'task_date'] =
'';
770 $row[
'task_duration'] =
'';
771 $row[
'$tasktime'] =
'';
773 $row[
'fk_user'] =
'';
775 $row[
'firstname'] =
'';
776 $row[
'fullcivname'] =
'';
777 $row[
'amountht'] =
'';
778 $row[
'amountttc'] =
'';
781 foreach ($tmparray as $key => $val) {
783 $listlinestasktime->setVars($key, $val,
true,
'UTF-8');
784 }
catch (OdfException $e) {
786 }
catch (SegmentException $e) {
790 $listlinestasktime->merge();
793 $row = $this->
db->fetch_array(
$resql);
794 if (!empty($row[
'fk_user'])) {
795 $objectdetail =
new User($this->
db);
796 $objectdetail->fetch($row[
'fk_user']);
797 $row[
'fullcivname'] = $objectdetail->getFullName($outputlangs, 1);
799 $row[
'fullcivname'] =
'';
802 if (!empty($row[
'thm'])) {
803 $row[
'amountht'] = ($row[
'task_duration'] / 3600) * $row[
'thm'];
805 $row[
'amountttc'] =
price2num($row[
'amountht'] * (1 + ($defaultvat / 100)),
'MT');
807 $row[
'amountht'] = 0;
808 $row[
'amountttc'] = 0;
814 foreach ($tmparray as $key => $val) {
816 $listlinestasktime->setVars($key, $val,
true,
'UTF-8');
817 }
catch (OdfException $e) {
819 }
catch (SegmentException $e) {
823 $listlinestasktime->merge();
831 $listtasksfiles = $listlines->__get(
'tasksfiles');
834 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'name', SORT_ASC, 1);
837 foreach ($filearray as $filedetail) {
840 foreach ($tmparray as $key => $val) {
842 $listtasksfiles->setVars($key, $val,
true,
'UTF-8');
843 }
catch (OdfException $e) {
845 }
catch (SegmentException $e) {
849 $listtasksfiles->merge();
853 $odfHandler->mergeSegment($listlines);
854 }
catch (OdfException $e) {
855 $ExceptionTrace = $e->getTrace();
857 if ($ExceptionTrace[0][
'function'] !=
'setSegment') {
858 $this->error = $e->getMessage();
866 $listlines = $odfHandler->setSegment(
'projectfiles');
869 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'name', SORT_ASC, 1);
871 foreach ($filearray as $filedetail) {
875 foreach ($tmparray as $key => $val) {
877 $listlines->setVars($key, $val,
true,
'UTF-8');
878 }
catch (OdfException $e) {
880 }
catch (SegmentException $e) {
886 $odfHandler->mergeSegment($listlines);
887 }
catch (OdfException $e) {
888 $this->error = $e->getMessage();
894 $sourcearray = array(
'internal',
'external');
895 $contact_arrray = array();
896 foreach ($sourcearray as $source) {
897 $contact_temp = $object->liste_contact(-1, $source);
898 if ((is_array($contact_temp) && count($contact_temp) > 0)) {
899 $contact_arrray = array_merge($contact_arrray, $contact_temp);
902 if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
904 $listlines = $odfHandler->setSegment(
'projectcontacts');
906 foreach ($contact_arrray as $contact) {
907 if ($contact[
'source'] ==
'internal') {
908 $objectdetail =
new User($this->
db);
909 $objectdetail->fetch($contact[
'id']);
910 $contact[
'socname'] = $mysoc->name;
911 } elseif ($contact[
'source'] ==
'external') {
913 $objectdetail->fetch($contact[
'id']);
916 $soc->fetch($contact[
'socid']);
917 $contact[
'socname'] = $soc->name;
919 $contact[
'fullname'] = $objectdetail->getFullName($outputlangs, 1);
922 foreach ($tmparray as $key => $val) {
924 $listlines->setVars($key, $val,
true,
'UTF-8');
925 }
catch (OdfException $e) {
927 }
catch (SegmentException $e) {
933 $odfHandler->mergeSegment($listlines);
934 }
catch (OdfException $e) {
935 $this->error = $e->getMessage();
943 $listofreferent = array(
945 'title' =>
"ListProposalsAssociatedProject",
948 'test' => $conf->propal->enabled && $user->rights->propal->lire
951 'title' =>
"ListOrdersAssociatedProject",
952 'class' =>
'Commande',
953 'table' =>
'commande',
954 'test' => $conf->commande->enabled && $user->rights->commande->lire
957 'title' =>
"ListInvoicesAssociatedProject",
958 'class' =>
'Facture',
959 'table' =>
'facture',
960 'test' => $conf->facture->enabled && $user->rights->facture->lire
962 'invoice_predefined' => array(
963 'title' =>
"ListPredefinedInvoicesAssociatedProject",
964 'class' =>
'FactureRec',
965 'table' =>
'facture_rec',
966 'test' => $conf->facture->enabled && $user->rights->facture->lire
968 'proposal_supplier' => array(
969 'title' =>
"ListSupplierProposalsAssociatedProject",
970 'class' =>
'SupplierProposal',
971 'table' =>
'supplier_proposal',
972 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire
974 'order_supplier' => array(
975 'title' =>
"ListSupplierOrdersAssociatedProject",
976 'table' =>
'commande_fournisseur',
977 'class' =>
'CommandeFournisseur',
978 'test' => (
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (
isModEnabled(
"supplier_order") && $user->rights->supplier_order->lire)
980 'invoice_supplier' => array(
981 'title' =>
"ListSupplierInvoicesAssociatedProject",
982 'table' =>
'facture_fourn',
983 'class' =>
'FactureFournisseur',
984 'test' => (
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (
isModEnabled(
"supplier_invoice") && $user->rights->supplier_invoice->lire)
987 'title' =>
"ListContractAssociatedProject",
988 'class' =>
'Contrat',
989 'table' =>
'contrat',
990 'test' => $conf->contrat->enabled && $user->rights->contrat->lire
992 'intervention' => array(
993 'title' =>
"ListFichinterAssociatedProject",
994 'class' =>
'Fichinter',
995 'table' =>
'fichinter',
996 'disableamount' => 1,
997 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
1000 'title' =>
"ListShippingAssociatedProject",
1001 'class' =>
'Expedition',
1002 'table' =>
'expedition',
1003 'disableamount' => 1,
1004 'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1007 'title' =>
"ListTripAssociatedProject",
1008 'class' =>
'Deplacement',
1009 'table' =>
'deplacement',
1010 'disableamount' => 1,
1011 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1013 'expensereport' => array(
1014 'title' =>
"ListExpenseReportsAssociatedProject",
1015 'class' =>
'ExpenseReportLine',
1016 'table' =>
'expensereport_det',
1017 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1019 'donation' => array(
1020 'title' =>
"ListDonationsAssociatedProject",
1023 'test' => $conf->don->enabled && $user->rights->don->lire
1026 'title' =>
"ListLoanAssociatedProject",
1029 'test' => $conf->loan->enabled && $user->rights->loan->read
1031 'chargesociales' => array(
1032 'title' =>
"ListSocialContributionAssociatedProject",
1033 'class' =>
'ChargeSociales',
1034 'table' =>
'chargesociales',
1035 'urlnew' => DOL_URL_ROOT.
'/compta/sociales/card.php?action=create&projectid='.$object->id,
1036 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire
1038 'stock_mouvement' => array(
1039 'title' =>
"ListMouvementStockProject",
1040 'class' =>
'MouvementStock',
1041 'table' =>
'stock_mouvement',
1042 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW))
1045 'title' =>
"ListActionsAssociatedProject",
1046 'class' =>
'ActionComm',
1047 'table' =>
'actioncomm',
1048 'disableamount' => 1,
1049 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1055 $listlines = $odfHandler->setSegment(
'projectrefs');
1057 foreach ($listofreferent as $keyref => $valueref) {
1058 $title = $valueref[
'title'];
1059 $tablename = $valueref[
'table'];
1060 $classname = $valueref[
'class'];
1061 $qualified = $valueref[
'test'];
1063 $elementarray = $object->get_element_list($keyref, $tablename);
1064 if (count($elementarray) > 0 && is_array($elementarray)) {
1067 $num = count($elementarray);
1068 for ($i = 0; $i < $num; $i++) {
1069 $ref_array = array();
1070 $ref_array[
'type'] = $langs->trans($classname);
1072 $element =
new $classname($this->
db);
1073 $element->fetch($elementarray[$i]);
1074 $element->fetch_thirdparty();
1077 $ref_array[
'ref'] = $element->ref;
1080 $dateref = $element->date;
1081 if (empty($dateref)) {
1082 $dateref = $element->datep;
1084 if (empty($dateref)) {
1085 $dateref = $element->date_contrat;
1087 $ref_array[
'date'] = $dateref;
1090 if (is_object($element->thirdparty)) {
1091 $ref_array[
'socname'] = $element->thirdparty->name;
1093 $ref_array[
'socname'] =
'';
1097 if (empty($valueref[
'disableamount'])) {
1098 if (!empty($element->total_ht)) {
1099 $ref_array[
'amountht'] = $element->total_ht;
1100 $ref_array[
'amountttc'] = $element->total_ttc;
1102 $ref_array[
'amountht'] = 0;
1103 $ref_array[
'amountttc'] = 0;
1106 $ref_array[
'amountht'] =
'';
1107 $ref_array[
'amountttc'] =
'';
1110 $ref_array[
'status'] = $element->getLibStatut(0);
1114 foreach ($tmparray as $key => $val) {
1116 $listlines->setVars($key, $val,
true,
'UTF-8');
1117 }
catch (OdfException $e) {
1119 }
catch (SegmentException $e) {
1123 $listlines->merge();
1127 $odfHandler->mergeSegment($listlines);
1129 }
catch (OdfException $e) {
1130 $this->error = $e->getMessage();
1136 $tmparray = $outputlangs->get_translations_for_substitutions();
1137 foreach ($tmparray as $key => $value) {
1139 $odfHandler->setVars($key, $value,
true,
'UTF-8');
1140 }
catch (OdfException $e) {
1146 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
1147 $reshook = $hookmanager->executeHooks(
'beforeODTSave', $parameters, $this, $action);
1151 if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1153 $odfHandler->exportAsAttachedPDF($file);
1155 $this->error = $e->getMessage();
1160 $odfHandler->saveToDisk($file);
1162 $this->error = $e->getMessage();
1167 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
1168 $reshook = $hookmanager->executeHooks(
'afterODTCreation', $parameters, $this, $action);
1170 if (!empty($conf->global->MAIN_UMASK)) {
1171 @chmod($file, octdec($conf->global->MAIN_UMASK));
1176 $this->result = array(
'fullpath'=>$file);
1180 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive=1)
Define array with couple substitution key => substitution value.
get_substitutionarray_mysoc($mysoc, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_contact($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
get_substitutionarray_other($outputlangs)
Define array with couple substitution key => substitution value.
fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs)
Fill array with couple extrafield key => extrafield value.
get_substitutionarray_thirdparty($object, $outputlangs, $array_key='company')
Define array with couple substitution key => substitution value For example {company_name},...
get_substitutionarray_user($user, $outputlangs)
Define array with couple substitution key => substitution value.
Parent class for projects models.
Class to manage projects.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage Dolibarr users.
Class to build documents using ODF templates generator.
get_substitutionarray_tasks(Task $task, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_task_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_tasksressource($taskressource, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_project_file($file, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_taskstime($tasktime, $outputlangs)
Define array with couple substitution key => substitution value.
get_substitutionarray_project_contacts($contact, $outputlangs)
Define array with couple substitution key => substitution value.
__construct($db)
Constructor.
get_substitutionarray_object($object, $outputlangs, $array_key='object')
Define array with couple substitution key => substitution value.
write_file($object, $outputlangs, $srctemplatepath)
Function to build a document on disk using the generic odt module.
get_substitutionarray_project_reference($refdetail, $outputlangs)
Define array with couple substitution key => substitution value.
info($langs)
Return description of a module.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("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->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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...
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null)
Return array of possible common substitutions.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
isModEnabled($module)
Is Dolibarr module enabled.
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...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.