--- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_19.0.3_doc_generic_shipment_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_doc_generic_shipment_odt.modules.php @@ -6 +6 @@ - * Copyright (C) 2018-2021 Philippe Grand + * Copyright (C) 2018-2019 Philippe Grand @@ -44,2 +44,2 @@ - * Dolibarr version of the loaded document - * @var string + * Issuer + * @var Societe @@ -46,0 +47,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 + */ @@ -55 +67 @@ - public function __construct($db) + public function __construct($db) @@ -60 +72 @@ - $langs->loadLangs(array("main", "companies")); + $langs->loadLangs(array("main", "companies")); @@ -77,6 +89,7 @@ - $this->option_logo = 1; // Display logo - $this->option_tva = 0; // Manage the vat option EXPEDITION_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 EXPEDITION_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 @@ -89,3 +102 @@ - 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 @@ -101 +112 @@ - public function info($langs) + public function info($langs) @@ -106 +117 @@ - $langs->loadLangs(array("errors", "companies")); + $langs->loadLangs(array("errors", "companies")); @@ -113 +123,0 @@ - $texte .= ''; @@ -123 +133,2 @@ - foreach ($listofdir as $key => $tmpdir) { + foreach ($listofdir as $key=>$tmpdir) + { @@ -127,2 +138 @@ - unset($listofdir[$key]); - continue; + unset($listofdir[$key]); continue; @@ -130,3 +140,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 + { @@ -134,3 +144 @@ - if (count($tmpfiles)) { - $listoffiles = array_merge($listoffiles, $tmpfiles); - } + if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); @@ -140 +147,0 @@ - $texthelp .= '

