--- /tmp/dsg/dolibarr/htdocs/core/modules/reception/doc/github_19.0.3_doc_generic_reception_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/reception/doc/client_doc_generic_reception_odt.modules.php
@@ -39,3 +39,14 @@
- /**
- * @var string Dolibarr version of the loaded document
- */
+ /**
+ * @var Societe Issuer object that emits
+ */
+ public $emetteur; // Objet societe qui emet
+
+ /**
+ * @var array Minimum version of PHP required by module.
+ * e.g.: PHP ≥ 5.5 = array(5, 5)
+ */
+ public $phpmin = array(5, 5);
+
+ /**
+ * @var string Dolibarr version of the loaded document
+ */
@@ -50,2 +61,2 @@
- public function __construct($db)
- {
+ public function __construct($db)
+ {
@@ -54 +65,2 @@
- $langs->loadLangs(array("main", "companies"));
+ $langs->load("main");
+ $langs->load("companies");
@@ -71,6 +83,7 @@
- $this->option_logo = 1; // Display logo
- $this->option_tva = 0; // Manage the vat option RECEPTION_TVAOPTION
- $this->option_modereg = 0; // Display payment mode
- $this->option_condreg = 0; // Display payment terms
- $this->option_multilang = 1; // Available in several languages
- $this->option_escompte = 0; // Displays if there has been a discount
+ $this->option_logo = 1; // Affiche logo
+ $this->option_tva = 0; // Gere option tva RECEPTION_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
@@ -81 +94 @@
- // Get source company
+ // Recupere emetteur
@@ -83,15 +96,13 @@
- if (!$this->emetteur->country_code) {
- $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
- }
- }
-
-
- /**
- * Return description of a module
- *
- * @param Translate $langs Lang object to use for output
- * @return string Description
- */
- public function info($langs)
- {
- global $conf, $langs;
+ if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
+ }
+
+
+ /**
+ * Return description of a module
+ *
+ * @param Translate $langs Lang object to use for output
+ * @return string Description
+ */
+ public function info($langs)
+ {
+ global $conf, $langs;
@@ -107 +117,0 @@
- $texte .= '';
@@ -110 +120 @@
- $texte .= '
';
+ $texte .= '';
@@ -117 +127,2 @@
- foreach ($listofdir as $key => $tmpdir) {
+ foreach ($listofdir as $key=>$tmpdir)
+ {
@@ -121,2 +132 @@
- unset($listofdir[$key]);
- continue;
+ unset($listofdir[$key]); continue;
@@ -124,3 +134,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
+ {
@@ -128,3 +138 @@
- if (count($tmpfiles)) {
- $listoffiles = array_merge($listoffiles, $tmpfiles);
- }
+ if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
@@ -134 +141,0 @@
- $texthelp .= '
'.$langs->trans("ExampleOfDirectoriesForModelGen").'';
@@ -139 +146 @@
- $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name);
+ $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1);
@@ -142 +149 @@
- $texte .= getDolGlobalString('RECEPTION_ADDON_PDF_ODT_PATH');
+ $texte .= $conf->global->RECEPTION_ADDON_PDF_ODT_PATH;
@@ -145 +152 @@
- $texte .= '';
+ $texte .= '';
@@ -150 +157,2 @@
- if (getDolGlobalString('RECEPTION_ADDON_PDF_ODT_PATH')) {
+ if (!empty($conf->global->RECEPTION_ADDON_PDF_ODT_PATH))
+ {
@@ -157,9 +165,8 @@
- if ($nbofiles) {
- $texte .= '';
+ if ($nbofiles)
+ {
+ $texte .= '';
+ foreach ($listoffiles as $file)
+ {
+ $texte .= $file['name'].'
';
+ }
+ $texte .= '
';
@@ -167,11 +173,0 @@
- // 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 .= '
';
@@ -180,0 +177,3 @@
+ $texte .= '';
+ $texte .= $langs->trans("ExampleOfDirectoriesForModelGen");
+ $texte .= ' | ';
@@ -187 +186 @@
- }
+ }
@@ -201,2 +200,2 @@
- 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)
+ {
@@ -206 +205,2 @@
- if (empty($srctemplatepath)) {
+ if (empty($srctemplatepath))
+ {
@@ -212 +212,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -219,3 +220 @@
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -225,3 +224,7 @@
- $outputlangs->loadLangs(array("main", "dict", "companies", "bills"));
-
- if ($conf->reception->dir_output) {
+ $outputlangs->load("main");
+ $outputlangs->load("dict");
+ $outputlangs->load("companies");
+ $outputlangs->load("bills");
+
+ if ($conf->reception->dir_output."/reception")
+ {
@@ -229 +232,2 @@
- if (!is_object($object)) {
+ if (!is_object($object))
+ {
@@ -233 +237,2 @@
- if ($result < 0) {
+ if ($result < 0)
+ {
@@ -239,3 +244 @@
- $object->fetch_thirdparty();
-
- $dir = !empty($conf->reception->multidir_output[$object->entity]) ? $conf->reception->multidir_output[$object->entity] : $conf->reception->dir_output;
+ $dir = $conf->reception->dir_output."/reception";
@@ -243,3 +246 @@
- if (!preg_match('/specimen/i', $objectref)) {
- $dir .= "/".$objectref;
- }
+ if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref;
@@ -248,2 +249,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -255 +258,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -258 +262 @@
- $newfiletmp = preg_replace('/\.od[ts]/i', '', $newfile);
+ $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile);
@@ -261 +265 @@
- $newfiletmp = $objectref . '_' . $newfiletmp;
+ $newfiletmp = $objectref.'_'.$newfiletmp;
@@ -265,10 +269,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;
@@ -281,7 +286,3 @@
- if (!is_writable($conf->reception->dir_temp)) {
- $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->reception->dir_temp);
- dol_syslog('Error in write_file: ' . $this->error, LOG_ERR);
- return -1;
- }
-
- // If CUSTOMER contact defined on reception, we use it
+
+
+ // If BILLING contact defined on invoice, we use it
@@ -289,2 +290,3 @@
- $arrayidcontact = $object->getIdContact('external', 'CUSTOMER');
- if (count($arrayidcontact) > 0) {
+ $arrayidcontact = $object->getIdContact('external', 'BILLING');
+ if (count($arrayidcontact) > 0)
+ {
@@ -296,13 +298,8 @@
- $contactobject = null;
- if (!empty($usecontact)) {
- // We can use the company of contact instead of thirdparty company
- if ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT'))) {
- $object->contact->fetch_thirdparty();
- $socobject = $object->contact->thirdparty;
- $contactobject = $object->contact;
- } else {
- $socobject = $object->thirdparty;
- // if we have a CUSTOMER contact and we dont use it as thirdparty recipient we store the contact object for later use
- $contactobject = $object->contact;
- }
- } else {
+ if (!empty($usecontact))
+ {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact;
+ else $socobject = $object->thirdparty;
+ }
+ else
+ {
@@ -321 +317,0 @@
-
@@ -329,2 +325,3 @@
- if (!empty($conf->global->$paramfreetext)) {
- $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray);
+ if (!empty($conf->global->$paramfreetext))
+ {
+ $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
@@ -336 +333 @@
- $odfHandler = new Odf(
+ $odfHandler = new odf(
@@ -345 +342,3 @@
- } catch (Exception $e) {
+ }
+ catch (Exception $e)
+ {
@@ -347 +345,0 @@
- dol_syslog($e->getMessage(), LOG_INFO);
@@ -362,17 +360,62 @@
- }
-
- // Define substitution array
- $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
- $array_object_from_properties = $this->get_substitutionarray_each_var_object($object, $outputlangs);
- $array_objet = $this->get_substitutionarray_object($object, $outputlangs);
- $array_user = $this->get_substitutionarray_user($user, $outputlangs);
- $array_soc = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
- $array_thirdparty = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
- $array_other = $this->get_substitutionarray_other($outputlangs);
- // retrieve contact information for use in object as contact_xxx tags
- $array_thirdparty_contact = array();
- if ($usecontact && is_object($contactobject)) {
- $array_thirdparty_contact = $this->get_substitutionarray_contact($contactobject, $outputlangs, 'contact');
- }
-
- $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other, $array_thirdparty_contact);
+ }
+
+ // Make substitutions into odt of user info
+ $tmparray = $this->get_substitutionarray_user($user, $outputlangs);
+ //var_dump($tmparray); exit;
+ foreach ($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/', $key)) // Image
+ {
+ //var_dump($value);exit;
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ } catch (OdfException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ }
+ // Make substitutions into odt of mysoc
+ $tmparray = $this->get_substitutionarray_mysoc($mysoc, $outputlangs);
+ //var_dump($tmparray); exit;
+ foreach ($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/', $key)) // Image
+ {
+ //var_dump($value);exit;
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ } catch (OdfException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ }
+ // Make substitutions into odt of thirdparty
+ $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
+ foreach ($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/', $key)) // Image
+ {
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ } catch (OdfException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ }
+ // Replace tags of object + external modules
+ $tmparray = $this->get_substitutionarray_reception($object, $outputlangs);
@@ -380 +422,0 @@
-
@@ -384,7 +426,35 @@
- foreach ($tmparray as $key => $value) {
- try {
- if (preg_match('/logo$/', $key)) { // Image
- if (file_exists($value)) {
- $odfHandler->setImage($key, $value);
- } else {
- $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ foreach ($tmparray as $key=>$value)
+ {
+ try {
+ if (preg_match('/logo$/', $key)) // Image
+ {
+ if (file_exists($value)) $odfHandler->setImage($key, $value);
+ else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
+ }
+ else // Text
+ {
+ $odfHandler->setVars($key, $value, true, 'UTF-8');
+ }
+ } catch (OdfException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ }
+ // Replace tags of lines
+ try
+ {
+ $listlines = $odfHandler->setSegment('lines');
+ foreach ($object->lines as $line)
+ {
+ $tmparray = $this->get_substitutionarray_reception_lines($line, $outputlangs);
+ complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
+ // Call the ODTSubstitutionLine hook
+ $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
+ $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ foreach ($tmparray as $key => $val)
+ {
+ try {
+ $listlines->setVars($key, $val, true, 'UTF-8');
+ } catch (OdfException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
+ } catch (SegmentException $e) {
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -392,43 +462,7 @@
- } else { // Text
- $odfHandler->setVars($key, $value, true, 'UTF-8');
- }
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
- }
- }
- // Replace tags of lines
- try {
- $foundtagforlines = 1;
- try {
- $listlines = $odfHandler->setSegment('lines');
- } catch (OdfExceptionSegmentNotFound $e) {
- // We may arrive here if tags for lines not present into template
- $foundtagforlines = 0;
- dol_syslog($e->getMessage(), LOG_INFO);
- } catch (OdfException $e) {
- $foundtagforlines = 0;
- dol_syslog($e->getMessage(), LOG_INFO);
- }
- if ($foundtagforlines) {
- $linenumber = 0;
- foreach ($object->lines as $line) {
- $linenumber++;
- $tmparray = $this->get_substitutionarray_lines($line, $outputlangs);
- complete_substitutions_array($tmparray, $outputlangs, $object, $line, "completesubstitutionarray_lines");
- // Call the ODTSubstitutionLine hook
- $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray, 'line'=>$line);
- $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- foreach ($tmparray as $key => $val) {
- try {
- $listlines->setVars($key, $val, true, 'UTF-8');
- } catch (OdfException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
- } catch (SegmentException $e) {
- dol_syslog($e->getMessage(), LOG_INFO);
- }
- }
- $listlines->merge();
- }
- $odfHandler->mergeSegment($listlines);
- }
- } catch (OdfException $e) {
+ }
+ $listlines->merge();
+ }
+ $odfHandler->mergeSegment($listlines);
+ }
+ catch (OdfException $e)
+ {
@@ -442 +476,2 @@
- foreach ($tmparray as $key => $value) {
+ foreach ($tmparray as $key=>$value)
+ {
@@ -446 +481 @@
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
@@ -455 +490 @@
- if (getDolGlobalString('MAIN_ODT_AS_PDF')) {
+ if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
@@ -460 +494,0 @@
- dol_syslog($e->getMessage(), LOG_INFO);
@@ -463,3 +497,4 @@
- } else {
- try {
- $odfHandler->saveToDisk($file);
+ }
+ else {
+ try {
+ $odfHandler->saveToDisk($file);
@@ -468 +502,0 @@
- dol_syslog($e->getMessage(), LOG_INFO);
@@ -475 +509,2 @@
- dolChmod($file);
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -479,2 +513,0 @@
- $this->result = array('fullpath'=>$file);
-
@@ -482 +515,3 @@
- } else {
+ }
+ else
+ {
--- /tmp/dsg/dolibarr/htdocs/core/modules/reception/doc/github_19.0.3_pdf_squille.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/reception/doc/client_pdf_squille.modules.php
@@ -2,2 +2 @@
-/* Copyright (C) 2018 Quentin Vial-Gouteyron
- * Copyright (C) 2023 Frédéric France
+/* Copyright (C) 2018 Quentin Vial-Gouteyron
@@ -36,24 +35 @@
- /**
- * @var string Dolibarr version of the loaded document
- */
- public $version = 'dolibarr';
-
- /**
- * @var int posx weight vol
- */
- public $posxweightvol;
-
- /**
- * @var int posx qty ordered
- */
- public $posxqtyordered;
-
- /**
- * @var int posx qty to ship
- */
- public $posxqtytoship;
-
- /**
- * @var int posx totalht
- */
- public $posxtotalht;
+ public $emetteur; // Objet societe qui emet
@@ -67 +43 @@
- public function __construct(DoliDB $db)
+ public function __construct($db = 0)
@@ -80,8 +56,6 @@
- $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->option_logo = 1; // Display logo
- $this->option_draft_watermark = 1; // Support add of a watermark on drafts
- $this->watermark = '';
+ $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;
+
+ $this->option_logo = 1;
@@ -91,3 +65 @@
- if (!$this->emetteur->country_code) {
- $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
- }
+ if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
@@ -102 +74 @@
- if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
+ if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
@@ -110,13 +82,15 @@
- $this->posxpicture = $this->posxweightvol - (!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->posxweightvol -= 20;
- $this->posxpicture -= 20;
- $this->posxqtyordered -= 20;
- $this->posxqtytoship -= 20;
- }
-
- if (getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
- $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
- $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
- $this->posxqtyordered = $this->posxqtytoship;
+ $this->posxpicture = $this->posxweightvol - (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->posxweightvol -= 20;
+ $this->posxpicture -= 20;
+ $this->posxqtyordered -= 20;
+ $this->posxqtytoship -= 20;
+ }
+
+ if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
+ {
+ $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
+ $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
+ $this->posxqtyordered = $this->posxqtytoship;
@@ -130 +104 @@
- * @param Reception $object Object reception to generate (or id if old method)
+ * @param Object $object Object reception to generate (or id if old method)
@@ -132,5 +106,5 @@
- * @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
+ * @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
@@ -145,3 +119 @@
- if (!is_object($outputlangs)) {
- $outputlangs = $langs;
- }
+ if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -149,3 +121 @@
- if (getDolGlobalString('MAIN_USE_FPDF')) {
- $outputlangs->charset_output = 'ISO-8859-1';
- }
+ if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
@@ -155,5 +124,0 @@
- // Show Draft Watermark
- if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('RECEPTION_DRAFT_WATERMARK'))) {
- $this->watermark = $conf->global->RECEPTION_DRAFT_WATERMARK;
- }
-
@@ -162,9 +127,9 @@
- // Loop on each lines to detect if there is at least one image to show
- $realpatharray = array();
- if (getDolGlobalString('MAIN_GENERATE_SHIPMENT_WITH_PICTURE')) {
- $objphoto = new Product($this->db);
-
- for ($i = 0; $i < $nblines; $i++) {
- if (empty($object->lines[$i]->fk_product)) {
- continue;
- }
+ // Loop on each lines to detect if there is at least one image to show
+ $realpatharray = array();
+ if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
+ {
+ $objphoto = new Product($this->db);
+
+ for ($i = 0; $i < $nblines; $i++)
+ {
+ if (empty($object->lines[$i]->fk_product)) continue;
@@ -175,7 +140,2 @@
- if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) {
- $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
- $dir = $conf->product->dir_output.'/'.$pdir;
- } else {
- $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product');
- $dir = $conf->product->dir_output.'/'.$pdir;
- }
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
+ $dir = $conf->product->dir_output.'/'.$pdir;
@@ -185,27 +145,29 @@
- 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;
- break;
- }
-
- if ($realpath) {
- $realpatharray[$i] = $realpath;
- }
- }
- }
-
- if (count($realpatharray) == 0) {
- $this->posxpicture = $this->posxweightvol;
- }
-
- if ($conf->reception->dir_output) {
+ 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;
+ break;
+ }
+
+ if ($realpath) $realpatharray[$i] = $realpath;
+ }
+ }
+
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
+
+ if ($conf->reception->dir_output)
+ {
@@ -213 +175,2 @@
- if ($object->specimen) {
+ if ($object->specimen)
+ {
@@ -216 +179,3 @@
- } else {
+ }
+ else
+ {
@@ -222,2 +187,4 @@
- if (!file_exists($dir)) {
- if (dol_mkdir($dir) < 0) {
+ if (!file_exists($dir))
+ {
+ if (dol_mkdir($dir) < 0)
+ {
@@ -229 +196,2 @@
- if (file_exists($dir)) {
+ if (file_exists($dir))
+ {
@@ -231 +199,2 @@
- if (!is_object($hookmanager)) {
+ if (!is_object($hookmanager))
+ {
@@ -246,14 +215,16 @@
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- $pdf->SetAutoPageBreak(1, 0);
-
- if (class_exists('TCPDF')) {
- $pdf->setPrintHeader(false);
- $pdf->setPrintFooter(false);
- }
- $pdf->SetFont(pdf_getPDFFont($outputlangs));
- // Set path to the background PDF File
- if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND'));
- $tplidx = $pdf->importPage(1);
- }
+ $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+ $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+ $pdf->SetAutoPageBreak(1, 0);
+
+ if (class_exists('TCPDF'))
+ {
+ $pdf->setPrintHeader(false);
+ $pdf->setPrintFooter(false);
+ }
+ $pdf->SetFont(pdf_getPDFFont($outputlangs));
+ // Set path to the background PDF File
+ if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+ {
+ $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+ $tplidx = $pdf->importPage(1);
+ }
@@ -265,3 +236 @@
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -274,3 +243 @@
- if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
- $pdf->SetCompression(false);
- }
+ if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
@@ -282,3 +249 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -292,3 +257,3 @@
- $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
-
- $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
+ $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
+ $tab_height = 130;
+ $tab_height_newpage = 150;
@@ -298 +263,2 @@
- if (isModEnabled('incoterm')) {
+ if ($conf->incoterm->enabled)
+ {
@@ -300,2 +266,3 @@
- if ($desc_incoterms) {
- $tab_top -= 2;
+ if ($desc_incoterms)
+ {
+ $tab_top = 88;
@@ -317 +284,2 @@
- if (!empty($object->note_public) || !empty($object->tracking_number)) {
+ if (!empty($object->note_public) || !empty($object->tracking_number))
+ {
@@ -328 +296,2 @@
- if (!empty($object->tracking_number)) {
+ if (!empty($object->tracking_number))
+ {
@@ -330,2 +299,4 @@
- if (!empty($object->tracking_url)) {
- if ($object->reception_method_id > 0) {
+ if (!empty($object->tracking_url))
+ {
+ if ($object->reception_method_id > 0)
+ {
@@ -335,3 +306 @@
- if ($object->tracking_url != $object->tracking_number) {
- $label .= $outputlangs->trans("LinkToTrackYourPackage")."
";
- }
+ if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
";
@@ -340 +309,2 @@
- if ($object->tracking_url != $object->tracking_number) {
+ if ($object->tracking_url != $object->tracking_number)
+ {
@@ -353 +323,2 @@
- if (!empty($object->note_public)) {
+ if (!empty($object->note_public))
+ {
@@ -367 +338,3 @@
- } else {
+ }
+ else
+ {
@@ -376,2 +348,0 @@
- $totalAmount = 0;
-
@@ -379 +350,2 @@
- for ($i = 0; $i < $nblines; $i++) {
+ for ($i = 0; $i < $nblines; $i++)
+ {
@@ -386,3 +358 @@
- if (!empty($realpatharray[$i])) {
- $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
- }
+ if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
@@ -399 +369,2 @@
- 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
+ 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
+ {
@@ -401,6 +372,2 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -412 +379 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -414 +381 @@
- } else {
+ else
@@ -416,4 +383,4 @@
- }
- }
-
- if (isset($imglinesize['width']) && isset($imglinesize['height'])) {
+ }
+
+ if (isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
@@ -429,12 +395,0 @@
- // The desc of line is not store into reception, so we force it to the value of product.
- /*
- if (empty($object->lines[0]->desc)) {
- // TODO We must get value from fk_commendefourndet
- $sqldesc = 'SELECT description FROM '.MAIN_DB_PREFIX.' WHERE rowid = '.((int) $object->lines[0]->fk_commandefourndet);
- $resqldesc = $this->db->query($sqldesc);
- if ($resqldesc) {
- $objdesc = $this->db->fetch_object($resqldesc);
- $object->lines[0]->desc = $objdesc->description;
- }
- }*/
-
@@ -445 +400,2 @@
- if ($pageposafter > $pageposbefore) { // There is a pagebreak
+ if ($pageposafter > $pageposbefore) // There is a pagebreak
+ {
@@ -456,2 +412,4 @@
- if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
- if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
+ if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) // There is no space left for total+free text
+ {
+ if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page
+ {
@@ -459,6 +417,2 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
- if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) {
- $this->_pagehead($pdf, $object, 0, $outputlangs);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+ if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
@@ -467 +421,3 @@
- } else {
+ }
+ else
+ {
@@ -471 +427 @@
- if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
+ if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
@@ -473 +429 @@
- } else {
+ else
@@ -475 +430,0 @@
- }
@@ -477 +432,3 @@
- } else { // No pagebreak
+ }
+ else // No pagebreak
+ {
@@ -482 +439 @@
- $nexY = max($pdf->GetY(), $posYAfterImage);
+ $nexY = $pdf->GetY();
@@ -491,2 +448 @@
- $pdf->setPage($pageposafter);
- $curY = $tab_top_newpage;
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
@@ -497,2 +453 @@
- $pdf->setPage($pageposafter);
- $curY = $tab_top_newpage;
+ $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
@@ -503 +457,0 @@
- // Description
@@ -506,2 +460,3 @@
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
- $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units, 1);
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight)
+ {
+ $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units);
@@ -510,2 +465,3 @@
- if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
- $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, 1);
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume)
+ {
+ $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0);
@@ -517,11 +473,9 @@
- // Qty ordered
- if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
- $pdf->SetXY($this->posxqtyordered, $curY);
- if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
- $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
- $totalOrdered += $object->lines[$i]->qty_asked;
- }
- $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
- }
-
- // Qty received
+ if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
+ $pdf->SetXY($this->posxqtyordered, $curY);
+ if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
+ $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
+ $totalOrdered += $object->lines[$i]->qty_asked;
+ }
+ $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
+ }
+
@@ -531,2 +485,2 @@
- // Amount
- if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
+ if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT))
+ {
@@ -536 +489,0 @@
- $amountreceived = price2num($object->lines[$i]->subprice * $object->lines[$i]->qty, 'MT');
@@ -538,3 +491 @@
- $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($amountreceived, 0, $outputlangs), '', 'R');
-
- $totalAmount += $amountreceived;
+ $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3, price($object->lines[$i]->total_ht, 0, $outputlangs), '', 'R');
@@ -544,3 +495 @@
- if ($weighttxt && $voltxt) {
- $nexY += 2;
- }
+ if ($weighttxt && $voltxt) $nexY += 2;
@@ -549 +498,2 @@
- if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) {
+ if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
+ {
@@ -558 +508,2 @@
- while ($pagenb < $pageposafter) {
+ while ($pagenb < $pageposafter)
+ {
@@ -560,4 +511,7 @@
- if ($pagenb == 1) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
+ }
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
@@ -569,2 +523,6 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
+ }
+ if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
+ {
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
@@ -572,6 +530,3 @@
- }
- 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);
- } else {
- $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
@@ -582,3 +537 @@
- if (!empty($tplidx)) {
- $pdf->useTemplate($tplidx);
- }
+ if (!empty($tplidx)) $pdf->useTemplate($tplidx);
@@ -590,5 +543,3 @@
- if ($pagenb == 1) {
- $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
- $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);
+ if ($pagenb == 1)
+ {
+ $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
@@ -596,0 +548,5 @@
+ else
+ {
+ $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
+ $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
+ }
@@ -599 +555 @@
- $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered, $totalAmount);
+ $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
@@ -603,3 +559 @@
- if (method_exists($pdf, 'AliasNbPages')) {
- $pdf->AliasNbPages();
- }
+ if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
@@ -616,3 +570,4 @@
- if ($reshook < 0) {
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
+ if ($reshook < 0)
+ {
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
@@ -621 +576,2 @@
- dolChmod($file);
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
@@ -624 +580,3 @@
- } else {
+ }
+ else
+ {
@@ -628 +586,3 @@
- } else {
+ }
+ else
+ {
@@ -639,2 +599,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Reception $object Object reception
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
@@ -645 +604,0 @@
- * @param int $totalAmount Total amount
@@ -648 +607 @@
- protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
+ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
@@ -653,3 +612,3 @@
- $sign = 1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $sign = 1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -662,2 +621 @@
- $col1x = $this->posxweightvol - 50;
- $col2x = $this->posxweightvol;
+ $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol;
@@ -668,5 +626,2 @@
- if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
- $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
- } else {
- $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
- }
+ if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
+ else $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
@@ -688,23 +643,31 @@
- if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
- $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
- $object->volume_units = $object->size_units * 3;
- }
-
- if ($totalWeight != '') {
- $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1);
- }
- if ($totalVolume != '') {
- $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1);
- }
- if (isset($object->trueWeight) && !empty($object->trueWeight)) {
- $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs, -1, 'no', 1);
- }
- if (isset($object->trueVolume) && !empty($object->trueVolume)) {
- $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs, -1, 'no', 1);
- }
-
- $pdf->SetFillColor(255, 255, 255);
- $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
-
- $index2 = 0;
+ if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
+ {
+ $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
+ $object->volume_units = $object->size_units * 3;
+ }
+
+ if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
+ if ($totalVolume != '') $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs);
+ if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
+ if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
+
+ $pdf->SetFillColor(255, 255, 255);
+ $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
+
+ if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
+ {
+ $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
+ }
+
+ $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
+
+ if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
+ $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
+
+ $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
+ }
@@ -713,29 +676,15 @@
- if ($totalWeighttoshow) {
- $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
- $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
- $index2++;
- }
- if ($totalVolumetoshow) {
- $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
- $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
- $index2++;
- }
-
- // Total qty ordered
- if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
- $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
- }
-
- // Total received
- $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
-
- // Amount
- if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
- $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
-
- $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($totalAmount, 0, $outputlangs), 0, 'C', 1);
- }
+ if ($totalWeighttoshow)
+ {
+ $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
+
+ $index++;
+ }
+ if ($totalVolumetoshow)
+ {
+ $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+ $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
+
+ $index++;
+ }
+ if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
@@ -744,5 +692,0 @@
-
- $index++;
- if ($index2) {
- $index++;
- }
@@ -757 +701 @@
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
@@ -764 +707,0 @@
- * @param Object|NULL $object Object reception to generate
@@ -767 +710 @@
- protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object = null)
+ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
@@ -773,3 +716 @@
- if ($hidetop) {
- $hidetop = -1;
- }
+ if ($hidetop) $hidetop = -1;
@@ -789,2 +730,2 @@
- // Description
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -797 +737,0 @@
- // Volume / Weight
@@ -799 +739,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -804,10 +745,10 @@
- // Qty ordered
- if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) {
- $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
- if (empty($hidetop)) {
- $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
- $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
- }
- }
-
- // Qty reception
+ if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
+ {
+ $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
+ if (empty($hidetop))
+ {
+ $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
+ $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
+ }
+ }
+
@@ -815 +756,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -817,16 +759,4 @@
- $statusreceived = Reception::STATUS_CLOSED;
- if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION")) {
- $statusreceived = Reception::STATUS_VALIDATED;
- }
- if (getDolGlobalInt("STOCK_CALCULATE_ON_RECEPTION_CLOSE")) {
- $statusreceived = Reception::STATUS_CLOSED;
- }
- if ($object && $object->statut < $statusreceived) {
- $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyToReceive'), '', 'C');
- } else {
- $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities('QtyReceived'), '', 'C');
- }
- }
-
- // Amount
- if (getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')) {
+ $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToReceive"), '', 'C');
+ }
+
+ if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
@@ -834 +764,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -840 +771,2 @@
- if (empty($hidetop)) {
+ if (empty($hidetop))
+ {
@@ -851,2 +783,2 @@
- * @param TCPDF $pdf Object PDF
- * @param Reception $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
@@ -866,0 +799,6 @@
+ // Show Draft Watermark
+ if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK)))
+ {
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
+ }
+
@@ -880,5 +818,9 @@
- if ($this->emetteur->logo) {
- if (is_readable($logo)) {
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ if ($this->emetteur->logo)
+ {
+ if (is_readable($logo))
+ {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
@@ -890 +832,3 @@
- } else {
+ }
+ else
+ {
@@ -896 +840,2 @@
- if (isModEnabled('barcode')) {
+ if (!empty($conf->barcode->enabled))
+ {
@@ -898 +843,3 @@
- } else {
+ }
+ else
+ {
@@ -902 +849,2 @@
- if (isModEnabled('barcode')) {
+ if (!empty($conf->barcode->enabled))
+ {
@@ -908,0 +857,7 @@
+ if (!empty($conf->barcode->enabled))
+ {
+ // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref
+ //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
+ //$pdf->Image($logo,10, 5, 0, 24);
+ }
+
@@ -928,8 +883,10 @@
- if (!empty($object->date_delivery)) {
- $posy += 4;
- $pdf->SetXY($posx, $posy);
- $pdf->SetTextColor(0, 0, 60);
- $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
- }
-
- if (!empty($object->thirdparty->code_fournisseur)) {
+ if (!empty($object->date_delivery))
+ {
+ $posy += 4;
+ $pdf->SetXY($posx, $posy);
+ $pdf->SetTextColor(0, 0, 60);
+ $pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
+ }
+
+ if (!empty($object->thirdparty->code_fournisseur))
+ {
@@ -950,2 +907,3 @@
- // TODO move to external function
- if (isModEnabled("supplier_order")) { // commonly $origin='commande'
+ // TODO move to external function
+ if (!empty($conf->fournisseur->enabled)) // commonly $origin='commande'
+ {
@@ -957,2 +915,3 @@
- if ($result >= 0) {
- //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+ if ($result >= 0)
+ {
+ //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
@@ -962,3 +921 @@
- if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
- $text .= ' ('.$linkedobject->ref_client.')';
- }
+ if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')';
@@ -974 +931,2 @@
- if ($showaddress) {
+ if ($showaddress)
+ {
@@ -977 +935 @@
- // Add internal contact of origin element if defined
+ // Add internal contact of origin element if defined
@@ -979,19 +937,9 @@
- if (!empty($origin) && is_object($object->$origin)) {
- $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
- }
- if (empty($arrayidcontact)) {
- $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
- }
- if (count($arrayidcontact) > 0) {
- $object->fetch_user(reset($arrayidcontact));
- $labelbeforecontactname = ($outputlangs->transnoentities("FromContactName") != 'FromContactName' ? $outputlangs->transnoentities("FromContactName") : $outputlangs->transnoentities("Name"));
- $carac_emetteur .= ($carac_emetteur ? "\n" : '').$labelbeforecontactname.": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ' (' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') && getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ', ' : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email : '';
- $carac_emetteur .= (getDolGlobalInt('PDF_SHOW_PHONE_AFTER_USER_CONTACT') || getDolGlobalInt('PDF_SHOW_EMAIL_AFTER_USER_CONTACT')) ? ')' : '';
- $carac_emetteur .= "\n";
- }
-
- $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
+ if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL');
+ if (empty($arrayidcontact)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SHIPPING');
+ if (count($arrayidcontact) > 0)
+ {
+ $object->fetch_user(reset($arrayidcontact));
+ $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+ }
+
+ $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
@@ -1000 +948 @@
- $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42;
+ $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
@@ -1002,6 +950,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;
@@ -1013 +959 @@
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender"), 0, 'L');
+ $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L');
@@ -1024 +970,2 @@
- if (count($arrayidcontact) > 0) {
+ if (count($arrayidcontact) > 0)
+ {
@@ -1029,2 +976,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)) {
@@ -1040 +988 @@
- // Show recipient name
+ // Show recipient name
@@ -1053,5 +1001,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;
@@ -1059,3 +1005 @@
- if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) {
- $posx = $this->marge_gauche;
- }
+ if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
@@ -1067 +1011 @@
- $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L');
+ $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient").":", 0, 'L');
@@ -1090,2 +1034,2 @@
- *
- * @param TCPDF $pdf PDF
+ *
+ * @param PDF $pdf PDF
@@ -1099,2 +1043,3 @@
- $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
- return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
+ global $conf;
+ $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ return pdf_pagefoot($pdf, $outputlangs, 'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);