30 require_once DOL_DOCUMENT_ROOT.
'/core/modules/project/modules_project.php';
31 require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
39 require_once DOL_DOCUMENT_ROOT.
'/core/lib/doc.lib.php';
40 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
42 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/contrat/class/contrat.class.php';
63 require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
66 require_once DOL_DOCUMENT_ROOT.
'/compta/deplacement/class/deplacement.class.php';
69 require_once DOL_DOCUMENT_ROOT.
'/comm/action/class/actioncomm.class.php';
72 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
90 public $version =
'dolibarr';
100 global $conf, $langs, $mysoc;
103 $langs->loadLangs(array(
"companies",
"main"));
106 $this->
name =
"ODT templates";
107 $this->
description = $langs->trans(
"DocumentModelOdt");
108 $this->scandir =
'PROJECT_ADDON_PDF_ODT_PATH';
112 $this->page_largeur = 0;
113 $this->page_hauteur = 0;
114 $this->format = array($this->page_largeur, $this->page_hauteur);
115 $this->marge_gauche = 0;
116 $this->marge_droite = 0;
117 $this->marge_haute = 0;
118 $this->marge_basse = 0;
120 $this->option_logo = 1;
121 $this->option_tva = 0;
122 $this->option_modereg = 0;
123 $this->option_condreg = 0;
124 $this->option_multilang = 1;
125 $this->option_escompte = 0;
126 $this->option_credit_note = 0;
127 $this->option_freetext = 1;
128 $this->option_draft_watermark = 0;
131 $this->emetteur = $mysoc;
132 if (!$this->emetteur->country_code) {
133 $this->emetteur->country_code = substr($langs->defaultlang, -2);
153 $array_key.
'_id'=>$object->id,
154 $array_key.
'_ref'=>$object->ref,
155 $array_key.
'_title'=>$object->title,
156 $array_key.
'_description'=>$object->description,
157 $array_key.
'_date_creation'=>
dol_print_date($object->date_c,
'day'),
158 $array_key.
'_date_modification'=>
dol_print_date($object->date_m,
'day'),
159 $array_key.
'_date_start'=>
dol_print_date($object->date_start,
'day'),
161 $array_key.
'_note_private'=>$object->note_private,
162 $array_key.
'_note_public'=>$object->note_public,
163 $array_key.
'_public'=>$object->public,
164 $array_key.
'_statut'=>$object->getLibStatut()
167 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
169 $extrafields->fetch_name_optionals_label($object->table_element,
true);
170 $object->fetch_optionals();
189 'task_ref'=>$task->ref,
190 'task_fk_project'=>$task->fk_project,
191 'task_projectref'=>$task->projectref,
192 'task_projectlabel'=>$task->projectlabel,
193 'task_label'=>$task->label,
194 'task_description'=>$task->description,
195 'task_fk_parent'=>$task->fk_task_parent,
196 'task_duration'=>$task->duration,
198 'task_planned_workload'=>$task->planned_workload,
200 'task_progress'=>$task->progress,
201 'task_public'=>$task->public,
204 'task_note_private'=>$task->note_private,
205 'task_note_public'=>$task->note_public
208 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
210 $extrafields->fetch_name_optionals_label($task->table_element,
true);
211 $task->fetch_optionals();
230 $pc =
'projcontacts_';
233 $pc.
'id'=>$contact[
'id'],
234 $pc.
'rowid'=>$contact[
'rowid'],
235 $pc.
'role'=>$contact[
'libelle'],
236 $pc.
'lastname'=>$contact[
'lastname'],
237 $pc.
'firstname'=>$contact[
'firstname'],
238 $pc.
'civility'=>$contact[
'civility'],
239 $pc.
'fullcivname'=>$contact[
'fullname'],
240 $pc.
'socname'=>$contact[
'socname'],
241 $pc.
'email'=>$contact[
'email']
244 if ($contact[
'source'] ==
'external') {
245 $ret[$pc.
'isInternal'] =
'';
248 $ct->fetch($contact[
'id']);
249 $ret[$pc.
'phone_pro'] = $ct->phone_pro;
250 $ret[$pc.
'phone_perso'] = $ct->phone_perso;
251 $ret[$pc.
'phone_mobile'] = $ct->phone_mobile;
254 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
256 $extrafields->fetch_name_optionals_label($ct->table_element,
true);
257 $extrafields_num = $ct->fetch_optionals();
259 foreach ($ct->array_options as $efkey => $efval) {
260 dol_syslog(get_class($this).
"::get_substitutionarray_project_contacts: +++++ Extrafield ".$efkey.
" => ".$efval, LOG_DEBUG);
261 $ret[$pc.$efkey] = $efval;
263 } elseif ($contact[
'source'] ==
'internal') {
264 $ret[$pc.
'isInternal'] =
'1';
266 $ct =
new User($this->db);
267 $ct->fetch($contact[
'id']);
268 $ret[$pc.
'phone_pro'] = $ct->office_phone;
269 $ret[$pc.
'phone_perso'] =
'';
270 $ret[$pc.
'phone_mobile'] = $ct->user_mobile;
290 'projfile_name'=>$file[
'name'],
292 'projfile_size'=>$file[
'size']
310 'projref_type'=>$refdetail[
'type'],
311 'projref_ref'=>$refdetail[
'ref'],
313 'projref_socname'=>$refdetail[
'socname'],
314 'projref_amountht'=>
price($refdetail[
'amountht'], 0, $outputlangs),
315 'projref_amountttc'=>
price($refdetail[
'amountttc'], 0, $outputlangs),
316 'projref_status'=>$refdetail[
'status']
334 'taskressource_rowid'=>$taskressource[
'rowid'],
335 'taskressource_role'=>$taskressource[
'libelle'],
336 'taskressource_lastname'=>$taskressource[
'lastname'],
337 'taskressource_firstname'=>$taskressource[
'firstname'],
338 'taskressource_fullcivname'=>$taskressource[
'fullname'],
339 'taskressource_socname'=>$taskressource[
'socname'],
340 'taskressource_email'=>$taskressource[
'email']
358 'tasktime_rowid'=>$tasktime[
'rowid'],
359 'tasktime_task_date'=>
dol_print_date($tasktime[
'task_date'],
'day'),
360 'tasktime_task_duration_sec'=>$tasktime[
'task_duration'],
362 'tasktime_note'=>$tasktime[
'note'],
363 'tasktime_fk_user'=>$tasktime[
'fk_user'],
364 'tasktime_user_name'=>$tasktime[
'name'],
365 'tasktime_user_first'=>$tasktime[
'firstname'],
366 'tasktime_fullcivname'=>$tasktime[
'fullcivname'],
367 'tasktime_amountht'=>$tasktime[
'amountht'],
368 'tasktime_amountttc'=>$tasktime[
'amountttc'],
369 'tasktime_thm'=>$tasktime[
'thm'],
387 'tasksfile_name'=>$file[
'name'],
389 'tasksfile_size'=>$file[
'size']
402 global $conf, $langs;
405 $langs->loadLangs(array(
"companies",
"errors"));
410 $texte .=
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
411 $texte .=
'<input type="hidden" name="token" value="'.newToken().
'">';
412 $texte .=
'<input type="hidden" name="page_y" value="">';
413 $texte .=
'<input type="hidden" name="action" value="setModuleOptions">';
414 $texte .=
'<input type="hidden" name="param1" value="PROJECT_ADDON_PDF_ODT_PATH">';
415 $texte .=
'<table class="nobordernopadding" width="100%">';
418 $texte .=
'<tr><td>';
419 $texttitle = $langs->trans(
"ListOfDirectories");
420 $listofdir = explode(
',', preg_replace(
'/[\r\n]+/',
',', trim($conf->global->PROJECT_ADDON_PDF_ODT_PATH)));
421 $listoffiles = array();
422 foreach ($listofdir as $key => $tmpdir) {
423 $tmpdir = trim($tmpdir);
424 $tmpdir = preg_replace(
'/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
426 unset($listofdir[$key]);
429 if (!is_dir($tmpdir)) {
430 $texttitle .=
img_warning($langs->trans(
"ErrorDirNotFound", $tmpdir), 0);
432 $tmpfiles =
dol_dir_list($tmpdir,
'files', 0,
'\.(ods|odt)');
433 if (count($tmpfiles)) {
434 $listoffiles = array_merge($listoffiles, $tmpfiles);
438 $texthelp = $langs->trans(
"ListOfDirectoriesForModelGenODT");
440 $texthelp .=
'<br>'.$langs->trans(
"FollowingSubstitutionKeysCanBeUsed").
'<br>';
441 $texthelp .= $langs->transnoentitiesnoconv(
"FullListOnOnlineDocumentation");
443 $texte .=
$form->textwithpicto($texttitle, $texthelp, 1,
'help',
'', 1);
444 $texte .=
'<div><div style="display: inline-block; min-width: 100px; vertical-align: middle;">';
445 $texte .=
'<textarea class="flat" cols="60" name="value1">';
446 $texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH;
447 $texte .=
'</textarea>';
448 $texte .=
'</div><div style="display: inline-block; vertical-align: middle;">';
449 $texte .=
'<input type="submit" class="button small reposition" name="modify" value="'.$langs->trans(
"Modify").
'">';
450 $texte .=
'<br></div></div>';
453 $nbofiles = count($listoffiles);
454 if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) {
455 $texte .= $langs->trans(
"NumberOfModelFilesFound").
': <b>';
463 $texte .=
'<div id="div_'.get_class($this).
'" class="hiddenx">';
465 foreach ($listoffiles as $file) {
466 $texte .=
'- '.$file[
'name'].
' <a href="'.DOL_URL_ROOT.
'/document.php?modulepart=doctemplates&file=projects/'.urlencode(basename($file[
'name'])).
'">'.
img_picto(
'',
'listlight').
'</a>';
467 $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>';
475 $texte .=
'<td rowspan="2" class="tdtop hideonsmartphone">';
476 $texte .=
'<span class="opacitymedium">';
477 $texte .= $langs->trans(
"ExampleOfDirectoriesForModelGen");
482 $texte .=
'</table>';
497 public function write_file($object, $outputlangs, $srctemplatepath)
500 global $user, $langs, $conf, $mysoc, $hookmanager;
502 if (empty($srctemplatepath)) {
503 dol_syslog(
"doc_generic_odt::write_file parameter srctemplatepath empty", LOG_WARNING);
508 if (!is_object($hookmanager)) {
509 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
512 $hookmanager->initHooks(array(
'odtgeneration'));
515 if (!is_object($outputlangs)) {
516 $outputlangs = $langs;
518 $sav_charset_output = $outputlangs->charset_output;
519 $outputlangs->charset_output =
'UTF-8';
522 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"projects"));
524 if ($conf->project->dir_output) {
526 if (!is_object($object)) {
528 $object =
new Project($this->db);
529 $result = $object->fetch($id);
536 $object->fetch_thirdparty();
538 $dir = $conf->project->dir_output;
540 if (!preg_match(
'/specimen/i', $objectref)) {
541 $dir .=
"/".$objectref;
543 $file = $dir.
"/".$objectref.
".odt";
545 if (!file_exists($dir)) {
547 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
552 if (file_exists($dir)) {
554 $newfile = basename($srctemplatepath);
555 $newfiletmp = preg_replace(
'/\.od[ts]/i',
'', $newfile);
556 $newfiletmp = preg_replace(
'/template_/i',
'', $newfiletmp);
557 $newfiletmp = preg_replace(
'/modele_/i',
'', $newfiletmp);
558 $newfiletmp = $objectref .
'_' . $newfiletmp;
561 $newfileformat = substr($newfile, strrpos($newfile,
'.') + 1);
564 if ($format ==
'1') {
565 $format =
'%Y%m%d%H%M%S';
569 $filename = $newfiletmp .
'.' . $newfileformat;
571 $file = $dir .
'/' . $filename;
578 if (!is_writable($conf->project->dir_temp)) {
579 $this->error = $langs->transnoentities(
"ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp);
580 dol_syslog(
'Error in write_file: ' . $this->error, LOG_ERR);
586 $arrayidcontact = $object->getIdContact(
'external',
'PROJECTLEADER');
587 if (count($arrayidcontact) > 0) {
589 $result = $object->fetch_contact($arrayidcontact[0]);
593 $contactobject =
null;
594 if (!empty($usecontact)) {
596 $contactobject = $object->contact;
599 $socobject = $object->thirdparty;
602 $substitutionarray = array(
603 '__FROM_NAME__' => $this->emetteur->name,
604 '__FROM_EMAIL__' => $this->emetteur->email,
608 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$substitutionarray);
609 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
612 require_once ODTPHP_PATH.
'odf.php';
614 $odfHandler =
new Odf(
617 'PATH_TO_TMP' => $conf->project->dir_temp,
618 'ZIP_PROXY' =>
'PclZipProxy',
619 'DELIMITER_LEFT' =>
'{',
620 'DELIMITER_RIGHT' =>
'}'
624 $this->error = $e->getMessage();
644 $array_project_contact = array();
645 if ($usecontact && is_object($contactobject)) {
649 $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_project_contact);
653 $parameters = array(
'odfHandler'=>&$odfHandler,
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs,
'substitutionarray'=>&$tmparray);
654 $reshook = $hookmanager->executeHooks(
'ODTSubstitution', $parameters, $this, $action);
656 foreach ($tmparray as $key => $value) {
658 if (preg_match(
'/logo$/', $key)) {
659 if (file_exists($value)) {
660 $odfHandler->setImage($key, $value);
662 $odfHandler->setVars($key,
'ErrorFileNotFound',
true,
'UTF-8');
666 $odfHandler->setVars($key, $value,
true,
'UTF-8');
668 }
catch (OdfException $e) {
675 $listlines = $odfHandler->setSegment(
'tasks');
677 $taskstatic =
new Task($this->db);
681 if (!empty($object->fk_soc)) {
682 $socid = $object->fk_soc;
685 $tasksarray = $taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
688 foreach ($tasksarray as $task) {
691 foreach ($tmparray as $key => $val) {
693 $listlines->setVars($key, $val,
true,
'UTF-8');
694 }
catch (OdfException $e) {
696 }
catch (SegmentException $e) {
701 $taskobj =
new Task($this->db);
702 $taskobj->fetch($task->id);
705 $sourcearray = array(
'internal',
'external');
706 $contact_arrray = array();
707 foreach ($sourcearray as $source) {
708 $contact_temp = $taskobj->liste_contact(-1, $source);
709 if ((is_array($contact_temp) && count($contact_temp) > 0)) {
710 $contact_arrray = array_merge($contact_arrray, $contact_temp);
713 if ((is_array($contact_arrray) && count($contact_arrray) > 0)) {
714 $listlinestaskres = $listlines->__get(
'tasksressources');
716 foreach ($contact_arrray as $contact) {
717 if ($contact[
'source'] ==
'internal') {
718 $objectdetail =
new User($this->db);
719 $objectdetail->fetch($contact[
'id']);
720 $contact[
'socname'] = $mysoc->name;
721 } elseif ($contact[
'source'] ==
'external') {
722 $objectdetail =
new Contact($this->db);
723 $objectdetail->fetch($contact[
'id']);
726 $soc->fetch($contact[
'socid']);
727 $contact[
'socname'] = $soc->name;
729 $contact[
'fullname'] = $objectdetail->getFullName($outputlangs, 1);
733 foreach ($tmparray as $key => $val) {
735 $listlinestaskres->setVars($key, $val,
true,
'UTF-8');
736 }
catch (OdfException $e) {
738 }
catch (SegmentException $e) {
742 $listlinestaskres->merge();
747 $sql =
"SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note";
748 $sql .=
", u.lastname, u.firstname, t.thm";
749 $sql .=
" FROM ".MAIN_DB_PREFIX.
"element_time as t";
750 $sql .=
" , ".MAIN_DB_PREFIX.
"user as u";
751 $sql .=
" WHERE t.fk_element =".((int) $task->id);
752 $sql .=
" AND t.elementtype = 'task'";
753 $sql .=
" AND t.fk_user = u.rowid";
754 $sql .=
" ORDER BY t.element_date DESC";
756 $resql = $this->db->query(
$sql);
758 $num = $this->db->num_rows($resql);
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();
822 $this->db->free($resql);
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') {
908 $objectdetail =
new Contact($this->db);
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' =>
isModEnabled(
'propal') && $user->hasRight(
'propal',
'lire')
947 'title' =>
"ListOrdersAssociatedProject",
948 'class' =>
'Commande',
949 'table' =>
'commande',
950 'test' =>
isModEnabled(
'commande') && $user->hasRight(
'commande',
'lire')
953 'title' =>
"ListInvoicesAssociatedProject",
954 'class' =>
'Facture',
955 'table' =>
'facture',
956 'test' =>
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
958 'invoice_predefined' => array(
959 'title' =>
"ListPredefinedInvoicesAssociatedProject",
960 'class' =>
'FactureRec',
961 'table' =>
'facture_rec',
962 'test' =>
isModEnabled(
'facture') && $user->hasRight(
'facture',
'lire')
964 'proposal_supplier' => array(
965 'title' =>
"ListSupplierProposalsAssociatedProject",
966 'class' =>
'SupplierProposal',
967 'table' =>
'supplier_proposal',
968 'test' =>
isModEnabled(
'supplier_proposal') && $user->rights->supplier_proposal->lire
970 'order_supplier' => array(
971 'title' =>
"ListSupplierOrdersAssociatedProject",
972 'table' =>
'commande_fournisseur',
973 'class' =>
'CommandeFournisseur',
974 'test' => (
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->commande->lire) || (
isModEnabled(
"supplier_order") && $user->rights->supplier_order->lire)
976 'invoice_supplier' => array(
977 'title' =>
"ListSupplierInvoicesAssociatedProject",
978 'table' =>
'facture_fourn',
979 'class' =>
'FactureFournisseur',
980 'test' => (
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire) || (
isModEnabled(
"supplier_invoice") && $user->rights->supplier_invoice->lire)
983 'title' =>
"ListContractAssociatedProject",
984 'class' =>
'Contrat',
985 'table' =>
'contrat',
986 'test' =>
isModEnabled(
'contrat') && $user->hasRight(
'contrat',
'lire')
988 'intervention' => array(
989 'title' =>
"ListFichinterAssociatedProject",
990 'class' =>
'Fichinter',
991 'table' =>
'fichinter',
992 'disableamount' => 1,
993 'test' =>
isModEnabled(
'ficheinter') && $user->hasRight(
'ficheinter',
'lire')
996 'title' =>
"ListShippingAssociatedProject",
997 'class' =>
'Expedition',
998 'table' =>
'expedition',
999 'disableamount' => 1,
1000 'test' =>
isModEnabled(
'expedition') && $user->rights->expedition->lire
1003 'title' =>
"ListTripAssociatedProject",
1004 'class' =>
'Deplacement',
1005 'table' =>
'deplacement',
1006 'disableamount' => 1,
1007 'test' =>
isModEnabled(
'deplacement') && $user->rights->deplacement->lire
1009 'expensereport' => array(
1010 'title' =>
"ListExpenseReportsAssociatedProject",
1011 'class' =>
'ExpenseReportLine',
1012 'table' =>
'expensereport_det',
1013 'test' =>
isModEnabled(
'expensereport') && $user->rights->expensereport->lire
1015 'donation' => array(
1016 'title' =>
"ListDonationsAssociatedProject",
1019 'test' =>
isModEnabled(
'don') && $user->rights->don->lire
1022 'title' =>
"ListLoanAssociatedProject",
1025 'test' =>
isModEnabled(
'loan') && $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' =>
isModEnabled(
'tax') && $user->rights->tax->charges->lire
1034 'stock_mouvement' => array(
1035 'title' =>
"ListMouvementStockProject",
1036 'class' =>
'MouvementStock',
1037 'table' =>
'stock_mouvement',
1038 'test' => (
isModEnabled(
'stock') && $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' =>
isModEnabled(
'agenda') && $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);
1170 $this->result = array(
'fullpath'=>$file);
1174 $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 Note that vars into substitutions array are...
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') && $user->hasRight('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') && $user->hasRight('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)) $sql
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).
dolChmod($filepath, $newmask='')
Change mod of a file.
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...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $object=null, $include=null)
Return array of possible common substitutions.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.