'.$langs->trans("ExampleOfDirectoriesForModelGen").''; @@ -145 +152 @@ - $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1, 3, $this->name); + $texte .= $form->textwithpicto($texttitle, $texthelp, 1, 'help', '', 1); @@ -148 +155 @@ - $texte .= getDolGlobalString('EXPEDITION_ADDON_PDF_ODT_PATH'); + $texte .= $conf->global->EXPEDITION_ADDON_PDF_ODT_PATH; @@ -151 +158 @@ - $texte .= ''; + $texte .= ''; @@ -156 +163,2 @@ - if (getDolGlobalString('EXPEDITION_ADDON_PDF_ODT_PATH')) { + if (!empty($conf->global->EXPEDITION_ADDON_PDF_ODT_PATH)) + { @@ -163,9 +171,8 @@ - if ($nbofiles) { - $texte .= '
'; - // Show list of found files - foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; - $texte .= '   '.img_picto('', 'delete').''; - $texte .= '
'; - } - $texte .= '
'; + if ($nbofiles) + { + $texte .= ''; @@ -173,11 +180,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 .= '
'; @@ -185,0 +187,3 @@ + $texte .= ''; + $texte .= $langs->trans("ExampleOfDirectoriesForModelGen"); + $texte .= ''; @@ -194 +198 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -206 +210 @@ - 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) @@ -208 +212 @@ - // phpcs:enable + // phpcs:enable @@ -211 +215,2 @@ - if (empty($srctemplatepath)) { + if (empty($srctemplatepath)) + { @@ -217 +222,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -224,3 +230 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -233 +237,2 @@ - if ($conf->expedition->dir_output."/sending") { + if ($conf->expedition->dir_output."/sending") + { @@ -235 +240,2 @@ - if (!is_object($object)) { + if (!is_object($object)) + { @@ -239 +245,2 @@ - if ($result < 0) { + if ($result < 0) + { @@ -245,2 +251,0 @@ - $object->fetch_thirdparty(); - @@ -249,3 +254 @@ - if (!preg_match('/specimen/i', $objectref)) { - $dir .= "/".$objectref; - } + if (!preg_match('/specimen/i', $objectref)) $dir .= "/".$objectref; @@ -254,2 +257,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -261 +266,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -264 +270 @@ - $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; @@ -287,5 +294 @@ - if (!is_writable($conf->expedition->dir_temp)) { - $this->error = $langs->transnoentities("ErrorFailedToWriteInTempDirectory", $conf->expedition->dir_temp); - dol_syslog('Error in write_file: ' . $this->error, LOG_ERR); - return -1; - } + @@ -296 +299,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -304,6 +308,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 { @@ -311 +313 @@ - // if we have a SHIPPING contact and we dont use it as thirdparty recipient we store the contact object for later use + // if we have a SHIIPPING contact and we dont use it as recipient we store the contact object for later use @@ -324 +326 @@ - '__TOTAL_VAT__' => $object->total_tva + '__TOTAL_VAT__' => $object->total_vat @@ -334,2 +336,3 @@ - if (!empty($conf->global->$paramfreetext)) { - $newfreetext = make_substitutions(getDolGlobalString($paramfreetext), $substitutionarray); + if (!empty($conf->global->$paramfreetext)) + { + $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); @@ -341 +344 @@ - $odfHandler = new Odf( + $odfHandler = new odf( @@ -350 +353,3 @@ - } catch (Exception $e) { + } + catch (Exception $e) + { @@ -365 +370,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -372,3 +379,5 @@ - foreach ($tmparray as $key => $value) { - try { - if (preg_match('/logo$/', $key)) { // Image + foreach ($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { @@ -376,6 +385,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 + { @@ -384,2 +392,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -391,3 +401,5 @@ - foreach ($tmparray as $key => $value) { - try { - if (preg_match('/logo$/', $key)) { // Image + foreach ($tmparray as $key=>$value) + { + try { + if (preg_match('/logo$/', $key)) // Image + { @@ -395,6 +407,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 + { @@ -403,2 +414,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -408,14 +421,15 @@ - if ($socobject->element == 'contact') { - $tmparray = $this->get_substitutionarray_contact($socobject, $outputlangs); - } else { - $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 + if ($socobject->element == 'contact') { + $tmparray = $this->get_substitutionarray_contact($socobject, $outputlangs); + } else { + $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 + { @@ -424,2 +438,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -431 +447,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -433,7 +450,7 @@ - if (preg_match('/logo$/', $key)) { // Image - if (file_exists($value)) { - $odfHandler->setImage($key, $value); - } else { - $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); - } - } else { // Text + if (preg_match('/logo$/', $key)) // Image + { + if (file_exists($value)) $odfHandler->setImage($key, $value); + else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); + } + else // Text + { @@ -442,2 +459,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -449,3 +468 @@ - $tmparray = array_merge($tmparray, $this->get_substitutionarray_shipment($object, $outputlangs)); - $tmparray = array_merge($tmparray, $this->get_substitutionarray_other($outputlangs)); - + $tmparray = $this->get_substitutionarray_shipment($object, $outputlangs); @@ -456,9 +473,10 @@ - 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 + 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 + { @@ -467,2 +485,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -472 +492,2 @@ - try { + try + { @@ -476 +497,3 @@ - } catch (OdfExceptionSegmentNotFound $e) { + } + catch (OdfException $e) + { @@ -480,7 +503,6 @@ - } catch (OdfException $e) { - $foundtagforlines = 0; - dol_syslog($e->getMessage(), LOG_INFO); - } - if ($foundtagforlines) { - foreach ($object->lines as $line) { - $tmparray = $this->get_substitutionarray_lines($line, $outputlangs); + } + if ($foundtagforlines) + { + foreach ($object->lines as $line) + { + $tmparray = $this->get_substitutionarray_shipment_lines($line, $outputlangs); @@ -491,2 +513,4 @@ - foreach ($tmparray as $key => $val) { - try { + foreach ($tmparray as $key => $val) + { + try + { @@ -494 +518,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -496 +522,3 @@ - } catch (SegmentException $e) { + } + catch (SegmentException $e) + { @@ -504 +532,3 @@ - } catch (OdfException $e) { + } + catch (OdfException $e) + { @@ -512 +542,2 @@ - foreach ($tmparray as $key => $value) { + foreach ($tmparray as $key=>$value) + { @@ -515,2 +546,4 @@ - } catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + } + catch (OdfException $e) + { + dol_syslog($e->getMessage(), LOG_INFO); @@ -525 +558 @@ - if (getDolGlobalString('MAIN_ODT_AS_PDF')) { + if (!empty($conf->global->MAIN_ODT_AS_PDF)) { @@ -530 +563 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -533,3 +566,4 @@ - } else { - try { - $odfHandler->saveToDisk($file); + } + else { + try { + $odfHandler->saveToDisk($file); @@ -538 +572 @@ - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); @@ -545 +579,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -552 +587,3 @@ - } else { + } + else + { --- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_19.0.3_pdf_espadon.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_espadon.modules.php @@ -6,2 +6 @@ - * Copyright (C) 2018-2020 Frédéric France - * Copyright (C) 2023 Charlene Benke + * Copyright (C) 2018 Frédéric France @@ -33 +32 @@ -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + @@ -40,2 +39,70 @@ - /** - * @var DoliDb Database handler + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe object that emits @@ -43,31 +110 @@ - 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; - - public $posxweightvol; - public $posxqtytoship; - public $posxqtyordered; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; + public $emetteur; @@ -81 +118 @@ - public function __construct(DoliDB $db) + public function __construct($db = 0) @@ -83 +120 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -88 +124,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -95,8 +131,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; @@ -106,3 +140 @@ - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } + if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -117 +149 @@ - * @param Expedition $object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) @@ -119,5 +151,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 @@ -132,3 +164 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -136,3 +166 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -141,10 +169,4 @@ - $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); - - // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) { - $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK; - } - - global $outputlangsbis; - $outputlangsbis = null; - if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + + if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) { + global $outputlangsbis; @@ -153 +175 @@ - $outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + $outputlangsbis->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -158,11 +180,12 @@ - // Loop on each lines to detect if there is at least one image to show - $realpatharray = array(); - $this->atleastonephoto = false; - 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(); + $this->atleastonephoto = false; + 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; + + $objphoto = new Product($this->db); @@ -171,5 +194,3 @@ - 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, 0, 0, 0, $objphoto, 'product'); + if (! empty($conf->global->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/"; @@ -177,0 +199,5 @@ + else + { + $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/'; + $dir = $conf->product->dir_output.'/'.$pdir; + } @@ -181,10 +207,17 @@ - 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']; - } + 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']; + } @@ -194,16 +227,14 @@ - break; - } - - if ($realpath) { - $realpatharray[$i] = $realpath; - } - } - } - - if (count($realpatharray) == 0) { - $this->posxpicture = $this->posxweightvol; - } - - if ($conf->expedition->dir_output) { - // Definition of $dir and $file - if ($object->specimen) { + break; + } + + if ($realpath) $realpatharray[$i] = $realpath; + } + } + + if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol; + + if ($conf->expedition->dir_output) + { + // Definition of $dir and $file + if ($object->specimen) + { @@ -212 +243,3 @@ - } else { + } + else + { @@ -218,2 +251,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -225 +260,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -227 +263,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -242,17 +279,17 @@ - $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; - } - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -264,3 +301 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -273,3 +308 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -281,3 +314 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -285 +316 @@ - $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); @@ -291,5 +322,5 @@ - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); - - $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; - - $this->posxdesc = $this->marge_gauche + 1; + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10); + $tab_height = 130; + $tab_height_newpage = 150; + + $this->posxdesc = $this->marge_gauche + 1; @@ -299 +330,2 @@ - if (isModEnabled('incoterm')) { + if ($conf->incoterm->enabled) + { @@ -301,2 +333,3 @@ - if ($desc_incoterms) { - $tab_top -= 2; + if ($desc_incoterms) + { + $tab_top = 88; @@ -318,12 +351,20 @@ - // display note - $notetoshow = empty($object->note_public) ? '' : $object->note_public; - - // Extrafields in note - $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); - if (!empty($extranote)) { - $notetoshow = dol_concatdesc($notetoshow, $extranote); - } - - if (!empty($notetoshow) || !empty($object->tracking_number)) { - $tab_top -= 2; - $tab_topbeforetrackingnumber = $tab_top; + // display note + $notetoshow = empty($object->note_public) ? '' : $object->note_public; + + // Extrafields in note + $extranote = $this->getExtrafieldsInHtml($object, $outputlangs); + if (!empty($extranote)) + { + $notetoshow = dol_concatdesc($notetoshow, $extranote); + } + + if (!empty($notetoshow) || !empty($object->tracking_number)) + { + $tab_top = 88 + $height_incoterms; + $tab_top_alt = $tab_top; + + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); + + $tab_top_alt = $pdf->GetY(); + //$tab_top_alt += 1; @@ -332,7 +373,2 @@ - if (!empty($object->tracking_number)) { - $height_trackingnumber = 4; - - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber") . " : " . $object->tracking_number, 0, 1, false, true, 'L'); - - $tab_top_alt = $pdf->GetY(); + if (!empty($object->tracking_number)) + { @@ -340,2 +376,4 @@ - if (!empty($object->tracking_url)) { - if ($object->shipping_method_id > 0) { + if (!empty($object->tracking_url)) + { + if ($object->shipping_method_id > 0) + { @@ -345,3 +383 @@ - if ($object->tracking_url != $object->tracking_number) { - $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; - } + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; @@ -350 +386,2 @@ - if ($object->tracking_url != $object->tracking_number) { + if ($object->tracking_url != $object->tracking_number) + { @@ -354,2 +390,0 @@ - - $height_trackingnumber += 4; @@ -357 +392,3 @@ - $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); + + $tab_top_alt = $pdf->GetY(); @@ -360,3 +397 @@ - $tab_top = $pdf->GetY(); - } - + } @@ -365,137 +400,19 @@ - $pagenb = $pdf->getPage(); - if (!empty($notetoshow) || !empty($object->tracking_number)) { - $tab_top -= 1; - - $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 (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - // $this->_pagefoot($pdf,$object,$outputlangs,1); - $pdf->setTopMargin($tab_top_newpage); - // The only function to edit the bottom margin of current page to set it. - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - } - - // back to start - $pdf->setPage($pageposbeforenote); - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - $pdf->SetFont('', '', $default_font_size - 1); - $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); - $pageposafternote = $pdf->getPage(); - - $posyafter = $pdf->GetY(); - - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { // There is no space left for total+free text - $pdf->AddPage('', '', true); - $pagenb++; - $pageposafternote++; - $pdf->setPage($pageposafternote); - $pdf->setTopMargin($tab_top_newpage); - // The only function to edit the bottom margin of current page to set it. - $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext); - //$posyafter = $tab_top_newpage; - } - - - // apply note frame to previous pages - $i = $pageposbeforenote; - while ($i < $pageposafternote) { - $pdf->setPage($i); - - - $pdf->SetDrawColor(128, 128, 128); - // Draw note frame - if ($i > $pageposbeforenote) { - if (empty($height_trackingnumber)) { - $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); - } else { - $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter) + $height_trackingnumber + 1; - $tab_top_newpage = $tab_topbeforetrackingnumber; - } - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 2); - } else { - if (empty($height_trackingnumber)) { - $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); - } else { - $height_note = $this->page_hauteur - ($tab_top + $heightforfooter)+ $height_trackingnumber + 1; - $tab_top = $tab_topbeforetrackingnumber; - } - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2); - } - - // Add footer - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. - $this->_pagefoot($pdf, $object, $outputlangs, 1); - - $i++; - } - - // apply note frame to last page - $pdf->setPage($pageposafternote); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - $height_note = $posyafter - $tab_top_newpage; - $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1); - } else { // No pagebreak - $pdf->commitTransaction(); - $posyafter = $pdf->GetY(); - if (empty($height_trackingnumber)) { - $height_note = $posyafter - $tab_top + 1; - } else { - $height_note = $posyafter - $tab_top + $height_trackingnumber + 1; - $tab_top = $tab_topbeforetrackingnumber; - } - $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 2); - - - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) { - // not enough space, need to add page - $pdf->AddPage('', '', true); - $pagenb++; - $pageposafternote++; - $pdf->setPage($pageposafternote); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } - - $posyafter = $tab_top_newpage; - } - } - - $tab_height = $tab_height - $height_note; - $tab_top = $posyafter + 6; - } else { - $height_note = 0; - } + if (!empty($notetoshow)) + { + $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page + $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1); + } + + $nexY = $pdf->GetY(); + $height_note = $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_note + 1); + + $tab_height = $tab_height - $height_note; + $tab_top = $nexY + 6; + } + else + { + $height_note = 0; @@ -510 +427 @@ - $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs); + $this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop); @@ -517,3 +434,2 @@ - $pageposbeforeprintlines = $pdf->getPage(); - $pagenb = $pageposbeforeprintlines; - for ($i = 0; $i < $nblines; $i++) { + for ($i = 0; $i < $nblines; $i++) + { @@ -526,3 +442 @@ - if (!empty($realpatharray[$i])) { - $imglinesize = pdf_getSizeForImage($realpatharray[$i]); - } + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); @@ -537,13 +451,12 @@ - $heightforsignature = 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 + $heightforsignature + $heightforinfotot))) { // If photo too high, we moved completely on new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposbefore + 1); - - $curY = $tab_top_newpage; + + if ($this->getColumnStatus('photo')) + { + // We start with Photo of product line + if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // If photo too high, we moved completely on new page + { + $pdf->AddPage('', '', true); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposbefore + 1); + + $curY = $tab_top_newpage; @@ -552 +465 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -554 +467 @@ - } else { + else @@ -556,9 +469,9 @@ - } - } - - - if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) { - $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi - // $pdf->Image does not increase value return by getY, so we save it manually - $posYAfterImage = $curY + $imglinesize['height']; - } + } + + + if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) + { + $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi + // $pdf->Image does not increase value return by getY, so we save it manually + $posYAfterImage = $curY + $imglinesize['height']; + } @@ -568,25 +481,29 @@ - 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); - - $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); - - $pageposafter = $pdf->getPage(); - $posyafter = $pdf->GetY(); - //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; - if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) { // There is no space left for total+free text - if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page - $pdf->AddPage('', '', true); - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - //if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) $this->_pagehead($pdf, $object, 0, $outputlangs); - $pdf->setPage($pageposafter + 1); - } - } else { - // We found a page break + if ($this->getColumnStatus('desc')) + { + $pdf->startTransaction(); + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); + + $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) // There is a pagebreak + { + $pdf->rollbackTransaction(true); + + $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc); + + $pageposafter = $pdf->getPage(); + $posyafter = $pdf->GetY(); + //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; + if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) // There is no space left for total+free text + { + if ($i == ($nblines - 1)) // No more lines, and no space left to show total, so we create a new page + { + $pdf->AddPage('', '', true); + if (!empty($tplidx)) $pdf->useTemplate($tplidx); + //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + $pdf->setPage($pageposafter + 1); + } + } + else + { + // We found a page break @@ -594 +511 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -596 +513 @@ - } else { + else @@ -598,9 +515,10 @@ - } - } - } else { // No pagebreak - $pdf->commitTransaction(); - } - $posYAfterDescription = $pdf->GetY(); - } - - $nexY = max($pdf->GetY(), $posYAfterImage); + } + } + else // No pagebreak + { + $pdf->commitTransaction(); + } + $posYAfterDescription = $pdf->GetY(); + } + + $nexY = $pdf->GetY(); @@ -615,2 +533 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -621,2 +538 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -630 +546,2 @@ - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + { @@ -634 +551,2 @@ - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + { @@ -639,35 +557,35 @@ - if ($this->getColumnStatus('weight')) { - $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt); - $nexY = max($pdf->GetY(), $nexY); - } - - if ($this->getColumnStatus('qty_asked')) { - $this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked); - $nexY = max($pdf->GetY(), $nexY); - } - - if ($this->getColumnStatus('unit_order')) { - $this->printStdColumnContent($pdf, $curY, 'unit_order', measuringUnitString($object->lines[$i]->fk_unit)); - $nexY = max($pdf->GetY(), $nexY); - } - - if ($this->getColumnStatus('qty_shipped')) { - $this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped); - $nexY = max($pdf->GetY(), $nexY); - } - - if ($this->getColumnStatus('subprice')) { - $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs)); - $nexY = max($pdf->GetY(), $nexY); - } - - // Extrafields - if (!empty($object->lines[$i]->array_options)) { - foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) { - if ($this->getColumnStatus($extrafieldColKey)) { - $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs); - $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue); - $nexY = max($pdf->GetY(), $nexY); - } - } - } + if ($this->getColumnStatus('weight')) + { + $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, array('html'=>1)); + $nexY = max($pdf->GetY(), $nexY); + } + + if ($this->getColumnStatus('qty_asked')) + { + $this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked); + $nexY = max($pdf->GetY(), $nexY); + } + + if ($this->getColumnStatus('qty_shipped')) + { + $this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped); + $nexY = max($pdf->GetY(), $nexY); + } + + if ($this->getColumnStatus('subprice')) + { + $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs)); + $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); + } + } + } @@ -676 +594,2 @@ - if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + { @@ -685 +604,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -687 +607,2 @@ - if ($pagenb == $pageposbeforeprintlines) { + if ($pagenb == 1) + { @@ -689 +610,3 @@ - } else { + } + else + { @@ -696,2 +619,7 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); @@ -699,8 +627,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - } - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + else + { @@ -712,3 +634 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -716,3 +636 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -723 +641,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -726 +645,3 @@ - } else { + } + else + { @@ -736,3 +657 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -749,3 +668,4 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; @@ -754 +674,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -759 +680,3 @@ - } else { + } + else + { @@ -763 +686,3 @@ - } else { + } + else + { @@ -774,2 +699,2 @@ - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object expedition + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice @@ -786,3 +711,3 @@ - $sign = 1; - - $default_font_size = pdf_getPDFFontSize($outputlangs); + $sign = 1; + + $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -795,2 +720 @@ - $col1x = $this->posxweightvol - 50; - $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; @@ -801,5 +725,2 @@ - if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) { - $largcol2 = ($this->posxqtyordered - $this->posxweightvol); - } else { - $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - } + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); + else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); @@ -820,49 +741,48 @@ - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = $object->trueWidth * $object->trueHeight * $object->trueDepth; - $object->volume_units = $object->size_units * 3; - } - - if (!empty($totalWeight)) { - $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); - } - if (!empty($totalVolume)) { - $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); - } - if ($object->trueWeight) { - $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - } - if ($object->trueVolume) { - if ($object->volume_units < 50) { - $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); - } else { - $totalVolumetoshow = price($object->trueVolume, 0, $outputlangs, 0, 0).' '.measuringUnitString(0, "volume", $object->volume_units); - } - } - - if ($this->getColumnStatus('desc')) { - $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total")); - } - - - if ($this->getColumnStatus('weight')) { - if ($totalWeighttoshow) { - $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow); - $index++; - } - - if ($totalVolumetoshow) { - $y = $tab2_top + ($tab2_hl * $index); - $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow); - } - } - - if ($this->getColumnStatus('qty_asked') && $totalOrdered) { - $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered); - } - - if ($this->getColumnStatus('qty_shipped') && $totalToShip) { - $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip); - } - - if ($this->getColumnStatus('subprice')) { - $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs)); + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + { + $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); + $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); + + + + + if ($this->getColumnStatus('desc')) + { + $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total")); + } + + + if ($this->getColumnStatus('weight')) + { + if ($totalWeighttoshow) + { + $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow); + $index++; + } + + if ($totalVolumetoshow) + { + $y = $tab2_top + ($tab2_hl * $index); + $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow); + } + } + + if ($this->getColumnStatus('qty_asked') && $totalOrdered) + { + $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered); + } + + if ($this->getColumnStatus('qty_shipped') && $totalToShip) + { + $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip); + } + + if ($this->getColumnStatus('subprice')) + { + $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs)); @@ -880 +800 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -887,2 +806,0 @@ - * @param string $currency Currency code - * @param Translate $outputlangsbis Langs object bis @@ -891 +809 @@ - protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '', $outputlangsbis = null) + protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) @@ -897,3 +815 @@ - if ($hidetop) { - $hidetop = -1; - } + if ($hidetop) $hidetop = -1; @@ -908 +824,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -910,2 +827,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)); @@ -925 +842 @@ - $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 @@ -933,2 +850,2 @@ - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object to show + * @param PDF $pdf Object PDF + * @param Object $object Object to show @@ -937 +854 @@ - * @return int Return integer <0 if KO, > if OK + * @return void @@ -948,0 +866,6 @@ + // Show Draft Watermark + if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) + { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); + } + @@ -961,4 +884,7 @@ - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity]; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) @@ -966,9 +892,2 @@ - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + else + { @@ -980 +899,3 @@ - } else { + } + else + { @@ -986 +907,2 @@ - if (isModEnabled('barcode')) { + if (!empty($conf->barcode->enabled)) + { @@ -988 +910,3 @@ - } else { + } + else + { @@ -992 +916,2 @@ - if (isModEnabled('barcode')) { + if (!empty($conf->barcode->enabled)) + { @@ -998,0 +924,7 @@ + if (!empty($conf->barcode->enabled)) + { + // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); + //$pdf->Image($logo,10, 5, 0, 24); + } + @@ -1018,8 +950,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 (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) { + 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_client)) + { @@ -1040,2 +974,3 @@ - // TODO move to external function - if (!empty($conf->$origin->enabled)) { // commonly $origin='commande' + // TODO move to external function + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' + { @@ -1047,2 +982,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 @@ -1052,3 +988 @@ - if ($linkedobject->ref_client) { - $text .= ' ('.$linkedobject->ref_client.')'; - } + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; @@ -1064,9 +998,2 @@ - $top_shift = 0; - // Show list of linked objects - /*$current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) { - $top_shift = $pdf->getY() - $current_y; - }*/ - - if ($showaddress) { + if ($showaddress) + { @@ -1075 +1002 @@ - // Add internal contact of origin element if defined + // Add internal contact of origin element if defined @@ -1077,16 +1004,8 @@ - if (!empty($origin) && is_object($object->$origin)) { - $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); - } - if (is_array($arrayidcontact) && 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, '', 0, 'source', $object); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); + if (is_array($arrayidcontact) && 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, '', 0, 'source', $object); @@ -1095 +1014 @@ - $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; @@ -1097,6 +1016,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; @@ -1105,11 +1022,9 @@ - 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("Sender"), 0, 'L'); - $pdf->SetXY($posx, $posy); - $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFillColor(255, 255, 255); - } + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx, $posy - 5); + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); + $pdf->SetXY($posx, $posy); + $pdf->SetFillColor(230, 230, 230); + $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(255, 255, 255); @@ -1118,6 +1033,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, 'L'); - $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(); @@ -1134 +1047,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -1139,2 +1053,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 + // You can use the name of the contact company + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { @@ -1151,5 +1066,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; @@ -1157,3 +1070 @@ - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { - $posx = $this->marge_gauche; - } + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -1162,7 +1073,5 @@ - if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) { - $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $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("Recipient").":", 0, 'L'); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); @@ -1184 +1092,0 @@ - return $top_shift; @@ -1190,3 +1098,3 @@ - * - * @param TCPDF $pdf PDF - * @param Expedition $object Object to show + * + * @param PDF $pdf PDF + * @param Object $object Object to show @@ -1199,2 +1107,3 @@ - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); - return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_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, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); @@ -1206 +1115 @@ - * @param Expedition $object common object + * @param object $object common object @@ -1211 +1120 @@ - * @return void + * @return null @@ -1215,166 +1124,158 @@ - global $conf, $hookmanager; - - // Default field style for content - $this->defaultContentsFieldsStyle = array( - 'align' => 'R', // R,C,L - 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ); - - // Default field style for content - $this->defaultTitlesFieldsStyle = array( - 'align' => 'C', // R,C,L - 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ); - - /* - * For exemple - $this->cols['theColKey'] = array( - 'rank' => $rank, // int : use for ordering columns - 'width' => 20, // the column width in mm - 'title' => array( - 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - 'label' => ' ', // the final label : used fore final generated text - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'content' => array( - 'align' => 'L', // text alignement : R,C,L - 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - */ - - $rank = 0; // do not use negative rank - $this->cols['desc'] = array( - 'rank' => $rank, - 'width' => false, // only for desc - 'status' => true, - 'title' => array( - 'textkey' => 'Designation', // use lang key is usefull in somme case with module - 'align' => 'L', - // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label - // 'label' => ' ', // the final label - 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - 'content' => array( - 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left - ), - ); - - $rank = $rank + 10; - $this->cols['photo'] = array( - 'rank' => $rank, - 'width' => (!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_SHIPMENT_WITH_PICTURE') && !empty($this->atleastonephoto)) { - $this->cols['photo']['status'] = true; - } - - $rank = $rank + 10; - $this->cols['weight'] = array( - 'rank' => $rank, - 'width' => 30, // in mm - 'status' => true, - 'title' => array( - 'textkey' => 'WeightVolShort' - ), - 'border-left' => true, // add left line separator - ); - - - $rank = $rank + 10; - $this->cols['subprice'] = array( - 'rank' => $rank, - 'width' => 19, // in mm - 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0, - 'title' => array( - 'textkey' => 'PriceUHT' - ), - 'border-left' => true, // add left line separator - ); - - $rank = $rank + 10; - $this->cols['totalexcltax'] = array( - 'rank' => $rank, - 'width' => 26, // in mm - 'status' => getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT') ? 1 : 0, - 'title' => array( - 'textkey' => 'TotalHT' - ), - 'border-left' => true, // add left line separator - ); - - $rank = $rank + 10; - $this->cols['qty_asked'] = array( - 'rank' => $rank, - 'width' => 30, // in mm - 'status' => !getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED') ? 1 : 0, - 'title' => array( - 'textkey' => 'QtyOrdered' - ), - 'border-left' => true, // add left line separator - 'content' => array( - 'align' => 'C', - ), - ); - - $rank = $rank + 10; - $this->cols['unit_order'] = array( - 'rank' => $rank, - 'width' => 15, // in mm - 'status' => !getDolGlobalString('PRODUCT_USE_UNITS') ? 0 : 1, - 'title' => array( - 'textkey' => 'Unit' - ), - 'border-left' => true, // add left line separator - 'content' => array( - 'align' => 'C', - ), - ); - - $rank = $rank + 10; - $this->cols['qty_shipped'] = array( - 'rank' => $rank, - 'width' => 30, // in mm - 'status' => true, - 'title' => array( - 'textkey' => 'QtyToShip' - ), - 'border-left' => true, // add left line separator - 'content' => array( - 'align' => 'C', - ), - ); - - // 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; - } + global $conf, $hookmanager; + + // Default field style for content + $this->defaultContentsFieldsStyle = array( + 'align' => 'R', // R,C,L + 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + // Default field style for content + $this->defaultTitlesFieldsStyle = array( + 'align' => 'C', // R,C,L + 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ); + + /* + * For exemple + $this->cols['theColKey'] = array( + 'rank' => $rank, // int : use for ordering columns + 'width' => 20, // the column width in mm + 'title' => array( + 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + 'label' => ' ', // the final label : used fore final generated text + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'align' => 'L', // text alignement : R,C,L + 'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + */ + + $rank = 0; // do not use negative rank + $this->cols['desc'] = array( + 'rank' => $rank, + 'width' => false, // only for desc + 'status' => true, + 'title' => array( + 'textkey' => 'Designation', // use lang key is usefull in somme case with module + 'align' => 'L', + // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label + // 'label' => ' ', // the final label + 'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'content' => array( + 'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + ); + + $rank = $rank + 10; + $this->cols['photo'] = array( + 'rank' => $rank, + 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm + 'status' => false, + 'title' => array( + 'textkey' => 'Photo', + 'label' => ' ' + ), + 'content' => array( + 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left + ), + 'border-left' => false, // remove left line separator + ); + + if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto)) + { + $this->cols['photo']['status'] = true; + } + + $rank = $rank + 10; + $this->cols['weight'] = array( + 'rank' => $rank, + 'width' => 30, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'WeightVolShort' + ), + 'border-left' => true, // add left line separator + ); + + + $rank = $rank + 10; + $this->cols['subprice'] = array( + 'rank' => $rank, + 'width' => 19, // in mm + 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, + 'title' => array( + 'textkey' => 'PriceUHT' + ), + 'border-left' => true, // add left line separator + ); + + $rank = $rank + 10; + $this->cols['totalexcltax'] = array( + 'rank' => $rank, + 'width' => 26, // in mm + 'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0, + 'title' => array( + 'textkey' => 'TotalHT' + ), + 'border-left' => true, // add left line separator + ); + + $rank = $rank + 10; + $this->cols['qty_asked'] = array( + 'rank' => $rank, + 'width' => 30, // in mm + 'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0, + 'title' => array( + 'textkey' => 'QtyOrdered' + ), + 'border-left' => true, // add left line separator + 'content' => array( + 'align' => 'C', + ), + ); + + $rank = $rank + 10; + $this->cols['qty_shipped'] = array( + 'rank' => $rank, + 'width' => 30, // in mm + 'status' => true, + 'title' => array( + 'textkey' => 'QtyToShip' + ), + 'border-left' => true, // add left line separator + 'content' => array( + 'align' => 'C', + ), + ); + + // 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; + } --- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_19.0.3_pdf_merou.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_merou.modules.php @@ -40,2 +40,70 @@ - /** - * @var DoliDb Database handler + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe @@ -43,31 +111 @@ - 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; - - public $destinataire; - public $expediteur; - public $livreur; - - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; + public $emetteur; @@ -81 +119 @@ - public function __construct(DoliDB $db) + public function __construct($db = 0) @@ -83 +121 @@ - global $langs, $mysoc; + global $conf, $langs, $mysoc; @@ -88 +125,0 @@ - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template @@ -95,4 +132,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; @@ -104,3 +141 @@ - 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 @@ -110 +145 @@ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -114 +149 @@ - * @param Expedition $object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) @@ -116,5 +151,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 @@ -124 +159 @@ - // phpcs:enable + // phpcs:enable @@ -129,3 +164 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -133,3 +166 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -140 +171,2 @@ - if ($conf->expedition->dir_output) { + if ($conf->expedition->dir_output) + { @@ -150,4 +182,2 @@ - $this->destinataire = new Contact($this->db); - if (!empty($idcontact[0])) { - $this->destinataire->fetch($idcontact[0]); - } + $this->destinataire = new Contact($this->db); + if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]); @@ -158,3 +188 @@ - if (!empty($idcontact[0])) { - $this->livreur->fetch($idcontact[0]); - } + if (!empty($idcontact[0])) $this->livreur->fetch($idcontact[0]); @@ -163 +191,2 @@ - if ($object->specimen) { + if ($object->specimen) + { @@ -166 +195,3 @@ - } else { + } + else + { @@ -172,2 +203,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -179 +212,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -181 +215,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -195,17 +230,17 @@ - $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; - } - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -217,3 +252 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -226,3 +259 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -241,3 +272,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 = $this->page_hauteur - $tab_top - $heightforfooter; + $tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter; @@ -246 +277,2 @@ - if (!empty($object->note_public)) { + if (!empty($object->note_public)) + { @@ -258 +290,3 @@ - } else { + } + else + { @@ -273 +307,2 @@ - for ($i = 0; $i < $num; $i++) { + for ($i = 0; $i < $num; $i++) + { @@ -293,2 +328 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -316 +350,2 @@ - if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + { @@ -327 +362,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -329 +365,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -331 +368,3 @@ - } else { + } + else + { @@ -339,2 +378,4 @@ - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) + { + if ($pagenb == 1) + { @@ -342 +383,3 @@ - } else { + } + else + { @@ -353 +396,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -356 +400,3 @@ - } else { + } + else + { @@ -363,3 +409 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -372 +416,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -380,6 +425,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)); @@ -390 +437,3 @@ - } else { + } + else + { @@ -394 +443,3 @@ - } else { + } + else + { @@ -404 +455 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -419,3 +470,4 @@ - $langs->loadLangs(array("main", "bills", "orders")); - - if (empty($hidetop)) { + $langs->loadLangs(array("main", "bills")); + + if (empty($hidetop)) + { @@ -444,3 +496,3 @@ - * - * @param TCPDF $pdf PDF - * @param Expedition $object Object to show + * + * @param PDF $pdf PDF + * @param Object $object Object to show @@ -463,5 +515,5 @@ - //if (pdf_getPDFFont($outputlangs) == 'Helvetica') - //{ - // $pdf->SetXY(-10,-10); - // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); - //} + //if (pdf_getPDFFont($outputlangs) == 'Helvetica') + //{ + // $pdf->SetXY(-10,-10); + // $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0); + //} @@ -474,2 +526,2 @@ - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object to show + * @param PDF $pdf Object PDF + * @param Object $object Object to show @@ -478 +530 @@ - * @return int Return integer <0 if KO, > if OK + * @return void @@ -488,7 +540,8 @@ - //Affiche le filigrane brouillon - Print Draft Watermark - if ($object->statut == 0 && (getDolGlobalString('SENDING_DRAFT_WATERMARK'))) { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK); - } - - $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; + //Affiche le filigrane brouillon - Print Draft Watermark + if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK))) + { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK); + } + + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; @@ -506,4 +559,7 @@ - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity]; + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) @@ -511,9 +567,2 @@ - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto) - } else { + else + { @@ -525 +574,3 @@ - } else { + } + else + { @@ -550 +601 @@ - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1); + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size - 1, $hookmanager); @@ -575 +626,2 @@ - if ($object->thirdparty->code_client) { + if ($object->thirdparty->code_client) + { @@ -589 +641 @@ - $pdf->MultiCell(70, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, 'day', false, $outputlangs, true), '', 'L'); @@ -594 +646 @@ - $pdf->MultiCell(70, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L'); + $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L'); @@ -601 +653,2 @@ - if (!empty($object->tracking_number)) { + if (!empty($object->tracking_number)) + { @@ -603,2 +656,4 @@ - if (!empty($object->tracking_url)) { - if ($object->shipping_method_id > 0) { + if (!empty($object->tracking_url)) + { + if ($object->shipping_method_id > 0) + { @@ -611 +666,2 @@ - if ($object->tracking_url != $object->tracking_number) { + if ($object->tracking_url != $object->tracking_number) + { @@ -619 +675,3 @@ - } else { + } + else + { @@ -636 +694,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -642 +701,2 @@ - if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || getDolGlobalString('MAIN_USE_COMPANY_NAME_OF_CONTACT')))) { + // You can use the name of the contact company + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { @@ -655,12 +714,0 @@ - - $widthrecbox = $blW; - - $top_shift = 0; - // Show list of linked objects - /* - $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) { - $top_shift = $pdf->getY() - $current_y; - } - */ @@ -685,2 +732,0 @@ - - return $top_shift; --- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_19.0.3_pdf_rouget.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_rouget.modules.php @@ -6 +6 @@ - * Copyright (C) 2018-2023 Frédéric France + * Copyright (C) 2018 Frédéric France @@ -40,2 +40,70 @@ - /** - * @var DoliDb Database handler + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ + public $version = 'dolibarr'; + + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ + public $marge_gauche; + + /** + * @var int marge_droite + */ + public $marge_droite; + + /** + * @var int marge_haute + */ + public $marge_haute; + + /** + * @var int marge_basse + */ + public $marge_basse; + + /** + * Issuer + * @var Societe object that emits @@ -43,31 +111 @@ - 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 $posxweightvol; - public $posxqtytoship; - public $posxqtyordered; + public $emetteur; @@ -81 +119 @@ - public function __construct(DoliDB $db) + public function __construct($db = 0) @@ -87,2 +125 @@ - $this->description = $langs->trans("DocumentModelStandardPDF").' ('.$langs->trans("OldImplementation").')'; - $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template + $this->description = $langs->trans("DocumentModelStandardPDF"); @@ -95,4 +132,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; @@ -101,2 +137,0 @@ - $this->option_draft_watermark = 1; // Support add of a watermark on drafts - $this->watermark = ''; @@ -106,3 +141 @@ - 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 @@ -112,2 +145,2 @@ - $this->posxweightvol = $this->page_largeur - $this->marge_droite - 82; - $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 60; + $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; + $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56; @@ -117 +150 @@ - if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) { // Show also the prices + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { // Show also the prices @@ -125,18 +158,16 @@ - if (getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) { - $this->posxweightvol = $this->posxqtyordered; - } - - $this->posxpicture = $this->posxweightvol - (!getDolGlobalString('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - - // To work with US executive format - if ($this->page_largeur < 210) { - $this->posxweightvol -= 20; - $this->posxpicture -= 20; - $this->posxqtyordered -= 20; - $this->posxqtytoship -= 20; - } - - if (getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) { - $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); - $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); - $this->posxqtyordered = $this->posxqtytoship; + if (!empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqtyordered; + + $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images + + // To work with US executive format + if ($this->page_largeur < 210) { + $this->posxweightvol -= 20; + $this->posxpicture -= 20; + $this->posxqtyordered -= 20; + $this->posxqtytoship -= 20; + } + + if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { + $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); + $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); + $this->posxqtyordered = $this->posxqtytoship; @@ -150 +181 @@ - * @param Expedition $object Object expedition to generate (or id if old method) + * @param Object $object Object expedition to generate (or id if old method) @@ -152,5 +183,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 @@ -165,3 +196 @@ - if (!is_object($outputlangs)) { - $outputlangs = $langs; - } + if (!is_object($outputlangs)) $outputlangs = $langs; @@ -169,3 +198 @@ - if (getDolGlobalString('MAIN_USE_FPDF')) { - $outputlangs->charset_output = 'ISO-8859-1'; - } + if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1'; @@ -174,6 +201 @@ - $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "other")); - - // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) { - $this->watermark = $conf->global->SHIPPING_DRAFT_WATERMARK; - } + $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); @@ -183,9 +205,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; @@ -195 +217,2 @@ - if (getDolGlobalInt('PRODUCT_USE_OLD_PATH_FOR_PHOTO')) { + if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) + { @@ -198 +221,3 @@ - } else { + } + else + { @@ -205,27 +230,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->expedition->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->expedition->dir_output) + { @@ -233 +260,2 @@ - if ($object->specimen) { + if ($object->specimen) + { @@ -236 +264,3 @@ - } else { + } + else + { @@ -242,2 +272,4 @@ - if (!file_exists($dir)) { - if (dol_mkdir($dir) < 0) { + if (!file_exists($dir)) + { + if (dol_mkdir($dir) < 0) + { @@ -249 +281,2 @@ - if (file_exists($dir)) { + if (file_exists($dir)) + { @@ -251 +284,2 @@ - if (!is_object($hookmanager)) { + if (!is_object($hookmanager)) + { @@ -266,17 +300,17 @@ - $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; - } - $pdf->SetAutoPageBreak(1, 0); - - if (class_exists('TCPDF')) { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + $pdf->SetAutoPageBreak(1, 0); + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } @@ -288,3 +322 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -297,3 +329 @@ - if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) { - $pdf->SetCompression(false); - } + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); @@ -305,3 +335 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -315,3 +343,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; @@ -321 +349,2 @@ - if (isModEnabled('incoterm')) { + if ($conf->incoterm->enabled) + { @@ -323,2 +352,3 @@ - if ($desc_incoterms) { - $tab_top -= 2; + if ($desc_incoterms) + { + $tab_top = 88; @@ -340 +370,2 @@ - if (!empty($object->note_public) || !empty($object->tracking_number)) { + if (!empty($object->note_public) || !empty($object->tracking_number)) + { @@ -345 +376,3 @@ - + $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); + + $tab_top_alt = $pdf->GetY(); @@ -349,4 +382,2 @@ - if (!empty($object->tracking_number)) { - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); - + if (!empty($object->tracking_number)) + { @@ -354,2 +385,4 @@ - if (!empty($object->tracking_url)) { - if ($object->shipping_method_id > 0) { + if (!empty($object->tracking_url)) + { + if ($object->shipping_method_id > 0) + { @@ -359,3 +392 @@ - if ($object->tracking_url != $object->tracking_number) { - $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; - } + if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans("LinkToTrackYourPackage")."
"; @@ -364 +395,2 @@ - if ($object->tracking_url != $object->tracking_number) { + if ($object->tracking_url != $object->tracking_number) + { @@ -377 +409,2 @@ - if (!empty($object->note_public)) { + if (!empty($object->note_public)) + { @@ -391 +424,3 @@ - } else { + } + else + { @@ -400 +435,2 @@ - for ($i = 0; $i < $nblines; $i++) { + for ($i = 0; $i < $nblines; $i++) + { @@ -407,3 +443 @@ - if (!empty($realpatharray[$i])) { - $imglinesize = pdf_getSizeForImage($realpatharray[$i]); - } + if (!empty($realpatharray[$i])) $imglinesize = pdf_getSizeForImage($realpatharray[$i]); @@ -420 +454,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 + { @@ -422,6 +457,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); @@ -433 +464 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -435 +466 @@ - } else { + else @@ -437,4 +468,4 @@ - } - } - - if (isset($imglinesize['width']) && isset($imglinesize['height'])) { + } + + if (isset($imglinesize['width']) && isset($imglinesize['height'])) + { @@ -454 +485,2 @@ - if ($pageposafter > $pageposbefore) { // There is a pagebreak + if ($pageposafter > $pageposbefore) // There is a pagebreak + { @@ -464,2 +496,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 + { @@ -467,6 +501,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); @@ -475 +505,3 @@ - } else { + } + else + { @@ -479 +511 @@ - if (getDolGlobalString('MAIN_PDF_DATA_ON_FIRST_PAGE')) { + if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) @@ -481 +513 @@ - } else { + else @@ -483 +514,0 @@ - } @@ -485 +516,3 @@ - } else { // No pagebreak + } + else // No pagebreak + { @@ -499,2 +532 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -505,2 +537 @@ - $pdf->setPage($pageposafter); - $curY = $tab_top_newpage; + $pdf->setPage($pageposafter); $curY = $tab_top_newpage; @@ -513 +544,2 @@ - if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight) { + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) + { @@ -517 +549,2 @@ - if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume) { + if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) + { @@ -521 +554,2 @@ - if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) { + if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) + { @@ -526,6 +560,8 @@ - if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) { - $pdf->SetXY($this->posxqtyordered, $curY); - $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); - } - - if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) { + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) + { + $pdf->SetXY($this->posxqtyordered, $curY); + $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C'); + } + + if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) + { @@ -536 +572,2 @@ - if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) { + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) + { @@ -545,3 +582 @@ - if ($weighttxt && $voltxt) { - $nexY += 2; - } + if ($weighttxt && $voltxt) $nexY += 2; @@ -550 +585,2 @@ - if (getDolGlobalString('MAIN_PDF_DASH_BETWEEN_LINES') && $i < ($nblines - 1)) { + if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) + { @@ -559 +595,2 @@ - while ($pagenb < $pageposafter) { + while ($pagenb < $pageposafter) + { @@ -561 +598,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -563 +601,3 @@ - } else { + } + else + { @@ -570,2 +610,7 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); + } + if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); @@ -573,8 +618,2 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } - } - if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { - if ($pagenb == 1) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + else + { @@ -586,3 +625 @@ - if (!empty($tplidx)) { - $pdf->useTemplate($tplidx); - } + if (!empty($tplidx)) $pdf->useTemplate($tplidx); @@ -590,3 +627 @@ - if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { - $this->_pagehead($pdf, $object, 0, $outputlangs); - } + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); @@ -597 +632,2 @@ - if ($pagenb == 1) { + if ($pagenb == 1) + { @@ -600 +636,3 @@ - } else { + } + else + { @@ -610,3 +648 @@ - if (method_exists($pdf, 'AliasNbPages')) { - $pdf->AliasNbPages(); - } + if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); @@ -623,3 +659,4 @@ - if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + if ($reshook < 0) + { + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; @@ -628 +665,2 @@ - dolChmod($file); + if (!empty($conf->global->MAIN_UMASK)) + @chmod($file, octdec($conf->global->MAIN_UMASK)); @@ -633 +671,3 @@ - } else { + } + else + { @@ -637 +677,3 @@ - } else { + } + else + { @@ -648,2 +690,2 @@ - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object invoice + * @param PDF $pdf Object PDF + * @param Facture $object Object invoice @@ -660,3 +702,3 @@ - $sign = 1; - - $default_font_size = pdf_getPDFFontSize($outputlangs); + $sign = 1; + + $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -669,2 +711 @@ - $col1x = $this->posxweightvol - 50; - $col2x = $this->posxweightvol; + $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; @@ -675,5 +716,2 @@ - if (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) { - $largcol2 = ($this->posxqtyordered - $this->posxweightvol); - } else { - $largcol2 = ($this->posxqtytoship - $this->posxweightvol); - } + if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxqtyordered - $this->posxweightvol); + else $largcol2 = ($this->posxqtytoship - $this->posxweightvol); @@ -694,41 +732,38 @@ - if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); - $object->volume_units = $object->size_units * 3; - } - - if (!empty($totalWeight)) { - $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs, -1, 'no', 1); - } - if (!empty($totalVolume)) { - $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs, -1, 'no', 1); - } - if (!empty($object->trueWeight)) { - $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); - } - if (!empty($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 (!getDolGlobalString('SHIPPING_PDF_HIDE_ORDERED')) { - $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); - } - - if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) { - $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1); - } - - if (getDolGlobalString('SHIPPING_PDF_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); - } - - if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) { + if ($object->trueWidth && $object->trueHeight && $object->trueDepth) + { + $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0); + $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->SHIPPING_PDF_HIDE_ORDERED)) + { + $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1); + } + + if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) + { + $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->SHIPPING_PDF_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); + } + + if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) + { @@ -736,15 +771,15 @@ - 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++; - } + 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++; @@ -762 +797 @@ - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF @@ -777,3 +812 @@ - if ($hidetop) { - $hidetop = -1; - } + if ($hidetop) $hidetop = -1; @@ -793 +826,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -800 +834,2 @@ - if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) { + if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME)) + { @@ -802 +837,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -808,9 +844,12 @@ - if (!getDolGlobalString('SHIPPING_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'); - } - } - - if (!getDolGlobalString('SHIPPING_PDF_HIDE_QTYTOSHIP')) { + if (empty($conf->global->SHIPPING_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'); + } + } + + if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP)) + { @@ -818 +857,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -822,3 +862,3 @@ - } - - if (getDolGlobalString('SHIPPING_PDF_DISPLAY_AMOUNT_HT')) { + } + + if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) { @@ -826 +866,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -832 +873,2 @@ - if (empty($hidetop)) { + if (empty($hidetop)) + { @@ -843,2 +885,2 @@ - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object to show + * @param PDF $pdf Object PDF + * @param Object $object Object to show @@ -847 +889 @@ - * @return int Return integer <0 if KO, > if OK + * @return void @@ -858,0 +901,6 @@ + // Show Draft Watermark + if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) + { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); + } + @@ -871,14 +919,10 @@ - if ($this->emetteur->logo) { - $logodir = $conf->mycompany->dir_output; - if (!empty($conf->mycompany->multidir_output[$object->entity])) { - $logodir = $conf->mycompany->multidir_output[$object->entity]; - } - if (!getDolGlobalInt('MAIN_PDF_USE_LARGE_LOGO')) { - $logo = $logodir.'/logos/thumbs/'.$this->emetteur->logo_small; - } else { - $logo = $logodir.'/logos/'.$this->emetteur->logo; - } - if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + 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 +934,3 @@ - } else { + } + else + { @@ -896 +942,2 @@ - if (isModEnabled('barcode')) { + if (!empty($conf->barcode->enabled)) + { @@ -898 +945,3 @@ - } else { + } + else + { @@ -902 +951,2 @@ - if (isModEnabled('barcode')) { + if (!empty($conf->barcode->enabled)) + { @@ -908,0 +959,7 @@ + if (!empty($conf->barcode->enabled)) + { + // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref + //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); + //$pdf->Image($logo,10, 5, 0, 24); + } + @@ -928,8 +985,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 (!getDolGlobalString('MAIN_PDF_HIDE_CUSTOMER_CODE') && !empty($object->thirdparty->code_client)) { + 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_client)) + { @@ -950,2 +1009,3 @@ - // TODO move to external function - if (!empty($conf->$origin->enabled)) { // commonly $origin='commande' + // TODO move to external function + if (!empty($conf->$origin->enabled)) // commonly $origin='commande' + { @@ -957,2 +1017,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 +1023 @@ - if ($linkedobject->ref_client) { - $text .= ' ('.$linkedobject->ref_client.')'; - } + if ($linkedobject->ref_client) $text .= ' ('.$linkedobject->ref_client.')'; @@ -974,11 +1033,2 @@ - $top_shift = 0; - // Show list of linked objects - /* - $current_y = $pdf->getY(); - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3, 'R', $default_font_size); - if ($current_y < $pdf->getY()) { - $top_shift = $pdf->getY() - $current_y; - } - */ - - if ($showaddress) { + if ($showaddress) + { @@ -987 +1037 @@ - // Add internal contact of origin element if defined + // Add internal contact of origin element if defined @@ -989,16 +1039,8 @@ - if (!empty($origin) && is_object($object->$origin)) { - $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); - } - 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, '', 0, 'source', $object); + if (!empty($origin) && is_object($object->$origin)) $arrayidcontact = $object->$origin->getIdContact('internal', 'SALESREPFOLL'); + 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, '', 0, 'source', $object); @@ -1007 +1049 @@ - $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; + $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42; @@ -1009,6 +1051,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; @@ -1017,11 +1057,9 @@ - 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("Sender"), 0, 'L'); - $pdf->SetXY($posx, $posy); - $pdf->SetFillColor(230, 230, 230); - $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFillColor(255, 255, 255); - } + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + $pdf->SetXY($posx, $posy - 5); + $pdf->MultiCell(66, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); + $pdf->SetXY($posx, $posy); + $pdf->SetFillColor(230, 230, 230); + $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFillColor(255, 255, 255); @@ -1030,6 +1068,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, 'L'); - $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(); @@ -1046 +1082,2 @@ - if (count($arrayidcontact) > 0) { + if (count($arrayidcontact) > 0) + { @@ -1051,2 +1088,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)) { @@ -1063,5 +1101,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; @@ -1069,3 +1105 @@ - if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { - $posx = $this->marge_gauche; - } + if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche; @@ -1074,7 +1108,5 @@ - if (!getDolGlobalString('MAIN_PDF_NO_RECIPENT_FRAME')) { - $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); - $pdf->SetXY($posx + 2, $posy - 5); - $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Recipient"), 0, 'L'); - $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("Recipient").":", 0, 'L'); + $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); @@ -1096 +1127,0 @@ - return $top_shift; @@ -1102,3 +1133,3 @@ - * - * @param TCPDF $pdf PDF - * @param Expedition $object Object to show + * + * @param PDF $pdf PDF + * @param Object $object Object to show @@ -1111,2 +1142,3 @@ - $showdetails = getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0); - return pdf_pagefoot($pdf, $outputlangs, 'SHIPPING_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, 'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);