NEW Support option PDF_ADD_POSITION on shipment espadon template

This commit is contained in:
Laurent Destailleur 2024-10-14 22:38:51 +02:00
parent 1a5b5c6df4
commit 530fb167a2

View file

@ -98,6 +98,7 @@ class pdf_espadon extends ModelePdfExpedition
$this->description = $langs->trans("DocumentModelStandardPDF");
$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
// Dimension page
$this->type = 'pdf';
$formatarray = pdf_getFormat();
$this->page_largeur = $formatarray['width'];
@ -114,7 +115,7 @@ class pdf_espadon extends ModelePdfExpedition
// Get source company
$this->emetteur = $mysoc;
if (!$this->emetteur->country_code) {
if (empty($this->emetteur->country_code)) {
$this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
}
@ -189,9 +190,9 @@ class pdf_espadon extends ModelePdfExpedition
$realpath = '';
$arephoto = false;
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 (!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 {
@ -202,11 +203,12 @@ class pdf_espadon extends ModelePdfExpedition
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
break;
}
if ($realpath) {
if ($realpath && $arephoto) {
$realpatharray[$i] = $realpath;
}
}
@ -328,7 +330,7 @@ class pdf_espadon extends ModelePdfExpedition
}
}
// Public note and Tracking code
// Displays notes. Here we are still on code executed only for the first page.
$notetoshow = empty($object->note_public) ? '' : $object->note_public;
// Extrafields in note
@ -582,6 +584,10 @@ class pdf_espadon extends ModelePdfExpedition
$posYAfterDescription = 0;
$heightforsignature = 0;
if ($this->getColumnStatus('position')) {
$this->printStdColumnContent($pdf, $curY, 'position', (string) ($i + 1));
}
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
@ -1282,6 +1288,24 @@ class pdf_espadon extends ModelePdfExpedition
*/
$rank = 0; // do not use negative rank
$this->cols['position'] = array(
'rank' => $rank,
'width' => 10,
'status' => getDolGlobalInt('PDF_ESPADON_ADD_POSITION') ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false),
'title' => array(
'textkey' => '#', // use lang key is useful in somme case with module
'align' => 'C',
// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
// 'label' => ' ', // the final label
'padding' => array(0.5, 0.5, 0.5, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'C',
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
$rank = 5; // do not use negative rank
$this->cols['desc'] = array(
'rank' => $rank,
'width' => false, // only for desc
@ -1291,14 +1315,15 @@ class pdf_espadon extends ModelePdfExpedition
'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
'padding' => array(0.5, 0.5, 0.5, 0.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
'align' => 'L',
'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
// Image of product
$rank += 10;
$this->cols['photo'] = array(
'rank' => $rank,