--- /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/github_19.0.3_doc_generic_project_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/client_doc_generic_project_odt.modules.php @@ -5,3 +5,2 @@ - * Copyright (C) 2016-2023 Charlene Benke - * Copyright (C) 2018 Frédéric France - * Copyright (C) 2023 Gauthier VERDOL + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018 Frédéric France @@ -41,33 +40,11 @@ -if (isModEnabled("propal")) { - require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -} -if (isModEnabled('facture')) { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -} -if (isModEnabled('facture')) { - require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; -} -if (isModEnabled('commande')) { - require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; -} -if (isModEnabled("supplier_invoice")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; -} -if (isModEnabled("supplier_order")) { - require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; -} -if (isModEnabled('contrat')) { - require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; -} -if (isModEnabled('ficheinter')) { - require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; -} -if (isModEnabled('deplacement')) { - require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; -} -if (isModEnabled('agenda')) { - require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -} -if (isModEnabled('expedition')) { - require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; -} +if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture-rec.class.php'; +if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; +if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +if (!empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; +if (!empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; +if (!empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php'; +if (!empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; + @@ -81,2 +58,2 @@ - * Dolibarr version of the loaded document - * @var string + * Issuer + * @var Societe @@ -83,0 +61,12 @@ + public $emetteur; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ @@ -94 +83 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -114,6 +103,7 @@ - $this->option_logo = 1; // Display logo - $this->option_tva = 0; // Manage the vat option COMMANDE_TVAOPTION - $this->option_modereg = 0; // Display payment mode - $this->option_condreg = 0; // Display payment terms - $this->option_multilang = 1; // Available in several languages - $this->option_escompte = 0; // Displays if there has been a discount + $this->option_logo = 1; // Affiche logo + $this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION + $this->option_modereg = 0; // Affiche mode reglement + $this->option_condreg = 0; // Affiche conditions reglement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 0; // Affiche si il y a eu escompte @@ -124 +114 @@ - // Get source company + // Recupere emetteur @@ -126,3 +116 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini - } + if (!$this->emetteur->pays_code) $this->emetteur->pays_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini @@ -132 +120 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -138 +126 @@ - * @param string $array_key Name of the key for return array + * @param string $array_key Name of the key for return array @@ -143 +131 @@ - // phpcs:enable + // phpcs:enable @@ -147,12 +135,12 @@ - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_title'=>$object->title, - $array_key.'_description'=>$object->description, - $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'), - $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'), - $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'), - $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'), - $array_key.'_note_private'=>$object->note_private, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_public'=>$object->public, - $array_key.'_statut'=>$object->getLibStatut() + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_title'=>$object->title, + $array_key.'_description'=>$object->description, + $array_key.'_date_creation'=>dol_print_date($object->date_c, 'day'), + $array_key.'_date_modification'=>dol_print_date($object->date_m, 'day'), + $array_key.'_date_start'=>dol_print_date($object->date_start, 'day'), + $array_key.'_date_end'=>dol_print_date($object->date_end, 'day'), + $array_key.'_note_private'=>$object->note_private, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_public'=>$object->public, + $array_key.'_statut'=>$object->getLibStatut() @@ -171 +159 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -175 +163 @@ - * @param Task $task Task Object + * @param array $task Task Object @@ -181 +169,3 @@ - // phpcs:enable + // phpcs:enable + global $conf; + @@ -189 +179 @@ - 'task_fk_parent'=>$task->fk_task_parent, + 'task_fk_parent'=>$task->fk_parent, @@ -192,2 +181,0 @@ - 'task_planned_workload'=>$task->planned_workload, - 'task_planned_workload_hour'=>convertSecondToTime($task->planned_workload, 'all'), @@ -212 +200 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -222 +210 @@ - // phpcs:enable + // phpcs:enable @@ -270 +258 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -278,13 +266,13 @@ - public function get_substitutionarray_project_file($file, $outputlangs) - { - // phpcs:enable - global $conf; - - return array( - 'projfile_name'=>$file['name'], - 'projfile_date'=>dol_print_date($file['date'], 'day'), - 'projfile_size'=>$file['size'] - ); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + public function get_substitutionarray_project_file($file, $outputlangs) + { + // phpcs:enable + global $conf; + + return array( + 'projfile_name'=>$file['name'], + 'projfile_date'=>dol_print_date($file['date'], 'day'), + 'projfile_size'=>$file['size'] + ); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -298,17 +286,17 @@ - public function get_substitutionarray_project_reference($refdetail, $outputlangs) - { - // phpcs:enable - global $conf; - - return array( - 'projref_type'=>$refdetail['type'], - 'projref_ref'=>$refdetail['ref'], - 'projref_date'=>dol_print_date($refdetail['date'], 'day'), - 'projref_socname'=>$refdetail['socname'], - 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), - 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), - 'projref_status'=>$refdetail['status'] - ); - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + public function get_substitutionarray_project_reference($refdetail, $outputlangs) + { + // phpcs:enable + global $conf; + + return array( + 'projref_type'=>$refdetail['type'], + 'projref_ref'=>$refdetail['ref'], + 'projref_date'=>dol_print_date($refdetail['date'], 'day'), + 'projref_socname'=>$refdetail['socname'], + 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), + 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), + 'projref_status'=>$refdetail['status'] + ); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -324 +312 @@ - // phpcs:enable + // phpcs:enable @@ -338 +326 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -348 +336 @@ - // phpcs:enable + // phpcs:enable @@ -367 +355 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -377 +365 @@ - // phpcs:enable + // phpcs:enable @@ -399 +387 @@ - $langs->loadLangs(array("companies", "errors")); + $langs->loadLangs(array("companies", "errors")); @@ -404 +392 @@ - $texte .= '
'; + $texte .= ''; @@ -406 +393,0 @@ - $texte .= ''; @@ -409 +396 @@ - $texte .= ''; + $texte .= '
'; @@ -416 +403,2 @@ - foreach ($listofdir as $key => $tmpdir) { + foreach ($listofdir as $key=>$tmpdir) + { @@ -420,2 +408 @@ - unset($listofdir[$key]); - continue; + unset($listofdir[$key]); continue; @@ -423,3 +410,3 @@ - if (!is_dir($tmpdir)) { - $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - } else { + if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); + else + { @@ -427,3 +414 @@ - if (count($tmpfiles)) { - $listoffiles = array_merge($listoffiles, $tmpfiles); - } + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); @@ -433 +417,0 @@ - $texthelp .= '

'.$langs->trans("ExampleOfDirectoriesForModelGen").''; @@ -438 +422 @@ - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); @@ -441 +425 @@ - $texte .= getDolGlobalString('PROJECT_ADDON_PDF_ODT_PATH'); + $texte .= $conf->global->PROJECT_ADDON_PDF_ODT_PATH; @@ -444 +428 @@ - $texte .= ''; + $texte .= ''; @@ -449 +433,2 @@ - if (getDolGlobalString('PROJECT_ADDON_PDF_ODT_PATH')) { + if (!empty($conf->global->PROJECT_ADDON_PDF_ODT_PATH)) + { @@ -457,9 +442,8 @@ - if ($nbofiles) { - $texte .= '
'; - // Show list of found files - foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; - $texte .= '   '.img_picto('', 'delete').''; - $texte .= '
'; - } - $texte .= '
'; + if ($nbofiles) + { + $texte .= ''; @@ -467,11 +451 @@ - // Add input to upload a new template file. - $texte .= '
'.$langs->trans("UploadNewTemplate"); - $maxfilesizearray = getMaxFileSizeArray(); - $maxmin = $maxfilesizearray['maxmin']; - if ($maxmin > 0) { - $texte .= ''; // MAX_FILE_SIZE must precede the field type=file - } - $texte .= ' '; - $texte .= ''; - $texte .= ''; - $texte .= '
'; + @@ -479,0 +454,3 @@ + $texte .= ''; @@ -488 +465 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -499 +476 @@ - // phpcs:enable + // phpcs:enable @@ -502 +479,2 @@ - if (empty($srctemplatepath)) { + if (empty($srctemplatepath)) + { @@ -508 +486,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -515,3 +494 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -524 +501,2 @@ - if ($conf->project->dir_output) { + if ($conf->projet->dir_output) + { @@ -526 +504,2 @@ - if (!is_object($object)) { + if (!is_object($object)) + { @@ -530 +509,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -536,3 +516 @@ - $object->fetch_thirdparty(); - - $dir = $conf->project->dir_output; + $dir = $conf->projet->dir_output; @@ -540,3 +518 @@ - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -545,2 +521,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -552 +530,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -555 +534 @@ - $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile); + $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); @@ -558 +537 @@ - $newfiletmp = $objectref . '_' . $newfiletmp; + $newfiletmp = $objectref.'_'.$newfiletmp; @@ -562,10 +541,11 @@ - if (getDolGlobalString('MAIN_DOC_USE_TIMING')) { - $format = getDolGlobalString('MAIN_DOC_USE_TIMING'); - if ($format == '1') { - $format = '%Y%m%d%H%M%S'; - } - $filename = $newfiletmp . '-' . dol_print_date(dol_now(), $format) . '.' . $newfileformat; - } else { - $filename = $newfiletmp . '.' . $newfileformat; - } - $file = $dir . '/' . $filename; + if (!empty($conf->global->MAIN_DOC_USE_TIMING)) + { + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; + $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; + } + else + { + $filename = $newfiletmp.'.'.$newfileformat; + } + $file = $dir.'/'.$filename; @@ -577,6 +557 @@ - dol_mkdir($conf->project->dir_temp); - if (!is_writable($conf->project->dir_temp)) { - $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->project->dir_temp); - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); - return -1; - } + dol_mkdir($conf->projet->dir_temp); @@ -587 +562,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -594,3 +570,4 @@ - if (!empty($usecontact)) { - // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; + if (!empty($usecontact)) + { + // if we have a PROJECTLEADER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; @@ -614 +591 @@ - $odfHandler = new Odf( + $odfHandler = new odf( @@ -617 +594 @@ - 'PATH_TO_TMP' => $conf->project->dir_temp, + 'PATH_TO_TMP' => $conf->projet->dir_temp, @@ -645,3 +622 @@ - if ($usecontact && is_object($contactobject)) { - $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); - } + if ($usecontact && is_object($contactobject)) $array_project_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact'); @@ -656 +631,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -658,7 +634,7 @@ - if (preg_match('/logo$/', $key)) { // Image - if (file_exists($value)) { - $odfHandler->setImage($key, $value); - } else { - $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); - } - } else { // Text + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { @@ -667,2 +642,0 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); @@ -669,0 +644,4 @@ + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); + } @@ -673 +651,2 @@ - try { + try + { @@ -680,3 +659 @@ - if (!empty($object->fk_soc)) { - $socid = $object->fk_soc; - } + if (!empty($object->fk_soc)) $socid = $object->fk_soc; @@ -687 +664,2 @@ - foreach ($tasksarray as $task) { + foreach ($tasksarray as $task) + { @@ -690,2 +668,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -693 +673,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -695 +677,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -708 +692,2 @@ - if ((is_array($contact_temp) && count($contact_temp) > 0)) { + if ((is_array($contact_temp) && count($contact_temp) > 0)) + { @@ -712 +697,2 @@ - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) + { @@ -715 +701,2 @@ - foreach ($contact_arrray as $contact) { + foreach ($contact_arrray as $contact) + { @@ -732,2 +719,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -735 +724,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -737 +728,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -746 +739 @@ - $sql = "SELECT t.rowid, t.element_date as task_date, t.element_duration as task_duration, t.fk_user, t.note"; + $sql = "SELECT t.rowid, t.task_date, t.task_duration, t.fk_user, t.note"; @@ -748 +741 @@ - $sql .= " FROM ".MAIN_DB_PREFIX."element_time as t"; + $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t"; @@ -750,2 +743 @@ - $sql .= " WHERE t.fk_element =".((int) $task->id); - $sql .= " AND t.elementtype = 'task'"; + $sql .= " WHERE t.fk_task =".$task->id; @@ -753 +745 @@ - $sql .= " ORDER BY t.element_date DESC"; + $sql .= " ORDER BY t.task_date DESC"; @@ -756 +748,2 @@ - if ($resql) { + if ($resql) + { @@ -776,2 +769,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -779 +774,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -781 +778,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -787 +786,2 @@ - while ($i < $num) { + while ($i < $num) + { @@ -809,2 +809,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -812 +814,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -814 +818,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -828 +834 @@ - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref); + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref).'/'.dol_sanitizeFileName($task->ref); @@ -832 +838,2 @@ - foreach ($filearray as $filedetail) { + foreach ($filearray as $filedetail) + { @@ -835,2 +842,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -838 +847,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -840 +851,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -849 +862,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -852 +867,2 @@ - if ($ExceptionTrace[0]['function'] != 'setSegment') { + if ($ExceptionTrace[0]['function'] != 'setSegment') + { @@ -860 +876,2 @@ - try { + try + { @@ -863 +880 @@ - $upload_dir = $conf->project->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); @@ -866 +883,2 @@ - foreach ($filearray as $filedetail) { + foreach ($filearray as $filedetail) + { @@ -870,2 +888,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -873 +893,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -875 +897,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -882 +906,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -893 +919,2 @@ - if ((is_array($contact_temp) && count($contact_temp) > 0)) { + if ((is_array($contact_temp) && count($contact_temp) > 0)) + { @@ -897,2 +924,4 @@ - if ((is_array($contact_arrray) && count($contact_arrray) > 0)) { - try { + if ((is_array($contact_arrray) && count($contact_arrray) > 0)) + { + try + { @@ -901 +930,2 @@ - foreach ($contact_arrray as $contact) { + foreach ($contact_arrray as $contact) + { @@ -917,2 +947,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -920 +952,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -922 +956,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -929 +965,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -943 +981 @@ - 'test' => isModEnabled('propal') && $user->hasRight('propal', 'lire') + 'test' => $conf->propal->enabled && $user->rights->propale->lire @@ -949 +987 @@ - 'test' => isModEnabled('commande') && $user->hasRight('commande', 'lire') + 'test' => $conf->commande->enabled && $user->rights->commande->lire @@ -955 +993 @@ - 'test' => isModEnabled('facture') && $user->hasRight('facture', 'lire') + 'test' => $conf->facture->enabled && $user->rights->facture->lire @@ -961 +999 @@ - 'test' => isModEnabled('facture') && $user->hasRight('facture', 'lire') + 'test' => $conf->facture->enabled && $user->rights->facture->lire @@ -967 +1005 @@ - 'test' => isModEnabled('supplier_proposal') && $user->rights->supplier_proposal->lire + 'test' => $conf->supplier_proposal->enabled && $user->rights->supplier_proposal->lire @@ -973 +1011 @@ - 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire) + 'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled)) && $user->rights->fournisseur->commande->lire @@ -979 +1017 @@ - 'test' => (isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire) + 'test' => (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire @@ -985 +1023 @@ - 'test' => isModEnabled('contrat') && $user->hasRight('contrat', 'lire') + 'test' => $conf->contrat->enabled && $user->rights->contrat->lire @@ -992 +1030 @@ - 'test' => isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire') + 'test' => $conf->ficheinter->enabled && $user->rights->ficheinter->lire @@ -999 +1037 @@ - 'test' => isModEnabled('expedition') && $user->rights->expedition->lire + 'test' => $conf->expedition->enabled && $user->rights->expedition->lire @@ -1006 +1044 @@ - 'test' => isModEnabled('deplacement') && $user->rights->deplacement->lire + 'test' => $conf->deplacement->enabled && $user->rights->deplacement->lire @@ -1012 +1050 @@ - 'test' => isModEnabled('expensereport') && $user->rights->expensereport->lire + 'test' => $conf->expensereport->enabled && $user->rights->expensereport->lire @@ -1018 +1056 @@ - 'test' => isModEnabled('don') && $user->rights->don->lire + 'test' => $conf->don->enabled && $user->rights->don->lire @@ -1024 +1062 @@ - 'test' => isModEnabled('loan') && $user->rights->loan->read + 'test' => $conf->loan->enabled && $user->rights->loan->read @@ -1031 +1069 @@ - 'test' => isModEnabled('tax') && $user->rights->tax->charges->lire + 'test' => $conf->tax->enabled && $user->rights->tax->charges->lire @@ -1037 +1075 @@ - 'test' => (isModEnabled('stock') && $user->rights->stock->mouvement->lire && getDolGlobalString('STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW')) + 'test' => ($conf->stock->enabled && $user->rights->stock->mouvement->lire && !empty($conf->global->STOCK_MOVEMENT_INTO_PROJECT_OVERVIEW)) @@ -1044 +1082 @@ - 'test' => isModEnabled('agenda') && $user->rights->agenda->allactions->lire + 'test' => $conf->agenda->enabled && $user->rights->agenda->allactions->lire @@ -1048,2 +1086,3 @@ - // Insert list of objects into the project - try { + //Insert reference + try + { @@ -1052 +1091,2 @@ - foreach ($listofreferent as $keyref => $valueref) { + foreach ($listofreferent as $keyref => $valueref) + { @@ -1057 +1097,2 @@ - if ($qualified) { + if ($qualified) + { @@ -1059 +1100,2 @@ - if (count($elementarray) > 0 && is_array($elementarray)) { + if (count($elementarray) > 0 && is_array($elementarray)) + { @@ -1063 +1105,2 @@ - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { @@ -1076,6 +1119,2 @@ - if (empty($dateref)) { - $dateref = $element->datep; - } - if (empty($dateref)) { - $dateref = $element->date_contrat; - } + if (empty($dateref)) $dateref = $element->datep; + if (empty($dateref)) $dateref = $element->date_contrat; @@ -1109,2 +1148,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -1112 +1153,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -1114 +1157,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -1124,2 +1168,0 @@ - } catch (OdfExceptionSegmentNotFound $e) { - // Do nothing @@ -1134 +1177,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -1138 +1182 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -1148 +1192 @@ - if (getDolGlobalString('MAIN_ODT_AS_PDF')) { + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { @@ -1160 +1204 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -1167 +1211,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -1174 +1219,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/github_19.0.3_pdf_baleine.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/client_pdf_baleine.modules.php @@ -42 +42,69 @@ - * @var DoliDb Database handler + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Company object that emits @@ -44,38 +112 @@ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - - /** - * @var string document type - */ - public $type; - - /** - * @var int posxdatestart - */ - public $posxdatestart; - - /** - * @var int posxdateend - */ - public $posxdateend; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - + public $emetteur; @@ -90 +121 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -98 +128,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -106,4 +136,4 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; @@ -112,0 +143 @@ + $this->option_codeproduitservice = 1; // Display product-service code @@ -116,3 +147 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -123,5 +152,6 @@ - $this->posxworkload = $this->marge_gauche + 117; - $this->posxprogress = $this->marge_gauche + 137; - $this->posxdatestart = $this->marge_gauche + 147; - $this->posxdateend = $this->marge_gauche + 169; - if ($this->page_largeur < 210) { // To work with US executive format + $this->posxworkload = $this->marge_gauche + 120; + $this->posxprogress = $this->marge_gauche + 140; + $this->posxdatestart = $this->marge_gauche + 152; + $this->posxdateend = $this->marge_gauche + 170; + if ($this->page_largeur < 210) // To work with US executive format + { @@ -138 +168 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -148 +178 @@ - // phpcs:enable + // phpcs:enable @@ -151,3 +181 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -155,3 +183 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -162 +188,2 @@ - if ($conf->project->multidir_output[$object->entity]) { + if ($conf->projet->dir_output) + { @@ -166,4 +193,2 @@ - $dir = $conf->project->multidir_output[$object->entity]; - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + $dir = $conf->projet->dir_output; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -172,2 +197,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -179 +206,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -181 +209,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -196,16 +225,16 @@ - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { - $heightforfooter += 6; - } - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -217 +246,2 @@ - if (!$object->id > 0) { // Special case when used with object = specimen, we may return all lines + if (!$object->id > 0) // Special case when used with object = specimen, we may return all lines + { @@ -233,3 +263 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -241,3 +269 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -251,3 +277,3 @@ - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); - - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_height = 170; + $tab_height_newpage = 190; @@ -257 +283,2 @@ - if ($notetoshow) { + if ($notetoshow) + { @@ -276 +303,3 @@ - } else { + } + else + { @@ -286 +315,2 @@ - for ($i = 0; $i < $nblines; $i++) { + for ($i = 0; $i < $nblines; $i++) + { @@ -310 +340,2 @@ - if ($pageposafter > $pageposbefore) { // There is a pagebreak + if ($pageposafter > $pageposbefore) // There is a pagebreak + { @@ -321,2 +352,4 @@ - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page + { @@ -324,6 +357,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -332 +361,3 @@ - } else { + } + else + { @@ -336 +367 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -338 +369 @@ - } else { + else @@ -340 +370,0 @@ - } @@ -343 +373,2 @@ - if ($forcedesconsamepage) { + if ($forcedesconsamepage) + { @@ -349,6 +380,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -372 +399,3 @@ - } else { // No pagebreak + } + else // No pagebreak + { @@ -386,2 +415 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; @@ -397 +424,0 @@ - $pdf->SetFont('', '', $default_font_size - 2); // We use a smaller font @@ -402,3 +429 @@ - $pdf->SetFont('', '', $default_font_size - 1); // We restore font - - // Date start and end + // Date @@ -411 +436,2 @@ - if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + { @@ -422 +448,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -424 +451,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -426 +454,3 @@ - } else { + } + else + { @@ -433,2 +463,7 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); @@ -436,8 +471,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - } - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + else + { @@ -449,3 +478 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -453,3 +480 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -460 +485 @@ - if ($pagenb == 1) { + if ($pagenb == 1) @@ -462 +487 @@ - } else { + else @@ -464 +488,0 @@ - } @@ -469,3 +493 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -482,3 +504,4 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; @@ -487 +510,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -492 +516,3 @@ - } else { + } + else + { @@ -496 +522,3 @@ - } else { + } + else + { @@ -506 +534 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -528 +556 @@ - // Line takes a position y in 3rd parameter + // line takes a position y in 3rd parameter @@ -546 +573,0 @@ - // Date start @@ -548,3 +575,2 @@ - $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->trans("Start"), 0, 'C'); - - // Date end + $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C'); + @@ -552 +578 @@ - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $outputlangs->trans("End"), 0, 'C'); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); @@ -559 +585 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -576 +602 @@ - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - 100; @@ -583,5 +609,9 @@ - if ($mysoc->logo) { - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { @@ -593,2 +622,0 @@ - } else { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -595,0 +624 @@ + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -608,7 +637,6 @@ - if ($object->date_end) { - $posy += 6; - $pdf->SetXY($posx, $posy); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R'); - } - - if (is_object($object->thirdparty)) { + $posy += 6; + $pdf->SetXY($posx, $posy); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("DateEnd")." : ".dol_print_date($object->date_end, 'day', false, $outputlangs, true), '', 'R'); + + if (is_object($object->thirdparty)) + { @@ -626,19 +654,19 @@ - foreach($object->linkedObjects as $objecttype => $objects) - { - //var_dump($objects);exit; - if ($objecttype == 'commande') - { - $outputlangs->load('orders'); - $num=count($objects); - for ($i=0;$i<$num;$i++) - { - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $text=$objects[$i]->ref; - if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); - } - } - } - */ + foreach($object->linkedObjects as $objecttype => $objects) + { + var_dump($objects);exit; + if ($objecttype == 'commande') + { + $outputlangs->load('orders'); + $num=count($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + } + } + } + */ @@ -650,2 +678,2 @@ - * - * @param TCPDF $pdf PDF + * + * @param PDF $pdf PDF @@ -659 +687,2 @@ - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + global $conf; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; --- /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/github_19.0.3_pdf_beluga.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/client_pdf_beluga.modules.php @@ -56,0 +57,6 @@ + /** + * Page orientation + * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' + */ + private $orientation = ''; + @@ -58 +64,2 @@ - * @var DoliDb Database handler + * Issuer + * @var Societe @@ -60,36 +67 @@ - public $db; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - - /** - * @var string document type - */ - public $type; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - - /** - * Page orientation - * @var string 'P' or 'Portait' (default), 'L' or 'Landscape' - */ - private $orientation; - - public $posxref; - public $posxdate; - public $posxsociety; - public $posxamountht; - public $posxamountttc; - public $posxstatut; - + public $emetteur; @@ -112 +83,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -117,8 +88,8 @@ - $this->orientation = 'L'; - if ($this->orientation == 'L' || $this->orientation == 'Landscape') { - $this->page_largeur = $formatarray['height']; - $this->page_hauteur = $formatarray['width']; - } else { - $this->page_largeur = $formatarray['width']; - $this->page_hauteur = $formatarray['height']; - } + $this->orientation = 'L'; + if ($this->orientation == 'L' || $this->orientation == 'Landscape') { + $this->page_largeur = $formatarray['height']; + $this->page_hauteur = $formatarray['width']; + } else { + $this->page_largeur = $formatarray['width']; + $this->page_hauteur = $formatarray['height']; + } @@ -126,4 +97,4 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; @@ -132,0 +104 @@ + $this->option_codeproduitservice = 1; // Display product-service code @@ -136,21 +108,20 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - - // Define position of columns - if ($this->orientation == 'L' || $this->orientation == 'Landscape') { - $this->posxref = $this->marge_gauche + 1; - $this->posxdate = $this->marge_gauche + 105; - $this->posxsociety = $this->marge_gauche + 126; - $this->posxamountht = $this->marge_gauche + 190; - $this->posxamountttc = $this->marge_gauche + 215; - $this->posxstatut = $this->marge_gauche + 245; - } else { - $this->posxref = $this->marge_gauche + 1; - $this->posxdate = $this->marge_gauche + 25; - $this->posxsociety = $this->marge_gauche + 46; - $this->posxamountht = $this->marge_gauche + 110; - $this->posxamountttc = $this->marge_gauche + 135; - $this->posxstatut = $this->marge_gauche + 165; - } - if ($this->page_largeur < 210) { // To work with US executive format + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + + // Define position of columns + if ($this->orientation == 'L' || $this->orientation == 'Landscape') { + $this->posxref = $this->marge_gauche + 1; + $this->posxdate = $this->marge_gauche + 105; + $this->posxsociety = $this->marge_gauche + 125; + $this->posxamountht = $this->marge_gauche + 190; + $this->posxamountttc = $this->marge_gauche + 215; + $this->posxstatut = $this->marge_gauche + 245; + } else { + $this->posxref = $this->marge_gauche + 1; + $this->posxdate = $this->marge_gauche + 25; + $this->posxsociety = $this->marge_gauche + 45; + $this->posxamountht = $this->marge_gauche + 110; + $this->posxamountttc = $this->marge_gauche + 135; + $this->posxstatut = $this->marge_gauche + 165; + } + if ($this->page_largeur < 210) // To work with US executive format + { @@ -159 +130 @@ - $this->posxsociety -= 20; + $this->posxsociete -= 20; @@ -162 +133 @@ - $this->posxstatut -= 20; + $this->posstatut -= 20; @@ -167 +138 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -177 +148 @@ - // phpcs:enable + // phpcs:enable @@ -180,5 +151,3 @@ - $formproject = new FormProjets($this->db); - - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + $formproject = new FormProjets($this->db); + + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -186,3 +155 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -193 +160,2 @@ - if ($conf->project->multidir_output[$object->entity]) { + if ($conf->projet->dir_output) + { @@ -197,4 +165,2 @@ - $dir = $conf->project->multidir_output[$object->entity]; - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + $dir = $conf->projet->dir_output; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -203,2 +169,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -210 +178,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -212 +181,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -227,16 +197,16 @@ - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { - $heightforfooter += 6; - } - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -266,3 +236 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -274,3 +242 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -284,3 +250,3 @@ - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); - - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_height = 170; + $tab_height_newpage = 190; @@ -290 +256,2 @@ - if ($notetoshow) { + if ($notetoshow) + { @@ -309 +276,3 @@ - } else { + } + else + { @@ -318,227 +287,228 @@ - $listofreferent = array( - 'propal'=>array( - 'name'=>"Proposals", - 'title'=>"ListProposalsAssociatedProject", - 'class'=>'Propal', - 'table'=>'propal', - 'datefieldname'=>'datep', - 'test'=> isModEnabled('propal') && $user->hasRight('propal', 'lire'), - 'lang'=>'propal'), - 'order'=>array( - 'name'=>"CustomersOrders", - 'title'=>"ListOrdersAssociatedProject", - 'class'=>'Commande', - 'table'=>'commande', - 'datefieldname'=>'date_commande', - 'test'=> isModEnabled('commande') && $user->hasRight('commande', 'lire'), - 'lang'=>'orders'), - 'invoice'=>array( - 'name'=>"CustomersInvoices", - 'title'=>"ListInvoicesAssociatedProject", - 'class'=>'Facture', - 'margin'=>'add', - 'table'=>'facture', - 'datefieldname'=>'datef', - 'test'=> isModEnabled('facture') && $user->hasRight('facture', 'lire'), - 'lang'=>'bills'), - 'invoice_predefined'=>array( - 'name'=>"PredefinedInvoices", - 'title'=>"ListPredefinedInvoicesAssociatedProject", - 'class'=>'FactureRec', - 'table'=>'facture_rec', - 'datefieldname'=>'datec', - 'test'=> isModEnabled('facture') && $user->hasRight('facture', 'lire'), - 'lang'=>'bills'), - 'order_supplier'=>array( - 'name'=>"SuppliersOrders", - 'title'=>"ListSupplierOrdersAssociatedProject", - 'class'=>'CommandeFournisseur', - 'table'=>'commande_fournisseur', - 'datefieldname'=>'date_commande', - 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->commande->lire) || (isModEnabled("supplier_order") && $user->rights->supplier_order->lire), - 'lang'=>'orders'), - 'invoice_supplier'=>array( - 'name'=>"BillsSuppliers", - 'title'=>"ListSupplierInvoicesAssociatedProject", - 'class'=>'FactureFournisseur', - 'margin'=>'minus', - 'table'=>'facture_fourn', - 'datefieldname'=>'datef', - 'test'=>(isModEnabled("fournisseur") && !getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->rights->fournisseur->facture->lire) || (isModEnabled("supplier_invoice") && $user->rights->supplier_invoice->lire), - 'lang'=>'bills'), - 'contract'=>array( - 'name'=>"Contracts", - 'title'=>"ListContractAssociatedProject", - 'class'=>'Contrat', - 'table'=>'contrat', - 'datefieldname'=>'date_contrat', - 'test'=> isModEnabled('contrat') && $user->hasRight('contrat', 'lire'), - 'lang'=>'contract'), - 'intervention'=>array( - 'name'=>"Interventions", - 'title'=>"ListFichinterAssociatedProject", - 'class'=>'Fichinter', - 'table'=>'fichinter', - 'datefieldname'=>'date_valid', - 'disableamount'=>1, - 'test'=>isModEnabled('ficheinter') && $user->hasRight('ficheinter', 'lire'), - 'lang'=>'interventions'), - 'trip'=>array( - 'name'=>"TripsAndExpenses", - 'title'=>"ListExpenseReportsAssociatedProject", - 'class'=>'Deplacement', - 'table'=>'deplacement', - 'datefieldname'=>'dated', - 'margin'=>'minus', - 'disableamount'=>1, - 'test'=>isModEnabled('deplacement') && $user->rights->deplacement->lire, - 'lang'=>'trip'), - 'expensereport'=>array( - 'name'=>"ExpensesReports", - 'title'=>"ListExpenseReportsAssociatedProject", - 'class'=>'ExpenseReport', - 'table'=>'expensereport', - 'datefieldname'=>'dated', - 'margin'=>'minus', - 'disableamount'=>1, - 'test'=>isModEnabled('expensereport') && $user->rights->expensereport->lire, - 'lang'=>'trip'), - 'agenda'=>array( - 'name'=>"Agenda", - 'title'=>"ListActionsAssociatedProject", - 'class'=>'ActionComm', - 'table'=>'actioncomm', - 'datefieldname'=>'datep', - 'disableamount'=>1, - 'test'=> isModEnabled('agenda') && $user->rights->agenda->allactions->read, - 'lang'=>'agenda') - ); - - $hookmanager->initHooks(array('completeListOfReferent')); - $hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action); - if (!empty($hookmanager->resArray)) { - $listofreferent = array_merge($listofreferent, $hookmanager->resArray); - } - - foreach ($listofreferent as $key => $value) { - $title = $value['title']; - $classname = $value['class']; - $tablename = $value['table']; - $datefieldname = $value['datefieldname']; - $qualified = $value['test']; - $langstoload = $value['lang']; - $projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet'; - $langs->load($langstoload); - - if (!$qualified) { - continue; - } - - //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); - $elementarray = $object->get_element_list($key, $tablename, $datefieldname, '', '', $projectField); - - $num = count($elementarray); - if ($num >= 0) { - $nexY = $pdf->GetY() + 5; - - $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage - $pdf->SetTextColor(0, 0, 0); - - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); - - $selectList = $formproject->select_element($tablename, $object->thirdparty->id, '', -2, $projectField); - $nexY = $pdf->GetY() + 1; - $curY = $nexY; - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L'); - $pdf->SetXY($this->posxdate, $curY); - $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); - $pdf->SetXY($this->posxsociety, $curY); - $titlethirdparty = $outputlangs->transnoentities("ThirdParty"); - if ($classname == 'ExpenseReport') { - $titlethirdparty = $langs->trans("User"); - } - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L'); - if (empty($value['disableamount'])) { - $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); - $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R'); - } else { - $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); - } - $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); - - if (is_array($elementarray) && count($elementarray) > 0) { - $nexY = $pdf->GetY(); - - $total_ht = 0; - $total_ttc = 0; - $num = count($elementarray); - - // Loop on each lines - for ($i = 0; $i < $num; $i++) { - $curY = $nexY; - $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage - $pdf->SetTextColor(0, 0, 0); - - $pdf->setTopMargin($tab_top_newpage); - $pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. - $pageposbefore = $pdf->getPage(); - - // Description of line - $idofelement = $elementarray[$i]; - if ($classname == 'ExpenseReport') { - // We get id of expense report - $expensereportline = new ExpenseReportLine($this->db); - $expensereportline->fetch($idofelement); - $idofelement = $expensereportline->fk_expensereport; - } - - $element = new $classname($this->db); - $element->fetch($idofelement); - $element->fetch_thirdparty(); - // print $classname; - - $qualifiedfortotal = true; - if ($key == 'invoice') { - if ($element->close_code == 'replaced') { - $qualifiedfortotal = false; // Replacement invoice - } - } - - $showpricebeforepagebreak = 1; - - $pdf->startTransaction(); - // Label - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter = $pdf->getPage(); - if ($pageposafter > $pageposbefore) { // There is a pagebreak - $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - //print $pageposafter.'-'.$pageposbefore;exit; - $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - // Label - $pdf->SetXY($this->posxref, $curY); - $posybefore = $pdf->GetY(); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($num - 1)) { // No more lines, and no space left to show total, so we create a new page - $pdf->AddPage($this->orientation, '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposafter + 1); - } - } else { - // We found a page break + $listofreferent = array( + 'propal'=>array( + 'name'=>"Proposals", + 'title'=>"ListProposalsAssociatedProject", + 'class'=>'Propal', + 'table'=>'propal', + 'datefieldname'=>'datep', + 'test'=>$conf->propal->enabled && $user->rights->propale->lire, + 'lang'=>'propal'), + 'order'=>array( + 'name'=>"CustomersOrders", + 'title'=>"ListOrdersAssociatedProject", + 'class'=>'Commande', + 'table'=>'commande', + 'datefieldname'=>'date_commande', + 'test'=>$conf->commande->enabled && $user->rights->commande->lire, + 'lang'=>'orders'), + 'invoice'=>array( + 'name'=>"CustomersInvoices", + 'title'=>"ListInvoicesAssociatedProject", + 'class'=>'Facture', + 'margin'=>'add', + 'table'=>'facture', + 'datefieldname'=>'datef', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), + 'invoice_predefined'=>array( + 'name'=>"PredefinedInvoices", + 'title'=>"ListPredefinedInvoicesAssociatedProject", + 'class'=>'FactureRec', + 'table'=>'facture_rec', + 'datefieldname'=>'datec', + 'test'=>$conf->facture->enabled && $user->rights->facture->lire, + 'lang'=>'bills'), + 'order_supplier'=>array( + 'name'=>"SuppliersOrders", + 'title'=>"ListSupplierOrdersAssociatedProject", + 'class'=>'CommandeFournisseur', + 'table'=>'commande_fournisseur', + 'datefieldname'=>'date_commande', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire, + 'lang'=>'orders'), + 'invoice_supplier'=>array( + 'name'=>"BillsSuppliers", + 'title'=>"ListSupplierInvoicesAssociatedProject", + 'class'=>'FactureFournisseur', + 'margin'=>'minus', + 'table'=>'facture_fourn', + 'datefieldname'=>'datef', + 'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire, + 'lang'=>'bills'), + 'contract'=>array( + 'name'=>"Contracts", + 'title'=>"ListContractAssociatedProject", + 'class'=>'Contrat', + 'table'=>'contrat', + 'datefieldname'=>'date_contrat', + 'test'=>$conf->contrat->enabled && $user->rights->contrat->lire, + 'lang'=>'contract'), + 'intervention'=>array( + 'name'=>"Interventions", + 'title'=>"ListFichinterAssociatedProject", + 'class'=>'Fichinter', + 'table'=>'fichinter', + 'datefieldname'=>'date_valid', + 'disableamount'=>1, + 'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire, + 'lang'=>'interventions'), + 'trip'=>array( + 'name'=>"TripsAndExpenses", + 'title'=>"ListExpenseReportsAssociatedProject", + 'class'=>'Deplacement', + 'table'=>'deplacement', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire, + 'lang'=>'trip'), + 'expensereport'=>array( + 'name'=>"ExpensesReports", + 'title'=>"ListExpenseReportsAssociatedProject", + 'class'=>'ExpenseReport', + 'table'=>'expensereport', + 'datefieldname'=>'dated', + 'margin'=>'minus', + 'disableamount'=>1, + 'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire, + 'lang'=>'trip'), + 'agenda'=>array( + 'name'=>"Agenda", + 'title'=>"ListActionsAssociatedProject", + 'class'=>'ActionComm', + 'table'=>'actioncomm', + 'datefieldname'=>'datep', + 'disableamount'=>1, + 'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read, + 'lang'=>'agenda') + ); + + $hookmanager->initHooks(array('completeListOfReferent')); + $hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action); + if (!empty($hookmanager->resArray)) { + $listofreferent = array_merge($listofreferent, $hookmanager->resArray); + } + + foreach ($listofreferent as $key => $value) + { + $title = $value['title']; + $classname = $value['class']; + $tablename = $value['table']; + $datefieldname = $value['datefieldname']; + $qualified = $value['test']; + $langstoload = $value['lang']; + $projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet'; + $langs->load($langstoload); + + if (!$qualified) continue; + + //var_dump("$key, $tablename, $datefieldname, $dates, $datee"); + $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField); + + $num = count($elementarray); + if ($num >= 0) + { + $nexY = $pdf->GetY() + 5; + + $curY = $nexY; + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L'); + + $selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField); + $nexY = $pdf->GetY() + 1; + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L'); + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C'); + $pdf->SetXY($this->posxsociety, $curY); + $titlethirdparty = $outputlangs->transnoentities("ThirdParty"); + if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User"); + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L'); + if (empty($value['disableamount'])) { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R'); + } else { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R'); + + if (is_array($elementarray) && count($elementarray) > 0) + { + $nexY = $pdf->GetY(); + + $total_ht = 0; + $total_ttc = 0; + $num = count($elementarray); + + // Loop on each lines + for ($i = 0; $i < $num; $i++) + { + $curY = $nexY; + $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage + $pdf->SetTextColor(0, 0, 0); + + $pdf->setTopMargin($tab_top_newpage); + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. + $pageposbefore = $pdf->getPage(); + + // Description of line + $idofelement = $elementarray[$i]; + if ($classname == 'ExpenseReport') + { + // We get id of expense report + $expensereportline = new ExpenseReportLine($this->db); + $expensereportline->fetch($idofelement); + $idofelement = $expensereportline->fk_expensereport; + } + + $element = new $classname($this->db); + $element->fetch($idofelement); + $element->fetch_thirdparty(); + // print $classname; + + $qualifiedfortotal = true; + if ($key == 'invoice') { + if ($element->close_code == 'replaced') + $qualifiedfortotal = false; // Replacement invoice + } + + $showpricebeforepagebreak = 1; + + $pdf->startTransaction(); + // Label + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + $pageposafter = $pageposbefore; + //print $pageposafter.'-'.$pageposbefore;exit; + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + // Label + $pdf->SetXY($this->posxref, $curY); + $posybefore = $pdf->GetY(); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($num - 1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage($this->orientation, '', true); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } + } + else + { + // We found a page break @@ -547 +517 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -549 +519 @@ - } else { + else @@ -551,131 +521,131 @@ - } - - $forcedesconsamepage = 1; - if ($forcedesconsamepage) { - $pdf->rollbackTransaction(true); - $pageposafter = $pageposbefore; - $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - - $pdf->AddPage($this->orientation, '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $pdf->setPage($pageposafter + 1); - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut - $pdf->MultiCell(0, 3, ''); // Set interline to 3 - $pdf->SetTextColor(0, 0, 0); - - $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. - $curY = $tab_top_newpage + $heightoftitleline + 1; - - // Label - $pdf->SetXY($this->posxref, $curY); - $posybefore = $pdf->GetY(); - $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - } - } - //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); - } else { // No pagebreak - $pdf->commitTransaction(); - } - $posYAfterDescription = $pdf->GetY(); - - $nexY = $pdf->GetY(); - $pageposafter = $pdf->getPage(); - $pdf->setPage($pageposbefore); - $pdf->setTopMargin($this->marge_haute); - $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it. - - // We suppose that a too long description is moved completely on next page - if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { - //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage + $heightoftitleline + 1; - } - - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut - - // Date - if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') { - $date = $element->date_commande; - } else { - $date = $element->date; - if (empty($date)) { - $date = $element->datep; - } - if (empty($date)) { - $date = $element->date_contrat; - } - if (empty($date)) { - $date = $element->datev; // Fiche inter - } - } - - $pdf->SetXY($this->posxdate, $curY); - $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); - - $pdf->SetXY($this->posxsociety, $curY); - if ($classname == 'ExpenseReport') { - $fuser = new User($this->db); - $fuser->fetch($element->fk_user_author); - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); - } else { - $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L'); - } - - // Amount without tax - if (empty($value['disableamount'])) { - $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R'); - $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R'); - } else { - $pdf->SetXY($this->posxamountht, $curY); - if ($key == 'agenda') { - $textforamount = dol_trunc($element->label, 26); - $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L'); - } else { - $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); - } - } - - // Status - if ($element instanceof CommonInvoice) { - // This applies for Facture and FactureFournisseur - $outputstatut = $element->getLibStatut(1, $element->getSommePaiement()); - } else { - $outputstatut = $element->getLibStatut(1); - } - $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true); - - if ($qualifiedfortotal) { - $total_ht = $total_ht + $element->total_ht; - $total_ttc = $total_ttc + $element->total_ttc; - } - $nexY = $pdf->GetY(); - $curY = $nexY; - } - - if (empty($value['disableamount'])) { - $curY = $nexY; - $pdf->SetXY($this->posxref, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L'); - $pdf->SetXY($this->posxamountht, $curY); - $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R'); - $pdf->SetXY($this->posxamountttc, $curY); - $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R'); - $pdf->SetXY($this->posxstatut, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L'); - } - $nexY = $pdf->GetY() + 5; - $curY = $nexY; - } - } - - $nexY += 2; // Add space between lines + + $forcedesconsamepage = 1; + if ($forcedesconsamepage) + { + $pdf->rollbackTransaction(true); + $pageposafter = $pageposbefore; + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + + $pdf->AddPage($this->orientation, '', true); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + $pdf->MultiCell(0, 3, ''); // Set interline to 3 + $pdf->SetTextColor(0, 0, 0); + + $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. + $curY = $tab_top_newpage + $heightoftitleline + 1; + + // Label + $pdf->SetXY($this->posxref, $curY); + $posybefore = $pdf->GetY(); + $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L'); + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + } + } + //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = $pdf->GetY(); + + $nexY = $pdf->GetY(); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); + $pdf->setTopMargin($this->marge_haute); + $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it. + + // We suppose that a too long description is moved completely on next page + if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { + //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak); + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; + } + + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut + + // Date + if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order') + $date = $element->date_commande; + else { + $date = $element->date; + if (empty($date)) + $date = $element->datep; + if (empty($date)) + $date = $element->date_contrat; + if (empty($date)) + $date = $element->datev; // Fiche inter + } + + $pdf->SetXY($this->posxdate, $curY); + $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C'); + + $pdf->SetXY($this->posxsociety, $curY); + if ($classname == 'ExpenseReport') + { + $fuser = new User($this->db); + $fuser->fetch($element->fk_user_author); + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L'); + } + else + { + $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L'); + } + + // Amount without tax + if (empty($value['disableamount'])) { + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R'); + } else { + $pdf->SetXY($this->posxamountht, $curY); + if ($key == 'agenda') + { + $textforamount = dol_trunc($element->label, 26); + $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L'); + } + else + { + $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R'); + } + } + + // Status + if ($element instanceof CommonInvoice) { + // This applies for Facture and FactureFournisseur + $outputstatut = $element->getLibStatut(1, $element->getSommePaiement()); + } else { + $outputstatut = $element->getLibStatut(1); + } + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true); + + if ($qualifiedfortotal) { + $total_ht = $total_ht + $element->total_ht; + $total_ttc = $total_ttc + $element->total_ttc; + } + $nexY = $pdf->GetY(); + $curY = $nexY; + } + + if (empty($value['disableamount'])) { + $curY = $nexY; + $pdf->SetXY($this->posxref, $curY); + $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L'); + $pdf->SetXY($this->posxamountht, $curY); + $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R'); + $pdf->SetXY($this->posxamountttc, $curY); + $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R'); + $pdf->SetXY($this->posxstatut, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L'); + } + $nexY = $pdf->GetY() + 5; + $curY = $nexY; + } + } + + $nexY += 2; // Add space between lines @@ -684 +654,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -690,6 +661 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -701,3 +667 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -714,3 +678,4 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; @@ -719 +684,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -724 +690,3 @@ - } else { + } + else + { @@ -728 +696,3 @@ - } else { + } + else + { @@ -738 +708 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -748,0 +719,2 @@ + global $conf, $mysoc; + @@ -762,0 +735,18 @@ + + $pdf->SetXY($this->posxref, $tab_top + 1); + $pdf->MultiCell($this->posxlabel - $this->posxref, 3, $outputlangs->transnoentities("Tasks"), '', 'L'); + + $pdf->SetXY($this->posxlabel, $tab_top + 1); + $pdf->MultiCell($this->posxworkload - $this->posxlabel, 3, $outputlangs->transnoentities("Description"), 0, 'L'); + + $pdf->SetXY($this->posxworkload, $tab_top + 1); + $pdf->MultiCell($this->posxprogress - $this->posxworkload, 3, $outputlangs->transnoentities("PlannedWorkloadShort"), 0, 'R'); + + $pdf->SetXY($this->posxprogress, $tab_top + 1); + $pdf->MultiCell($this->posxdatestart - $this->posxprogress, 3, '%', 0, 'R'); + + $pdf->SetXY($this->posxdatestart, $tab_top + 1); + $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, '', 0, 'C'); + + $pdf->SetXY($this->posxdateend, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); @@ -769 +759 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -786 +776 @@ - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - 100; @@ -793,5 +783,9 @@ - if ($mysoc->logo) { - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { @@ -803,2 +796,0 @@ - } else { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -805,0 +798 @@ + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -822 +815,2 @@ - if (is_object($object->thirdparty)) { + if (is_object($object->thirdparty)) + { @@ -834,2 +828,2 @@ - * - * @param TCPDF $pdf PDF + * + * @param PDF $pdf PDF @@ -843 +837,2 @@ - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); + global $conf; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; --- /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/github_19.0.3_pdf_timespent.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/project/doc/client_pdf_timespent.modules.php @@ -41 +41,2 @@ - * @var DoliDb Database handler + * Issuer + * @var Societe @@ -43,33 +44 @@ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var int Save the name of generated file as the main doc when generating a doc with this template - */ - public $update_main_doc_field; - - /** - * @var string document type - */ - public $type; - - /** - * @var int - */ - public $posxuser; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; - + public $emetteur; @@ -84 +53 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -92 +60,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -100,4 +68,4 @@ - $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10); - $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10); - $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); - $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); + $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10; + $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10; + $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10; + $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10; @@ -106,0 +75 @@ + $this->option_codeproduitservice = 1; // Display product-service code @@ -110,3 +79 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -117 +83,0 @@ - $this->posxworkload = $this->marge_gauche + 100; @@ -120,3 +86,4 @@ - $this->posxuser = $this->marge_gauche + 147; - //$this->posxdateend = $this->marge_gauche + 169; - if ($this->page_largeur < 210) { // To work with US executive format + $this->posxdatestart = $this->marge_gauche + 152; + $this->posxdateend = $this->marge_gauche + 170; + if ($this->page_largeur < 210) // To work with US executive format + { @@ -127,2 +94,2 @@ - $this->posxuser -= 20; - //$this->posxdateend -= 20; + $this->posxdatestart -= 20; + $this->posxdateend -= 20; @@ -133 +100 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -135 +102 @@ - * Function to build pdf project onto disk + * Fonction generant le projet sur le disque @@ -143 +110 @@ - // phpcs:enable + // phpcs:enable @@ -146,3 +113 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -150,3 +115 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -157 +120,2 @@ - if ($conf->project->multidir_output[$object->entity]) { + if ($conf->projet->dir_output) + { @@ -161,4 +125,2 @@ - $dir = $conf->project->multidir_output[$object->entity]; - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + $dir = $conf->projet->dir_output; + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -167,2 +129,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -174 +138,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -176 +141,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -191,16 +157,15 @@ - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { - $heightforfooter += 6; - } - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -212,3 +177,4 @@ - if (!$object->id > 0) { // Special case when used with object = specimen, we may return all lines - $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray))); - } + if (!$object->id > 0) // Special case when used with object = specimen, we may return all lines + { + $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray))); + } @@ -228,3 +194 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -236,3 +200 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -246,3 +208,3 @@ - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); - - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_height = 170; + $tab_height_newpage = 190; @@ -252 +214,2 @@ - if ($notetoshow) { + if ($notetoshow) + { @@ -267 +230 @@ - $pdf->Rect($this->marge_gauche, $tab_top - 2, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2); + $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1); @@ -271 +234,3 @@ - } else { + } + else + { @@ -280,4 +244,0 @@ - $tmpuser = new User($this->db); - - // TODO We should loop on record of times spent grouped by user instead of lines of tasks - @@ -285 +246,2 @@ - for ($i = 0; $i < $nblines; $i++) { + for ($i = 0; $i < $nblines; $i++) + { @@ -309 +271,2 @@ - if ($pageposafter > $pageposbefore) { // There is a pagebreak + if ($pageposafter > $pageposbefore) // There is a pagebreak + { @@ -320,2 +283,4 @@ - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page + { @@ -323,6 +288,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -331 +292,3 @@ - } else { + } + else + { @@ -335 +298 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -337 +300 @@ - } else { + else @@ -339 +301,0 @@ - } @@ -342 +304,2 @@ - if ($forcedesconsamepage) { + if ($forcedesconsamepage) + { @@ -348,6 +311,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -371 +330,3 @@ - } else { // No pagebreak + } + else // No pagebreak + { @@ -385,2 +346 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage + $heightoftitleline + 1; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1; @@ -389 +349 @@ - $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font + $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut @@ -396 +356 @@ - $pdf->MultiCell($this->posxuser - $this->posxtimespent, 3, $duration ? $duration : '', 0, 'R'); + $pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $duration ? $duration : '', 0, 'R'); @@ -399,8 +359,6 @@ - //$pdf->MultiCell($this->posxuser-$this->posxprogress, 3, $progress, 0, 'R'); - - // User spending time - /*var_dump($object->lines[$i]);exit; - $tmpuser->fetch($object->lines[$i]->fk_user); - $pdf->SetXY($this->posxuser, $curY); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxuser, 3, $tmpuser->getFullName($outputlangs, 0, -1, 20), 0, 'C'); - */ + //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, $progress, 0, 'R'); + // Date + $pdf->SetXY($this->posxdatestart, $curY); + $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $datestart, 0, 'C'); + $pdf->SetXY($this->posxdateend, $curY); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdateend, 3, $dateend, 0, 'C'); @@ -409 +367,2 @@ - if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + { @@ -420 +379,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -422 +382,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -424 +385,3 @@ - } else { + } + else + { @@ -431,2 +394,7 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); @@ -434,8 +402,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - } - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + else + { @@ -447,3 +409 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -451,3 +411 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -458 +416 @@ - if ($pagenb == 1) { + if ($pagenb == 1) @@ -460 +418 @@ - } else { + else @@ -462 +419,0 @@ - } @@ -465 +422 @@ - // Footer of the page + // Pied de page @@ -467,3 +424 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -480,3 +435,4 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; @@ -485 +441,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -490 +447,3 @@ - } else { + } + else + { @@ -494 +453,3 @@ - } else { + } + else + { @@ -504 +465 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -519 +480 @@ - $default_font_size = pdf_getPDFFontSize($outputlangs); + $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -526 +487 @@ - // Line takes a position y in 3rd parameter + // line prend une position y en 3eme param @@ -539 +500 @@ - $pdf->MultiCell($this->posxuser - $this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R'); + $pdf->MultiCell($this->posxdatestart - $this->posxtimespent, 3, $outputlangs->transnoentities("TimeSpent"), 0, 'R'); @@ -542,4 +503,7 @@ - //$pdf->MultiCell($this->posxuser - $this->posxprogress, 3, '%', 0, 'R'); - - $pdf->SetXY($this->posxuser, $tab_top + 1); - $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxuser, 3, '', 0, 'C'); + //$pdf->MultiCell($this->posxdatestart-$this->posxprogress, 3, '%', 0, 'R'); + + $pdf->SetXY($this->posxdatestart, $tab_top + 1); + $pdf->MultiCell($this->posxdateend - $this->posxdatestart, 3, $outputlangs->transnoentities("Date"), 0, 'C'); + + $pdf->SetXY($this->posxdateend, $tab_top + 1); + $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxdatestart, 3, '', 0, 'C'); @@ -552 +516 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -569 +533 @@ - $posx = $this->page_largeur - $this->marge_droite - 100; + $posx = $this->page_largeur - $this->marge_droite - 100; @@ -576,5 +540,9 @@ - if ($mysoc->logo) { - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { @@ -586,2 +553,0 @@ - } else { - $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -588,0 +555 @@ + else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); @@ -605 +572,2 @@ - if (is_object($object->thirdparty)) { + if (is_object($object->thirdparty)) + { @@ -617,19 +585,19 @@ - foreach($object->linkedObjects as $objecttype => $objects) - { - //var_dump($objects);exit; - if ($objecttype == 'commande') - { - $outputlangs->load('orders'); - $num=count($objects); - for ($i=0;$i<$num;$i++) - { - $posy+=4; - $pdf->SetXY($posx,$posy); - $pdf->SetFont('','', $default_font_size - 1); - $text=$objects[$i]->ref; - if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); - } - } - } - */ + foreach($object->linkedObjects as $objecttype => $objects) + { + var_dump($objects);exit; + if ($objecttype == 'commande') + { + $outputlangs->load('orders'); + $num=count($objects); + for ($i=0;$i<$num;$i++) + { + $posy+=4; + $pdf->SetXY($posx,$posy); + $pdf->SetFont('','', $default_font_size - 1); + $text=$objects[$i]->ref; + if ($objects[$i]->ref_client) $text.=' ('.$objects[$i]->ref_client.')'; + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); + } + } + } + */ @@ -639,9 +607,9 @@ - /** - * Show footer of page. Need this->emetteur object - * - * @param TCPDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer - */ + /** + * Show footer of page. Need this->emetteur object + * + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer + */ @@ -649,4 +617,5 @@ - { - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); - return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + { + global $conf; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + }
'; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= '