--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_19.0.3_doc_generic_invoice_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_doc_generic_invoice_odt.modules.php
@@ -43,2 +43,2 @@
- * Dolibarr version of the loaded document
- * @var string
+ * Issuer
+ * @var Societe Object that emits
@@ -45,0 +46,12 @@
+ public $emetteur;
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
+
+ /**
+ * Dolibarr version of the loaded document
+ * @var string
+ */
@@ -54,3 +66,3 @@
- public function __construct($db)
- {
- global $langs, $mysoc;
+ public function __construct($db)
+ {
+ global $conf, $langs, $mysoc;
@@ -59 +71 @@
- $langs->loadLangs(array("main", "companies"));
+ $langs->loadLangs(array("main", "companies"));
@@ -76,6 +88,7 @@
- $this->option_logo = 1; // Display logo
- $this->option_tva = 0; // Manage the vat option FACTURE_TVAOPTION
- $this->option_modereg = 1; // Display payment mode
- $this->option_condreg = 1; // 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 FACTURE_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
@@ -88,4 +101,2 @@
- if (!$this->emetteur->country_code) {
- $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
- }
- }
+ if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini
+ }
@@ -100,2 +111,2 @@
- public function info($langs)
- {
+ public function info($langs)
+ {
@@ -105 +116 @@
- $langs->loadLangs(array("errors", "companies"));
+ $langs->loadLangs(array("errors", "companies"));
@@ -112 +122,0 @@
- $texte .= '';
@@ -122 +132,2 @@
- foreach ($listofdir as $key => $tmpdir) {
+ foreach ($listofdir as $key=>$tmpdir)
+ {
@@ -126,2 +137 @@
- unset($listofdir[$key]);
- continue;
+ unset($listofdir[$key]); continue;
@@ -129,3 +139,3 @@
- if (!is_dir($tmpdir)) {
- $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
- } else {
+ if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
+ else
+ {
@@ -133,3 +143 @@
- if (count($tmpfiles)) {
- $listoffiles = array_merge($listoffiles, $tmpfiles);
- }
+ if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
@@ -139 +146,0 @@
- $texthelp .= '
'.$langs->trans("ExampleOfDirectoriesForModelGen").'';
@@ -144 +151 @@
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
@@ -147 +154 @@
- $texte .= getDolGlobalString('FACTURE_ADDON_PDF_ODT_PATH');
+ $texte .= $conf->global->FACTURE_ADDON_PDF_ODT_PATH;
@@ -150 +157 @@
- $texte .= '';
+ $texte .= '';
@@ -155 +162,2 @@
- if (getDolGlobalString('FACTURE_ADDON_PDF_ODT_PATH')) {
+ if (!empty($conf->global->FACTURE_ADDON_PDF_ODT_PATH))
+ {
@@ -162,9 +170,8 @@
- if ($nbofiles) {
- $texte .= '
';
+ if ($nbofiles)
+ {
+ $texte .= '';
+ foreach ($listoffiles as $file)
+ {
+ $texte .= $file['name'].'
';
+ }
+ $texte .= '
';
@@ -172,11 +179,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 .= '
';
@@ -184,0 +186,3 @@
+ $texte .= '';
+ $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
+ $texte .= ' | ';
@@ -191,3 +195,3 @@
- }
-
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ }
+
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
@@ -205,3 +209,3 @@
- public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
- {
- // phpcs:enable
+ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ {
+ // phpcs:enable
@@ -210 +214,2 @@
- if (empty($srctemplatepath)) {
+ if (empty($srctemplatepath))
+ {
@@ -216 +221,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -223,3 +229 @@
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -232 +236,2 @@
- if ($conf->facture->dir_output) {
+ if ($conf->facture->dir_output)
+ {
@@ -234 +239,2 @@
- if (!is_object($object)) {
+ if (!is_object($object))
+ {
@@ -238 +244,2 @@
- if ($result < 0) {
+ if ($result < 0)
+ {
@@ -244,3 +251 @@
- $object->fetch_thirdparty();
-
- $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
+ $dir = $conf->facture->dir_output;
@@ -248,3 +253 @@
- if (!preg_match('/specimen/i', $objectref)) {
- $dir .= "/".$objectref;
- }
+ if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
@@ -253,2 +256,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -260 +265,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -263 +269 @@
- $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
+ $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
@@ -267 +273 @@
- $newfiletmp = $objectref . '_' . $newfiletmp;
+ $newfiletmp = $objectref.'_'.$newfiletmp;
@@ -271,10 +277,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;
@@ -288,5 +295 @@
- if (!is_writable($conf->facture->dir_temp)) {
- $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->facture->dir_temp);
- dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
- return -1;
- }
+
@@ -297 +300,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -305,6 +309,4 @@
- // 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 {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
+ $socobject = $object->contact;
+ else {
@@ -312 +314 @@
- // if we have a BILLING contact and we dont use it as thirdparty recipient we store the contact object for later use
+ // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use
@@ -323,36 +325 @@
- $propal_object = null;
- if (!empty($object->linkedObjects['propal'])) {
- $array_propal_object = $object->linkedObjects['propal'];
- if (isset($array_propal_object) && is_array($array_propal_object) && count($array_propal_object) > 0) {
- $tmparrayofvalue = array_values($array_propal_object);
- $propal_object = $tmparrayofvalue[0];
- }
- }
-
- // and determine category of operation
- $categoryOfOperation = 0;
- $nbProduct = 0;
- $nbService = 0;
- foreach ($object->lines as $line) {
- // determine category of operation
- if ($categoryOfOperation < 2) {
- $lineProductType = $line->product_type;
- if ($lineProductType == Product::TYPE_PRODUCT) {
- $nbProduct++;
- } elseif ($lineProductType == Product::TYPE_SERVICE) {
- $nbService++;
- }
- if ($nbProduct > 0 && $nbService > 0) {
- // mixed products and services
- $categoryOfOperation = 2;
- }
- }
- }
-
- // determine category of operation
- if ($categoryOfOperation <= 0) {
- // only services
- if ($nbProduct == 0 && $nbService > 0) {
- $categoryOfOperation = 1;
- }
- }
+ $propal_object = $object->linkedObjects['propal'][0];
@@ -362,5 +329,5 @@
- '__FROM_NAME__' => $this->emetteur->name,
- '__FROM_EMAIL__' => $this->emetteur->email,
- '__TOTAL_TTC__' => $object->total_ttc,
- '__TOTAL_HT__' => $object->total_ht,
- '__TOTAL_VAT__' => $object->total_tva
+ '__FROM_NAME__' => $this->emetteur->name,
+ '__FROM_EMAIL__' => $this->emetteur->email,
+ '__TOTAL_TTC__' => $object->total_ttc,
+ '__TOTAL_HT__' => $object->total_ht,
+ '__TOTAL_VAT__' => $object->total_tva
@@ -376,2 +343,3 @@
- if (!empty($conf->global->$paramfreetext)) {
- $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
+ if (!empty($conf->global->$paramfreetext))
+ {
+ $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
@@ -383 +351 @@
- $odfHandler = new Odf(
+ $odfHandler = new odf(
@@ -392 +360,3 @@
- } catch (Exception $e) {
+ }
+ catch (Exception $e)
+ {
@@ -407 +377,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -412 +384 @@
- $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); // Set tags __...__
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
@@ -414,2 +386,2 @@
- $array_objet = $this->get_substitutionarray_object($object, $outputlangs); // Set tags object_...
- $array_user = $this->get_substitutionarray_user($user, $outputlangs); // Set tags myuser_...
+ $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
+ $array_user = $this->get_substitutionarray_user($user, $outputlangs);
@@ -422,3 +394 @@
- 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');
@@ -428,17 +397,0 @@
-
- // Complete also with substitution from keys directly found into template
- // TODO Search all tags {object_...:xxxx} into template then loop on this found tags to analyze them and the the corresponding
- // property of object and use the xxxx to know how to format it.
- // Before that, we hard code this substitution as if we have found them into the template.
-
- $tmparray['object_PREVIOUS_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%m');
- $tmparray['object_MONTH'] = dol_print_date($object->date, '%m');
- $tmparray['object_NEXT_MONTH'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%m');
- $tmparray['object_PREVIOUS_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'm'), '%B');
- $tmparray['object_MONTH_TEXT'] = dol_print_date($object->date, '%B');
- $tmparray['object_NEXT_MONTH_TEXT'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'm'), '%B');
- $tmparray['object_PREVIOUS_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, -1, 'y'), '%Y');
- $tmparray['object_YEAR'] = dol_print_date($object->date, '%Y');
- $tmparray['object_NEXT_YEAR'] = dol_print_date(dol_time_plus_duree($object->date, 1, 'y'), '%Y');
- $tmparray['object_productorservice_operation'] = $outputlangs->transnoentities("MentionCategoryOfOperations" . $categoryOfOperation);
-
@@ -451 +404,2 @@
- foreach ($tmparray as $key => $value) {
+ foreach ($tmparray as $key=>$value)
+ {
@@ -453 +407,2 @@
- if (preg_match('/logo$/', $key)) { // Image
+ if (preg_match('/logo$/', $key)) // Image
+ {
@@ -455,7 +410,5 @@
- if (file_exists($value)) {
- $odfHandler->setImage($key, $value);
- } else {
- $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- }
- } else {
- // Text
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
@@ -464,2 +417,4 @@
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -469 +424,2 @@
- try {
+ try
+ {
@@ -473 +429,3 @@
- } catch (OdfExceptionSegmentNotFound $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -477,5 +435,3 @@
- } catch (OdfException $e) {
- $foundtagforlines = 0;
- dol_syslog($e->getMessage(), LOG_INFO);
- }
- if ($foundtagforlines) {
+ }
+ if ($foundtagforlines)
+ {
@@ -483 +439,2 @@
- foreach ($object->lines as $line) {
+ foreach ($object->lines as $line)
+ {
@@ -490,2 +447,4 @@
- foreach ($tmparray as $key => $val) {
- try {
+ foreach ($tmparray as $key => $val)
+ {
+ try
+ {
@@ -493 +452,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -495 +456,3 @@
- } catch (SegmentException $e) {
+ }
+ catch (SegmentException $e)
+ {
@@ -503 +466,3 @@
- } catch (OdfException $e) {
+ }
+ catch (OdfException $e)
+ {
@@ -511 +476,2 @@
- foreach ($tmparray as $key => $value) {
+ foreach ($tmparray as $key=>$value)
+ {
@@ -514,2 +480,4 @@
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -524 +492 @@
- if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
+ if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
@@ -529 +497 @@
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -532 +500,2 @@
- } else {
+ }
+ else {
@@ -537 +506 @@
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -544 +513,2 @@
- dolChmod($file);
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -551 +521,3 @@
- } else {
+ }
+ else
+ {
@@ -558 +530 @@
- }
+ }
--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_19.0.3_pdf_crabe.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_pdf_crabe.modules.php
@@ -12,2 +11,0 @@
- * Copyright (C) 2022 Anthony Berton
- * Copyright (C) 2022 Charlene Benke
@@ -48,2 +46,75 @@
- /**
- * @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 int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
+
+ /**
+ * @var string document type
+ */
+ public $type;
+
+ /**
+ * @var 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
@@ -51,27 +122 @@
- public $db;
-
- /**
- * @var string model name
- */
- public $name;
-
- /**
- * @var string model description (short text)
- */
- public $description;
-
- /**
- * @var int Save the name of generated file as the main doc when generating a doc with this template
- */
- public $update_main_doc_field;
-
- /**
- * @var string document type
- */
- public $type;
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
+ public $emetteur;
@@ -88,5 +132,0 @@
-
- /**
- * @var int Category of operation
- */
- public $categoryOfOperation = -1; // unknown by default
@@ -118,4 +158,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;
@@ -126,0 +167 @@
+ $this->option_codeproduitservice = 1; // Display product-service code
@@ -132 +172,0 @@
- $this->watermark = '';
@@ -136,3 +176 @@
- 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
@@ -142 +180,2 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if (!empty($conf->global->PRODUCT_USE_UNITS))
+ {
@@ -147,3 +186,5 @@
- } else {
- $this->posxtva = 106;
- $this->posxup = 122;
+ }
+ else
+ {
+ $this->posxtva = 110;
+ $this->posxup = 126;
@@ -157,13 +198,12 @@
- 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
- $this->posxpicture -= 20;
- $this->posxtva -= 20;
- $this->posxup -= 20;
- $this->posxqty -= 20;
- $this->posxunit -= 20;
- $this->posxdiscount -= 20;
- $this->posxprogress -= 20;
- $this->postotalht -= 20;
+ 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
+ {
+ $this->posxpicture -= 20;
+ $this->posxtva -= 20;
+ $this->posxup -= 20;
+ $this->posxqty -= 20;
+ $this->posxunit -= 20;
+ $this->posxdiscount -= 20;
+ $this->posxprogress -= 20;
+ $this->postotalht -= 20;
@@ -173 +212,0 @@
- $this->tva_array = array();
@@ -182,11 +221,11 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Facture $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
@@ -194 +233 @@
- public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
@@ -196 +235 @@
- // phpcs:enable
+ // phpcs:enable
@@ -201,3 +240 @@
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -205,3 +242 @@
- if (getDolGlobalString('MAIN_USE_FPDF')) {
- $outputlangs->charset_output = 'ISO-8859-1';
- }
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
@@ -212,13 +246,0 @@
- // Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
- $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
- }
-
- 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", "bills", "products", "dict", "companies"));
- }
-
@@ -229,5 +251,5 @@
- if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
- for ($i = 0; $i < $nblines; $i++) {
- if (empty($object->lines[$i]->fk_product)) {
- continue;
- }
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
+ {
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
@@ -242 +264,2 @@
- foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+ foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+ {
@@ -249,10 +272,7 @@
- if ($realpath) {
- $realpatharray[$i] = $realpath;
- }
- }
- }
- if (count($realpatharray) == 0) {
- $this->posxpicture = $this->posxtva;
- }
-
- if ($conf->facture->dir_output) {
+ if ($realpath) $realpatharray[$i] = $realpath;
+ }
+ }
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
+
+ if ($conf->facture->dir_output)
+ {
@@ -261,3 +281,3 @@
- $deja_regle = $object->getSommePaiement((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
@@ -266,2 +286,3 @@
- if ($object->specimen) {
- $dir = empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity];
+ if ($object->specimen)
+ {
+ $dir = $conf->facture->dir_output;
@@ -269 +290,3 @@
- } else {
+ }
+ else
+ {
@@ -271 +294 @@
- $dir = (empty($conf->facture->multidir_output[$object->entity]) ? $conf->facture->dir_output : $conf->facture->multidir_output[$object->entity])."/".$objectref;
+ $dir = $conf->facture->dir_output."/".$objectref;
@@ -274,2 +297,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -281 +306,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -283 +309,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -298,37 +325,21 @@
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
- if ($heightforinfotot > 220) {
- $heightforinfotot = 220;
- }
- $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;
- }
-
- $heightforqrinvoice_firstpage = 0;
- if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
- $heightforqrinvoice_firstpage = $this->getHeightForQRInvoice(1, $object, $langs);
- if ($heightforqrinvoice_firstpage > 0) {
- // Shrink infotot to a base 30
- $heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
- }
- }
-
- 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);
- }
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+ // Set path to the background PDF File
+ if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
@@ -343 +354 @@
- $pdf->SetAuthor($mysoc->name.($user->id > 0 ? ' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) : ''));
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
@@ -345,3 +356 @@
- if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
- $pdf->SetCompression(false);
- }
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
@@ -351,2 +360 @@
- $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE;
- // If user has no certificate, we try to take the company one
+ // If use has no certificate, we try to take the company one
@@ -354,4 +362 @@
- $cert = !getDolGlobalString('CERTIFICATE_CRT') ? '' : $conf->global->CERTIFICATE_CRT;
- }
- if (!$certprivate) {
- $certprivate = !getDolGlobalString('CERTIFICATE_CRT_PRIVATE') ? '' : $conf->global->CERTIFICATE_CRT_PRIVATE;
+ $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
@@ -367 +372 @@
- $pdf->setSignature($cert, $certprivate, $this->emetteur->name, '', 2, $info);
+ $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
@@ -373,6 +378,4 @@
- // and determine category of operation
- $categoryOfOperation = 0;
- $nbProduct = 0;
- $nbService = 0;
- for ($i = 0; $i < $nblines; $i++) {
- if ($object->lines[$i]->remise_percent) {
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if ($object->lines[$i]->remise_percent)
+ {
@@ -381,32 +384,11 @@
-
- // determine category of operation
- if ($categoryOfOperation < 2) {
- $lineProductType = $object->lines[$i]->product_type;
- if ($lineProductType == Product::TYPE_PRODUCT) {
- $nbProduct++;
- } elseif ($lineProductType == Product::TYPE_SERVICE) {
- $nbService++;
- }
- if ($nbProduct > 0 && $nbService > 0) {
- // mixed products and services
- $categoryOfOperation = 2;
- }
- }
- }
- // determine category of operation
- if ($categoryOfOperation <= 0) {
- // only services
- if ($nbProduct == 0 && $nbService > 0) {
- $categoryOfOperation = 1;
- }
- }
- $this->categoryOfOperation = $categoryOfOperation;
- if (empty($this->atleastonediscount)) { // retrieve space not used by discount
- $delta = ($this->posxprogress - $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)) // retreive space not used by discount
+ {
+ $delta = ($this->posxprogress - $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
@@ -417 +399,2 @@
- if ($object->situation_cycle_ref && !getDolGlobalString('MAIN_PDF_HIDE_SITUATION')) {
+ if ($object->situation_cycle_ref && empty($conf->global->MAIN_PDF_HIDE_SITUATION))
+ {
@@ -431,3 +414 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -436 +416,0 @@
- // Output header (logo, ref and address blocks). This is first call for first page.
@@ -442,45 +422,2 @@
- // $pdf->GetY() here can't be used. It is bottom of the second addresse box but first one may be higher
-
- // $tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
- $tab_top = 90 + $top_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
-
- // You can add more thing under header here, if you increase $extra_under_address_shift too.
- $extra_under_address_shift = 0;
- $qrcodestring = '';
- if (getDolGlobalString('INVOICE_ADD_ZATCA_QR_CODE')) {
- $qrcodestring = $object->buildZATCAQRString();
- } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1') {
- $qrcodestring = $object->buildSwitzerlandQRString();
- }
-
- if ($qrcodestring) {
- $qrcodecolor = array('25', '25', '25');
- // set style for QR-code
- $styleQr = array(
- 'border' => false,
- 'padding' => 0,
- 'fgcolor' => $qrcodecolor,
- 'bgcolor' => false, //array(255,255,255)
- 'module_width' => 1, // width of a single module in points
- 'module_height' => 1 // height of a single module in points
- );
- $pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr, 'N');
- $extra_under_address_shift += 25;
- }
-
- // Call hook printUnderHeaderPDFline
- $parameters = array(
- 'object' => $object,
- 'i' => $i,
- 'pdf' => &$pdf,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails
- );
- $reshook = $hookmanager->executeHooks('printUnderHeaderPDFline', $parameters, $this); // Note that $object may have been modified by hook
- if (!empty($hookmanager->resArray['extra_under_address_shift'])) {
- $extra_under_address_shift += $hookmanager->resArray['extra_under_address_shift'];
- }
-
- $tab_top += $extra_under_address_shift;
- $tab_top_newpage += 0;
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
@@ -489,2 +426,2 @@
- $height_incoterms = 0;
- if (isModEnabled('incoterm')) {
+ if ($conf->incoterm->enabled)
+ {
@@ -492 +429,2 @@
- if ($desc_incoterms) {
+ if ($desc_incoterms)
+ {
@@ -510 +448,2 @@
- if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ {
@@ -512 +451,2 @@
- if (is_object($object->thirdparty)) {
+ if (is_object($object->thirdparty))
+ {
@@ -516,11 +456,10 @@
- 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 ($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 ($notetoshow)
+ {
@@ -531 +469,0 @@
-
@@ -552 +490,2 @@
- for ($i = 0; $i < $nblines; $i++) {
+ for ($i = 0; $i < $nblines; $i++)
+ {
@@ -559,3 +498 @@
- if (!empty($realpatharray[$i])) {
- $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
- }
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
@@ -564,2 +501 @@
- $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs);
- $pdf->setPageOrientation('', 1, $page_bottom_margin);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
@@ -573 +509,2 @@
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - $page_bottom_margin)) { // 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 + $heightforinfotot))) // If photo too high, we moved completely on new page
+ {
@@ -575,7 +512,2 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -587 +519 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -589 +521 @@
- } else {
+ else
@@ -591,4 +523,4 @@
- }
- }
-
- if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
+ }
+
+ if (isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
@@ -607 +539,2 @@
- if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
@@ -616,2 +549,4 @@
- if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // There is no space left for total+free text
- if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
+ {
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
+ {
@@ -619,7 +554,2 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -628 +558,3 @@
- } else {
+ }
+ else
+ {
@@ -632 +564 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -634 +566 @@
- } else {
+ else
@@ -636 +567,0 @@
- }
@@ -638 +569,3 @@
- } else { // No pagebreak
+ }
+ else // No pagebreak
+ {
@@ -651,2 +584 @@
- $pdf->setPage($pageposafter);
- $curY = $tab_top_newpage;
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
@@ -658 +590,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))
+ {
@@ -675 +608,2 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if (!empty($conf->global->PRODUCT_USE_UNITS))
+ {
@@ -682,4 +616,5 @@
- if ($object->lines[$i]->remise_percent) {
- $pdf->SetXY($this->posxdiscount - 2, $curY);
- $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
- $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
+ if ($object->lines[$i]->remise_percent)
+ {
+ $pdf->SetXY($this->posxdiscount - 2, $curY);
+ $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+ $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
@@ -689,4 +624,5 @@
- if ($this->situationinvoice) {
- $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
- $pdf->SetXY($this->posxprogress, $curY);
- $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
+ if ($this->situationinvoice)
+ {
+ $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
+ $pdf->SetXY($this->posxprogress, $curY);
+ $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
@@ -702,3 +638 @@
- if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
@@ -707,6 +641,4 @@
- if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- } else {
- $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- }
+ if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
+ {
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
@@ -714,5 +646,2 @@
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
- } else {
- $tvaligne = $sign * $object->lines[$i]->total_tva;
- }
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva;
@@ -728,10 +657,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;
@@ -743 +665,2 @@
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
+ {
@@ -745,38 +668,15 @@
- $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;
- }
- $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete
- $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;
- }
+ $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;
+ $this->tva[$vatrate] += $tvaligne;
+
+ if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
@@ -785 +685,2 @@
- if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ {
@@ -796 +697,2 @@
- while ($pagenb < $pageposafter) {
+ while ($pagenb < $pageposafter)
+ {
@@ -798,3 +700,6 @@
- if ($pagenb == 1) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
- } else {
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
+ }
+ else
+ {
@@ -803 +708 @@
- $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs));
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -807,3 +712,7 @@
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
+ 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);
@@ -811,8 +720,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 - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1, $object->multicurrency_code);
- } else {
+ else
+ {
@@ -821 +724 @@
- $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pagenb, $object, $langs));
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -824,3 +727 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -828,4 +729 @@
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- }
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -836,4 +734,7 @@
- if ($pagenb == 1) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0, $object->multicurrency_code);
- $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
- } else {
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+ else
+ {
@@ -843 +743,0 @@
- dol_syslog("bottomlasttab=".$bottomlasttab." this->page_hauteur=".$this->page_hauteur." heightforinfotot=".$heightforinfotot." heightforfreetext=".$heightforfreetext." heightforfooter=".$heightforfooter);
@@ -846 +746 @@
- $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
+ $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
@@ -849 +749 @@
- $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
+ $posy = $this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
@@ -852 +752,2 @@
- if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
+ if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
+ {
@@ -857,12 +758,3 @@
- $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs));
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
-
- if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
- $result = $this->addBottomQRInvoice($pdf, $object, $outputlangs);
- if (!$result) {
- $pdf->Close();
- return 0;
- }
- }
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
+
@@ -878,6 +770,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));
@@ -888 +782,3 @@
- } else {
+ }
+ else
+ {
@@ -892 +788,3 @@
- } else {
+ }
+ else
+ {
@@ -904,6 +802,6 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object invoice
- * @param int $posy Position y in PDF
- * @param Translate $outputlangs Object langs for output
- * @param int $heightforfooter Height for footer
- * @return int Return integer <0 if KO, >0 if OK
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object invoice
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @param int $heightforfooter height for footer
+ * @return int <0 if KO, >0 if OK
@@ -913 +811 @@
- // phpcs:enable
+ // phpcs:enable
@@ -916,4 +814,2 @@
- $sign = 1;
- if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
@@ -922 +818 @@
- $tab3_posx = 120;
+ $tab3_posx = 120;
@@ -926,2 +822,3 @@
- if ($this->page_largeur < 210) { // To work with US executive format
- $tab3_posx -= 15;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $tab3_posx -= 20;
@@ -944 +841 @@
- $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
+ $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
@@ -946 +843,2 @@
- if ($resql) {
+ if ($resql)
+ {
@@ -950 +848,2 @@
- while ($i < $num) {
+ while ($i < $num)
+ {
@@ -952 +851,2 @@
- if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
+ if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
+ {
@@ -956,7 +856,2 @@
- /*if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }*/
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -969,9 +864,4 @@
- if ($obj->type == 2) {
- $text = $outputlangs->transnoentities("CreditNote");
- } elseif ($obj->type == 3) {
- $text = $outputlangs->transnoentities("Deposit");
- } elseif ($obj->type == 0) {
- $text = $outputlangs->transnoentities("ExcessReceived");
- } else {
- $text = $outputlangs->transnoentities("UnknownType");
- }
+ if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote");
+ elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit");
+ elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived");
+ else $text = $outputlangs->transnoentities("UnknownType");
@@ -984 +874 @@
- $pdf->MultiCell(20, 3, price((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
@@ -994 +884,3 @@
- } else {
+ }
+ else
+ {
@@ -1005 +897 @@
- $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
+ $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
@@ -1010 +902,2 @@
- if ($resql) {
+ if ($resql)
+ {
@@ -1013,2 +905,0 @@
- $y += 3;
- $maxY = $y;
@@ -1016 +907,3 @@
- if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
+ $y += 3;
+ if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter))
+ {
@@ -1020,7 +913,2 @@
- /*if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }*/
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $top_shift = $this->_pagehead($pdf, $object, 0, $outputlangs);
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -1036 +924 @@
- $pdf->MultiCell(20, 3, price($sign * ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
@@ -1041 +928,0 @@
- $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
@@ -1044 +931 @@
- $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
+
@@ -1046 +933 @@
- $y += 3;
+
@@ -1051 +938,3 @@
- } else {
+ }
+ else
+ {
@@ -1074,5 +963,3 @@
- // phpcs:enable
- $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
- if ($object->type == 2) {
- $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
- }
+ // phpcs:enable
+ $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
+ if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
@@ -1104,2 +991,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
@@ -1108,2 +995 @@
- * @param Translate $outputlangsbis Object lang for output bis
- * @return int Pos y
+ * @return void
@@ -1111 +997 @@
- protected function _tableau_info(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
+ protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
@@ -1113 +999 @@
- // phpcs:enable
+ // phpcs:enable
@@ -1121 +1007,2 @@
- if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
+ {
@@ -1124,5 +1011 @@
- if ($mysoc->forme_juridique_code == 92) {
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0);
- } else {
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- }
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@@ -1134,4 +1016,0 @@
- $posxend = 110; // End of x for text on left side
- if ($this->page_largeur < 210) { // To work with US executive format
- $posxend -= 10;
- }
@@ -1140 +1019,2 @@
- if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
+ if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
+ {
@@ -1148 +1028 @@
- $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);
@@ -1152,19 +1032,5 @@
- $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
- }
-
- // Show category of operations
- if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
- $pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : ';
- $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L');
-
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
- $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L');
-
- $posy = $pdf->GetY() + 3; // for 2 lines
- }
-
- if ($object->type != 2) {
+ $posy = $pdf->GetY() + 3;
+ }
+
+ if ($object->type != 2)
+ {
@@ -1173,2 +1039,3 @@
- && !getDolGlobalInt('FACTURE_CHQ_NUMBER')
- && !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
+ && empty($conf->global->FACTURE_CHQ_NUMBER)
+ && empty($conf->global->FACTURE_RIB_NUMBER))
+ {
@@ -1176,3 +1043,5 @@
- } elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
- || ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
- // Avoid having any valid PDF with setup that is not complete
+ }
+ // Avoid having any valid PDF with setup that is not complete
+ elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
+ || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)))
+ {
@@ -1192 +1061 @@
- if (!empty($object->mode_reglement_code)
+ if ($object->mode_reglement_code
@@ -1194 +1063,2 @@
- && $object->mode_reglement_code != 'VIR') {
+ && $object->mode_reglement_code != 'VIR')
+ {
@@ -1202,9 +1072 @@
- $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);
- //#21654: add account number used for the debit
- if ($object->mode_reglement_code == "PRE") {
- require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
- $bac = new CompanyBankAccount($this->db);
- $bac->fetch(0, $object->thirdparty->id);
- $iban= $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
- $lib_mode_reg .= ' '.$outputlangs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
- }
+ $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);
@@ -1213,31 +1075,3 @@
- $posy = $pdf->GetY();
- }
-
- // Show if Option VAT debit option is on also if transmitter is french
- // Decret n°2099-1299 2022-10-07
- // French mention : "Option pour le paiement de la taxe d'après les débits"
- if ($this->emetteur->country_code == 'FR') {
- if (getDolGlobalInt('TAX_MODE') == 1) {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1);
-
- $posy = $pdf->GetY() + 1;
- }
- }
-
- // Show online payment link
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
- $useonlinepayment = 0;
- if (getDolGlobalString('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) {
- if (isModEnabled('paypal')) {
- $useonlinepayment++;
- }
- if (isModEnabled('stripe')) {
- $useonlinepayment++;
- }
- if (isModEnabled('paybox')) {
- $useonlinepayment++;
- }
- }
-
- if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ // Show online payment link
+ $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
+ if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
@@ -1247 +1081 @@
- $langs->loadLangs(array('payment', 'paybox', 'stripe'));
+ $langs->loadLangs(array('payment', 'paybox'));
@@ -1252,5 +1086,5 @@
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->writeHTMLCell(80, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
-
- $posy = $pdf->GetY() + 1;
- }
+ $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
+ }
+
+
+ $posy = $pdf->GetY() + 2;
@@ -1260 +1094,2 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
+ {
@@ -1262,4 +1097,6 @@
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
- $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
-
- 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)
+ {
@@ -1267 +1104 @@
- $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
+ $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@@ -1274 +1111,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1279,3 +1117,4 @@
- }
- }
- if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
+ }
+ }
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1)
+ {
@@ -1287 +1126,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1292 +1132 @@
- }
+ }
@@ -1298,2 +1138,3 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
- if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
+ {
+ if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
@@ -1301,3 +1142 @@
- if ($object->fk_bank > 0) {
- $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
- }
+ if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
@@ -1326 +1165 @@
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
@@ -1331 +1169,0 @@
- * @param Translate $outputlangsbis Object lang for output bis
@@ -1334 +1172 @@
- protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
@@ -1336,17 +1174,7 @@
- // phpcs:enable
- global $conf, $mysoc, $hookmanager;
-
- $sign = 1;
- if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $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"));
- $default_font_size--;
- }
+ // phpcs:enable
+ global $conf, $mysoc;
+
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1359,5 +1187,4 @@
- $col1x = 120;
- $col2x = 170;
- if ($this->page_largeur < 210) { // To work with US executive format
- $col1x -= 15;
- $col2x -= 10;
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $col2x -= 20;
@@ -1372,5 +1199,5 @@
- $pdf->SetXY($col1x, $tab2_top);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total") : ''), 0, 'L', 1);
-
- $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
- $pdf->SetXY($col2x, $tab2_top);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $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);
@@ -1382 +1209 @@
- $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;
@@ -1385 +1212,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
@@ -1387 +1215,2 @@
- if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ {
@@ -1389 +1218,5 @@
- } else {
+ }
+ else
+ {
+ // FIXME amount of vat not supported with multicurrency
+
@@ -1391 +1224 @@
- //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')
@@ -1393,7 +1226,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
+ {
@@ -1406 +1240,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1411,2 +1246 @@
- $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT1", $mysoc->country_code) : '');
- $totalvat .= ' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT1", $mysoc->country_code).' ';
@@ -1416,2 +1249,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1419 +1251 @@
- $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);
@@ -1423 +1255 @@
- //}
+ //}
@@ -1425 +1257 @@
- //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')
@@ -1427,7 +1259,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
+ {
@@ -1434,0 +1268,2 @@
+
+
@@ -1440 +1275,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1444,2 +1280 @@
- $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transcountrynoentities("TotalLT2", $mysoc->country_code) : '');
- $totalvat .= ' ';
+ $totalvat = $outputlangs->transcountrynoentities("TotalLT2", $mysoc->country_code).' ';
@@ -1449,2 +1283,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1452 +1285 @@
- $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);
@@ -1457 +1290 @@
- //}
+ //}
@@ -1460,2 +1293,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
+ {
@@ -1468 +1303,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1472,9 +1308,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'].$tvacompl;
- } else {
- $totalvat .= vatrate($tvaval['vatrate'], 1).($tvaval['vatcode'] ? ' ('.$tvaval['vatcode'].')' : '').$tvacompl;
- }
+ $totalvat = $outputlangs->transcountrynoentities("TotalVAT", $mysoc->country_code).' ';
+ $totalvat .= vatrate($tvakey, 1).$tvacompl;
@@ -1484 +1313 @@
- $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval['amount'], 'MT'), 0, $outputlangs), 0, 'R', 1);
+ $pdf->MultiCell($largcol2, $tab2_hl, price(price2num($tvaval, 'MT'), 0, $outputlangs), 0, 'R', 1);
@@ -1489 +1318 @@
- //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')
@@ -1492,6 +1321,6 @@
- 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
+ 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
+ {
@@ -1504 +1333,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1512,3 +1341,0 @@
-
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1516 +1343 @@
- $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);
@@ -1520 +1347 @@
- //}
+ //}
@@ -1522 +1349 @@
- //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')
@@ -1524,6 +1351,6 @@
- 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) {
+ 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)
+ {
@@ -1536 +1363,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1545,2 +1372,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1548 +1374 @@
- $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);
@@ -1554 +1380,2 @@
- if (price2num($object->revenuestamp) != 0) {
+ if (price2num($object->revenuestamp) != 0)
+ {
@@ -1574 +1401,2 @@
- if ($object->displayRetainedWarranty()) {
+ if ($object->displayRetainedWarranty())
+ {
@@ -1604,2 +1432,2 @@
- $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
- $depositsamount = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+ $depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
@@ -1608,5 +1436,4 @@
- if (!empty($object->paye)) {
- $resteapayer = 0;
- }
-
- if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
+ if (!empty($object->paye)) $resteapayer = 0;
+
+ if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
+ {
@@ -1621 +1448,2 @@
- if ($creditnoteamount) {
+ if ($creditnoteamount)
+ {
@@ -1631 +1459,2 @@
- if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
+ if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
+ {
@@ -1656,8 +1484,0 @@
-
- if (getDolGlobalString("BILL_TEXT_TOTAL_FOOTER")) {
- $index++;
- $index++;
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $conf->global->BILL_TEXT_TOTAL_FOOTER, 0, 'L', 0);
- }
-
@@ -1671 +1492 @@
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
@@ -1687,3 +1508 @@
- if ($hidetop) {
- $hidetop = -1;
- }
+ if ($hidetop) $hidetop = -1;
@@ -1698,8 +1517,2 @@
- if (empty($hidetop)) {
- // Show category of operations
- if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
- $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
- $pdf->SetXY($this->marge_gauche, $tab_top - 4);
- $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
- }
-
+ if (empty($hidetop))
+ {
@@ -1711,3 +1524 @@
- 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));
@@ -1722 +1533,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1729 +1541,2 @@
- if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
+ {
@@ -1731 +1544,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1737 +1551,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))
+ {
@@ -1739 +1554,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1746 +1562,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1752 +1569,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -1757 +1575,2 @@
- if (getDolGlobalInt('PRODUCT_USE_UNITS')) {
+ if (!empty($conf->global->PRODUCT_USE_UNITS))
+ {
@@ -1765,18 +1584,21 @@
- if ($this->atleastonediscount) {
- $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
- if (empty($hidetop)) {
- $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
- $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
- }
- }
-
- if ($this->situationinvoice) {
- $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
- if (empty($hidetop)) {
- $pdf->SetXY($this->posxprogress, $tab_top + 1);
- $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
- }
- }
-
- $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
- if (empty($hidetop)) {
+ if ($this->atleastonediscount)
+ {
+ $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+ $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
+ }
+ }
+
+ if ($this->situationinvoice) {
+ $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
+ if (empty($hidetop)) {
+ $pdf->SetXY($this->posxprogress, $tab_top + 1);
+ $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
+ }
+ }
+
+ $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
@@ -1784 +1606 @@
- $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHTShort"), '', 'C');
+ $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C');
@@ -1792,2 +1614,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
@@ -1796,2 +1618 @@
- * @param Translate $outputlangsbis Object lang for output bis
- * @return int top shift of linked object lines
+ * @return void
@@ -1799 +1620 @@
- protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null)
+ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
@@ -1801 +1621,0 @@
- // phpcs:enable
@@ -1803,5 +1622,0 @@
-
- $ltrdirection = 'L';
- if ($outputlangs->trans("DIRECTION") == 'rtl') {
- $ltrdirection = 'R';
- }
@@ -1815,0 +1631,6 @@
+ // Show Draft Watermark
+ if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
+
@@ -1822 +1643 @@
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
@@ -1827,2 +1648,4 @@
- if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
- if ($this->emetteur->logo) {
+ if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
+ {
+ if ($this->emetteur->logo)
+ {
@@ -1830,4 +1653,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))
+ {
@@ -1835 +1657,2 @@
- } else {
+ }
+ else {
@@ -1838,2 +1661,3 @@
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
@@ -1841 +1665,3 @@
- } else {
+ }
+ else
+ {
@@ -1847 +1673,3 @@
- } else {
+ }
+ else
+ {
@@ -1849 +1677 @@
- $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1857,39 +1685,5 @@
- if ($object->type == 1) {
- $title = $outputlangs->transnoentities("InvoiceReplacement");
- }
- if ($object->type == 2) {
- $title = $outputlangs->transnoentities("InvoiceAvoir");
- }
- if ($object->type == 3) {
- $title = $outputlangs->transnoentities("InvoiceDeposit");
- }
- if ($object->type == 4) {
- $title = $outputlangs->transnoentities("InvoiceProForma");
- }
- if ($this->situationinvoice) {
- $langs->loadLangs(array("other"));
- $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " " . $outputlangs->transnoentities("NumberingShort") . $object->situation_counter . " -";
- }
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
- $title .= ' - ';
- if ($object->type == 0) {
- if ($this->situationinvoice) {
- $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation");
- }
- $title .= $outputlangsbis->transnoentities("PdfInvoiceTitle");
- } elseif ($object->type == 1) {
- $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
- } elseif ($object->type == 2) {
- $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
- } elseif ($object->type == 3) {
- $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
- } elseif ($object->type == 4) {
- $title .= $outputlangsbis->transnoentities("InvoiceProForma");
- }
- }
- $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT) {
- $pdf->SetTextColor(128, 0, 0);
- $title .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
-
+ if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
+ if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
+ if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
+ if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
+ if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
@@ -1900 +1693,0 @@
- /*
@@ -1905 +1698,2 @@
- if ($object->statut == $object::STATUS_DRAFT) {
+ if ($object->statut == Facture::STATUS_DRAFT)
+ {
@@ -1909,3 +1703,3 @@
- $pdf->MultiCell($w, 4, $textref, '', 'R');*/
-
- $posy += 3;
+ $pdf->MultiCell($w, 4, $textref, '', 'R');
+
+ $posy += 1;
@@ -1914 +1708,2 @@
- if ($object->ref_customer) {
+ if ($object->ref_client)
+ {
@@ -1918,4 +1713,5 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_customer), '', 'R');
- }
-
- if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
@@ -1923 +1719,2 @@
- if (!empty($object->project->ref)) {
+ if (!empty($object->project->ref))
+ {
@@ -1927,5 +1724,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))
+ {
@@ -1933,2 +1731,2 @@
- if (!empty($object->project->ref)) {
- $outputlangs->load("projects");
+ if (!empty($object->project->ref))
+ {
@@ -1938 +1736 @@
- $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');
@@ -1943 +1741,2 @@
- if ($object->type == 0 && $objectidnext) {
+ if ($object->type == 0 && $objectidnext)
+ {
@@ -1952 +1751,2 @@
- if ($object->type == 1) {
+ if ($object->type == 1)
+ {
@@ -1961 +1761,2 @@
- if ($object->type == 2 && !empty($object->fk_facture_source)) {
+ if ($object->type == 2 && !empty($object->fk_facture_source))
+ {
@@ -1974,7 +1775,4 @@
- $title = $outputlangs->transnoentities("DateInvoice");
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
- $title .= ' - '.$outputlangsbis->transnoentities("DateInvoice");
- }
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
-
- if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) {
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateInvoice")." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
+
+ if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
+ {
@@ -1987 +1785,2 @@
- if ($object->type != 2) {
+ if ($object->type != 2)
+ {
@@ -1991,8 +1790,5 @@
- $title = $outputlangs->transnoentities("DateDue");
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
- $title .= ' - '.$outputlangsbis->transnoentities("DateDue");
- }
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
- }
-
- if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("DateDue")." : ".dol_print_date($object->date_lim_reglement, "day", false, $outputlangs, true), '', 'R');
+ }
+
+ if ($object->thirdparty->code_client)
+ {
@@ -2006,10 +1802,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($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
@@ -2024 +1822,2 @@
- if ($current_y < $pdf->getY()) {
+ if ($current_y < $pdf->getY())
+ {
@@ -2028 +1827,2 @@
- if ($showaddress) {
+ if ($showaddress)
+ {
@@ -2030,11 +1830 @@
- $carac_emetteur = '';
- // Add internal contact of object if defined
- $arrayidcontact = $object->getIdContact('internal', 'BILLING');
- 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 .= "\n";
- }
-
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+ $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@@ -2043 +1833 @@
- $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
@@ -2046,6 +1836,4 @@
- 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;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+
+ $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
@@ -2055,10 +1843,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($widthrecbox, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
@@ -2067,6 +1853,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($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy = $pdf->getY();
@@ -2077 +1861,2 @@
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
+
@@ -2083 +1868,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -2088,2 +1874,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)) {
@@ -2097,2 +1884 @@
- $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);
@@ -2101,5 +1887,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;
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
@@ -2108,3 +1892 @@
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->marge_gauche;
- }
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -2113,7 +1895,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 - 2, 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);
@@ -2124 +1904 @@
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
@@ -2131,39 +1911 @@
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
-
- // Show shipping address
- if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) {
- $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
-
- if (!empty($idaddressshipping)) {
- $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
- $companystatic = new Societe($this->db);
- $companystatic->fetch($object->contact->fk_soc);
- $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs);
- $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object);
- } else {
- $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
- $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
- }
- if (!empty($carac_client_shipping)) {
- $posy += $hautcadre;
-
- // Show shipping frame
- $pdf->SetXY($posx + 2, $posy - 5);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
-
- // Show shipping name
- $pdf->SetXY($posx + 2, $posy + 3);
- $pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
-
- $posy = $pdf->getY();
-
- // Show shipping information
- $pdf->SetXY($posx+2, $posy);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
- $top_shift += $hautcadre;
- }
- }
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
@@ -2179,3 +1921,3 @@
- *
- * @param TCPDF $pdf PDF
- * @param Facture $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
@@ -2184 +1925,0 @@
- * @param int $heightforqrinvoice Height for QR invoices
@@ -2187 +1928 @@
- protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
@@ -2189,2 +1930,3 @@
- $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
- return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $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, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
--- /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/github_19.0.3_pdf_sponge.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/facture/doc/client_pdf_sponge.modules.php
@@ -12,2 +11,0 @@
- * Copyright (C) 2022 Anthony Berton
- * Copyright (C) 2022 Alexandre Spangaro
@@ -47,0 +46,5 @@
+ /**
+ * @var DoliDb Database handler
+ */
+ public $db;
+
@@ -49,3 +52,3 @@
- * @var DoliDb Database handler
- */
- public $db;
+ * @var string model name
+ */
+ public $name;
@@ -54,3 +57,8 @@
- * @var string model name
- */
- public $name;
+ * @var string model description (short text)
+ */
+ public $description;
+
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
@@ -59,3 +67,3 @@
- * @var string model description (short text)
- */
- public $description;
+ * @var string document type
+ */
+ public $type;
@@ -64,3 +72,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);
@@ -69,3 +78,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;
@@ -74,4 +89,3 @@
- * Dolibarr version of the loaded document
- * @var string
- */
- public $version = 'dolibarr';
+ * @var int page_hauteur
+ */
+ public $page_hauteur;
@@ -80,3 +94,3 @@
- * @var int heightforinfotot
- */
- public $heightforinfotot;
+ * @var array format
+ */
+ public $format;
@@ -85,3 +99,3 @@
- * @var int heightforfreetext
- */
- public $heightforfreetext;
+ * @var int marge_gauche
+ */
+ public $marge_gauche;
@@ -90,3 +104,3 @@
- * @var int heightforfooter
- */
- public $heightforfooter;
+ * @var int marge_droite
+ */
+ public $marge_droite;
@@ -95,3 +109,3 @@
- * @var int tab_top
- */
- public $tab_top;
+ * @var int marge_haute
+ */
+ public $marge_haute;
@@ -100,3 +114,9 @@
- * @var int tab_top_newpage
- */
- public $tab_top_newpage;
+ * @var int marge_basse
+ */
+ public $marge_basse;
+
+ /**
+ * Issuer
+ * @var Societe Object that emits
+ */
+ public $emetteur;
@@ -111 +131 @@
- * @var array of document table columns
+ * @var array of document table collumns
@@ -114,5 +133,0 @@
-
- /**
- * @var int Category of operation
- */
- public $categoryOfOperation = -1; // unknown by default
@@ -144,4 +159,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;
@@ -152,0 +168 @@
+ $this->option_codeproduitservice = 1; // Display product-service code
@@ -158 +173,0 @@
- $this->watermark = '';
@@ -162,3 +177 @@
- 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
@@ -175 +187,0 @@
- $this->tva_array = array();
@@ -184,11 +196,11 @@
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Function to build pdf onto disk
- *
- * @param Facture $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
@@ -198,510 +210,424 @@
- // phpcs:enable
- global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
-
- dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
-
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
- // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
- if (getDolGlobalString('MAIN_USE_FPDF')) {
- $outputlangs->charset_output = 'ISO-8859-1';
- }
-
- // Load translation files required by the page
- $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
-
- 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", "bills", "products", "dict", "companies"));
- }
-
- // Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('FACTURE_DRAFT_WATERMARK'))) {
- $this->watermark = $conf->global->FACTURE_DRAFT_WATERMARK;
- }
-
- $nblines = count($object->lines);
-
- $hidetop = 0;
- if (getDolGlobalString('MAIN_PDF_DISABLE_COL_HEAD_TITLE')) {
- $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
- }
-
- // Loop on each lines to detect if there is at least one image to show
- $realpatharray = array();
- $this->atleastonephoto = false;
- if (getDolGlobalString('MAIN_GENERATE_INVOICES_WITH_PICTURE')) {
- $objphoto = new Product($this->db);
-
- for ($i = 0; $i < $nblines; $i++) {
- if (empty($object->lines[$i]->fk_product)) {
- continue;
- }
-
- $objphoto->fetch($object->lines[$i]->fk_product);
- //var_dump($objphoto->ref);exit;
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
- $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
- $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
- } else {
- $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product'); // default
- $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
- }
-
- $arephoto = false;
- foreach ($pdir as $midir) {
- if (!$arephoto) {
- if ($conf->entity != $objphoto->entity) {
- $dir = $conf->product->multidir_output[$objphoto->entity].'/'.$midir; //Check repertories of current entities
- } else {
- $dir = $conf->product->dir_output.'/'.$midir; //Check repertory of the current product
- }
-
- 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']) {
- $filename = $obj['photo_vignette'];
- } else {
- $filename = $obj['photo'];
- }
- } else {
- $filename = $obj['photo'];
- }
-
- $realpath = $dir.$filename;
- $arephoto = true;
- $this->atleastonephoto = true;
- }
- }
- }
-
- if ($realpath && $arephoto) {
- $realpatharray[$i] = $realpath;
- }
- }
- }
-
- //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
-
- if ($conf->facture->multidir_output[$conf->entity]) {
- $object->fetch_thirdparty();
-
- $deja_regle = $object->getSommePaiement((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_credit_notes_included = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
- $amount_deposits_included = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
-
- // Definition of $dir and $file
- if ($object->specimen) {
- $dir = $conf->facture->multidir_output[$conf->entity];
- $file = $dir."/SPECIMEN.pdf";
- } else {
- $objectref = dol_sanitizeFileName($object->ref);
- $dir = $conf->facture->multidir_output[$object->entity]."/".$objectref;
- $file = $dir."/".$objectref.".pdf";
- }
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
- $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
- return 0;
- }
- }
-
- if (file_exists($dir)) {
- // Add pdfgeneration hook
- if (!is_object($hookmanager)) {
- include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
- $hookmanager = new HookManager($this->db);
- }
- $hookmanager->initHooks(array('pdfgeneration'));
- $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
- global $action;
- $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
-
- // Set nblines with the new facture lines content after hook
- $nblines = count($object->lines);
- $nbpayments = count($object->getListOfPayments());
-
- // Create pdf instance
- $pdf = pdf_getInstance($this->format);
- $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
- $pdf->SetAutoPageBreak(1, 0);
-
- $this->heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
- $this->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
- $this->heightforfooter = $this->marge_basse + (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
-
- $heightforqrinvoice = $heightforqrinvoice_firstpage = 0;
- if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
- if ($this->getHeightForQRInvoice(1, $object, $langs) > 0) {
- // Shrink infotot to a base 30
- $this->heightforinfotot = 30 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
- }
- }
-
- 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->Open();
- $pagenb = 0;
- $pdf->SetDrawColor(128, 128, 128);
-
- $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
- $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
- $pdf->SetCreator("Dolibarr ".DOL_VERSION);
- $pdf->SetAuthor($mysoc->name.($user->id > 0 ? ' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) : ''));
- $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
- if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
- $pdf->SetCompression(false);
- }
-
- // Set certificate
- $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
- $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ? '' : $user->conf->CERTIFICATE_CRT_PRIVATE;
- // If user has no certificate, we try to take the company one
- if (!$cert) {
- $cert = !getDolGlobalString('CERTIFICATE_CRT') ? '' : $conf->global->CERTIFICATE_CRT;
- }
- if (!$certprivate) {
- $certprivate = !getDolGlobalString('CERTIFICATE_CRT_PRIVATE') ? '' : $conf->global->CERTIFICATE_CRT_PRIVATE;
- }
- // If a certificate is found
- if ($cert) {
- $info = array(
- 'Name' => $this->emetteur->name,
- 'Location' => getCountry($this->emetteur->country_code, 0),
- 'Reason' => 'INVOICE',
- 'ContactInfo' => $this->emetteur->email
- );
- $pdf->setSignature($cert, $certprivate, $this->emetteur->name, '', 2, $info);
- }
-
- $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
-
- // Set $this->atleastonediscount if you have at least one discount
- // and determine category of operation
- $categoryOfOperation = 0;
- $nbProduct = 0;
- $nbService = 0;
- for ($i = 0; $i < $nblines; $i++) {
- if ($object->lines[$i]->remise_percent) {
- $this->atleastonediscount++;
- }
-
- // determine category of operation
- if ($categoryOfOperation < 2) {
- $lineProductType = $object->lines[$i]->product_type;
- if ($lineProductType == Product::TYPE_PRODUCT) {
- $nbProduct++;
- } elseif ($lineProductType == Product::TYPE_SERVICE) {
- $nbService++;
- }
- if ($nbProduct > 0 && $nbService > 0) {
- // mixed products and services
- $categoryOfOperation = 2;
- }
- }
- }
- // determine category of operation
- if ($categoryOfOperation <= 0) {
- // only services
- if ($nbProduct == 0 && $nbService > 0) {
- $categoryOfOperation = 1;
- }
- }
- $this->categoryOfOperation = $categoryOfOperation;
-
- // Situation invoice handling
- if ($object->situation_cycle_ref) {
- $this->situationinvoice = true;
- }
-
- // New page
- $pdf->AddPage();
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- $pagenb++;
-
- // Output header (logo, ref and address blocks). This is first call for first page.
- $pagehead = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
- $top_shift = $pagehead['top_shift'];
- $shipp_shift = $pagehead['shipp_shift'];
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell(0, 3, ''); // Set interline to 3
- $pdf->SetTextColor(0, 0, 0);
-
- // $pdf->GetY() here can't be used. It is bottom of the second addresse box but first one may be higher
-
- // $this->tab_top is y where we must continue content (90 = 42 + 48: 42 is height of logo and ref, 48 is address blocks)
- $this->tab_top = 90 + $top_shift + $shipp_shift; // top_shift is an addition for linked objects or addons (0 in most cases)
- $this->tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
-
- // You can add more thing under header here, if you increase $extra_under_address_shift too.
- $extra_under_address_shift = 0;
- $qrcodestring = '';
- if (getDolGlobalString('INVOICE_ADD_ZATCA_QR_CODE')) {
- $qrcodestring = $object->buildZATCAQRString();
- } elseif (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == '1') {
- $qrcodestring = $object->buildSwitzerlandQRString();
- }
- if ($qrcodestring) {
- $qrcodecolor = array('25', '25', '25');
- // set style for QR-code
- $styleQr = array(
- 'border' => false,
- 'padding' => 0,
- 'fgcolor' => $qrcodecolor,
- 'bgcolor' => false, //array(255,255,255)
- 'module_width' => 1, // width of a single module in points
- 'module_height' => 1 // height of a single module in points
- );
- $pdf->write2DBarcode($qrcodestring, 'QRCODE,M', $this->marge_gauche, $this->tab_top - 5, 25, 25, $styleQr, 'N');
- $extra_under_address_shift += 25;
- }
-
- // Call hook printUnderHeaderPDFline
- $parameters = array(
- 'object' => $object,
- 'i' => $i,
- 'pdf' => &$pdf,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails
- );
- $reshook = $hookmanager->executeHooks('printUnderHeaderPDFline', $parameters, $this); // Note that $object may have been modified by hook
- if (!empty($hookmanager->resArray['extra_under_address_shift'])) {
- $extra_under_address_shift += $hookmanager->resArray['extra_under_address_shift'];
- }
-
- $this->tab_top += $extra_under_address_shift;
- $this->tab_top_newpage += 0;
-
-
- // Define heigth of table for lines (for first page)
- $tab_height = $this->page_hauteur - $this->tab_top - $this->heightforfooter - $this->heightforfreetext - $this->getHeightForQRInvoice(1, $object, $langs);
-
- $nexY = $this->tab_top - 1;
-
- // Incoterm
- $height_incoterms = 0;
- if (isModEnabled('incoterm')) {
- $desc_incoterms = $object->getIncotermsForPDF();
- if ($desc_incoterms) {
- $this->tab_top -= 2;
-
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
- $nexY = max($pdf->GetY(), $nexY);
- $height_incoterms = $nexY - $this->tab_top;
-
- // Rect takes a length in 3rd parameter
- $pdf->SetDrawColor(192, 192, 192);
- $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
-
- $this->tab_top = $nexY + 6;
- $height_incoterms += 4;
- }
- }
-
- // Displays notes. Here we are still on code eecuted only for the first page.
- $notetoshow = empty($object->note_public) ? '' : $object->note_public;
- if (getDolGlobalString('MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE')) {
- // Get first sale rep
- if (is_object($object->thirdparty)) {
- $salereparray = $object->thirdparty->getSalesRepresentatives($user);
- $salerepobj = new User($this->db);
- $salerepobj->fetch($salereparray[0]['id']);
- 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);
- }
-
- $pagenb = $pdf->getPage();
- if ($notetoshow) {
- $this->tab_top -= 2;
-
- $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
- $pageposbeforenote = $pagenb;
-
- $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
- complete_substitutions_array($substitutionarray, $outputlangs, $object);
- $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
- $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
-
- $pdf->startTransaction();
-
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
- // Description
- $pageposafternote = $pdf->getPage();
- $posyafter = $pdf->GetY();
-
- 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, $outputlangsbis);
- }
- $pdf->setTopMargin($this->tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
- }
-
- // back to start
- $pdf->setPage($pageposbeforenote);
- $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $this->tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
- $pageposafternote = $pdf->getPage();
-
- $posyafter = $pdf->GetY();
-
- if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->heightforfreetext + 20))) { // There is no space left for total+free text
- $pdf->AddPage('', '', true);
- $pagenb++;
- $pageposafternote++;
- $pdf->setPage($pageposafternote);
- $pdf->setTopMargin($this->tab_top_newpage);
- // The only function to edit the bottom margin of current page to set it.
- $pdf->setPageOrientation('', 1, $this->heightforfooter + $this->heightforfreetext);
- //$posyafter = $this->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 - ($this->tab_top_newpage + $this->heightforfooter);
- $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else {
- $height_note = $this->page_hauteur - ($this->tab_top + $this->heightforfooter);
- $pdf->Rect($this->marge_gauche, $this->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, $this->getHeightForQRInvoice($i, $object, $outputlangs));
-
- $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, $outputlangsbis);
- }
- $height_note = $posyafter - $this->tab_top_newpage;
- $pdf->Rect($this->marge_gauche, $this->tab_top_newpage - 1, $tab_width, $height_note + 1);
- } else {
- // No pagebreak
- $pdf->commitTransaction();
- $posyafter = $pdf->GetY();
- $height_note = $posyafter - $this->tab_top;
- $pdf->Rect($this->marge_gauche, $this->tab_top - 1, $tab_width, $height_note + 1);
-
-
- if ($posyafter > ($this->page_hauteur - ($this->heightforfooter + $this->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, $outputlangsbis);
- }
-
- $posyafter = $this->tab_top_newpage;
- }
- }
-
- $tab_height = $tab_height - $height_note;
- $this->tab_top = $posyafter + 6;
- } else {
- $height_note = 0;
- }
-
- // Use new auto column system
- $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
-
- // Table simulation to know the height of the title line (this set this->tableTitleHeight)
- $pdf->startTransaction();
- $this->pdfTabTitles($pdf, $this->tab_top, $tab_height, $outputlangs, $hidetop);
- $pdf->rollbackTransaction(true);
-
- $nexY = $this->tab_top + $this->tabTitleHeight;
-
- // Loop on each lines
- $pageposbeforeprintlines = $pdf->getPage();
- $pagenb = $pageposbeforeprintlines;
- for ($i = 0; $i < $nblines; $i++) {
- $curY = $nexY;
- $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
- $pdf->SetTextColor(0, 0, 0);
-
- // Define size of image if we need it
- $imglinesize = array();
- if (!empty($realpatharray[$i])) {
- $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
- }
-
- $pdf->setTopMargin($this->tab_top_newpage);
- $page_bottom_margin = $this->heightforfooter + $this->heightforfreetext + $this->heightforinfotot + $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs);
- $pdf->setPageOrientation('', 1, $page_bottom_margin);
- $pageposbefore = $pdf->getPage();
-
- $showpricebeforepagebreak = 1;
- $posYAfterImage = 0;
- $posYAfterDescription = 0;
-
- if ($this->getColumnStatus('photo')) {
- // We start with Photo of product line
- if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - $page_bottom_margin)) { // If photo too high, we moved completely on new page
- $pdf->AddPage('', '', true);
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- $pdf->setPage($pageposbefore + 1);
-
- $curY = $this->tab_top_newpage;
+ // phpcs:enable
+ global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
+
+ dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
+
+ if (!is_object($outputlangs)) $outputlangs = $langs;
+ // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+
+ // Load translation files required by the page
+ $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
+
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
+ global $outputlangsbis;
+ $outputlangsbis = new Translate('', $conf);
+ $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
+ $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies"));
+ }
+
+ $nblines = count($object->lines);
+
+ $hidetop = 0;
+ if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
+ $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+ }
+
+ // Loop on each lines to detect if there is at least one image to show
+ $realpatharray = array();
+ $this->atleastonephoto = false;
+ if (!empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
+ {
+ $objphoto = new Product($this->db);
+
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
+
+ $objphoto->fetch($object->lines[$i]->fk_product);
+ //var_dump($objphoto->ref);exit;
+ if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ {
+ $pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
+ $pdir[1] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
+ }
+ else
+ {
+ $pdir[0] = get_exdir(0, 0, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/'; // default
+ $pdir[1] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/"; // alternative
+ }
+
+ $arephoto = false;
+ foreach ($pdir as $midir)
+ {
+ if (!$arephoto)
+ {
+ $dir = $conf->product->dir_output.'/'.$midir;
+
+ 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'])
+ {
+ $filename = $obj['photo_vignette'];
+ }
+ else
+ {
+ $filename = $obj['photo'];
+ }
+ }
+ else
+ {
+ $filename = $obj['photo'];
+ }
+
+ $realpath = $dir.$filename;
+ $arephoto = true;
+ $this->atleastonephoto = true;
+ }
+ }
+ }
+
+ if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
+ }
+ }
+
+ //if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
+
+ if ($conf->facture->dir_output)
+ {
+ $object->fetch_thirdparty();
+
+ $deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+ $amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
+
+ // Definition of $dir and $file
+ if ($object->specimen)
+ {
+ $dir = $conf->facture->dir_output;
+ $file = $dir."/SPECIMEN.pdf";
+ }
+ else
+ {
+ $objectref = dol_sanitizeFileName($object->ref);
+ $dir = $conf->facture->dir_output."/".$objectref;
+ $file = $dir."/".$objectref.".pdf";
+ }
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+
+ if (file_exists($dir))
+ {
+ // Add pdfgeneration hook
+ if (!is_object($hookmanager))
+ {
+ include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
+ $hookmanager = new HookManager($this->db);
+ }
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+
+ // Set nblines with the new facture lines content after hook
+ $nblines = count($object->lines);
+ $nbpayments = count($object->getListOfPayments());
+
+ // Create pdf instance
+ $pdf = pdf_getInstance($this->format);
+ $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+ $pdf->SetAutoPageBreak(1, 0);
+
+ $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
+ $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)
+
+ 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);
+ }
+
+ $pdf->Open();
+ $pagenb = 0;
+ $pdf->SetDrawColor(128, 128, 128);
+
+ $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
+ $pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
+ $pdf->SetCreator("Dolibarr ".DOL_VERSION);
+ $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
+ $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
+
+ // Set certificate
+ $cert = empty($user->conf->CERTIFICATE_CRT) ? '' : $user->conf->CERTIFICATE_CRT;
+ // If use has no certificate, we try to take the company one
+ if (!$cert) {
+ $cert = empty($conf->global->CERTIFICATE_CRT) ? '' : $conf->global->CERTIFICATE_CRT;
+ }
+ // If a certificate is found
+ if ($cert) {
+ $info = array(
+ 'Name' => $this->emetteur->name,
+ 'Location' => getCountry($this->emetteur->country_code, 0),
+ 'Reason' => 'INVOICE',
+ 'ContactInfo' => $this->emetteur->email
+ );
+ $pdf->setSignature($cert, $cert, $this->emetteur->name, '', 2, $info);
+ }
+
+ $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
+
+ // Does we have at least one line with discount $this->atleastonediscount
+ foreach ($object->lines as $line) {
+ if ($line->remise_percent) {
+ $this->atleastonediscount = true;
+ break;
+ }
+ }
+
+
+ // Situation invoice handling
+ if ($object->situation_cycle_ref)
+ {
+ $this->situationinvoice = true;
+ }
+
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+
+ $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->MultiCell(0, 3, ''); // Set interline to 3
+ $pdf->SetTextColor(0, 0, 0);
+
+ $tab_top = 90 + $top_shift;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
+ $tab_height = 130 - $top_shift;
+ $tab_height_newpage = 150;
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
+
+ $nexY = $tab_top - 1;
+
+ // Incoterm
+ $height_incoterms = 0;
+ if ($conf->incoterm->enabled)
+ {
+ $desc_incoterms = $object->getIncotermsForPDF();
+ if ($desc_incoterms)
+ {
+ $tab_top -= 2;
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
+ $nexY = max($pdf->GetY(), $nexY);
+ $height_incoterms = $nexY - $tab_top;
+
+ // Rect takes a length in 3rd parameter
+ $pdf->SetDrawColor(192, 192, 192);
+ $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
+
+ $tab_top = $nexY + 6;
+ $height_incoterms += 4;
+ }
+ }
+
+ // Display notes
+ $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+ if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
+ {
+ // Get first sale rep
+ if (is_object($object->thirdparty))
+ {
+ $salereparray = $object->thirdparty->getSalesRepresentatives($user);
+ $salerepobj = new User($this->db);
+ $salerepobj->fetch($salereparray[0]['id']);
+ 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);
+ }
+
+ $pagenb = $pdf->getPage();
+ if ($notetoshow)
+ {
+ $tab_top -= 2;
+
+ $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+ $pageposbeforenote = $pagenb;
+
+ $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+ $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
+ $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
+
+ $pdf->startTransaction();
+
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+ // Description
+ $pageposafternote = $pdf->getPage();
+ $posyafter = $pdf->GetY();
+
+ if ($pageposafternote > $pageposbeforenote)
+ {
+ $pdf->rollbackTransaction(true);
+
+ // prepare 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 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 (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;
+ }
+ }
+
+ $tab_height = $tab_height - $height_note;
+ $tab_top = $posyafter + 6;
+ }
+ else
+ {
+ $height_note = 0;
+ }
+
+ // Use new auto column system
+ $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref);
+
+ // Table simulation to know the height of the title line
+ $pdf->startTransaction();
+ $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
+ $pdf->rollbackTransaction(true);
+
+ $nexY = $tab_top + $this->tabTitleHeight;
+
+ // Loop on each lines
+ $pageposbeforeprintlines = $pdf->getPage();
+ $pagenb = $pageposbeforeprintlines;
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ $curY = $nexY;
+ $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+ $pdf->SetTextColor(0, 0, 0);
+
+ // Define size of image if we need it
+ $imglinesize = array();
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
+
+ $pdf->setTopMargin($tab_top_newpage);
+ $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+ $pageposbefore = $pdf->getPage();
+
+ $showpricebeforepagebreak = 1;
+ $posYAfterImage = 0;
+
+ 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 + $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;
@@ -710 +636 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -712 +638 @@
- } else {
+ else
@@ -714,37 +640,40 @@
- }
- }
-
- 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'];
- }
- }
-
- // Description of product line
- 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);
- $pageposafter = $pageposbefore;
- $pdf->setPageOrientation('', 1, $this->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 - ($this->heightforfooter+$this->heightforfreetext+$this->heightforinfotot))); exit;
- if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) { // 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 (!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'];
+ }
+ }
+
+ // Description of product line
+ 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 + $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
@@ -752 +681 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -754 +683 @@
- } else {
+ else
@@ -756,292 +685,256 @@
- }
- }
- } else { // No pagebreak
- $pdf->commitTransaction();
- }
- $posYAfterDescription = $pdf->GetY();
- }
-
- $nexY = max($pdf->GetY(), $posYAfterImage, $posYAfterDescription);
-
- $pageposafter = $pdf->getPage();
- $pdf->setPage($pageposbefore);
- $pdf->setTopMargin($this->marge_haute);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
-
- // We suppose that a too long description or photo were moved completely on next page
- if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
- $pdf->setPage($pageposafter);
- $curY = $this->tab_top_newpage;
- }
-
- $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
-
- // VAT Rate
- if ($this->getColumnStatus('vat')) {
- $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Unit price before discount
- 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);
- }
-
- // Quantity
- // Enough for 6 chars
- if ($this->getColumnStatus('qty')) {
- $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Situation progress
- if ($this->getColumnStatus('progress')) {
- $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
- $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Unit
- if ($this->getColumnStatus('unit')) {
- $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
- $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
- $nexY = max($pdf->GetY(), $nexY);
- }
-
- // Discount on line
- 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);
- }
- }
- }
-
-
- $parameters = array(
- 'object' => $object,
- 'i' => $i,
- 'pdf' =>& $pdf,
- 'curY' =>& $curY,
- 'nexY' =>& $nexY,
- 'outputlangs' => $outputlangs,
- 'hidedetails' => $hidedetails
- );
- $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
-
-
- $sign = 1;
- if (isset($object->type) && $object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
- // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
- $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
- if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) { // Compute progress from previous situation
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- } else {
- $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
- }
- } else {
- if (isModEnabled("multicurrency") && $object->multicurrency_tx != 1) {
- $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
- } else {
- $tvaligne = $sign * $object->lines[$i]->total_tva;
- }
- }
-
- $localtax1ligne = $object->lines[$i]->total_localtax1;
- $localtax2ligne = $object->lines[$i]->total_localtax2;
- $localtax1_rate = $object->lines[$i]->localtax1_tx;
- $localtax2_rate = $object->lines[$i]->localtax2_tx;
- $localtax1_type = $object->lines[$i]->localtax1_type;
- $localtax2_type = $object->lines[$i]->localtax2_type;
-
- // 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;
- }*/
-
- $vatrate = (string) $object->lines[$i]->tva_tx;
-
- // Retrieve type from database for backward compatibility with old records
- if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
- && (!empty($localtax1_rate) || !empty($localtax2_rate))) { // and there is local tax
- $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
- $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;
- }
- $this->tva[$vatrate] += $tvaligne; // ->tva is abandonned, we use now ->tva_array that is more complete
- $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);
-
- $nexY = max($nexY, $posYAfterImage);
-
- // Add line
- if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
- $pdf->setPage($pageposafter);
- $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
- //$pdf->SetDrawColor(190,190,200);
- $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
- $pdf->SetLineStyle(array('dash'=>0));
- }
-
- // Detect if some page were added automatically and output _tableau for past pages
- while ($pagenb < $pageposafter) {
- $pdf->setPage($pagenb);
- $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
- if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
- }
- $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
- $pagenb++;
- $pdf->setPage($pagenb);
- $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- }
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- }
-
- if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
- $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
- if ($pagenb == $pageposafter) {
- $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code, $outputlangsbis);
- } else {
- $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
- }
- $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
- // New page
- $pdf->AddPage();
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- $pagenb++;
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- }
- }
- }
-
- // Show square
- $heightforqrinvoice = $this->getHeightForQRInvoice($pagenb, $object, $langs);
- if ($pagenb == $pageposbeforeprintlines) {
- $this->_tableau($pdf, $this->tab_top, $this->page_hauteur - $this->tab_top - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
- } else {
- $this->_tableau($pdf, $this->tab_top_newpage, $this->page_hauteur - $this->tab_top_newpage - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
- $bottomlasttab = $this->page_hauteur - $this->heightforinfotot - $this->heightforfreetext - $this->heightforfooter - $heightforqrinvoice + 1;
- }
-
- // Display infos area
- $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs, $outputlangsbis);
-
- // Display total zone
- $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
-
- // Display payment area
- if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
- $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
- }
-
- // Pagefoot
- $this->_pagefoot($pdf, $object, $outputlangs, 0, $this->getHeightForQRInvoice($pdf->getPage(), $object, $langs));
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
-
- if (getDolGlobalString('INVOICE_ADD_SWISS_QR_CODE') == 'bottom') {
- $this->addBottomQRInvoice($pdf, $object, $outputlangs);
- }
- $pdf->Close();
-
- $pdf->Output($file, 'F');
-
- // Add pdfgeneration hook
- $hookmanager->initHooks(array('pdfgeneration'));
- $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
- global $action;
- $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook < 0) {
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
- }
-
- dolChmod($file);
-
- $this->result = array('fullpath'=>$file);
-
- return 1; // No error
- } else {
- $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
- return 0;
- }
- } else {
- $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
- return 0;
- }
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ }
+
+ $nexY = $pdf->GetY();
+ $pageposafter = $pdf->getPage();
+ $pdf->setPage($pageposbefore);
+ $pdf->setTopMargin($this->marge_haute);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+ // We suppose that a too long description or photo were moved completely on next page
+ if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
+ }
+
+ $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+
+ // VAT Rate
+ if ($this->getColumnStatus('vat'))
+ {
+ $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Unit price before discount
+ 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);
+ }
+
+ // Quantity
+ // Enough for 6 chars
+ if ($this->getColumnStatus('qty'))
+ {
+ $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Situation progress
+ if ($this->getColumnStatus('progress'))
+ {
+ $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
+ $this->printStdColumnContent($pdf, $curY, 'progress', $progress);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Unit
+ if ($this->getColumnStatus('unit'))
+ {
+ $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+ $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
+ $nexY = max($pdf->GetY(), $nexY);
+ }
+
+ // Discount on line
+ 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);
+ }
+ }
+ }
+
+
+ $parameters = array(
+ 'object' => $object,
+ 'i' => $i,
+ 'pdf' =>& $pdf,
+ 'curY' =>& $curY,
+ 'nexY' =>& $nexY,
+ 'outputlangs' => $outputlangs,
+ 'hidedetails' => $hidedetails
+ );
+ $reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
+
+
+ $sign = 1;
+ if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+ // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
+ $prev_progress = $object->lines[$i]->get_prev_progress($object->id);
+ if ($prev_progress > 0 && !empty($object->lines[$i]->situation_percent)) // Compute progress from previous situation
+ {
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva * ($object->lines[$i]->situation_percent - $prev_progress) / $object->lines[$i]->situation_percent;
+ } else {
+ if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $sign * $object->lines[$i]->multicurrency_total_tva;
+ else $tvaligne = $sign * $object->lines[$i]->total_tva;
+ }
+
+ $localtax1ligne = $object->lines[$i]->total_localtax1;
+ $localtax2ligne = $object->lines[$i]->total_localtax2;
+ $localtax1_rate = $object->lines[$i]->localtax1_tx;
+ $localtax2_rate = $object->lines[$i]->localtax2_tx;
+ $localtax1_type = $object->lines[$i]->localtax1_type;
+ $localtax2_type = $object->lines[$i]->localtax2_type;
+
+ 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;
+
+ $vatrate = (string) $object->lines[$i]->tva_tx;
+
+ // Retrieve type from database for backward compatibility with old records
+ if ((!isset($localtax1_type) || $localtax1_type == '' || !isset($localtax2_type) || $localtax2_type == '') // if tax type not defined
+ && (!empty($localtax1_rate) || !empty($localtax2_rate))) // and there is local tax
+ {
+ $localtaxtmp_array = getLocalTaxesFromRate($vatrate, 0, $object->thirdparty, $mysoc);
+ $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;
+ $this->tva[$vatrate] += $tvaligne;
+
+ $nexY = max($nexY, $posYAfterImage);
+
+ // Add line
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
+ $pdf->setPage($pageposafter);
+ $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
+ //$pdf->SetDrawColor(190,190,200);
+ $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
+ $pdf->SetLineStyle(array('dash'=>0));
+ }
+
+ // Detect if some page were added automatically and output _tableau for past pages
+ while ($pagenb < $pageposafter) {
+ $pdf->setPage($pagenb);
+ 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);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pagenb++;
+ $pdf->setPage($pagenb);
+ $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+ 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, $outputlangsbis);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code, $outputlangsbis);
+ }
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ // New page
+ $pdf->AddPage();
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ $pagenb++;
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+ }
+ }
+
+ // Show square
+ if ($pagenb == $pageposbeforeprintlines)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
+
+ // Display infos area
+ $posy = $this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
+
+ // Display total zone
+ $posy = $this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
+
+ // Display payment area
+ if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
+ {
+ $posy = $this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
+ }
+
+ // Pagefoot
+ $this->_pagefoot($pdf, $object, $outputlangs);
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
+
+ $pdf->Close();
+
+ $pdf->Output($file, 'F');
+
+ // Add pdfgeneration hook
+ $hookmanager->initHooks(array('pdfgeneration'));
+ $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
+ global $action;
+ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook < 0)
+ {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+
+ $this->result = array('fullpath'=>$file);
+
+ return 1; // No error
+ }
+ else
+ {
+ $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
+ return 0;
+ }
+ }
+ else
+ {
+ $this->error = $langs->transnoentities("ErrorConstantNotDefined", "FAC_OUTPUTDIR");
+ return 0;
+ }
@@ -1054,5 +947,5 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object invoice
- * @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 PDF $pdf Object PDF
+ * @param Object $object Object invoice
+ * @param int $posy Position y in PDF
+ * @param Translate $outputlangs Object langs for output
+ * @return int <0 if KO, >0 if OK
@@ -1064,6 +957,4 @@
- $sign = 1;
- if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
-
- $tab3_posx = 120;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $tab3_posx = 120;
@@ -1073,2 +964,3 @@
- if ($this->page_largeur < 210) { // To work with US executive format
- $tab3_posx -= 15;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $tab3_posx -= 20;
@@ -1080,3 +972 @@
- if ($object->type == 2) {
- $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
- }
+ if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
@@ -1112 +1002 @@
- $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int) $object->id);
+ $sql .= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id;
@@ -1114 +1004,2 @@
- if ($resql) {
+ if ($resql)
+ {
@@ -1118 +1009,2 @@
- while ($i < $num) {
+ while ($i < $num)
+ {
@@ -1122,9 +1014,4 @@
- if ($obj->type == 2) {
- $text = $outputlangs->transnoentities("CreditNote");
- } elseif ($obj->type == 3) {
- $text = $outputlangs->transnoentities("Deposit");
- } elseif ($obj->type == 0) {
- $text = $outputlangs->transnoentities("ExcessReceived");
- } else {
- $text = $outputlangs->transnoentities("UnknownType");
- }
+ if ($obj->type == 2) $text = $outputlangs->transnoentities("CreditNote");
+ elseif ($obj->type == 3) $text = $outputlangs->transnoentities("Deposit");
+ elseif ($obj->type == 0) $text = $outputlangs->transnoentities("ExcessReceived");
+ else $text = $outputlangs->transnoentities("UnknownType");
@@ -1137 +1024 @@
- $pdf->MultiCell(20, 3, price((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0, 'L', 0);
@@ -1147 +1034,3 @@
- } else {
+ }
+ else
+ {
@@ -1158 +1047 @@
- $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int) $object->id);
+ $sql .= " WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".$object->id;
@@ -1163 +1052,2 @@
- if ($resql) {
+ if ($resql)
+ {
@@ -1166,2 +1055,0 @@
- $y += 3;
- $maxY = $y;
@@ -1168,0 +1057 @@
+ $y += 3;
@@ -1169,0 +1059 @@
+
@@ -1173 +1063 @@
- $pdf->MultiCell(20, 3, price($sign * ((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
+ $pdf->MultiCell(20, 3, price($sign * (($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0, 'L', 0);
@@ -1178 +1067,0 @@
- $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
@@ -1181 +1070 @@
- $y = $maxY = max($pdf->GetY() - 3 - $tab3_top, $maxY);
+
@@ -1183 +1072 @@
- $y += 3;
+
@@ -1188 +1077,3 @@
- } else {
+ }
+ else
+ {
@@ -1198,2 +1089,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
+ * @param tcpdf $pdf Object PDF
+ * @param Object $object Object to show
@@ -1202 +1092,0 @@
- * @param Translate $outputlangsbis Object lang for output bis
@@ -1205 +1095 @@
- protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs, $outputlangsbis)
+ protected function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
@@ -1214 +1104,2 @@
- if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj)) {
+ if ($this->emetteur->country_code == 'FR' && empty($mysoc->tva_assuj))
+ {
@@ -1217,5 +1108 @@
- if ($mysoc->forme_juridique_code == 92) {
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoiceAsso"), 0, 'L', 0);
- } else {
- $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
- }
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0);
@@ -1226,5 +1113 @@
- $posxval = 52; // Position of values of properties shown on left side
- $posxend = 110; // End of x for text on left side
- if ($this->page_largeur < 210) { // To work with US executive format
- $posxend -= 10;
- }
+ $posxval = 52;
@@ -1233 +1116,2 @@
- if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) {
+ if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
+ {
@@ -1237 +1121 @@
- $pdf->MultiCell($posxval - $this->marge_gauche, 4, $titre, 0, 'L');
+ $pdf->MultiCell(43, 4, $titre, 0, 'L');
@@ -1241 +1125 @@
- $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);
@@ -1243,21 +1127,7 @@
- $pdf->MultiCell($posxend - $posxval, 4, $lib_condition_paiement, 0, 'L');
-
- $posy = $pdf->GetY() + 3; // We need spaces for 2 lines payment conditions
- }
-
- // Show category of operations
- if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
- $pdf->SetFont('', 'B', $default_font_size - 2);
- $pdf->SetXY($this->marge_gauche, $posy);
- $categoryOfOperationTitle = $outputlangs->transnoentities("MentionCategoryOfOperations").' : ';
- $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0, 'L');
-
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->SetXY($posxval, $posy);
- $categoryOfOperationLabel = $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
- $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0, 'L');
-
- $posy = $pdf->GetY() + 3; // for 2 lines
- }
-
- if ($object->type != 2) {
+ $pdf->MultiCell(67, 4, $lib_condition_paiement, 0, 'L');
+
+ $posy = $pdf->GetY() + 3;
+ }
+
+ if ($object->type != 2)
+ {
@@ -1266,2 +1136,3 @@
- && !getDolGlobalInt('FACTURE_CHQ_NUMBER')
- && !getDolGlobalInt('FACTURE_RIB_NUMBER')) {
+ && empty($conf->global->FACTURE_CHQ_NUMBER)
+ && empty($conf->global->FACTURE_RIB_NUMBER))
+ {
@@ -1269,3 +1140,5 @@
- } elseif (($object->mode_reglement_code == 'CHQ' && !getDolGlobalInt('FACTURE_CHQ_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))
- || ($object->mode_reglement_code == 'VIR' && !getDolGlobalInt('FACTURE_RIB_NUMBER') && empty($object->fk_account) && empty($object->fk_bank))) {
- // Avoid having any valid PDF with setup that is not complete
+ }
+ // Avoid having any valid PDF with setup that is not complete
+ elseif (($object->mode_reglement_code == 'CHQ' && empty($conf->global->FACTURE_CHQ_NUMBER) && empty($object->fk_account) && empty($object->fk_bank))
+ || ($object->mode_reglement_code == 'VIR' && empty($conf->global->FACTURE_RIB_NUMBER) && empty($object->fk_account) && empty($object->fk_bank)))
+ {
@@ -1278 +1151 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $this->error, 0, 'L', 0);
+ $pdf->MultiCell(80, 3, $this->error, 0, 'L', 0);
@@ -1285,3 +1158,4 @@
- if (!empty($object->mode_reglement_code)
- && $object->mode_reglement_code != 'CHQ'
- && $object->mode_reglement_code != 'VIR') {
+ if ($object->mode_reglement_code
+ && $object->mode_reglement_code != 'CHQ'
+ && $object->mode_reglement_code != 'VIR')
+ {
@@ -1291 +1165 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 5, $titre, 0, 'L');
+ $pdf->MultiCell(80, 5, $titre, 0, 'L');
@@ -1295,45 +1169,6 @@
- $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);
-
- //#21654: add account number used for the debit
- if ($object->mode_reglement_code == "PRE") {
- require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
- $bac = new CompanyBankAccount($this->db);
- $bac->fetch(0, $object->thirdparty->id);
- $iban= $bac->iban.(($bac->iban && $bac->bic) ? ' / ' : '').$bac->bic;
- $lib_mode_reg .= ' '.$outputlangs->trans("PaymentTypePREdetails", dol_trunc($iban, 6, 'right', 'UTF-8', 1));
- }
-
- $pdf->MultiCell($posxend - $posxval, 5, $lib_mode_reg, 0, 'L');
-
- $posy = $pdf->GetY();
- }
-
- // Show if Option VAT debit option is on also if transmitter is french
- // Decret n°2099-1299 2022-10-07
- // French mention : "Option pour le paiement de la taxe d'après les débits"
- if ($this->emetteur->country_code == 'FR') {
- if (getDolGlobalInt('TAX_MODE') == 1) {
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->writeHTMLCell(80, 5, '', '', $outputlangs->transnoentities("MentionVATDebitOptionIsOn"), 0, 1);
-
- $posy = $pdf->GetY() + 1;
- }
- }
-
- // Show online payment link
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') {
- $useonlinepayment = 0;
- if (getDolGlobalString('PDF_SHOW_LINK_TO_ONLINE_PAYMENT')) {
- if (isModEnabled('paypal')) {
- $useonlinepayment++;
- }
- if (isModEnabled('stripe')) {
- $useonlinepayment++;
- }
- if (isModEnabled('paybox')) {
- $useonlinepayment++;
- }
- }
-
-
- if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
+ $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);
+ $pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
+
+ // Show online payment link
+ $useonlinepayment = ((!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled)) && !empty($conf->global->PDF_SHOW_LINK_TO_ONLINE_PAYMENT));
+ if (($object->mode_reglement_code == 'CB' || $object->mode_reglement_code == 'VAD') && $object->statut != Facture::STATUS_DRAFT && $useonlinepayment) {
@@ -1343 +1178 @@
- $langs->loadLangs(array('payment', 'paybox', 'stripe'));
+ $langs->loadLangs(array('payment', 'paybox'));
@@ -1348,4 +1183 @@
- $pdf->SetXY($this->marge_gauche, $posy);
- $pdf->writeHTMLCell($posxend - $this->marge_gauche, 5, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
-
- $posy = $pdf->GetY() + 1;
+ $pdf->writeHTMLCell(80, 10, '', '', dol_htmlentitiesbr($linktopay), 0, 1);
@@ -1352,0 +1185,2 @@
+
+ $posy = $pdf->GetY() + 2;
@@ -1356 +1190,2 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
+ {
@@ -1358,4 +1193,6 @@
- if (getDolGlobalInt('FACTURE_CHQ_NUMBER')) {
- $diffsizetitle = (!getDolGlobalString('PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
-
- 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)
+ {
@@ -1363 +1200 @@
- $account->fetch(getDolGlobalInt('FACTURE_CHQ_NUMBER'));
+ $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
@@ -1367 +1204 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
@@ -1370 +1207,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1373 +1211 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
@@ -1375 +1213 @@
- }
+ }
@@ -1377 +1215,2 @@
- if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
+ if ($conf->global->FACTURE_CHQ_NUMBER == -1)
+ {
@@ -1380 +1219 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
+ $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
@@ -1383 +1222,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CHQ_ADDRESS')) {
+ if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+ {
@@ -1386 +1226 @@
- $pdf->MultiCell($posxend - $this->marge_gauche, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
+ $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
@@ -1388 +1228 @@
- }
+ }
@@ -1394,2 +1234,3 @@
- if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') {
- if ($object->fk_account > 0 || $object->fk_bank > 0 || getDolGlobalInt('FACTURE_RIB_NUMBER')) {
+ if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR')
+ {
+ if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER)) {
@@ -1397,3 +1238 @@
- if ($object->fk_bank > 0) {
- $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
- }
+ if ($object->fk_bank > 0) $bankid = $object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank
@@ -1420 +1259 @@
- * @param TCPDF $pdf Object PDF
+ * @param TCPDI $pdf Object PDF
@@ -1425 +1263,0 @@
- * @param Translate $outputlangsbis Object lang for output bis
@@ -1428 +1266 @@
- protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis)
+ protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
@@ -1432,8 +1270,14 @@
- $sign = 1;
- if ($object->type == 2 && getDolGlobalString('INVOICE_POSITIVE_CREDIT_NOTE')) {
- $sign = -1;
- }
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
-
- $tab2_top = $posy;
+ $sign = 1;
+ if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
+
+ $outputlangsbis = null;
+ if (!empty($conf->global->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"));
+ $default_font_size--;
+ }
+
+ $tab2_top = $posy;
@@ -1441,5 +1285 @@
- if (is_object($outputlangsbis)) { // When we show 2 languages we need more room for text, so we use a smaller font.
- $pdf->SetFont('', '', $default_font_size - 2);
- } else {
- $pdf->SetFont('', '', $default_font_size - 1);
- }
+ $pdf->SetFont('', '', $default_font_size - 1);
@@ -1448,5 +1288,4 @@
- $col1x = 120;
- $col2x = 170;
- if ($this->page_largeur < 210) { // To work with US executive format
- $col1x -= 15;
- $col2x -= 10;
+ $col1x = 120; $col2x = 170;
+ if ($this->page_largeur < 210) // To work with US executive format
+ {
+ $col2x -= 20;
@@ -1469,5 +1308,4 @@
- foreach ($object->lines as $line) {
- if ($line->product_type != 9) {
- $percent += $line->situation_percent;
- $i++;
- }
+ foreach ($object->lines as $line)
+ {
+ $percent += $line->situation_percent;
+ $i++;
@@ -1477,3 +1315,4 @@
- $avancementGlobal = $percent / $i;
- } else {
- $avancementGlobal = 0;
+ $avancementGlobal = $percent / $i;
+ }
+ else {
+ $avancementGlobal = 0;
@@ -1488,2 +1327,2 @@
- $total_a_payer += $fac->total_ht;
- $total_a_payer_ttc += $fac->total_ttc;
+ $total_a_payer += $fac->total_ht;
+ $total_a_payer_ttc += $fac->total_ttc;
@@ -1495,5 +1334,6 @@
- $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
- $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
- } else {
- $total_a_payer = 0;
- $total_a_payer_ttc = 0;
+ $total_a_payer = $total_a_payer * 100 / $avancementGlobal;
+ $total_a_payer_ttc = $total_a_payer_ttc * 100 / $avancementGlobal;
+ }
+ else {
+ $total_a_payer = 0;
+ $total_a_payer_ttc = 0;
@@ -1504,90 +1344,78 @@
- $pdf->setY($tab2_top);
- $posy = $pdf->GetY();
-
- foreach ($TPreviousIncoice as &$fac) {
- if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
- $this->_pagefoot($pdf, $object, $outputlangs, 1, $this->getHeightForQRInvoice($pdf->getPage(), $object, $outputlangs));
- $pdf->addPage();
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- $pdf->setY($this->tab_top_newpage);
- } else {
- $pdf->setY($this->marge_haute);
- }
- $posy = $pdf->GetY();
- }
-
- // Cumulate preceding VAT
- $index++;
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
-
- $facSign = '';
- if ($i > 1) {
- $facSign = $fac->total_ht >= 0 ? '+' : '';
- }
-
- $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
-
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
-
- $i++;
- $posy += $tab2_hl;
-
- $pdf->setY($posy);
- }
-
- // Display current total
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
- $facSign = '';
- if ($i > 1) {
- $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
- }
-
- if ($fac->type === Facture::TYPE_CREDIT_NOTE) {
- $facSign = '-'; // les avoirs
- }
-
-
- $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
- $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
-
- $posy += $tab2_hl;
-
- // Display all total
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $posy);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
-
- $pdf->SetXY($col2x, $posy);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
- $pdf->SetFont('', '', $default_font_size - 2);
-
- $posy += $tab2_hl;
-
- if ($posy > $this->page_hauteur - 4 - $this->heightforfooter) {
- $pdf->addPage();
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs, $outputlangsbis);
- $pdf->setY($this->tab_top_newpage);
- } else {
- $pdf->setY($this->marge_haute);
- }
-
- $posy = $pdf->GetY();
- }
-
- $tab2_top = $posy;
- $index = 0;
-
- $tab2_top += 3;
- }
-
+ $pdf->setY($tab2_top);
+ $posy = $pdf->GetY();
+
+ foreach ($TPreviousIncoice as &$fac) {
+ if ($posy > $this->page_hauteur - 4) {
+ $this->_pagefoot($pdf, $object, $outputlangs, 1);
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ // cumul TVA précédent
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $fac->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $fac->total_ht >= 0 ? '+' : '';
+ }
+
+ $displayAmount = ' '.$facSign.' '.price($fac->total_ht, 0, $outputlangs);
+
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $i++;
+ $posy += $tab2_hl;
+
+ $pdf->setY($posy);
+ }
+
+ // Display current total
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("PDFSituationTitle", $object->situation_counter).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $facSign = '';
+ if ($i > 1) {
+ $facSign = $object->total_ht >= 0 ? '+' : ''; // management of a particular customer case
+ }
+
+ if ($fac->type === facture::TYPE_CREDIT_NOTE) {
+ $facSign = '-'; // les avoirs
+ }
+
+
+ $displayAmount = ' '.$facSign.' '.price($object->total_ht, 0, $outputlangs);
+ $pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
+
+ $posy += $tab2_hl;
+
+ // Display all total
+ $pdf->SetFont('', '', $default_font_size - 1);
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $posy);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("SituationTotalProgress", $avancementGlobal), 0, 'L', 1);
+
+ $pdf->SetXY($col2x, $posy);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer * $avancementGlobal / 100, 0, $outputlangs), 0, 'R', 1);
+ $pdf->SetFont('', '', $default_font_size - 2);
+
+ $posy += $tab2_hl;
+
+ if ($posy > $this->page_hauteur - 4) {
+ $pdf->addPage();
+ $pdf->setY($this->marge_haute);
+ $posy = $pdf->GetY();
+ }
+
+ $tab2_top = $posy;
+ $index = 0;
+ }
+
+ $tab2_top += 3;
@@ -1596 +1424 @@
- $total_ht = (isModEnabled("multicurrency") && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
+ $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
@@ -1601,6 +1429,3 @@
- $resdiscount = pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2);
- $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
- // Gestion remise sous forme de ligne négative
- if ($line->total_ht < 0) {
- $total_line_remise += -$line->total_ht;
- }
+ $total_line_remise += pdfGetLineTotalDiscountAmount($object, $i, $outputlangs, 2); // TODO: add this methode to core/lib/pdf.lib
+ // Gestion remise sous forme de ligne négative
+ if ($line->total_ht < 0) $total_line_remise += -$line->total_ht;
@@ -1609,19 +1434,19 @@
- if (getDolGlobalString('MAIN_SHOW_AMOUNT_DISCOUNT')) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
-
- $index++;
- }
- // Show total NET before discount
- if (getDolGlobalString('MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT')) {
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top);
- $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
-
- $index++;
- }
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
+ // Show total NET before discount
+ if (!empty($conf->global->MAIN_SHOW_AMOUNT_BEFORE_DISCOUNT)) {
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + 0);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHTBeforeDiscount").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHTBeforeDiscount") : ''), 0, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + 0);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($total_line_remise + $total_ht, 0, $outputlangs), 0, 'R', 1);
+
+ $index++;
+ }
@@ -1633,3 +1458,3 @@
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities(!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ? "TotalHT" : "Total") : ''), 0, 'L', 1);
-
- $total_ht = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("TotalHT") : ''), 0, 'L', 1);
+
+ $total_ht = (($conf->multicurrency->enabled && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
@@ -1642 +1467 @@
- $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;
@@ -1645 +1470,2 @@
- if (!getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) {
+ if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+ {
@@ -1647 +1473,2 @@
- if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
+ if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
+ {
@@ -1649 +1476,5 @@
- } else {
+ }
+ else
+ {
+ // FIXME amount of vat not supported with multicurrency
+
@@ -1651 +1482 @@
- //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')
@@ -1653,7 +1484,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
+ {
@@ -1666 +1498,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1676,2 +1508,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1679 +1510 @@
- $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);
@@ -1683 +1514 @@
- //}
+ //}
@@ -1685 +1516 @@
- //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')
@@ -1687,7 +1518,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
+ {
@@ -1700 +1532,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1709,2 +1541,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1712 +1543 @@
- $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);
@@ -1716,4 +1547,5 @@
- //}
-
- // Situations totals migth be wrong on huge amounts with old mode 1
- if (getDolGlobalInt('INVOICE_USE_SITUATION') == 1 && $object->situation_cycle_ref && $object->situation_counter > 1) {
+ //}
+
+ // VAT
+ // Situations totals migth be wrong on huge amounts
+ if ($object->situation_cycle_ref && $object->situation_counter > 1) {
@@ -1726 +1558,2 @@
- if (!empty($sum_pdf_tva)) {
+ if (!empty($sum_pdf_tva))
+ {
@@ -1728,3 +1561,4 @@
- } else {
- $coef_fix_tva = 1;
- }
+ }
+ else {
+ $coef_fix_tva = 1;
+ }
@@ -1736,3 +1569,0 @@
- foreach ($this->tva_array as $tvakey => $tvaval) {
- $this->tva_array[$tvakey]['amount'] = $tvaval['amount'] * $coef_fix_tva;
- }
@@ -1742,3 +1573,4 @@
- // VAT
- 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
+ {
@@ -1751 +1583,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1757,7 +1590 @@
- 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 .= vatrate($tvakey, 1).$tvacompl;
@@ -1767 +1594 @@
- $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);
@@ -1772 +1599 @@
- //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')
@@ -1774,7 +1601,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
+ {
@@ -1787 +1615,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1796,3 +1624,0 @@
-
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1800 +1626 @@
- $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);
@@ -1804 +1630 @@
- //}
+ //}
@@ -1806 +1632 @@
- //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')
@@ -1808,8 +1634,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
+ {
@@ -1822 +1649,2 @@
- if (preg_match('/\*/', $tvakey)) {
+ if (preg_match('/\*/', $tvakey))
+ {
@@ -1832,2 +1659,0 @@
- $total_localtax = ((isModEnabled("multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? price2num($tvaval * $object->multicurrency_tx, 'MT') : $tvaval);
-
@@ -1835 +1661 @@
- $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);
@@ -1842 +1668,2 @@
- if (price2num($object->revenuestamp) != 0) {
+ if (price2num($object->revenuestamp) != 0)
+ {
@@ -1861,0 +1689,2 @@
+
+
@@ -1863 +1692,2 @@
- if ($object->displayRetainedWarranty()) {
+ if ($object->displayRetainedWarranty())
+ {
@@ -1894,2 +1724,2 @@
- $creditnoteamount = $object->getSumCreditNotesUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
- $depositsamount = $object->getSumDepositsUsed((isModEnabled("multicurrency") && $object->multicurrency_tx != 1) ? 1 : 0);
+ $creditnoteamount = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0); // Warning, this also include excess received
+ $depositsamount = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
@@ -1898,5 +1728,4 @@
- if (!empty($object->paye)) {
- $resteapayer = 0;
- }
-
- if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !getDolGlobalString('INVOICE_NO_PAYMENT_DETAILS')) {
+ if (!empty($object->paye)) $resteapayer = 0;
+
+ if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
+ {
@@ -1911 +1740,2 @@
- if ($creditnoteamount) {
+ if ($creditnoteamount)
+ {
@@ -1913 +1743 @@
- $labeltouse .= (is_object($outputlangsbis) ? (' / '.($outputlangsbis->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities("CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities("CreditNotes")) : '');
+ $labeltouse .= (is_object($outputlangsbis) ? ' / '.($outputlangsbis->transnoentities("CreditNotesOrExcessReceived") != "CreditNotesOrExcessReceived") ? $outputlangsbis->transnoentities("CreditNotesOrExcessReceived") : $outputlangsbis->transnoentities("CreditNotes") : '');
@@ -1921,14 +1751,13 @@
- /*
- if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
- {
- $index++;
- $pdf->SetFillColor(255, 255, 255);
-
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("EscompteOfferedShort") : ''), $useborder, 'L', 1);
- $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
-
- $resteapayer = 0;
- }
- */
+ // Escompte
+ if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT)
+ {
+ $index++;
+ $pdf->SetFillColor(255, 255, 255);
+
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOfferedShort").(is_object($outputlangsbis) ? ' / '.$outputlangsbis->transnoentities("EscompteOfferedShort") : ''), $useborder, 'L', 1);
+ $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder, 'R', 1);
+
+ $resteapayer = 0;
+ }
@@ -1970 +1799 @@
- * @param TCPDF $pdf Object PDF
+ * @param tcpdf $pdf Object PDF
@@ -1987,3 +1816 @@
- if ($hidetop) {
- $hidetop = -1;
- }
+ if ($hidetop) $hidetop = -1;
@@ -1998,8 +1825,2 @@
- if (empty($hidetop)) {
- // Show category of operations
- if (getDolGlobalInt('INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
- $categoryOfOperations = $outputlangs->transnoentities("MentionCategoryOfOperations") . ' : ' . $outputlangs->transnoentities("MentionCategoryOfOperations" . $this->categoryOfOperation);
- $pdf->SetXY($this->marge_gauche, $tab_top - 4);
- $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
- }
-
+ if (empty($hidetop))
+ {
@@ -2007 +1828 @@
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
@@ -2015,2 +1836,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));
@@ -2030 +1851 @@
- $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
@@ -2036 +1857 @@
- * Show top header of page. This include the logo, ref and address blocs
+ * Show top header of page.
@@ -2038,3 +1859,3 @@
- * @param TCPDF $pdf Object PDF
- * @param Facture $object Object to show
- * @param int $showaddress 0=no, 1=yes (usually set to 1 for first page, and 0 for next pages)
+ * @param Tcpdf $pdf Object PDF
+ * @param Object $object Object to show
+ * @param int $showaddress 0=no, 1=yes
@@ -2043 +1864 @@
- * @return array top shift of linked object lines
+ * @return void
@@ -2047 +1867,0 @@
- // phpcs:enable
@@ -2049,5 +1868,0 @@
-
- $ltrdirection = 'L';
- if ($outputlangs->trans("DIRECTION") == 'rtl') {
- $ltrdirection = 'R';
- }
@@ -2061,0 +1877,6 @@
+ // Show Draft Watermark
+ if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+ }
+
@@ -2068 +1889 @@
- $posx = $this->page_largeur - $this->marge_droite - $w;
+ $posx = $this->page_largeur - $this->marge_droite - $w;
@@ -2073,2 +1894,4 @@
- if (!getDolGlobalInt('PDF_DISABLE_MYCOMPANY_LOGO')) {
- if ($this->emetteur->logo) {
+ if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
+ {
+ if ($this->emetteur->logo)
+ {
@@ -2076,2 +1899,4 @@
- if (!empty($conf->mycompany->multidir_output[$object->entity])) {
- $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
+ if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
+ {
+ $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
@@ -2079,3 +1904 @@
- if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) {
- $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small;
- } else {
+ else {
@@ -2084,2 +1907,3 @@
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
@@ -2087 +1911,3 @@
- } else {
+ }
+ else
+ {
@@ -2093 +1919,3 @@
- } else {
+ }
+ else
+ {
@@ -2095 +1923 @@
- $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
+ $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -2103,17 +1931,6 @@
- if ($object->type == 1) {
- $title = $outputlangs->transnoentities("InvoiceReplacement");
- }
- if ($object->type == 2) {
- $title = $outputlangs->transnoentities("InvoiceAvoir");
- }
- if ($object->type == 3) {
- $title = $outputlangs->transnoentities("InvoiceDeposit");
- }
- if ($object->type == 4) {
- $title = $outputlangs->transnoentities("InvoiceProForma");
- }
- if ($this->situationinvoice) {
- $langs->loadLangs(array("other"));
- $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " " . $outputlangs->transnoentities("NumberingShort") . $object->situation_counter . " -";
- }
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
+ if ($object->type == 1) $title = $outputlangs->transnoentities("InvoiceReplacement");
+ if ($object->type == 2) $title = $outputlangs->transnoentities("InvoiceAvoir");
+ if ($object->type == 3) $title = $outputlangs->transnoentities("InvoiceDeposit");
+ if ($object->type == 4) $title = $outputlangs->transnoentities("InvoiceProForma");
+ if ($this->situationinvoice) $title = $outputlangs->transnoentities("InvoiceSituation");
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
@@ -2122,3 +1939 @@
- if ($this->situationinvoice) {
- $title .= $outputlangsbis->transnoentities("PDFInvoiceSituation");
- }
+ if ($this->situationinvoice) $title .= $outputlangsbis->transnoentities("InvoiceSituation");
@@ -2126,8 +1940,0 @@
- } elseif ($object->type == 1) {
- $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
- } elseif ($object->type == 2) {
- $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
- } elseif ($object->type == 3) {
- $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
- } elseif ($object->type == 4) {
- $title .= $outputlangsbis->transnoentities("InvoiceProForma");
@@ -2135,3 +1942,15 @@
- }
- $title .= ' '.$outputlangs->convToOutputCharset($object->ref);
- if ($object->statut == $object::STATUS_DRAFT) {
+ elseif ($object->type == 1) $title .= $outputlangsbis->transnoentities("InvoiceReplacement");
+ elseif ($object->type == 2) $title .= $outputlangsbis->transnoentities("InvoiceAvoir");
+ elseif ($object->type == 3) $title .= $outputlangsbis->transnoentities("InvoiceDeposit");
+ elseif ($object->type == 4) $title .= $outputlangsbis->transnoentities("InvoiceProForma");
+ }
+ $pdf->MultiCell($w, 3, $title, '', 'R');
+
+ $pdf->SetFont('', 'B', $default_font_size);
+
+ $posy += 5;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $textref = $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref);
+ if ($object->statut == Facture::STATUS_DRAFT)
+ {
@@ -2139,19 +1958,5 @@
- $title .= ' - '.$outputlangs->transnoentities("NotValidated");
- }
-
- $pdf->MultiCell($w, 3, $title, '', 'R');
-
- $pdf->SetFont('', 'B', $default_font_size);
-
- /*
- $posy += 5;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $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;
+ $textref .= ' - '.$outputlangs->transnoentities("NotValidated");
+ }
+ $pdf->MultiCell($w, 4, $textref, '', 'R');
+
+ $posy += 1;
@@ -2160 +1965,2 @@
- if ($object->ref_customer) {
+ if ($object->ref_client)
+ {
@@ -2164,4 +1970,5 @@
- $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".dol_trunc($outputlangs->convToOutputCharset($object->ref_customer), 65), '', 'R');
- }
-
- if (getDolGlobalString('PDF_SHOW_PROJECT_TITLE')) {
+ $pdf->MultiCell($w, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
+ }
+
+ if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
+ {
@@ -2169 +1976,2 @@
- if (!empty($object->project->ref)) {
+ if (!empty($object->project->ref))
+ {
@@ -2173 +1981 @@
- $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');
@@ -2177 +1985,2 @@
- if (getDolGlobalString('PDF_SHOW_PROJECT')) {
+ if (!empty($conf->global->PDF_SHOW_PROJECT))
+ {
@@ -2179,2 +1988,2 @@
- if (!empty($object->project->ref)) {
- $outputlangs->load("projects");
+ if (!empty($object->project->ref))
+ {
@@ -2184 +1993 @@
- $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');
@@ -2189 +1998,2 @@
- if ($object->type == 0 && $objectidnext) {
+ if ($object->type == 0 && $objectidnext)
+ {
@@ -2198 +2008,2 @@
- if ($object->type == 1) {
+ if ($object->type == 1)
+ {
@@ -2207 +2018,2 @@
- if ($object->type == 2 && !empty($object->fk_facture_source)) {
+ if ($object->type == 2 && !empty($object->fk_facture_source))
+ {
@@ -2222 +2034 @@
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
@@ -2225,3 +2037,4 @@
- $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs, true), '', 'R');
-
- if (getDolGlobalString('INVOICE_POINTOFTAX_DATE')) {
+ $pdf->MultiCell($w, 3, $title." : ".dol_print_date($object->date, "day", false, $outputlangs), '', 'R');
+
+ if (!empty($conf->global->INVOICE_POINTOFTAX_DATE))
+ {
@@ -2234 +2047,2 @@
- if ($object->type != 2) {
+ if ($object->type != 2)
+ {
@@ -2239 +2053 @@
- if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
+ if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
@@ -2245 +2059,2 @@
- if (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && $object->thirdparty->code_client) {
+ if ($object->thirdparty->code_client)
+ {
@@ -2253,10 +2068,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($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+ }
@@ -2268 +2084,0 @@
- $shipp_shift = 0;
@@ -2272 +2088,2 @@
- if ($current_y < $pdf->getY()) {
+ if ($current_y < $pdf->getY())
+ {
@@ -2276 +2093,2 @@
- if ($showaddress) {
+ if ($showaddress)
+ {
@@ -2278,11 +2096 @@
- $carac_emetteur = '';
- // Add internal contact of object if defined
- $arrayidcontact = $object->getIdContact('internal', 'BILLING');
- 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 .= "\n";
- }
-
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+ $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
@@ -2291 +2099 @@
- $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
@@ -2294,6 +2102,5 @@
- 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;
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
+
+ $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
+
@@ -2302,10 +2109,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($widthrecbox, $hautcadre, "", 0, 'R', 1);
+ $pdf->SetTextColor(0, 0, 60);
@@ -2314,6 +2119,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($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
+ $posy = $pdf->getY();
@@ -2324 +2127 @@
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, 'L');
@@ -2329 +2132,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -2334,2 +2138,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)) {
@@ -2343,2 +2148 @@
- $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);
@@ -2347,5 +2151,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;
+ $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
+ if ($this->page_largeur < 210) $widthrecbox = 84; // To work with US executive format
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
@@ -2354,3 +2156 @@
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->marge_gauche;
- }
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -2359,7 +2159,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 - 2, 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);
@@ -2370 +2168 @@
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
+ $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, 'L');
@@ -2377,39 +2175 @@
- $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
-
- // Show shipping address
- if (getDolGlobalInt('INVOICE_SHOW_SHIPPING_ADDRESS')) {
- $idaddressshipping = $object->getIdContact('external', 'SHIPPING');
-
- if (!empty($idaddressshipping)) {
- $contactshipping = $object->fetch_Contact($idaddressshipping[0]);
- $companystatic = new Societe($this->db);
- $companystatic->fetch($object->contact->fk_soc);
- $carac_client_name_shipping=pdfBuildThirdpartyName($object->contact, $outputlangs);
- $carac_client_shipping = pdf_build_address($outputlangs, $this->emetteur, $companystatic, $object->contact, $usecontact, 'target', $object);
- } else {
- $carac_client_name_shipping=pdfBuildThirdpartyName($object->thirdparty, $outputlangs);
- $carac_client_shipping=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'target', $object);
- }
- if (!empty($carac_client_shipping)) {
- $posy += $hautcadre;
-
- // Show shipping frame
- $pdf->SetXY($posx + 2, $posy - 5);
- $pdf->SetFont('', '', $default_font_size - 2);
- $pdf->MultiCell($widthrecbox, '', $outputlangs->transnoentities('ShippingTo'), 0, 'L', 0);
- $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
-
- // Show shipping name
- $pdf->SetXY($posx + 2, $posy + 3);
- $pdf->SetFont('', 'B', $default_font_size);
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping, '', 'L');
-
- $posy = $pdf->getY();
-
- // Show shipping information
- $pdf->SetXY($posx+2, $posy);
- $pdf->SetFont('', '', $default_font_size - 1);
- $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping, '', 'L');
- $shipp_shift += $hautcadre;
- }
- }
+ $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
@@ -2419,3 +2179 @@
-
- $pagehead = array('top_shift' => $top_shift, 'shipp_shift' => $shipp_shift);
- return $pagehead;
+ return $top_shift;
@@ -2427,3 +2185,3 @@
- *
- * @param TCPDF $pdf PDF
- * @param Facture $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
@@ -2432 +2189,0 @@
- * @param int $heightforqrinvoice Height for QR invoices
@@ -2435 +2192 @@
- protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0, $heightforqrinvoice = 0)
+ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
@@ -2437,2 +2194,3 @@
- $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
- return pdf_pagefoot($pdf, $outputlangs, 'INVOICE_FREE_TEXT', $this->emetteur, $heightforqrinvoice + $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, 'INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
@@ -2444,215 +2202,201 @@
- * @param Facture $object common object
- * @param Translate $outputlangs langs
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return void
- */
- 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_INVOICES_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 (!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['progress'] = array(
- 'rank' => $rank,
- 'width' => 19, // in mm
- 'status' => false,
- 'title' => array(
- 'textkey' => 'ProgressShort'
- ),
- 'border-left' => true, // add left line separator
- );
-
- if ($this->situationinvoice) {
- $this->cols['progress']['status'] = true;
- }
-
- $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;
- }
+ * @param object $object common object
+ * @param Translate $outputlangs langs
+ * @param int $hidedetails Do not show line details
+ * @param int $hidedesc Do not show desc
+ * @param int $hideref Do not show ref
+ * @return null
+ */
+ 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
+ ),
+ );
+
+ // PHOTO
+ $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_INVOICES_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['progress'] = array(
+ 'rank' => $rank,
+ 'width' => 19, // in mm
+ 'status' => false,
+ 'title' => array(
+ 'textkey' => 'Progress'
+ ),
+ 'border-left' => true, // add left line separator
+ );
+
+ if ($this->situationinvoice)
+ {
+ $this->cols['progress']['status'] = true;
+ }
+
+ $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;
+ }