--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_19.0.3_doc_generic_proposal_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_doc_generic_proposal_odt.modules.php
@@ -34 +33,0 @@
-require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
@@ -42,4 +41,15 @@
- /**
- * @var string Dolibarr version of the loaded document
- */
- public $version = 'dolibarr';
+ /**
+ * @var Company Issuer object that emits
+ */
+ public $emetteur;
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
+
+ /**
+ * @var string Dolibarr version of the loaded document
+ */
+ public $version = 'dolibarr';
@@ -55 +65 @@
- global $langs, $mysoc;
+ global $conf, $langs, $mysoc;
@@ -58 +68 @@
- $langs->loadLangs(array("main", "companies"));
+ $langs->loadLangs(array("main", "companies"));
@@ -63 +72,0 @@
- $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
@@ -76,6 +85,7 @@
- $this->option_logo = 1; // Display logo
- $this->option_tva = 0; // Manage the vat option PROPALE_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 PROPALE_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
@@ -86 +96 @@
- // Get source company
+ // Recupere emetteur
@@ -88,3 +98 @@
- 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
@@ -102 +110 @@
- global $langs;
+ global $conf, $langs;
@@ -105 +113 @@
- $langs->loadLangs(array("errors", "companies"));
+ $langs->loadLangs(array("errors", "companies"));
@@ -108,3 +115,0 @@
-
- $odtChosen = getDolGlobalInt('MAIN_PROPAL_CHOOSE_ODT_DOCUMENT') > 0;
- $odtPath = trim(getDolGlobalString('PROPALE_ADDON_PDF_ODT_PATH'));
@@ -115 +119,0 @@
- $texte .= '';
@@ -118 +122,2 @@
- if ($odtChosen) {
+ if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
+ {
@@ -123 +128 @@
- $texte .= '
';
+ $texte .= '';
@@ -128 +133 @@
- $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', $odtPath));
+ $listofdir = explode(',', preg_replace('/[\r\n]+/', ',', trim($conf->global->PROPALE_ADDON_PDF_ODT_PATH)));
@@ -130 +135,2 @@
- foreach ($listofdir as $key => $tmpdir) {
+ foreach ($listofdir as $key=>$tmpdir)
+ {
@@ -134,6 +140,5 @@
- unset($listofdir[$key]);
- continue;
- }
- if (!is_dir($tmpdir)) {
- $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
- } else {
+ unset($listofdir[$key]); continue;
+ }
+ if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
+ else
+ {
@@ -141,3 +146 @@
- if (count($tmpfiles)) {
- $listoffiles = array_merge($listoffiles, $tmpfiles);
- }
+ if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
@@ -147 +149,0 @@
- $texthelp .= '
'.$langs->trans("ExampleOfDirectoriesForModelGen").'';
@@ -152 +154 @@
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
@@ -155 +157 @@
- $texte .= $odtPath;
+ $texte .= $conf->global->PROPALE_ADDON_PDF_ODT_PATH;
@@ -158 +160 @@
- $texte .= '';
+ $texte .= '';
@@ -163 +165,2 @@
- if (!empty($odtPath)) {
+ if (!empty($conf->global->PROPALE_ADDON_PDF_ODT_PATH))
+ {
@@ -171,13 +174,11 @@
- if ($nbofiles) {
- $texte .= '';
-
- // Set default template for different status of proposal
- if ($odtChosen) {
+ if ($nbofiles)
+ {
+ $texte .= '';
+ foreach ($listoffiles as $file)
+ {
+ $texte .= $file['name'].'
';
+ }
+ $texte .= '
';
+
+ if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
+ {
@@ -185,2 +186,2 @@
- $list = ModelePDFPropales::liste_modeles($this->db);
- $texte .= '';
+ $liste = ModelePDFPropales::liste_modeles($this->db);
+ $texte .= '';
@@ -188 +189 @@
- $texte .= ''.$langs->trans("DefaultModelPropalCreate").' | ';
+ $texte .= ''.$langs->trans("DefaultModelPropalCreate").' | ';
@@ -190 +191 @@
- $texte .= $form->selectarray('value2', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_DEFAULT'));
+ $texte .= $form->selectarray('value2', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_DEFAULT);
@@ -194 +195 @@
- $texte .= ''.$langs->trans("DefaultModelPropalToBill").' | ';
+ $texte .= ''.$langs->trans("DefaultModelPropalToBill").' | ';
@@ -196 +197 @@
- $texte .= $form->selectarray('value3', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_TOBILL'));
+ $texte .= $form->selectarray('value3', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_TOBILL);
@@ -200 +201 @@
- $texte .= ''.$langs->trans("DefaultModelPropalClosed").' | ';
+ $texte .= ''.$langs->trans("DefaultModelPropalClosed").' | ';
@@ -202 +203 @@
- $texte .= $form->selectarray('value4', $list, getDolGlobalString('PROPALE_ADDON_PDF_ODT_CLOSED'));
+ $texte .= $form->selectarray('value4', $liste, $conf->global->PROPALE_ADDON_PDF_ODT_CLOSED);
@@ -207,11 +208,5 @@
- // 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 .= '
';
+ // Add input to upload a new template file.
+ $texte .= ''.$langs->trans("UploadNewTemplate").' ';
+ $texte .= '';
+ $texte .= '';
+ $texte .= '
';
@@ -219,0 +215,3 @@
+ $texte .= '';
+ $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
+ $texte .= ' | ';
@@ -228 +226 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -232 +230 @@
- * @param Propal $object Object source to build document
+ * @param Propale $object Object source to build document
@@ -242 +240 @@
- // phpcs:enable
+ // phpcs:enable
@@ -245 +243,2 @@
- if (empty($srctemplatepath)) {
+ if (empty($srctemplatepath))
+ {
@@ -251 +250,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -258,3 +258 @@
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -267 +265,2 @@
- if ($conf->propal->multidir_output[$conf->entity]) {
+ if ($conf->propal->multidir_output[$conf->entity])
+ {
@@ -269 +268,2 @@
- if (!is_object($object)) {
+ if (!is_object($object))
+ {
@@ -273 +273,2 @@
- if ($result < 0) {
+ if ($result < 0)
+ {
@@ -279,2 +279,0 @@
- $object->fetch_thirdparty();
-
@@ -283,3 +282 @@
- if (!preg_match('/specimen/i', $objectref)) {
- $dir .= "/".$objectref;
- }
+ if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
@@ -288,2 +285,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -295 +294,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -298 +298 @@
- $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
+ $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
@@ -302 +302 @@
- $newfiletmp = $objectref . '_' . $newfiletmp;
+ $newfiletmp = $objectref.'_'.$newfiletmp;
@@ -306,10 +306,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;
@@ -322,5 +323 @@
- if (!is_writable($conf->propal->dir_temp)) {
- $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->propal->dir_temp);
- dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
- return -1;
- }
+
@@ -331 +328,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -338,12 +336,12 @@
- if (!empty($usecontact)) {
- // We can use the company of contact instead of thirdparty company
- if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
- $object->contact->fetch_thirdparty();
- $socobject = $object->contact->thirdparty;
- $contactobject = $object->contact;
- } else {
- $socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
- $contactobject = $object->contact;
- }
- } else {
+ if (!empty($usecontact))
+ {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
+ else {
+ $socobject = $object->thirdparty;
+ // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+ $contactobject = $object->contact;
+ }
+ }
+ else
+ {
@@ -358 +356 @@
- '__TOTAL_VAT__' => $object->total_tva
+ '__TOTAL_VAT__' => $object->total_vat
@@ -368,2 +366,3 @@
- if (!empty($conf->global->$paramfreetext)) {
- $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
+ if (!empty($conf->global->$paramfreetext))
+ {
+ $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
@@ -375 +374 @@
- $odfHandler = new Odf(
+ $odfHandler = new odf(
@@ -384 +383,3 @@
- } catch (Exception $e) {
+ }
+ catch (Exception $e)
+ {
@@ -400 +401,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -412,7 +414,0 @@
-
- include_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
- $companybankaccount = new CompanyBankAccount($this->db);
- $companybankaccount->fetch(0, $object->thirdparty->id);
- $array_objet['company_default_bank_iban']=$companybankaccount->iban;
- $array_objet['company_default_bank_bic']=$companybankaccount->bic;
-
@@ -421,3 +417 @@
- if ($usecontact && is_object($contactobject)) {
- $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
- }
+ if ($usecontact && is_object($contactobject)) $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
@@ -432 +426,2 @@
- foreach ($tmparray as $key => $value) {
+ foreach ($tmparray as $key=>$value)
+ {
@@ -434,7 +429,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
+ {
@@ -443,2 +438,4 @@
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -448 +445,2 @@
- try {
+ try
+ {
@@ -452 +450,3 @@
- } catch (OdfExceptionSegmentNotFound $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -456,5 +456,3 @@
- } catch (OdfException $e) {
- $foundtagforlines = 0;
- dol_syslog($e->getMessage(), LOG_INFO);
- }
- if ($foundtagforlines) {
+ }
+ if ($foundtagforlines)
+ {
@@ -462 +460,2 @@
- foreach ($object->lines as $line) {
+ foreach ($object->lines as $line)
+ {
@@ -469,2 +468,4 @@
- foreach ($tmparray as $key => $val) {
- try {
+ foreach ($tmparray as $key => $val)
+ {
+ try
+ {
@@ -472 +473,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -474 +477,3 @@
- } catch (SegmentException $e) {
+ }
+ catch (SegmentException $e)
+ {
@@ -482 +487,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -490 +497,2 @@
- foreach ($tmparray as $key => $value) {
+ foreach ($tmparray as $key=>$value)
+ {
@@ -493,2 +501,4 @@
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -503 +513 @@
- if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
+ if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
@@ -508 +518 @@
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -511 +521,2 @@
- } else {
+ }
+ else {
@@ -513 +524 @@
- $odfHandler->saveToDisk($file);
+ $odfHandler->saveToDisk($file);
@@ -516 +527 @@
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -523 +534,2 @@
- dolChmod($file);
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -530 +542,3 @@
- } else {
+ }
+ else
+ {
--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_19.0.3_pdf_azur.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_pdf_azur.modules.php
@@ -33 +32,0 @@
-
@@ -47 +46,74 @@
- * @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 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 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 Societe Object that emits
@@ -49,32 +121 @@
- public $db;
-
- /**
- * @var int The environment ID when using a multicompany module
- */
- public $entity;
-
- /**
- * @var string model name
- */
- public $name;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
- /**
- * @var string 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';
+ public $emetteur;
@@ -106,4 +147,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;
@@ -114,0 +156 @@
+ $this->option_codeproduitservice = 1; // Display product-service code
@@ -120 +161,0 @@
- $this->watermark = '';
@@ -124,3 +165 @@
- if (empty($this->emetteur->country_code)) {
- $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
- }
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -130 +169,2 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if ($conf->global->PRODUCT_USE_UNITS)
+ {
@@ -135,3 +175,5 @@
- } else {
- $this->posxtva = 106;
- $this->posxup = 122;
+ }
+ else
+ {
+ $this->posxtva = 110;
+ $this->posxup = 126;
@@ -143,5 +185,4 @@
- if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') || getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
- $this->posxtva = $this->posxup;
- }
- $this->posxpicture = $this->posxtva - (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
- if ($this->page_largeur < 210) { // To work with US executive format
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
+ $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
@@ -158 +198,0 @@
- $this->tva_array = array();
@@ -165,11 +205,11 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Propal $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ /**
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
@@ -179 +219 @@
- // phpcs:enable
+ // phpcs:enable
@@ -182,5 +222 @@
- dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
-
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -188,5 +224,3 @@
- if (getDolGlobalString('MAIN_USE_FPDF')) {
- $outputlangs->charset_output = 'ISO-8859-1';
- }
-
- // Load translation files required by page
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+
+ // Load traductions files required by page
@@ -194,13 +227,0 @@
-
- global $outputlangsbis;
- $outputlangsbis = null;
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
- $outputlangsbis = new Translate('', $conf);
- $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
- $outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
- }
-
- // Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('PROPALE_DRAFT_WATERMARK')) {
- $this->watermark = getDolGlobalString('PROPALE_DRAFT_WATERMARK');
- }
@@ -212,2 +233,2 @@
- $this->atleastonephoto = false;
- if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) {
+ if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
+ {
@@ -216,4 +237,3 @@
- for ($i = 0; $i < $nblines; $i++) {
- if (empty($object->lines[$i]->fk_product)) {
- continue;
- }
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
@@ -222,2 +242,3 @@
- //var_dump($objphoto->ref);exit;
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
+ //var_dump($objphoto->ref);exit;
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
@@ -226,2 +247,4 @@
- } else {
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
+ }
+ else
+ {
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
@@ -232,4 +255,5 @@
- $realpath = '';
- foreach ($pdir as $midir) {
- if (!$arephoto) {
- if ($conf->entity != $objphoto->entity) {
+ foreach ($pdir as $midir)
+ {
+ if (!$arephoto)
+ {
+ if ($conf->product->entity != $objphoto->entity) {
@@ -240,3 +264,7 @@
- foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
- if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
- if ($obj['photo_vignette']) {
+
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+ {
+ if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ {
+ if ($obj['photo_vignette'])
+ {
@@ -244 +272,3 @@
- } else {
+ }
+ else
+ {
@@ -247 +277,3 @@
- } else {
+ }
+ else
+ {
@@ -253 +284,0 @@
- $this->atleastonephoto = true;
@@ -258,11 +289,8 @@
- if ($realpath && $arephoto) {
- $realpatharray[$i] = $realpath;
- }
- }
- }
-
- if (count($realpatharray) == 0) {
- $this->posxpicture = $this->posxtva;
- }
-
- if ($conf->propal->multidir_output[$conf->entity]) {
+ if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
+ }
+ }
+
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
+
+ if ($conf->propal->multidir_output[$conf->entity])
+ {
@@ -274 +302,2 @@
- if ($object->specimen) {
+ if ($object->specimen)
+ {
@@ -277 +306,3 @@
- } else {
+ }
+ else
+ {
@@ -283,2 +314,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -290 +323,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -292 +326,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -301,4 +335,0 @@
- // Set nblines with the new content of lines after hook
- $nblines = count($object->lines);
- //$nbpayments = count($object->getListOfPayments());
-
@@ -306,18 +337,16 @@
- $pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- 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')) {
- $logodir = $conf->mycompany->dir_output;
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
- }
- $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
- $tplidx = $pdf->importPage(1);
- }
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ 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->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
@@ -334,3 +363 @@
- if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
- $pdf->SetCompression(false);
- }
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
@@ -340,3 +367,5 @@
- // Set $this->atleastonediscount if you have at least one discount
- for ($i = 0; $i < $nblines; $i++) {
- if ($object->lines[$i]->remise_percent) {
+ // Positionne $this->atleastonediscount si on a au moins une remise
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if ($object->lines[$i]->remise_percent)
+ {
@@ -346,9 +375,10 @@
- if (empty($this->atleastonediscount)) {
- $delta = ($this->postotalht - $this->posxdiscount);
- $this->posxpicture += $delta;
- $this->posxtva += $delta;
- $this->posxup += $delta;
- $this->posxqty += $delta;
- $this->posxunit += $delta;
- $this->posxdiscount += $delta;
- // post of fields after are not modified, stay at same position
+ if (empty($this->atleastonediscount))
+ {
+ $delta = ($this->postotalht - $this->posxdiscount);
+ $this->posxpicture += $delta;
+ $this->posxtva += $delta;
+ $this->posxup += $delta;
+ $this->posxqty += $delta;
+ $this->posxunit += $delta;
+ $this->posxdiscount += $delta;
+ // post of fields after are not modified, stay at same position
@@ -359,3 +389 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -364,10 +392,8 @@
- $heightforinfotot = 40; // Height reserved to output the info and total part
- $heightforsignature = !getDolGlobalString('PROPAL_DISABLE_SIGNATURE') ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
- $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;
- }
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
-
- $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
+ $heightforinfotot = 40; // Height reserved to output the info and total part
+ $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+ $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;
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -379,2 +405,2 @@
- $tab_top = 90 + $top_shift;
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
@@ -383,2 +409,2 @@
- $height_incoterms = 0;
- if (isModEnabled('incoterm')) {
+ if ($conf->incoterm->enabled)
+ {
@@ -386 +412,2 @@
- if ($desc_incoterms) {
+ if ($desc_incoterms)
+ {
@@ -399,5 +426,4 @@
- $height_incoterms += 4;
- }
- }
-
- // Displays notes
+ }
+ }
+
+ // Affiche notes
@@ -405 +431,2 @@
- if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ {
@@ -407 +434,2 @@
- if (is_object($object->thirdparty)) {
+ if (is_object($object->thirdparty))
+ {
@@ -411,27 +439,18 @@
- if (!empty($salerepobj->signature)) {
- $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
- }
- }
- }
- // Extrafields in note
- $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
- if (!empty($extranote)) {
- $notetoshow = dol_concatdesc($notetoshow, $extranote);
- }
- if (getDolGlobalString('MAIN_ADD_CREATOR_IN_NOTE') && $object->user_author_id > 0) {
- $tmpuser = new User($this->db);
- $tmpuser->fetch($object->user_author_id);
-
-
- $creator_info = $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
- if ($tmpuser->email) {
- $creator_info .= ', '.$langs->trans("EMail").': '.$tmpuser->email;
- }
- if ($tmpuser->office_phone) {
- $creator_info .= ', '.$langs->trans("Phone").': '.$tmpuser->office_phone;
- }
-
- $notetoshow = dol_concatdesc($notetoshow, $creator_info);
- }
-
- if ($notetoshow) {
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
+ }
+ }
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote)) {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+ if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
+ {
+ $tmpuser = new User($this->db);
+ $tmpuser->fetch($object->user_author_id);
+ $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+ if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
+ if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
+ }
+ if ($notetoshow)
+ {
@@ -462 +481,2 @@
- for ($i = 0; $i < $nblines; $i++) {
+ for ($i = 0; $i < $nblines; $i++)
+ {
@@ -469,3 +489 @@
- if (!empty($realpatharray[$i])) {
- $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
- }
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
@@ -482 +500,2 @@
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // If photo too high, we moved completely on new page
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
+ {
@@ -484,6 +503,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);
@@ -495 +510 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -497 +512 @@
- } else {
+ else
@@ -499,4 +514,4 @@
- }
- }
-
- if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
+ }
+
+ if (isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
@@ -515 +530,2 @@
- if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
@@ -525,2 +541,4 @@
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $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 + $heightforsignature + $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
+ {
@@ -528,6 +546,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);
@@ -536 +550,3 @@
- } else {
+ }
+ else
+ {
@@ -540 +556 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -542 +558 @@
- } else {
+ else
@@ -544 +559,0 @@
- }
@@ -546 +561,3 @@
- } else { // No pagebreak
+ }
+ else // No pagebreak
+ {
@@ -560,2 +577 @@
- $pdf->setPage($pageposafter);
- $curY = $tab_top_newpage;
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
@@ -567 +583,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+ {
@@ -584 +601,2 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if ($conf->global->PRODUCT_USE_UNITS)
+ {
@@ -592 +610,2 @@
- if ($object->lines[$i]->remise_percent) {
+ if ($object->lines[$i]->remise_percent)
+ {
@@ -604,5 +623,2 @@
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $object->lines[$i]->multicurrency_total_tva;
- } else {
- $tvaligne = $object->lines[$i]->total_tva;
- }
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
@@ -617,10 +633,3 @@
- // TODO remise_percent is an obsolete field for object parent
- /*if ($object->remise_percent) {
- $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- }*/
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
@@ -632 +641,2 @@
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
+ {
@@ -634,28 +644,12 @@
- $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
- $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
- }
-
- // retrieve global local tax
- if ($localtax1_type && $localtax1ligne != 0) {
- if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
- $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
- } else {
- $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
- }
- }
- if ($localtax2_type && $localtax2ligne != 0) {
- if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
- $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
- } else {
- $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- }
- }
-
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
- $vatrate .= '*';
- }
-
- // Fill $this->tva and $this->tva_array
- if (!isset($this->tva[$vatrate])) {
- $this->tva[$vatrate] = 0;
- }
+ $localtax1_type = $localtaxtmp_array[0];
+ $localtax2_type = $localtaxtmp_array[2];
+ }
+
+ // retrieve global local tax
+ if ($localtax1_type && $localtax1ligne != 0)
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
+ if ($localtax2_type && $localtax2ligne != 0)
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
+
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
@@ -663,9 +657,2 @@
- $vatcode = $object->lines[$i]->vat_src_code;
- if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
- $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
- }
- $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
-
- if ($posYAfterImage > $posYAfterDescription) {
- $nexY = $posYAfterImage;
- }
+
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
@@ -674 +661,2 @@
- if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ {
@@ -685 +673,2 @@
- while ($pagenb < $pageposafter) {
+ while ($pagenb < $pageposafter)
+ {
@@ -687 +676,2 @@
- if ($pagenb == 1) {
+ if ($pagenb == 1)
+ {
@@ -689 +679,3 @@
- } else {
+ }
+ else
+ {
@@ -696,2 +688,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, $object->multicurrency_code);
@@ -699,8 +696,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, $object->multicurrency_code);
- } else {
+ else
+ {
@@ -712,3 +703 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -716,3 +705 @@
- 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);
@@ -723 +710,2 @@
- if ($pagenb == 1) {
+ if ($pagenb == 1)
+ {
@@ -726 +714,3 @@
- } else {
+ }
+ else
+ {
@@ -746,2 +736,3 @@
- if (!getDolGlobalString('PROPAL_DISABLE_SIGNATURE')) {
- $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
+ if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
+ {
+ $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
@@ -752,3 +743 @@
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -757 +746,2 @@
- if (getDolGlobalString('PRODUIT_PDF_MERGE_PROPAL')) {
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ {
@@ -766 +756 @@
- if (getDolGlobalInt('MAIN_MULTILANGS')) {
+ if ($conf->global->MAIN_MULTILANGS) {
@@ -787,2 +777,3 @@
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
- if (isModEnabled("product")) {
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
+ if (!empty($conf->product->enabled)) {
@@ -790 +781 @@
- } elseif (isModEnabled("service")) {
+ } elseif (!empty($conf->service->enabled)) {
@@ -793,5 +784,7 @@
- } else {
- if (isModEnabled("product")) {
- $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
- } elseif (isModEnabled("service")) {
- $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
+ }
+ else
+ {
+ if (!empty($conf->product->enabled)) {
+ $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
+ } elseif (!empty($conf->service->enabled)) {
+ $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
@@ -833,6 +826,8 @@
- if ($reshook < 0) {
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
- }
-
- dolChmod($file);
+ if ($reshook < 0)
+ {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -843 +838,3 @@
- } else {
+ }
+ else
+ {
@@ -847 +844,3 @@
- } else {
+ }
+ else
+ {
@@ -854 +853 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -858,5 +857,5 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @return int Return integer <0 if KO, >0 if OK
+ * @param TCPDF $pdf Object PDF
+ * @param Object $object Object proposal
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
@@ -866,2 +865 @@
- // phpcs:enable
- return 1;
+ // phpcs:enable
@@ -871 +869 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -876 +874 @@
- * @param Propal $object Object to show
+ * @param Object $object Object to show
@@ -879 +877 @@
- * @return int
+ * @return void
@@ -883 +881 @@
- // phpcs:enable
+ // phpcs:enable
@@ -889,2 +886,0 @@
- $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
-
@@ -892,2 +888,3 @@
- if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -901,10 +898,6 @@
- if (getDolGlobalString('MAIN_PDF_DELIVERY_DATE_TEXT')) {
- $displaydate = "daytext";
- } else {
- $displaydate = "day";
- }
-
- // Show shipping date
- if (!empty($object->delivery_date)) {
- $outputlangs->load("sendings");
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+
+ // Show shipping date
+ if (!empty($object->date_livraison))
+ {
+ $outputlangs->load("sendings");
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -914 +907 @@
- $pdf->SetFont('', '', $default_font_size -$diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -916 +909 @@
- $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
@@ -919,3 +912,5 @@
- $posy = $pdf->GetY() + 1;
- } elseif ($object->availability_code || $object->availability) { // Show availability conditions
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $posy = $pdf->GetY() + 1;
+ }
+ elseif ($object->availability_code || $object->availability) // Show availability conditions
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -926 +921 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -928 +923 @@
- $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
+ $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
@@ -935,25 +929,0 @@
- // Show delivery mode
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
- $outputlangs->load("sendings");
-
- $shipping_method_id = $object->shipping_method_id;
- if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
- $shipping_method_id = $this->emetteur->shipping_method_id;
- }
- $shipping_method_code = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
- $shipping_method_label = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle');
-
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("SendingMethod").':';
- $pdf->MultiCell(43, 4, $titre, 0, 'L');
-
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = ($outputlangs->transnoentities("SendingMethod".strtoupper($shipping_method_code)) != "SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans("SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
- $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
- $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
-
- $posy = $pdf->GetY() + 1;
- }
-
@@ -961,2 +931,3 @@
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && ($object->cond_reglement_code || $object->cond_reglement))
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -967 +938 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -969 +940 @@
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
@@ -971,3 +941,0 @@
- if ($object->deposit_percent > 0) {
- $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
- }
@@ -979 +947,18 @@
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTMODE')) {
+ if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE))
+ {
+ // Check a payment mode is defined
+ /* Not required on a proposal
+ if (empty($object->mode_reglement_code)
+ && ! $conf->global->FACTURE_CHQ_NUMBER
+ && ! $conf->global->FACTURE_RIB_NUMBER)
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200,0,0);
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
+ $pdf->SetTextColor(0,0,0);
+
+ $posy=$pdf->GetY()+1;
+ }
+ */
+
@@ -983,2 +968,3 @@
- && $object->mode_reglement_code != 'VIR') {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ && $object->mode_reglement_code != 'VIR')
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -988 +974 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -990 +976 @@
- $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
@@ -997 +983,2 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
+ {
@@ -999,2 +986,6 @@
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER))
+ {
+ $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
+
+ if ($conf->global->FACTURE_CHQ_NUMBER > 0)
+ {
@@ -1002 +993 @@
- $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
+ $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@@ -1009 +1000,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1014,3 +1006,4 @@
- }
- }
- if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1)
+ {
@@ -1022 +1015,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1027 +1021 @@
- }
+ }
@@ -1033,2 +1027,4 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
- if (!empty($object->fk_account) || !empty($object->fk_bank) || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
+ {
+ if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
+ {
@@ -1036,3 +1032 @@
- if (!empty($object->fk_bank)) {
- $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
- }
+ if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
@@ -1056 +1050 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -1060,4 +1054,4 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object propal
- * @param int $deja_regle Amount already paid
- * @param int $posy Start position
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
+ * @param int $posy Position depart
@@ -1065,2 +1059 @@
- * @param Translate $outputlangsbis Object lang for output bis
- * @return int Position for continuation
+ * @return int Position pour suite
@@ -1068 +1061 @@
- protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
@@ -1070 +1063 @@
- // phpcs:enable
+ // phpcs:enable
@@ -1078,4 +1071,4 @@
- // Total table
- $col1x = 120;
- $col2x = 170;
- if ($this->page_largeur < 210) { // To work with US executive format
+ // Tableau total
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
@@ -1091 +1084 @@
- $pdf->SetXY($col1x, $tab2_top);
+ $pdf->SetXY($col1x, $tab2_top + 0);
@@ -1094,2 +1087,2 @@
- $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
- $pdf->SetXY($col2x, $tab2_top);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->SetXY($col2x, $tab2_top + 0);
@@ -1101 +1094 @@
- $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
@@ -1104 +1097,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
@@ -1106 +1100,2 @@
- if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ {
@@ -1108 +1103,3 @@
- } else {
+ }
+ else
+ {
@@ -1110 +1107 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1112,7 +1109,8 @@
- foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('1', '3', '5'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1125 +1123,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1133,2 +1131,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1136 +1133 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1140 +1137 @@
- //}
+ //}
@@ -1142 +1139 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
@@ -1144,7 +1141,8 @@
- foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('1', '3', '5'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1151,0 +1150,2 @@
+
+
@@ -1157 +1157,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1165,2 +1165,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1168 +1167 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1173 +1171,0 @@
-
@@ -1175,2 +1173,4 @@
- foreach ($this->tva_array as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->tva as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1183 +1183,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1187,9 +1188,2 @@
- $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalVAT", $mysoc->country_code) : '');
- $totalvat .= ' ';
- if (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'rateonly') {
- $totalvat .= vatrate($tvaval['vatrate'], 1).$tvacompl;
- } elseif (getDolGlobalString('PDF_VAT_LABEL_IS_CODE_OR_RATE') == 'codeonly') {
- $totalvat .= ($tvaval['vatcode'] ? $tvaval['vatcode'] : vatrate($tvaval['vatrate'], 1)).$tvacompl;
- } else {
- $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
- }
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
@@ -1199 +1193 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1204 +1198 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1206,7 +1200,8 @@
- foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('2', '4', '6'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1219 +1214,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1227,3 +1222,0 @@
-
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1231 +1224 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1235 +1228 @@
- //}
+ //}
@@ -1237 +1230 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
@@ -1239,8 +1232,9 @@
- foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('2', '4', '6'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- // retrieve global local tax
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ // retrieve global local tax
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1253 +1247,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1262,2 +1256,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1265 +1258 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1285 +1277,0 @@
- $resteapayer = 0;
@@ -1288 +1280 @@
- if (!empty($object->paye)) $resteapayer=0;
+ if (! empty($object->paye)) $resteapayer=0;
@@ -1291 +1283,2 @@
- if ($deja_regle > 0) {
+ if ($deja_regle > 0)
+ {
@@ -1301 +1294,2 @@
- if ($object->close_code == 'discount_vat') {
+ if ($object->close_code == 'discount_vat')
+ {
@@ -1336 +1330 @@
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
@@ -1352,3 +1346 @@
- if ($hidetop) {
- $hidetop = -1;
- }
+ if ($hidetop) $hidetop = -1;
@@ -1363 +1355,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1369,3 +1362 @@
- if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
- $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
- }
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
@@ -1380 +1371,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1387 +1379,2 @@
- if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) {
+ if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
+ {
@@ -1389 +1382,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1395 +1389,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+ {
@@ -1397 +1392,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1405 +1401,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1411 +1408,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1416 +1414 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if ($conf->global->PRODUCT_USE_UNITS) {
@@ -1420,7 +1418,2 @@
- $pdf->MultiCell(
- $this->posxdiscount - $this->posxunit - 1,
- 2,
- $outputlangs->transnoentities("Unit"),
- '',
- 'C'
- );
+ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '',
+ 'C');
@@ -1431,2 +1424,4 @@
- if (empty($hidetop)) {
- if ($this->atleastonediscount) {
+ if (empty($hidetop))
+ {
+ if ($this->atleastonediscount)
+ {
@@ -1437 +1432,2 @@
- if ($this->atleastonediscount) {
+ if ($this->atleastonediscount)
+ {
@@ -1440 +1436,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1442 +1439 @@
- $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
+ $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
@@ -1450,2 +1447,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
@@ -1454,2 +1451 @@
- * @param Translate $outputlangsbis Object lang for output bis
- * @return int|float
+ * @return void
@@ -1457 +1453 @@
- protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
@@ -1461,5 +1456,0 @@
- $ltrdirection = 'L';
- if ($outputlangs->trans("DIRECTION") == 'rtl') {
- $ltrdirection = 'R';
- }
-
@@ -1472,0 +1464,6 @@
+ // Show Draft Watermark
+ if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+ }
+
@@ -1476,2 +1472,0 @@
- $w = 100;
-
@@ -1479 +1474 @@
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
@@ -1484,2 +1479,4 @@
- if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
- if ($this->emetteur->logo) {
+ if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
+ {
+ if ($this->emetteur->logo)
+ {
@@ -1487,4 +1484,3 @@
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
- }
- if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
+ {
@@ -1492 +1488,2 @@
- } else {
+ }
+ else {
@@ -1495,4 +1492,7 @@
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
@@ -1504 +1504,3 @@
- } else {
+ }
+ else
+ {
@@ -1506 +1508 @@
- $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1514,5 +1515,0 @@
- $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT) {
- $pdf->SetTextColor(128, 0, 0);
- $title .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
@@ -1523 +1519,0 @@
- /*
@@ -1528,3 +1524,2 @@
- */
-
- $posy += 3;
+
+ $posy += 1;
@@ -1533 +1528,2 @@
- if ($object->ref_client) {
+ if ($object->ref_client)
+ {
@@ -1540 +1536,2 @@
- if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
@@ -1542 +1539,2 @@
- if (!empty($object->project->ref)) {
+ if (!empty($object->project->ref))
+ {
@@ -1546,5 +1544,6 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
- }
- }
-
- if (getDolGlobalString('PDF_SHOW_PROJECT')) {
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
+ }
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
@@ -1552,2 +1551,2 @@
- if (!empty($object->project->ref)) {
- $outputlangs->load("projects");
+ if (!empty($object->project->ref))
+ {
@@ -1557,15 +1556,3 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
- }
- }
-
- if (getDolGlobalString('MAIN_PDF_DATE_TEXT')) {
- $displaydate = "daytext";
- } else {
- $displaydate = "day";
- }
-
- //$posy += 4;
- $posy = $pdf->getY();
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DatePropal")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
+ }
+ }
@@ -1576,3 +1563,9 @@
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, $displaydate, false, $outputlangs, true), '', 'R');
-
- if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
+
+ if ($object->thirdparty->code_client)
+ {
@@ -1586,10 +1579,12 @@
- if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
- $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0) {
- $usertmp = new User($this->db);
- $usertmp->fetch($arrayidcontact[0]);
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell(100, 3, $outputlangs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
- }
+ if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
+ {
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0)
+ {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
@@ -1604 +1599,2 @@
- if ($current_y < $pdf->getY()) {
+ if ($current_y < $pdf->getY())
+ {
@@ -1608 +1604,2 @@
- if ($showaddress) {
+ if ($showaddress)
+ {
@@ -1611 +1608 @@
- // Add internal contact of object if defined
+ // Add internal contact of proposal if defined
@@ -1613,13 +1610,8 @@
- if (count($arrayidcontact) > 0) {
- $object->fetch_user($arrayidcontact[0]);
- $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
- $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
- $carac_emetteur .= "\n";
- }
-
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+ if (count($arrayidcontact) > 0)
+ {
+ $object->fetch_user($arrayidcontact[0]);
+ $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@@ -1629,4 +1621,2 @@
- $posx = $this->marge_gauche;
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->page_largeur - $this->marge_droite - 80;
- }
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
@@ -1636,18 +1626,14 @@
- if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy - 5);
- $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
- $pdf->SetXY($posx, $posy);
- $pdf->SetFillColor(230, 230, 230);
- $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0, 0, 60);
- }
-
- // Show company name
- if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
- $pdf->SetXY($posx + 2, $posy + 3);
- $pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
- $posy = $pdf->getY();
- }
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy - 5);
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
+
+ // Show sender name
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy = $pdf->getY();
@@ -1658 +1644 @@
- $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
@@ -1664 +1650,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -1669,2 +1656,3 @@
- // Recipient name
- if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
+ //Recipient name
+ // On peut utiliser le nom de la societe du contact
+ if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
@@ -1678,2 +1666 @@
- $mode = 'target';
- $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
@@ -1683,3 +1670 @@
- if ($this->page_largeur < 210) {
- $widthrecbox = 84; // To work with US executive format
- }
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
@@ -1688,3 +1673 @@
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->marge_gauche;
- }
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -1693,7 +1676,5 @@
- if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx + 2, $posy - 5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
- }
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx + 2, $posy - 5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
@@ -1704 +1685 @@
- $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -1711 +1692 @@
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
@@ -1721,3 +1702,3 @@
- *
- * @param TCPDF $pdf PDF
- * @param Propal $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
@@ -1730,2 +1711,3 @@
- $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
- return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
+ global $conf;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
@@ -1735 +1717 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -1739,2 +1721,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object invoice
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
@@ -1747 +1729,2 @@
- // phpcs:enable
+ // phpcs:enable
+ global $conf;
@@ -1754 +1737,2 @@
-
+ $useborder = 0;
+ $index = 0;
@@ -1757 +1741 @@
- $pdf->SetXY($posx, $tab_top);
+ $pdf->SetXY($posx, $tab_top + 0);
@@ -1763 +1747 @@
- if (getDolGlobalString('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING')) {
+ if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
--- /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/github_19.0.3_pdf_cyan.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/propale/doc/client_pdf_cyan.modules.php
@@ -43,0 +44,5 @@
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
@@ -45,3 +50,3 @@
- * @var DoliDb Database handler
- */
- public $db;
+ * @var string model name
+ */
+ public $name;
@@ -50,3 +55,8 @@
- * @var string model name
- */
- public $name;
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var string Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
@@ -55,3 +65,3 @@
- * @var string model description (short text)
- */
- public $description;
+ * @var string document type
+ */
+ public $type;
@@ -60,3 +70,4 @@
- * @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 array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
@@ -65,3 +76,9 @@
- * @var string document type
- */
- public $type;
+ * Dolibarr version of the loaded document
+ * @var string
+ */
+ public $version = 'dolibarr';
+
+ /**
+ * @var int page_largeur
+ */
+ public $page_largeur;
@@ -70,4 +87,3 @@
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
@@ -76,3 +92,29 @@
- * @var array of document table columns
- */
- public $cols;
+ * @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 Societe Object that emits
+ */
+ public $emetteur;
@@ -88 +130 @@
- global $langs, $mysoc;
+ global $conf, $langs, $mysoc;
@@ -104,4 +146,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 +155 @@
+ $this->option_codeproduitservice = 1; // Display product-service code
@@ -118 +160,0 @@
- $this->watermark = '';
@@ -122,3 +164 @@
- if (empty($this->emetteur->country_code)) {
- $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
- }
+ if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
@@ -127 +167 @@
- $this->posxdesc = $this->marge_gauche + 1; // used for notes ans other stuff
+ $this->posxdesc = $this->marge_gauche + 1;
@@ -132,2 +171,0 @@
- // Use new system for position of columns, view $this->defineColumnField()
-
@@ -135 +172,0 @@
- $this->tva_array = array();
@@ -142 +179 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -144,9 +181,9 @@
- * Function to build pdf onto disk
- *
- * @param Propal $object Object to generate
- * @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ * Function to build pdf onto disk
+ *
+ * @param Object $object Object to generate
+ * @param Translate $outputlangs Lang output object
+ * @param string $srctemplatepath Full path of source filename for generator using a template file
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return int 1=OK, 0=KO
@@ -156 +193 @@
- // phpcs:enable
+ // phpcs:enable
@@ -159,5 +196 @@
- dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
-
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -165,5 +198,3 @@
- if (getDolGlobalString('MAIN_USE_FPDF')) {
- $outputlangs->charset_output = 'ISO-8859-1';
- }
-
- // Load translation files required by page
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+
+ // Load traductions files required by page
@@ -172,8 +203,2 @@
- // Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && getDolGlobalString('PROPALE_DRAFT_WATERMARK')) {
- $this->watermark = getDolGlobalString('PROPALE_DRAFT_WATERMARK');
- }
-
- global $outputlangsbis;
- $outputlangsbis = null;
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
@@ -188,2 +213,2 @@
- if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
- $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
@@ -195 +220,2 @@
- if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) {
+ if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
+ {
@@ -198,4 +224,3 @@
- for ($i = 0; $i < $nblines; $i++) {
- if (empty($object->lines[$i]->fk_product)) {
- continue;
- }
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
@@ -204,2 +229,3 @@
- //var_dump($objphoto->ref);exit;
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
+ //var_dump($objphoto->ref);exit;
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
@@ -208,2 +234,4 @@
- } else {
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
+ }
+ else
+ {
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
@@ -214,3 +242,5 @@
- foreach ($pdir as $midir) {
- if (!$arephoto) {
- if ($conf->entity != $objphoto->entity) {
+ foreach ($pdir as $midir)
+ {
+ if (!$arephoto)
+ {
+ if ($conf->product->entity != $objphoto->entity) {
@@ -222,3 +252,6 @@
- foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
- if (!getDolGlobalInt('CAT_HIGH_QUALITY_IMAGES')) { // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
- if ($obj['photo_vignette']) {
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+ {
+ if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+ {
+ if ($obj['photo_vignette'])
+ {
@@ -226 +259,3 @@
- } else {
+ }
+ else
+ {
@@ -229 +264,3 @@
- } else {
+ }
+ else
+ {
@@ -240,3 +277 @@
- if ($realpath && $arephoto) {
- $realpatharray[$i] = $realpath;
- }
+ if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
@@ -246,5 +281,4 @@
- if (count($realpatharray) == 0) {
- $this->posxpicture = $this->posxtva;
- }
-
- if ($conf->propal->multidir_output[$conf->entity]) {
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
+
+ if ($conf->propal->multidir_output[$conf->entity])
+ {
@@ -256 +290,2 @@
- if ($object->specimen) {
+ if ($object->specimen)
+ {
@@ -259 +294,3 @@
- } else {
+ }
+ else
+ {
@@ -265,2 +302,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -272 +311,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -274 +314,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -283,4 +323,0 @@
- // Set nblines with the new content of lines after hook
- $nblines = count($object->lines);
- //$nbpayments = count($object->getListOfPayments());
-
@@ -288,18 +325,16 @@
- $pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- 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')) {
- $logodir = $conf->mycompany->dir_output;
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
- }
- $pagecount = $pdf->setSourceFile($logodir.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
- $tplidx = $pdf->importPage(1);
- }
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ 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->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
@@ -316,3 +351 @@
- if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
- $pdf->SetCompression(false);
- }
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
@@ -322,6 +355,8 @@
- // Set $this->atleastonediscount if you have at least one discount
- for ($i = 0; $i < $nblines; $i++) {
- if ($object->lines[$i]->remise_percent) {
- $this->atleastonediscount++;
- }
- }
+ // Does we have at least one line with discount $this->atleastonediscount
+ foreach ($object->lines as $line) {
+ if ($line->remise_percent) {
+ $this->atleastonediscount = true;
+ break;
+ }
+ }
+
@@ -332,3 +367 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -337,7 +370,7 @@
- $heightforinfotot = 40; // Height reserved to output the info and total part
- $heightforsignature = !getDolGlobalString('PROPAL_DISABLE_SIGNATURE') ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
- $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 + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
- //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
-
- $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
+ $heightforinfotot = 40; // Height reserved to output the info and total part
+ $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+ $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 + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
+ //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
@@ -349,4 +382,3 @@
- $tab_top = 90 + $top_shift;
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
-
- $nexY = $tab_top;
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
+
@@ -356 +388,2 @@
- if (isModEnabled('incoterm')) {
+ if ($conf->incoterm->enabled)
+ {
@@ -358 +391,2 @@
- if ($desc_incoterms) {
+ if ($desc_incoterms)
+ {
@@ -363 +397 @@
- $nexY = max($pdf->GetY(), $nexY);
+ $nexY = $pdf->GetY();
@@ -371,5 +405,4 @@
- $height_incoterms += 4;
- }
- }
-
- // Displays notes
+ }
+ }
+
+ // Affiche notes
@@ -377 +410,2 @@
- if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ {
@@ -379 +413,2 @@
- if (is_object($object->thirdparty)) {
+ if (is_object($object->thirdparty))
+ {
@@ -383,25 +418,18 @@
- if (!empty($salerepobj->signature)) {
- $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
- }
- }
- }
-
- // Extrafields in note
- $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
- if (!empty($extranote)) {
- $notetoshow = dol_concatdesc($notetoshow, $extranote);
- }
-
- if (getDolGlobalString('MAIN_ADD_CREATOR_IN_NOTE') && $object->user_author_id > 0) {
- $tmpuser = new User($this->db);
- $tmpuser->fetch($object->user_author_id);
-
- $creator_info = $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
- if ($tmpuser->email) {
- $creator_info .= ', '.$langs->trans("EMail").': '.$tmpuser->email;
- }
- if ($tmpuser->office_phone) {
- $creator_info .= ', '.$langs->trans("Phone").': '.$tmpuser->office_phone;
- }
-
- $notetoshow = dol_concatdesc($notetoshow, $creator_info);
+ if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
+ }
+ }
+
+ // Extrafields in note
+ $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+ if (!empty($extranote))
+ {
+ $notetoshow = dol_concatdesc($notetoshow, $extranote);
+ }
+
+ if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
+ {
+ $tmpuser = new User($this->db);
+ $tmpuser->fetch($object->user_author_id);
+ $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+ if ($tmpuser->email) $notetoshow .= ', Mail: '.$tmpuser->email;
+ if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
@@ -413 +441,2 @@
- if ($notetoshow) {
+ if ($notetoshow)
+ {
@@ -416,2 +445,2 @@
- $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
- $pageposbeforenote = $pagenb;
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+ $pageposbeforenote = $pagenb;
@@ -432,96 +461,89 @@
- if ($pageposafternote > $pageposbeforenote) {
- $pdf->rollbackTransaction(true);
-
- // prepare pages to receive notes
- while ($pagenb < $pageposafternote) {
- $pdf->AddPage();
- $pagenb++;
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
- // $this->_pagefoot($pdf,$object,$outputlangs,1);
- $pdf->setTopMargin($tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- }
-
- // back to start
- $pdf->setPage($pageposbeforenote);
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
- $pageposafternote = $pdf->getPage();
-
- $posyafter = $pdf->GetY();
-
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text
- $pdf->AddPage('', '', true);
- $pagenb++;
- $pageposafternote++;
- $pdf->setPage($pageposafternote);
- $pdf->setTopMargin($tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
- //$posyafter = $tab_top_newpage;
- }
-
-
- // apply note frame to previous pages
- $i = $pageposbeforenote;
- while ($i < $pageposafternote) {
- $pdf->setPage($i);
-
-
- $pdf->SetDrawColor(128, 128, 128);
- // Draw note frame
- if ($i > $pageposbeforenote) {
- $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
- $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else {
- $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
- $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
- }
-
- // Add footer
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
- $this->_pagefoot($pdf, $object, $outputlangs, 1);
-
- $i++;
- }
-
- // apply note frame to last page
- $pdf->setPage($pageposafternote);
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
- $height_note = $posyafter - $tab_top_newpage;
- $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else {
- // No pagebreak
- $pdf->commitTransaction();
- $posyafter = $pdf->GetY();
- $height_note = $posyafter - $tab_top;
- $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
-
-
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
- // not enough space, need to add page
- $pdf->AddPage('', '', true);
- $pagenb++;
- $pageposafternote++;
- $pdf->setPage($pageposafternote);
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
-
- $posyafter = $tab_top_newpage;
- }
+ if ($pageposafternote > $pageposbeforenote)
+ {
+ $pdf->rollbackTransaction(true);
+
+ // prepar pages to receive notes
+ while ($pagenb < $pageposafternote) {
+ $pdf->AddPage();
+ $pagenb++;
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ // $this->_pagefoot($pdf,$object,$outputlangs,1);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ }
+
+ // back to start
+ $pdf->setPage($pageposbeforenote);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ $pageposafternote = $pdf->getPage();
+
+ $posyafter = $pdf->GetY();
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) // There is no space left for total+free text
+ {
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ $pdf->setTopMargin($tab_top_newpage);
+ // The only function to edit the bottom margin of current page to set it.
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+ //$posyafter = $tab_top_newpage;
+ }
+
+
+ // apply note frame to previus pages
+ $i = $pageposbeforenote;
+ while ($i < $pageposafternote) {
+ $pdf->setPage($i);
+
+
+ $pdf->SetDrawColor(128, 128, 128);
+ // Draw note frame
+ if ($i > $pageposbeforenote) {
+ $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ }
+ else {
+ $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+ }
+
+ // Add footer
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+
+ $i++;
+ }
+
+ // apply note frame to last page
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $height_note = $posyafter - $tab_top_newpage;
+ $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ $posyafter = $pdf->GetY();
+ $height_note = $posyafter - $tab_top;
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+
+
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
+ {
+ // not enough space, need to add page
+ $pdf->AddPage('', '', true);
+ $pagenb++;
+ $pageposafternote++;
+ $pdf->setPage($pageposafternote);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+
+ $posyafter = $tab_top_newpage;
+ }
@@ -531 +553,3 @@
- } else {
+ }
+ else
+ {
@@ -535 +559 @@
- // Use new auto column system
+ // Use new auto collum system
@@ -538 +562 @@
- // Table simulation to know the height of the title line
+ // Simulation de tableau pour connaitre la hauteur de la ligne de titre
@@ -548 +572,2 @@
- for ($i = 0; $i < $nblines; $i++) {
+ for ($i = 0; $i < $nblines; $i++)
+ {
@@ -555,3 +580 @@
- if (!empty($realpatharray[$i])) {
- $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
- }
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
@@ -567,10 +590,11 @@
- if ($this->getColumnStatus('photo')) {
- // We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // If photo too high, we moved completely on new page
- $pdf->AddPage('', '', true);
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- $pdf->setPage($pageposbefore + 1);
-
- $curY = $tab_top_newpage;
+ if ($this->getColumnStatus('photo'))
+ {
+ // We start with Photo of product line
+ if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page
+ {
+ $pdf->AddPage('', '', true);
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ $pdf->setPage($pageposbefore + 1);
+
+ $curY = $tab_top_newpage;
@@ -579 +603 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -581 +605 @@
- } else {
+ else
@@ -583,9 +607,9 @@
- }
- }
-
-
- if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
- $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
- // $pdf->Image does not increase value return by getY, so we save it manually
- $posYAfterImage = $curY + $imglinesize['height'];
- }
+ }
+
+
+ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ // $pdf->Image does not increase value return by getY, so we save it manually
+ $posYAfterImage = $curY + $imglinesize['height'];
+ }
@@ -595,26 +619,31 @@
- if ($this->getColumnStatus('desc')) {
- $pdf->startTransaction();
-
- $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
- $pageposafter = $pdf->getPage();
-
- if ($pageposafter > $pageposbefore) { // There is a pagebreak
- $pdf->rollbackTransaction(true);
-
- $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-
- $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
- $pageposafter = $pdf->getPage();
- $posyafter = $pdf->GetY();
- //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $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
- $pdf->AddPage('', '', true);
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- $pdf->setPage($pageposafter + 1);
- }
- } else {
- // We found a page break
+ if ($this->getColumnStatus('desc'))
+ {
+ $pdf->startTransaction();
+
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+ $pageposafter = $pdf->getPage();
+
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
+ $pdf->rollbackTransaction(true);
+
+ $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+
+ $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+
+ $pageposafter = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+ //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $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
+ {
+ $pdf->AddPage('', '', 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
@@ -622 +651 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -624 +653 @@
- } else {
+ else
@@ -626,6 +655,7 @@
- }
- }
- } else { // No pagebreak
- $pdf->commitTransaction();
- }
- $posYAfterDescription = $pdf->GetY();
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = $pdf->GetY();
@@ -643,5 +673,4 @@
- $pdf->setPage($pageposafter);
- $curY = $tab_top_newpage;
- }
-
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
@@ -650,4 +679,5 @@
- if ($this->getColumnStatus('vat')) {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
- $nexY = max($pdf->GetY(), $nexY);
+ if ($this->getColumnStatus('vat'))
+ {
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
+ $nexY = max($pdf->GetY(), $nexY);
@@ -657,4 +687,5 @@
- if ($this->getColumnStatus('subprice')) {
- $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
- $nexY = max($pdf->GetY(), $nexY);
+ if ($this->getColumnStatus('subprice'))
+ {
+ $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
@@ -665,4 +696,5 @@
- if ($this->getColumnStatus('qty')) {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
- $nexY = max($pdf->GetY(), $nexY);
+ if ($this->getColumnStatus('qty'))
+ {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $nexY = max($pdf->GetY(), $nexY);
@@ -673,4 +705,5 @@
- if ($this->getColumnStatus('unit')) {
- $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
- $nexY = max($pdf->GetY(), $nexY);
+ if ($this->getColumnStatus('unit'))
+ {
+ $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
+ $nexY = max($pdf->GetY(), $nexY);
@@ -680,30 +713,26 @@
- if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent) {
- $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Total excl tax line (HT)
- if ($this->getColumnStatus('totalexcltax')) {
- $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Total with tax line (TTC)
- if ($this->getColumnStatus('totalincltax')) {
- $total_incl_tax = pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'totalincltax', $total_incl_tax);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Extrafields
- if (!empty($object->lines[$i]->array_options)) {
- foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
- if ($this->getColumnStatus($extrafieldColKey)) {
- $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
- $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
- $nexY = max($pdf->GetY(), $nexY);
- }
- }
- }
+ if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
+ {
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Total HT line
+ if ($this->getColumnStatus('totalexcltax'))
+ {
+ $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Extrafields
+ if (!empty($object->lines[$i]->array_options)) {
+ foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
+ if ($this->getColumnStatus($extrafieldColKey))
+ {
+ $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
+ $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+ }
+ }
@@ -712,7 +741,7 @@
- 'object' => $object,
- 'i' => $i,
- 'pdf' =>& $pdf,
- 'curY' =>& $curY,
- 'nexY' =>& $nexY,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails
+ 'object' => $object,
+ 'i' => $i,
+ 'pdf' =>& $pdf,
+ 'curY' =>& $curY,
+ 'nexY' =>& $nexY,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails
@@ -723,6 +752,4 @@
- // Collection of totals by value of vat in $this->tva["rate"] = total_tva
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $object->lines[$i]->multicurrency_total_tva;
- } else {
- $tvaligne = $object->lines[$i]->total_tva;
- }
+
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $object->lines[$i]->total_tva;
@@ -737,10 +764,3 @@
- // TODO remise_percent is an obsolete field for object parent
- /*if ($object->remise_percent) {
- $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
- }
- if ($object->remise_percent) {
- $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
- }*/
+ if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
+ if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
@@ -752 +772,2 @@
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
+ {
@@ -754,28 +775,12 @@
- $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : '';
- $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : '';
- }
-
- // retrieve global local tax
- if ($localtax1_type && $localtax1ligne != 0) {
- if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
- $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
- } else {
- $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
- }
- }
- if ($localtax2_type && $localtax2ligne != 0) {
- if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
- $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
- } else {
- $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
- }
- }
-
- if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
- $vatrate .= '*';
- }
-
- // Fill $this->tva and $this->tva_array
- if (!isset($this->tva[$vatrate])) {
- $this->tva[$vatrate] = 0;
- }
+ $localtax1_type = $localtaxtmp_array[0];
+ $localtax2_type = $localtaxtmp_array[2];
+ }
+
+ // retrieve global local tax
+ if ($localtax1_type && $localtax1ligne != 0)
+ $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
+ if ($localtax2_type && $localtax2ligne != 0)
+ $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
+
+ if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .= '*';
+ if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
@@ -783,9 +788,2 @@
- $vatcode = $object->lines[$i]->vat_src_code;
- if (empty($this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'])) {
- $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] = 0;
- }
- $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')] = array('vatrate'=>$vatrate, 'vatcode'=>$vatcode, 'amount'=> $this->tva_array[$vatrate.($vatcode ? ' ('.$vatcode.')' : '')]['amount'] + $tvaligne);
-
- if ($posYAfterImage > $posYAfterDescription) {
- $nexY = max($nexY, $posYAfterImage);
- }
+
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
@@ -794 +792,2 @@
- if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ {
@@ -798 +797 @@
- $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
+ $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
@@ -802 +801 @@
- $nexY += 2; // Add space between lines
+
@@ -805 +804,2 @@
- while ($pagenb < $pageposafter) {
+ while ($pagenb < $pageposafter)
+ {
@@ -807,4 +807,7 @@
- if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
+ if ($pagenb == $pageposbeforeprintlines)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
@@ -816,2 +819,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 == $pageposafter)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
@@ -819,10 +827,3 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- }
-
- if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
- if ($pagenb == $pageposafter) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
@@ -833,3 +834 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -837,3 +836 @@
- 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);
@@ -844,2 +841,3 @@
- if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
+ if ($pagenb == $pageposbeforeprintlines)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
@@ -847,2 +845,4 @@
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
@@ -852 +852 @@
- // Display infos area
+ // Affiche zone infos
@@ -855 +855 @@
- // Display total zone
+ // Affiche zone totaux
@@ -857,0 +858,8 @@
+ // Affiche zone versements
+ /*
+ if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
+ {
+ $posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
+ }
+ */
+
@@ -859,5 +867,6 @@
- if (!getDolGlobalString('PROPAL_DISABLE_SIGNATURE')) {
- $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
- }
-
- // Pagefoot
+ if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
+ {
+ $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pied de page
@@ -865,3 +874 @@
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -870 +877,2 @@
- if (getDolGlobalString('PRODUIT_PDF_MERGE_PROPAL')) {
+ if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
+ {
@@ -879 +887 @@
- if (getDolGlobalInt('MAIN_MULTILANGS')) {
+ if ($conf->global->MAIN_MULTILANGS) {
@@ -900,2 +908,3 @@
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
- if (isModEnabled("product")) {
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
+ if (!empty($conf->product->enabled)) {
@@ -903 +912 @@
- } elseif (isModEnabled("service")) {
+ } elseif (!empty($conf->service->enabled)) {
@@ -906,5 +915,7 @@
- } else {
- if (isModEnabled("product")) {
- $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
- } elseif (isModEnabled("service")) {
- $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product');
+ }
+ else
+ {
+ if (!empty($conf->product->enabled)) {
+ $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
+ } elseif (!empty($conf->service->enabled)) {
+ $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].'/'.get_exdir(0, 0, 0, 0, $product, 'product').dol_sanitizeFileName($product->ref);
@@ -946,6 +957,8 @@
- if ($reshook < 0) {
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
- }
-
- dolChmod($file);
+ if ($reshook < 0)
+ {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -956 +969,3 @@
- } else {
+ }
+ else
+ {
@@ -960 +975,3 @@
- } else {
+ }
+ else
+ {
@@ -963,0 +981,13 @@
+ }
+
+ /**
+ * Show payments table
+ *
+ * @param TCPDF $pdf Object PDF
+ * @param Object $object Object proposal
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
+ */
+ protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
+ {
@@ -970 +1000 @@
- * @param Propal $object Object to show
+ * @param Object $object Object to show
@@ -982,2 +1011,0 @@
- $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
-
@@ -985,2 +1013,3 @@
- if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -994,10 +1023,6 @@
- if (getDolGlobalString('MAIN_PDF_DATE_TEXT')) {
- $displaydate = "daytext";
- } else {
- $displaydate = "day";
- }
-
- // Show shipping date
- if (!empty($object->delivery_date)) {
- $outputlangs->load("sendings");
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+
+ // Show shipping date
+ if (!empty($object->date_livraison))
+ {
+ $outputlangs->load("sendings");
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1007 +1032 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -1009 +1034 @@
- $dlp = dol_print_date($object->delivery_date, $displaydate, false, $outputlangs, true);
+ $dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
@@ -1012,3 +1037,5 @@
- $posy = $pdf->GetY() + 1;
- } elseif ($object->availability_code || $object->availability) { // Show availability conditions
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ $posy = $pdf->GetY() + 1;
+ }
+ elseif ($object->availability_code || $object->availability) // Show availability conditions
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1019 +1046 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -1021 +1048 @@
- $lib_availability = ($outputlangs->transnoentities("AvailabilityType".$object->availability_code) != 'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
+ $lib_availability = $outputlangs->transnoentities("AvailabilityType".$object->availability_code) != ('AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities("AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
@@ -1028,25 +1054,0 @@
- // Show delivery mode
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_DELIVERYMODE') && $object->shipping_method_id > 0) {
- $outputlangs->load("sendings");
-
- $shipping_method_id = $object->shipping_method_id;
- if (getDolGlobalString('SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
- $shipping_method_id = $this->emetteur->shipping_method_id;
- }
- $shipping_method_code = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'code');
- $shipping_method_label = dol_getIdFromCode($this->db, $shipping_method_id, 'c_shipment_mode', 'rowid', 'libelle');
-
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
- $pdf->SetXY($this->marge_gauche, $posy);
- $titre = $outputlangs->transnoentities("SendingMethod").':';
- $pdf->MultiCell(43, 4, $titre, 0, 'L');
-
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
- $pdf->SetXY($posxval, $posy);
- $lib_condition_paiement = ($outputlangs->transnoentities("SendingMethod".strtoupper($shipping_method_code)) != "SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans("SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
- $lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
- $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
-
- $posy = $pdf->GetY() + 1;
- }
-
@@ -1054,2 +1056,3 @@
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTTERM') && $object->cond_reglement_code) {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && ($object->cond_reglement_code || $object->cond_reglement))
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1060 +1063 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -1062 +1065 @@
- $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
+ $lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc);
@@ -1064,2 +1067,20 @@
- if ($object->deposit_percent > 0) {
- $lib_condition_paiement = str_replace('__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
+ $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy = $pdf->GetY() + 3;
+ }
+
+ if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE))
+ {
+ // Check a payment mode is defined
+ /* Not required on a proposal
+ if (empty($object->mode_reglement_code)
+ && ! $conf->global->FACTURE_CHQ_NUMBER
+ && ! $conf->global->FACTURE_RIB_NUMBER)
+ {
+ $pdf->SetXY($this->marge_gauche, $posy);
+ $pdf->SetTextColor(200,0,0);
+ $pdf->SetFont('','B', $default_font_size - 2);
+ $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
+ $pdf->SetTextColor(0,0,0);
+
+ $posy=$pdf->GetY()+1;
@@ -1067,6 +1088,2 @@
- $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
-
- $posy = $pdf->GetY() + 3;
- }
-
- if (!getDolGlobalString('PROPOSAL_PDF_HIDE_PAYMENTMODE')) {
+ */
+
@@ -1076,2 +1093,3 @@
- && $object->mode_reglement_code != 'VIR') {
- $pdf->SetFont('', 'B', $default_font_size - $diffsizetitle);
+ && $object->mode_reglement_code != 'VIR')
+ {
+ $pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1081 +1099 @@
- $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+ $pdf->SetFont('', '', $default_font_size - 2);
@@ -1083 +1101 @@
- $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+ $lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
@@ -1090 +1108,2 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
+ {
@@ -1092,2 +1111,6 @@
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER') > 0) {
+ if (!empty($conf->global->FACTURE_CHQ_NUMBER))
+ {
+ $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
+
+ if ($conf->global->FACTURE_CHQ_NUMBER > 0)
+ {
@@ -1095 +1118 @@
- $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
+ $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@@ -1102 +1125,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1107,3 +1131,4 @@
- }
- }
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER') == -1) {
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1)
+ {
@@ -1115 +1140,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1120 +1146 @@
- }
+ }
@@ -1126,6 +1152,6 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
- if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
- $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
- if ($object->fk_bank > 0) {
- $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
- }
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
+ {
+ if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
+ {
+ $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
+ if (!empty($object->fk_bank)) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
@@ -1152,3 +1178,3 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
- * @param int $deja_regle Amount already paid (in the currency of invoice)
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
+ * @param int $deja_regle Montant deja regle
@@ -1157 +1182,0 @@
- * @param Translate $outputlangsbis Object lang for output bis
@@ -1160 +1185 @@
- protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis = null)
+ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
@@ -1162 +1187 @@
- global $conf, $mysoc, $hookmanager;
+ global $conf, $mysoc;
@@ -1166 +1191,17 @@
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ $tab2_top = $posy;
+ $tab2_hl = 4;
+ $pdf->SetFont('', '', $default_font_size - 1);
+
+ // Tableau total
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $col2x -= 20;
+ }
+ $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
+
+ $useborder = 0;
+ $index = 0;
+
+ $outputlangsbis = null;
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
@@ -1170,17 +1211 @@
- $default_font_size--;
- }
-
- $tab2_top = $posy;
- $tab2_hl = 4;
- $pdf->SetFont('', '', $default_font_size - 1);
-
- // Total table
- $col1x = 120;
- $col2x = 170;
- if ($this->page_largeur < 210) { // To work with US executive format
- $col2x -= 20;
- }
- $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
-
- $useborder = 0;
- $index = 0;
+ }
@@ -1190 +1215 @@
- $pdf->SetXY($col1x, $tab2_top);
+ $pdf->SetXY($col1x, $tab2_top + 0);
@@ -1193,2 +1218,2 @@
- $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
- $pdf->SetXY($col2x, $tab2_top);
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->SetXY($col2x, $tab2_top + 0);
@@ -1200 +1225 @@
- $total_ttc = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
+ $total_ttc = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
@@ -1203 +1228,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
@@ -1205 +1231,2 @@
- if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ {
@@ -1207 +1234,3 @@
- } else {
+ }
+ else
+ {
@@ -1209 +1238 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1211,7 +1240,8 @@
- foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('1', '3', '5'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1224 +1254,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1233,2 +1263,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1236 +1265 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1240 +1269 @@
- //}
+ //}
@@ -1242 +1271 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
@@ -1244,7 +1273,8 @@
- foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('1', '3', '5'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('1', '3', '5'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1251,0 +1282,2 @@
+
+
@@ -1257 +1289,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1266,2 +1298,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1269 +1300 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1274 +1304,0 @@
-
@@ -1276,2 +1306,4 @@
- foreach ($this->tva as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->tva as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1284 +1316,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1299 +1332 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1301,7 +1334,8 @@
- foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('2', '4', '6'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax1 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1314 +1348,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1323,3 +1357,0 @@
-
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1327 +1359 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1331 +1363 @@
- //}
+ //}
@@ -1333 +1365 @@
- //if (!empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
+ //if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
@@ -1335,8 +1367,9 @@
- foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
- if (in_array((string) $localtax_type, array('2', '4', '6'))) {
- continue;
- }
-
- foreach ($localtax_rate as $tvakey => $tvaval) {
- // retrieve global local tax
- if ($tvakey != 0) { // On affiche pas taux 0
+ foreach ($this->localtax2 as $localtax_type => $localtax_rate)
+ {
+ if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
+
+ foreach ($localtax_rate as $tvakey => $tvaval)
+ {
+ // retrieve global local tax
+ if ($tvakey != 0) // On affiche pas taux 0
+ {
@@ -1349 +1382,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1359,2 +1392,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1362 +1394 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_localtax, 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1385 +1417 @@
- if (!empty($object->paye)) $resteapayer=0;
+ if (! empty($object->paye)) $resteapayer=0;
@@ -1388,2 +1420,2 @@
- if ($deja_regle > 0) {
- // Already paid + Deposits
+ if ($deja_regle > 0)
+ {
@@ -1405 +1437 @@
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
+ $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort"), $useborder, 'L', 1);
@@ -1435 +1467 @@
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
@@ -1443 +1474,0 @@
- * @param Translate $outputlangsbis Langs object bis
@@ -1446 +1477 @@
- protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null)
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
@@ -1452,3 +1483 @@
- if ($hidetop) {
- $hidetop = -1;
- }
+ if ($hidetop) $hidetop = -1;
@@ -1463 +1492,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1465,4 +1494,0 @@
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
- $titre .= ' - '.$outputlangsbis->transnoentities("AmountInCurrency", $outputlangsbis->transnoentitiesnoconv("Currency".$currency));
- }
-
@@ -1473,2 +1499,2 @@
- if (getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')) {
- $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', getDolGlobalString('MAIN_PDF_TITLE_BACKGROUND_COLOR')));
+ if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
+ $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
@@ -1484,5 +1509,0 @@
- if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
- $arrayColorTextTitle = explode(',', getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR'));
- $pdf->SetTextColor($arrayColorTextTitle[0], $arrayColorTextTitle[1], $arrayColorTextTitle[2]);
- }
-
@@ -1491,4 +1511,0 @@
- if (getDolGlobalString('MAIN_PDF_TITLE_TEXT_COLOR')) {
- $pdf->SetTextColor(0, 0, 0);
- }
-
@@ -1496 +1513 @@
- $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+ $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
@@ -1504,2 +1521,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
@@ -1508,2 +1525 @@
- * @param Translate $outputlangsbis Object lang for output bis
- * @return float|int
+ * @return void
@@ -1511 +1527 @@
- protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
@@ -1515,5 +1530,0 @@
- $ltrdirection = 'L';
- if ($outputlangs->trans("DIRECTION") == 'rtl') {
- $ltrdirection = 'R';
- }
-
@@ -1526,0 +1538,6 @@
+ // Show Draft Watermark
+ if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+ }
+
@@ -1530,2 +1546,0 @@
- $w = 100;
-
@@ -1533 +1548 @@
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - 100;
@@ -1538,2 +1553,4 @@
- if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
- if ($this->emetteur->logo) {
+ if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
+ {
+ if ($this->emetteur->logo)
+ {
@@ -1541,4 +1558,3 @@
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
- }
- if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
+ {
@@ -1546 +1562,2 @@
- } else {
+ }
+ else {
@@ -1549,4 +1566,7 @@
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
@@ -1555,4 +1575,6 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
- }
- } else {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+ }
+ }
+ else
+ {
@@ -1560 +1582 @@
- $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1568,7 +1590 @@
- $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT) {
- $pdf->SetTextColor(128, 0, 0);
- $title .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
-
- $pdf->MultiCell($w, 4, $title, '', 'R');
+ $pdf->MultiCell(100, 4, $title, '', 'R');
@@ -1578 +1593,0 @@
- /*
@@ -1582,9 +1597,3 @@
- $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT) {
- $pdf->SetTextColor(128, 0, 0);
- $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
- $pdf->MultiCell($w, 4, $textref, '', 'R');
- */
-
- $posy += 3;
+ $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R');
+
+ $posy += 1;
@@ -1593 +1602,2 @@
- if ($object->ref_client) {
+ if ($object->ref_client)
+ {
@@ -1597,4 +1607,5 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_client), 65), '', 'R');
- }
-
- if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
@@ -1602 +1613,2 @@
- if (!empty($object->project->ref)) {
+ if (!empty($object->project->ref))
+ {
@@ -1606 +1618 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->project->title), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->title) ? '' : $object->projet->title), '', 'R');
@@ -1610 +1622,2 @@
- if (getDolGlobalString('PDF_SHOW_PROJECT')) {
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
@@ -1612,2 +1625,2 @@
- if (!empty($object->project->ref)) {
- $outputlangs->load("projects");
+ if (!empty($object->project->ref))
+ {
@@ -1617 +1630 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->project->ref), '', 'R');
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefProject")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
@@ -1620,12 +1632,0 @@
-
- if (getDolGlobalString('MAIN_PDF_DATE_TEXT')) {
- $displaydate = "daytext";
- } else {
- $displaydate = "day";
- }
-
- //$posy += 4;
- $posy = $pdf->getY();
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, $displaydate, false, $outputlangs, true), '', 'R');
@@ -1636,8 +1637,9 @@
-
- $title = $outputlangs->transnoentities("DateEndPropal");
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
- $title .= ' - '.$outputlangsbis->transnoentities("DateEndPropal");
- }
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->fin_validite, $displaydate, false, $outputlangs, true), '', 'R');
-
- if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
+
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : ".dol_print_date($object->fin_validite, "day", false, $outputlangs, true), '', 'R');
+
+ if ($object->thirdparty->code_client)
+ {
@@ -1647 +1649 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : ".$outputlangs->transnoentities($object->thirdparty->code_client), '', 'R');
@@ -1651,10 +1653,12 @@
- if (getDolGlobalString('DOC_SHOW_FIRST_SALES_REP')) {
- $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
- if (count($arrayidcontact) > 0) {
- $usertmp = new User($this->db);
- $usertmp->fetch($arrayidcontact[0]);
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
- }
+ if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
+ {
+ $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+ if (count($arrayidcontact) > 0)
+ {
+ $usertmp = new User($this->db);
+ $usertmp->fetch($arrayidcontact[0]);
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
@@ -1668,2 +1672,3 @@
- $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size);
- if ($current_y < $pdf->getY()) {
+ $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+ if ($current_y < $pdf->getY())
+ {
@@ -1673 +1678,2 @@
- if ($showaddress) {
+ if ($showaddress)
+ {
@@ -1676 +1682 @@
- // Add internal contact of object if defined
+ // Add internal contact of proposal if defined
@@ -1678,13 +1684,8 @@
- if (count($arrayidcontact) > 0) {
- $object->fetch_user($arrayidcontact[0]);
- $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
- $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
- $carac_emetteur .= "\n";
- }
-
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+ if (count($arrayidcontact) > 0)
+ {
+ $object->fetch_user($arrayidcontact[0]);
+ $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname." ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@@ -1693,9 +1694,4 @@
- $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
- $posy += $top_shift;
- $posx = $this->marge_gauche;
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->page_largeur - $this->marge_droite - 80;
- }
-
- $hautcadre = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 38 : 40;
- $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 82;
+ $posy = 42 + $top_shift;
+ $posx = $this->marge_gauche;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+ $hautcadre = 40;
@@ -1704,10 +1700,8 @@
- if (!getDolGlobalString('MAIN_PDF_NO_SENDER_FRAME')) {
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx, $posy - 5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillFrom"), 0, $ltrdirection);
- $pdf->SetXY($posx, $posy);
- $pdf->SetFillColor(230, 230, 230);
- $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1);
- $pdf->SetTextColor(0, 0, 60);
- }
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx, $posy - 5);
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetFillColor(230, 230, 230);
+ $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
@@ -1716,6 +1710,4 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_SENDER_NAME')) {
- $pdf->SetXY($posx + 2, $posy + 3);
- $pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
- $posy = $pdf->getY();
- }
+ $pdf->SetXY($posx + 2, $posy + 3);
+ $pdf->SetFont('', 'B', $default_font_size);
+ $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy = $pdf->getY();
@@ -1726 +1718 @@
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
+ $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
@@ -1732 +1724,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -1737,2 +1730,3 @@
- // Recipient name
- if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
+ //Recipient name
+ // On peut utiliser le nom de la societe du contact
+ if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
@@ -1746,2 +1740 @@
- $mode = 'target';
- $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, $mode, $object);
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact : ''), $usecontact, 'target', $object);
@@ -1750,6 +1743,3 @@
- $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100;
- if ($this->page_largeur < 210) {
- $widthrecbox = 84; // To work with US executive format
- }
- $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
- $posy += $top_shift;
+ $widthrecbox = 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = 42 + $top_shift;
@@ -1757,3 +1747 @@
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->marge_gauche;
- }
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -1762,7 +1750,5 @@
- if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) {
- $pdf->SetTextColor(0, 0, 0);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posx + 2, $posy - 5);
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo"), 0, $ltrdirection);
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
- }
+ $pdf->SetTextColor(0, 0, 0);
+ $pdf->SetFont('', '', $default_font_size - 2);
+ $pdf->SetXY($posx + 2, $posy - 5);
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":", 0, 'L');
+ $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
@@ -1773 +1759 @@
- $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
@@ -1780 +1766 @@
- $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
@@ -1790,3 +1776,3 @@
- *
- * @param TCPDF $pdf PDF
- * @param Propal $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
@@ -1799,2 +1785,3 @@
- $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
- return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
+ global $conf;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
@@ -1806,2 +1793,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Propal $object Object proposal
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
@@ -1813,0 +1801 @@
+ global $conf;
@@ -1820 +1808,2 @@
-
+ $useborder = 0;
+ $index = 0;
@@ -1823 +1812 @@
- $pdf->SetXY($posx, $tab_top);
+ $pdf->SetXY($posx, $tab_top + 0);
@@ -1829 +1818 @@
- if (getDolGlobalString('MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING')) {
+ if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
@@ -1840 +1829 @@
- * @param Propal $object object proposal
+ * @param object $object common object
@@ -1845 +1834 @@
- * @return void
+ * @return null
@@ -1847,194 +1836,177 @@
- public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
- {
- global $conf, $hookmanager;
-
- // Default field style for content
- $this->defaultContentsFieldsStyle = array(
- 'align' => 'R', // R,C,L
- 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- // Default field style for content
- $this->defaultTitlesFieldsStyle = array(
- 'align' => 'C', // R,C,L
- 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- /*
- * For exemple
- $this->cols['theColKey'] = array(
- 'rank' => $rank, // int : use for ordering columns
- 'width' => 20, // the column width in mm
- 'title' => array(
- 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
- 'label' => ' ', // the final label : used fore final generated text
- 'align' => 'L', // text alignement : R,C,L
- 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'content' => array(
- 'align' => 'L', // text alignement : R,C,L
- 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- );
- */
-
- $rank = 0; // do not use negative rank
- $this->cols['desc'] = array(
- 'rank' => $rank,
- 'width' => false, // only for desc
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Designation', // use lang key is usefull in somme case with module
- 'align' => 'L',
- // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
- // 'label' => ' ', // the final label
- 'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'content' => array(
- 'align' => 'L',
- 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- );
-
- // Image of product
- $rank = $rank + 10;
- $this->cols['photo'] = array(
- 'rank' => $rank,
- 'width' => (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Photo',
- 'label' => ' '
- ),
- 'content' => array(
- 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- ),
- 'border-left' => false, // remove left line separator
- );
-
- if (getDolGlobalString('MAIN_GENERATE_PROPOSALS_WITH_PICTURE') && !empty($this->atleastonephoto)) {
- $this->cols['photo']['status'] = true;
- $this->cols['photo']['border-left'] = true;
- }
-
-
- $rank = $rank + 10;
- $this->cols['vat'] = array(
- 'rank' => $rank,
- 'status' => false,
- 'width' => 16, // in mm
- 'title' => array(
- 'textkey' => 'VAT'
- ),
- 'border-left' => true, // add left line separator
- );
-
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') && !getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN')) {
- $this->cols['vat']['status'] = true;
- }
-
- $rank = $rank + 10;
- $this->cols['subprice'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'PriceUHT'
- ),
- 'border-left' => true, // add left line separator
- );
-
- // Adapt dynamically the width of subprice, if text is too long.
- $tmpwidth = 0;
- $nblines = count($object->lines);
- for ($i = 0; $i < $nblines; $i++) {
- $tmpwidth2 = dol_strlen(dol_string_nohtmltag(pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails)));
- $tmpwidth = max($tmpwidth, $tmpwidth2);
- }
- if ($tmpwidth > 10) {
- $this->cols['subprice']['width'] += (2 * ($tmpwidth - 10));
- }
-
- $rank = $rank + 10;
- $this->cols['qty'] = array(
- 'rank' => $rank,
- 'width' => 16, // in mm
- 'status' => true,
- 'title' => array(
- 'textkey' => 'Qty'
- ),
- 'border-left' => true, // add left line separator
- );
-
- $rank = $rank + 10;
- $this->cols['unit'] = array(
- 'rank' => $rank,
- 'width' => 11, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'Unit'
- ),
- 'border-left' => true, // add left line separator
- );
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
- $this->cols['unit']['status'] = true;
- }
-
- $rank = $rank + 10;
- $this->cols['discount'] = array(
- 'rank' => $rank,
- 'width' => 13, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'ReductionShort'
- ),
- 'border-left' => true, // add left line separator
- );
- if ($this->atleastonediscount) {
- $this->cols['discount']['status'] = true;
- }
-
- $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
- $this->cols['totalexcltax'] = array(
- 'rank' => $rank,
- 'width' => 26, // in mm
- 'status' => !getDolGlobalString('PDF_PROPAL_HIDE_PRICE_EXCL_TAX') ? true : false,
- 'title' => array(
- 'textkey' => 'TotalHTShort'
- ),
- 'border-left' => true, // add left line separator
- );
-
- $rank = $rank + 1010; // add a big offset to be sure is the last col because default extrafield rank is 100
- $this->cols['totalincltax'] = array(
- 'rank' => $rank,
- 'width' => 26, // in mm
- 'status' => !getDolGlobalString('PDF_PROPAL_SHOW_PRICE_INCL_TAX') ? false : true,
- 'title' => array(
- 'textkey' => 'TotalTTCShort'
- ),
- 'border-left' => true, // add left line separator
- );
-
- // Add extrafields cols
- if (!empty($object->lines)) {
- $line = reset($object->lines);
- $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
- }
-
- $parameters = array(
- 'object' => $object,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails,
- 'hidedesc' => $hidedesc,
- 'hideref' => $hideref
- );
-
- $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
- if ($reshook < 0) {
- setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
- } elseif (empty($reshook)) {
- $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
- } else {
- $this->cols = $hookmanager->resArray;
- }
+ public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ global $conf, $hookmanager;
+
+ // Default field style for content
+ $this->defaultContentsFieldsStyle = array(
+ 'align' => 'R', // R,C,L
+ 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ // Default field style for content
+ $this->defaultTitlesFieldsStyle = array(
+ 'align' => 'C', // R,C,L
+ 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ );
+
+ /*
+ * For exemple
+ $this->cols['theColKey'] = array(
+ 'rank' => $rank, // int : use for ordering columns
+ 'width' => 20, // the column width in mm
+ 'title' => array(
+ 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ 'label' => ' ', // the final label : used fore final generated text
+ 'align' => 'L', // text alignement : R,C,L
+ 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L', // text alignement : R,C,L
+ 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+ */
+
+ $rank = 0; // do not use negative rank
+ $this->cols['desc'] = array(
+ 'rank' => $rank,
+ 'width' => false, // only for desc
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Designation', // use lang key is usefull in somme case with module
+ 'align' => 'L',
+ // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+ // 'label' => ' ', // the final label
+ 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'content' => array(
+ 'align' => 'L',
+ 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ );
+
+ $rank = $rank + 10;
+ $this->cols['photo'] = array(
+ 'rank' => $rank,
+ 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Photo',
+ 'label' => ' '
+ ),
+ 'content' => array(
+ 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+ ),
+ 'border-left' => false, // remove left line separator
+ );
+
+ if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
+ {
+ $this->cols['photo']['status'] = true;
+ }
+
+
+ $rank = $rank + 10;
+ $this->cols['vat'] = array(
+ 'rank' => $rank,
+ 'status' => false,
+ 'width' => 16, // in mm
+ 'title' => array(
+ 'textkey' => 'VAT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+ {
+ $this->cols['vat']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['subprice'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'PriceUHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ $rank = $rank + 10;
+ $this->cols['qty'] = array(
+ 'rank' => $rank,
+ 'width' => 16, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'Qty'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ $rank = $rank + 10;
+ $this->cols['unit'] = array(
+ 'rank' => $rank,
+ 'width' => 11, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Unit'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($conf->global->PRODUCT_USE_UNITS) {
+ $this->cols['unit']['status'] = true;
+ }
+
+ $rank = $rank + 10;
+ $this->cols['discount'] = array(
+ 'rank' => $rank,
+ 'width' => 13, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'ReductionShort'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+ if ($this->atleastonediscount) {
+ $this->cols['discount']['status'] = true;
+ }
+
+ $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
+ $this->cols['totalexcltax'] = array(
+ 'rank' => $rank,
+ 'width' => 26, // in mm
+ 'status' => true,
+ 'title' => array(
+ 'textkey' => 'TotalHT'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ // Add extrafields cols
+ if (!empty($object->lines)) {
+ $line = reset($object->lines);
+ $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+ }
+
+ $parameters = array(
+ 'object' => $object,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails,
+ 'hidedesc' => $hidedesc,
+ 'hideref' => $hideref
+ );
+
+ $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+ if ($reshook < 0)
+ {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ }
+ elseif (empty($reshook))
+ {
+ $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+ }
+ else
+ {
+ $this->cols = $hookmanager->resArray;
+ }