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';
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';
49 if (!empty($conf->commande->enabled)) {
50 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
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';
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';
58 if (!empty($conf->contrat->enabled)) {
59 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
61 if (!empty($conf->ficheinter->enabled)) {
62 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
64 if (!empty($conf->deplacement->enabled)) {
65 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
87 public $phpmin = array(5, 6);
93 public $version =
'dolibarr';
103 global $conf, $langs, $mysoc;
106 $langs->loadLangs(array(
"companies",
"main"));
109 $this->
name =
"ODT templates";
110 $this->
description = $langs->trans(
"DocumentModelOdt");
111 $this->scandir =
'PROJECT_ADDON_PDF_ODT_PATH';
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;
123 $this->option_logo = 1;
124 $this->option_tva = 0;
125 $this->option_modereg = 0;
126 $this->option_condreg = 0;
127 $this->option_multilang = 1;
128 $this->option_escompte = 0;
129 $this->option_credit_note = 0;
130 $this->option_freetext = 1;
131 $this->option_draft_watermark = 0;
134 $this->emetteur = $mysoc;
135 if (!$this->emetteur->pays_code) {
136 $this->emetteur->pays_code = substr($langs->defaultlang, -2);
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'),
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()
170 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
172 $extrafields->fetch_name_optionals_label($object->table_element,
true);
173 $object->fetch_optionals();
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,
203 'task_progress'=>$task->progress,
204 'task_public'=>$task->public,
207 'task_note_private'=>$task->note_private,
208 'task_note_public'=>$task->note_public
211 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
213 $extrafields->fetch_name_optionals_label($task->table_element,
true);
214 $task->fetch_optionals();
233 $pc =
'projcontacts_';
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']
247 if ($contact[
'source'] ==
'external') {
248 $ret[$pc.
'isInternal'] =
'';
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;
257 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
259 $extrafields->fetch_name_optionals_label($ct->table_element,
true);
260 $extrafields_num = $ct->fetch_optionals();
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;
266 } elseif ($contact[
'source'] ==
'internal') {
267 $ret[$pc.
'isInternal'] =
'1';
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;
293 'projfile_name'=>$file[
'name'],
295 'projfile_size'=>$file[
'size']
313 'projref_type'=>$refdetail[
'type'],
314 'projref_ref'=>$refdetail[
'ref'],
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']
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']
361 'tasktime_rowid'=>$tasktime[
'rowid'],
362 'tasktime_task_date'=>
dol_print_date($tasktime[
'task_date'],
'day'),
363 'tasktime_task_duration_sec'=>$tasktime[
'task_duration'],
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'],
390 'tasksfile_name'=>$file[
'name'],
392 'tasksfile_size'=>$file[
'size']
405 global $conf, $langs;
408 $langs->loadLangs(array(
"companies",
"errors"));
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%">';
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);
429 unset($listofdir[$key]);
432 if (!is_dir($tmpdir)) {
433 $texttitle .=
img_warning($langs->trans(
"ErrorDirNotFound", $tmpdir), 0);
435 $tmpfiles =
dol_dir_list($tmpdir,
'files', 0,
'\.(ods|odt)');
436 if (count($tmpfiles)) {
437 $listoffiles = array_merge($listoffiles, $tmpfiles);
441 $texthelp = $langs->trans(
"ListOfDirectoriesForModelGenODT");
443 $texthelp .=
'<br>'.$langs->trans(
"FollowingSubstitutionKeysCanBeUsed").
'<br>';
444 $texthelp .= $langs->transnoentitiesnoconv(
"FullListOnOnlineDocumentation");
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>';
456 $nbofiles = count($listoffiles);
457 if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) {
458 $texte .= $langs->trans(
"NumberOfModelFilesFound").
': <b>';
466 $texte .=
'<div id="div_'.get_class($this).
'" class="hiddenx">';
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>';
476 $texte .=
'<td rowspan="2" class="tdtop hideonsmartphone">';
477 $texte .=
'<span class="opacitymedium">';
478 $texte .= $langs->trans(
"ExampleOfDirectoriesForModelGen");
483 $texte .=
'</table>';
498 public function write_file($object, $outputlangs, $srctemplatepath)
501 global $user, $langs, $conf, $mysoc, $hookmanager;
503 if (empty($srctemplatepath)) {
504 dol_syslog(
"doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
509 if (!is_object($hookmanager)) {
510 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
513 $hookmanager->initHooks(array(
'odtgeneration'));
516 if (!is_object($outputlangs)) {
517 $outputlangs = $langs;
519 $sav_charset_output = $outputlangs->charset_output;
520 $outputlangs->charset_output =
'UTF-8';
523 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"projects"));
525 if ($conf->project->dir_output) {
527 if (!is_object($object)) {
530 $result = $object->fetch($id);
537 $object->fetch_thirdparty();
539 $dir = $conf->project->dir_output;
541 if (!preg_match(
'/specimen/i', $objectref)) {
542 $dir .=
"/".$objectref;
544 $file = $dir.
"/".$objectref.
".odt";
546 if (!file_exists($dir)) {
548 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
553 if (file_exists($dir)) {
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;
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';
570 $filename = $newfiletmp.
'.'.$newfileformat;
572 $file = $dir.
'/'.$filename;
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);
587 $arrayidcontact = $object->getIdContact(
'external',
'PROJECTLEADER');
588 if (count($arrayidcontact) > 0) {
590 $result = $object->fetch_contact($arrayidcontact[0]);
594 $contactobject =
null;
595 if (!empty($usecontact)) {
597 $contactobject = $object->contact;
600 $socobject = $object->thirdparty;
603 $substitutionarray = array(
604 '__FROM_NAME__' => $this->emetteur->name,
605 '__FROM_EMAIL__' => $this->emetteur->email,
609 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$substitutionarray);
610 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
613 require_once ODTPHP_PATH.
'odf.php';
615 $odfHandler =
new odf(
618 'PATH_TO_TMP' => $conf->project->dir_temp,
619 'ZIP_PROXY' =>
'PclZipProxy',
620 'DELIMITER_LEFT' =>
'{',
621 'DELIMITER_RIGHT' =>
'}'
625 $this->error = $e->getMessage();
645 $array_project_contact = array();
646 if ($usecontact && is_object($contactobject)) {
650 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
654 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
655 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
657 foreach ($tmparray as $key => $value) {
659 if (preg_match(
'/logo$/', $key)) {
660 if (file_exists($value)) {
661 $odfHandler->setImage($key, $value);
663 $odfHandler->setVars($key,
'ErrorFileNotFound',
true,
'UTF-8');
667 $odfHandler->setVars($key, $value,
true,
'UTF-8');
669 }
catch (OdfException $e) {
676 $listlines = $odfHandler->setSegment(
'tasks');
678 $taskstatic =
new Task($this->
db);
682 if (!empty($object->fk_soc)) {
683 $socid = $object->fk_soc;
686 $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
689 foreach ($tasksarray as $task) {
692 foreach ($tmparray as $key => $val) {
694 $listlines->setVars($key, $val,
true,
'UTF-8');
695 }
catch (OdfException $e) {
697 }
catch (SegmentException $e) {
702 $taskobj =
new Task($this->
db);
703 $taskobj->fetch($task->id);
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);
714 if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
715 $listlinestaskres = $listlines->__get(
'tasksressources');
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') {
724 $objectdetail->fetch($contact[
'id']);
727 $soc->fetch($contact[
'socid']);
728 $contact[
'socname'] = $soc->name;
730 $contact[
'fullname'] = $objectdetail->getFullName($outputlangs, 1);
734 foreach ($tmparray as $key => $val) {
736 $listlinestaskres->setVars($key, $val,
true,
'UTF-8');
737 }
catch (OdfException $e) {
739 }
catch (SegmentException $e) {
743 $listlinestaskres->merge();
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";
762 $listlinestasktime = $listlines->__get(
'taskstimes');
765 $row[
'task_date'] =
'';
766 $row[
'task_duration'] =
'';
767 $row[
'$tasktime'] =
'';
769 $row[
'fk_user'] =
'';
771 $row[
'firstname'] =
'';
772 $row[
'fullcivname'] =
'';
773 $row[
'amountht'] =
'';
774 $row[
'amountttc'] =
'';
777 foreach ($tmparray as $key => $val) {
779 $listlinestasktime->setVars($key, $val,
true,
'UTF-8');
780 }
catch (OdfException $e) {
782 }
catch (SegmentException $e) {
786 $listlinestasktime->merge();
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);
795 $row[
'fullcivname'] =
'';
798 if (!empty($row[
'thm'])) {
799 $row[
'amountht'] = ($row[
'task_duration'] / 3600) * $row[
'thm'];
801 $row[
'amountttc'] =
price2num($row[
'amountht'] * (1 + ($defaultvat / 100)),
'MT');
803 $row[
'amountht'] = 0;
804 $row[
'amountttc'] = 0;
810 foreach ($tmparray as $key => $val) {
812 $listlinestasktime->setVars($key, $val,
true,
'UTF-8');
813 }
catch (OdfException $e) {
815 }
catch (SegmentException $e) {
819 $listlinestasktime->merge();
827 $listtasksfiles = $listlines->__get(
'tasksfiles');
830 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'name', SORT_ASC, 1);
833 foreach ($filearray as $filedetail) {
836 foreach ($tmparray as $key => $val) {
838 $listtasksfiles->setVars($key, $val,
true,
'UTF-8');
839 }
catch (OdfException $e) {
841 }
catch (SegmentException $e) {
845 $listtasksfiles->merge();
849 $odfHandler->mergeSegment($listlines);
850 }
catch (OdfException $e) {
851 $ExceptionTrace = $e->getTrace();
853 if ($ExceptionTrace[0][
'function'] !=
'setSegment') {
854 $this->error = $e->getMessage();
862 $listlines = $odfHandler->setSegment(
'projectfiles');
865 $filearray =
dol_dir_list($upload_dir,
"files", 0,
'',
'(\.meta|_preview.*\.png)$',
'name', SORT_ASC, 1);
867 foreach ($filearray as $filedetail) {
871 foreach ($tmparray as $key => $val) {
873 $listlines->setVars($key, $val,
true,
'UTF-8');
874 }
catch (OdfException $e) {
876 }
catch (SegmentException $e) {
882 $odfHandler->mergeSegment($listlines);
883 }
catch (OdfException $e) {
884 $this->error = $e->getMessage();
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);
898 if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
900 $listlines = $odfHandler->setSegment(
'projectcontacts');
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') {
909 $objectdetail->fetch($contact[
'id']);
912 $soc->fetch($contact[
'socid']);
913 $contact[
'socname'] = $soc->name;
915 $contact[
'fullname'] = $objectdetail->getFullName($outputlangs, 1);
918 foreach ($tmparray as $key => $val) {
920 $listlines->setVars($key, $val,
true,
'UTF-8');
921 }
catch (OdfException $e) {
923 }
catch (SegmentException $e) {
929 $odfHandler->mergeSegment($listlines);
930 }
catch (OdfException $e) {
931 $this->error = $e->getMessage();
939 $listofreferent = array(
941 'title' =>
"ListProposalsAssociatedProject",
944 'test' => $conf->propal->enabled && $user->rights->propale->lire
947 'title' =>
"ListOrdersAssociatedProject",
948 'class' =>
'Commande',
949 'table' =>
'commande',
950 'test' => $conf->commande->enabled && $user->rights->commande->lire
953 'title' =>
"ListInvoicesAssociatedProject",
954 'class' =>
'Facture',
955 'table' =>
'facture',
956 'test' => $conf->facture->enabled && $user->rights->facture->lire
958 'invoice_predefined' => array(
959 'title' =>
"ListPredefinedInvoicesAssociatedProject",
960 'class' =>
'FactureRec',
961 'table' =>
'facture_rec',
962 'test' => $conf->facture->enabled && $user->rights->facture->lire
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
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)
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)
983 'title' =>
"ListContractAssociatedProject",
984 'class' =>
'Contrat',
985 'table' =>
'contrat',
986 'test' => $conf->contrat->enabled && $user->rights->contrat->lire
988 'intervention' => array(
989 'title' =>
"ListFichinterAssociatedProject",
990 'class' =>
'Fichinter',
991 'table' =>
'fichinter',
992 'disableamount' => 1,
993 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire
996 'title' =>
"ListShippingAssociatedProject",
997 'class' =>
'Expedition',
998 'table' =>
'expedition',
999 'disableamount' => 1,
1000 'test' => $conf->expedition->enabled && $user->rights->expedition->lire
1003 'title' =>
"ListTripAssociatedProject",
1004 'class' =>
'Deplacement',
1005 'table' =>
'deplacement',
1006 'disableamount' => 1,
1007 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire
1009 'expensereport' => array(
1010 'title' =>
"ListExpenseReportsAssociatedProject",
1011 'class' =>
'ExpenseReportLine',
1012 'table' =>
'expensereport_det',
1013 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire
1015 'donation' => array(
1016 'title' =>
"ListDonationsAssociatedProject",
1019 'test' => $conf->don->enabled && $user->rights->don->lire
1022 'title' =>
"ListLoanAssociatedProject",
1025 'test' => $conf->loan->enabled && $user->rights->loan->read
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
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))
1041 'title' =>
"ListActionsAssociatedProject",
1042 'class' =>
'ActionComm',
1043 'table' =>
'actioncomm',
1044 'disableamount' => 1,
1045 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire
1051 $listlines = $odfHandler->setSegment(
'projectrefs');
1053 foreach ($listofreferent as $keyref => $valueref) {
1054 $title = $valueref[
'title'];
1055 $tablename = $valueref[
'table'];
1056 $classname = $valueref[
'class'];
1057 $qualified = $valueref[
'test'];
1059 $elementarray = $object->get_element_list($keyref, $tablename);
1060 if (count($elementarray) > 0 && is_array($elementarray)) {
1063 $num = count($elementarray);
1064 for ($i = 0; $i < $num; $i++) {
1065 $ref_array = array();
1066 $ref_array[
'type'] = $langs->trans($classname);
1068 $element =
new $classname($this->
db);
1069 $element->fetch($elementarray[$i]);
1070 $element->fetch_thirdparty();
1073 $ref_array[
'ref'] = $element->ref;
1076 $dateref = $element->date;
1077 if (empty($dateref)) {
1078 $dateref = $element->datep;
1080 if (empty($dateref)) {
1081 $dateref = $element->date_contrat;
1083 $ref_array[
'date'] = $dateref;
1086 if (is_object($element->thirdparty)) {
1087 $ref_array[
'socname'] = $element->thirdparty->name;
1089 $ref_array[
'socname'] =
'';
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;
1098 $ref_array[
'amountht'] = 0;
1099 $ref_array[
'amountttc'] = 0;
1102 $ref_array[
'amountht'] =
'';
1103 $ref_array[
'amountttc'] =
'';
1106 $ref_array[
'status'] = $element->getLibStatut(0);
1110 foreach ($tmparray as $key => $val) {
1112 $listlines->setVars($key, $val,
true,
'UTF-8');
1113 }
catch (OdfException $e) {
1115 }
catch (SegmentException $e) {
1119 $listlines->merge();
1123 $odfHandler->mergeSegment($listlines);
1125 }
catch (OdfException $e) {
1126 $this->error = $e->getMessage();
1132 $tmparray = $outputlangs->get_translations_for_substitutions();
1133 foreach ($tmparray as $key => $value) {
1135 $odfHandler->setVars($key, $value,
true,
'UTF-8');
1136 }
catch (OdfException $e) {
1142 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
1143 $reshook = $hookmanager->executeHooks(
'beforeODTSave', $parameters, $this, $action);
1147 if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
1149 $odfHandler->exportAsAttachedPDF($file);
1151 $this->error = $e->getMessage();
1156 $odfHandler->saveToDisk($file);
1158 $this->error = $e->getMessage();
1163 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
1164 $reshook = $hookmanager->executeHooks(
'afterODTCreation', $parameters, $this, $action);
1166 if (!empty($conf->global->MAIN_UMASK)) {
1167 @chmod($file, octdec($conf->global->MAIN_UMASK));
1172 $this->result = array(
'fullpath'=>$file);
1176 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);