--- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_doc_generic_shipment_odt.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_doc_generic_shipment_odt.modules.php
@@ -47,15 +47,15 @@
public $emetteur;
/**
- * @var array Minimum version of PHP required by module.
- * e.g.: PHP ≥ 5.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
+ * @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
- */
+ * Dolibarr version of the loaded document
+ * @var string
+ */
public $version = 'dolibarr';
@@ -64,12 +64,12 @@
*
* @param DoliDB $db Database handler
*/
- public function __construct($db)
+ public function __construct($db)
{
global $conf, $langs, $mysoc;
// Load translation files required by the page
- $langs->loadLangs(array("main", "companies"));
+ $langs->loadLangs(array("main", "companies"));
$this->db = $db;
$this->name = "ODT templates";
@@ -109,12 +109,12 @@
* @param Translate $langs Lang object to use for output
* @return string Description
*/
- public function info($langs)
+ public function info($langs)
{
global $conf, $langs;
// Load translation files required by the page
- $langs->loadLangs(array("errors", "companies"));
+ $langs->loadLangs(array("errors", "companies"));
$form = new Form($this->db);
@@ -138,7 +138,8 @@
unset($listofdir[$key]); continue;
}
if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0);
- else {
+ else
+ {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)');
if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles);
}
@@ -169,18 +170,18 @@
}
if ($nbofiles)
{
- $texte .= '
';
- // Show list of found files
- foreach ($listoffiles as $file) {
- $texte .= '- '.$file['name'].'
'.img_picto('', 'listlight').'';
+ $texte .= '
';
+ foreach ($listoffiles as $file)
+ {
+ $texte .= $file['name'].'
';
}
$texte .= '
';
}
- // Add input to upload a new template file.
- $texte .= '
'.$langs->trans("UploadNewTemplate").' ';
- $texte .= '';
- $texte .= '';
- $texte .= '
';
+ // Add input to upload a new template file.
+ $texte .= '
'.$langs->trans("UploadNewTemplate").' ';
+ $texte .= '';
+ $texte .= '';
+ $texte .= '
';
$texte .= '';
$texte .= '
';
@@ -194,7 +195,7 @@
return $texte;
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build a document on disk using the generic odt module.
*
@@ -206,9 +207,9 @@
* @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO
*/
- 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)
{
- // phpcs:enable
+ // phpcs:enable
global $user, $langs, $conf, $mysoc, $hookmanager;
if (empty($srctemplatepath))
@@ -247,8 +248,6 @@
return -1;
}
}
-
- $object->fetch_thirdparty();
$dir = $conf->expedition->dir_output."/sending";
$objectref = dol_sanitizeFileName($object->ref);
@@ -277,10 +276,12 @@
$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
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';
+ $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 {
+ }
+ else
+ {
$filename = $newfiletmp.'.'.$newfileformat;
}
$file = $dir.'/'.$filename;
@@ -304,11 +305,12 @@
// Recipient name
$contactobject = null;
if (!empty($usecontact)) {
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
+ // On peut utiliser le nom de la societe du contact
+ if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT))
$socobject = $object->contact;
- } else {
+ else {
$socobject = $object->thirdparty;
- // if we have a SHIPPING contact and we dont use as 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
$contactobject = $object->contact;
}
} else {
@@ -321,7 +323,7 @@
'__FROM_EMAIL__' => $this->emetteur->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
- '__TOTAL_VAT__' => $object->total_tva
+ '__TOTAL_VAT__' => $object->total_vat
);
complete_substitutions_array($substitutionarray, $langs, $object);
// Call the ODTSubstitution hook
@@ -339,7 +341,7 @@
// Open and load template
require_once ODTPHP_PATH.'odf.php';
try {
- $odfHandler = new odf(
+ $odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->expedition->dir_temp,
@@ -348,7 +350,8 @@
'DELIMITER_RIGHT' => '}'
)
);
- } catch (Exception $e)
+ }
+ catch (Exception $e)
{
$this->error = $e->getMessage();
dol_syslog($e->getMessage(), LOG_INFO);
@@ -364,7 +367,8 @@
// Make substitutions into odt of freetext
try {
$odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@@ -380,13 +384,15 @@
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Make substitutions into odt of mysoc
@@ -400,21 +406,23 @@
//var_dump($value);exit;
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Make substitutions into odt of thirdparty
- if ($socobject->element == 'contact') {
- $tmparray = $this->get_substitutionarray_contact($socobject, $outputlangs);
- } else {
- $tmparray = $this->get_substitutionarray_thirdparty($socobject, $outputlangs);
- }
+ 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 {
@@ -422,13 +430,15 @@
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
@@ -441,20 +451,21 @@
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
}
// Replace tags of object + external modules
$tmparray = $this->get_substitutionarray_shipment($object, $outputlangs);
-
complete_substitutions_array($tmparray, $outputlangs, $object);
// Call the ODTSubstitution hook
$parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray);
@@ -466,21 +477,25 @@
{
if (file_exists($value)) $odfHandler->setImage($key, $value);
else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8');
- } else // Text
+ }
+ else // Text
{
$odfHandler->setVars($key, $value, true, 'UTF-8');
}
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
// Replace tags of lines
- try {
+ try
+ {
$foundtagforlines = 1;
try {
$listlines = $odfHandler->setSegment('lines');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
@@ -497,12 +512,15 @@
$reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
foreach ($tmparray as $key => $val)
{
- try {
+ try
+ {
$listlines->setVars($key, $val, true, 'UTF-8');
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
- } catch (SegmentException $e)
+ }
+ catch (SegmentException $e)
{
dol_syslog($e->getMessage(), LOG_INFO);
}
@@ -511,7 +529,8 @@
}
$odfHandler->mergeSegment($listlines);
}
- } catch (OdfException $e)
+ }
+ catch (OdfException $e)
{
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);
@@ -524,9 +543,10 @@
{
try {
$odfHandler->setVars($key, $value, true, 'UTF-8');
- } catch (OdfException $e)
- {
- dol_syslog($e->getMessage(), LOG_INFO);
+ }
+ catch (OdfException $e)
+ {
+ dol_syslog($e->getMessage(), LOG_INFO);
}
}
@@ -540,15 +560,16 @@
$odfHandler->exportAsAttachedPDF($file);
} catch (Exception $e) {
$this->error = $e->getMessage();
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
- } else {
- try {
- $odfHandler->saveToDisk($file);
+ }
+ else {
+ try {
+ $odfHandler->saveToDisk($file);
} catch (Exception $e) {
$this->error = $e->getMessage();
- dol_syslog($e->getMessage(), LOG_INFO);
+ dol_syslog($e->getMessage(), LOG_INFO);
return -1;
}
}
@@ -563,7 +584,9 @@
$this->result = array('fullpath'=>$file);
return 1; // Success
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return -1;
}
--- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_pdf_espadon.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_espadon.modules.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,71 +36,71 @@
*/
class pdf_espadon extends ModelePdfExpedition
{
- /**
- * @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.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
+ /**
+ * @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
- */
+ * @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
- */
+ * @var int marge_droite
+ */
public $marge_droite;
/**
- * @var int marge_haute
- */
+ * @var int marge_haute
+ */
public $marge_haute;
/**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
/**
@@ -146,13 +146,13 @@
/**
* Function to build pdf onto disk
*
- * @param Expedition $object Object expedition to generate (or id if old method)
+ * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ * @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
*/
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
@@ -166,76 +166,83 @@
if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
// Load traductions files required by page
- $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch"));
-
- global $outputlangsbis;
- $outputlangsbis = null;
+ $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;
$outputlangsbis = new Translate('', $conf);
$outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
- $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"));
}
$nblines = count($object->lines);
- // 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;
+ // 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);
$objphoto->fetch($object->lines[$i]->fk_product);
- if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
+ 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/";
- $dir = $conf->product->dir_output.'/'.$pdir;
- } else {
- $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
+ $pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product') . $object->lines[$i]->fk_product ."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
}
+ else
+ {
+ $pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product') . dol_sanitizeFileName($objphoto->ref).'/';
+ $dir = $conf->product->dir_output.'/'.$pdir;
+ }
$realpath = '';
- 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'];
- }
+ 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;
$this->atleastonephoto = true;
- break;
- }
-
- if ($realpath) $realpatharray[$i] = $realpath;
- }
- }
-
- if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
+ break;
+ }
+
+ if ($realpath) $realpatharray[$i] = $realpath;
+ }
+ }
+
+ if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
if ($conf->expedition->dir_output)
{
- // Definition of $dir and $file
+ // Definition of $dir and $file
if ($object->specimen)
{
$dir = $conf->expedition->dir_output."/sending";
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output."/sending/".$expref;
$file = $dir."/".$expref.".pdf";
@@ -269,23 +276,23 @@
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if (!empty($conf->global->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 (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->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);
+ }
$pdf->Open();
$pagenb = 0;
@@ -316,11 +323,11 @@
$tab_height = 130;
$tab_height_newpage = 150;
- $this->posxdesc = $this->marge_gauche + 1;
+ $this->posxdesc = $this->marge_gauche + 1;
// Incoterm
$height_incoterms = 0;
- if (!empty($conf->incoterm->enabled))
+ if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
@@ -341,15 +348,15 @@
}
}
- // 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);
- }
+ // 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))
{
@@ -392,7 +399,7 @@
// Notes
if (!empty($notetoshow))
{
- $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
+ $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);
}
@@ -405,7 +412,9 @@
$tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6;
- } else {
+ }
+ else
+ {
$height_note = 0;
}
@@ -442,69 +451,74 @@
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;
+ // 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;
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
- }
-
-
- 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'];
- }
+ else
+ $showpricebeforepagebreak = 0;
+ }
+
+
+ if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
+ {
+ $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+ // $pdf->Image does not increase value return by getY, so we save it manually
+ $posYAfterImage = $curY + $imglinesize['height'];
+ }
}
// Description of product line
if ($this->getColumnStatus('desc'))
{
- $pdf->startTransaction();
-
- $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
- $pageposafter = $pdf->getPage();
- if ($pageposafter > $pageposbefore) // There is a pagebreak
- {
- $pdf->rollbackTransaction(true);
-
- $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
+ $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
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
- }
- } else // No pagebreak
- {
- $pdf->commitTransaction();
- }
- $posYAfterDescription = $pdf->GetY();
+ else
+ $showpricebeforepagebreak = 0;
+ }
+ }
+ else // No pagebreak
+ {
+ $pdf->commitTransaction();
+ }
+ $posYAfterDescription = $pdf->GetY();
}
$nexY = $pdf->GetY();
@@ -542,39 +556,39 @@
if ($this->getColumnStatus('weight'))
{
- $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? ' ' : '').$voltxt, array('html'=>1));
- $nexY = max($pdf->GetY(), $nexY);
+ $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);
+ $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);
+ $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);
- }
- }
- }
+ $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);
+ }
+ }
+ }
// Add line
if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
@@ -593,7 +607,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -607,7 +623,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -624,7 +642,9 @@
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@@ -647,8 +667,8 @@
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
}
if (!empty($conf->global->MAIN_UMASK))
@@ -657,11 +677,15 @@
$this->result = array('fullpath'=>$file);
return 1; // No error
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0;
}
@@ -672,8 +696,8 @@
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
- * @param Expedition $object Object expedition
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
* @param int $deja_regle Amount already paid
* @param int $posy Start Position
* @param Translate $outputlangs Objet langs
@@ -684,9 +708,9 @@
// phpcs:enable
global $conf, $mysoc;
- $sign = 1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $sign = 1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
$tab2_hl = 4;
@@ -716,8 +740,8 @@
// Set trueVolume and volume_units not currently stored into database
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;
+ $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);
@@ -728,40 +752,40 @@
- if ($this->getColumnStatus('desc'))
- {
- $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
- }
+ 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 ($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);
+ $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered);
}
if ($this->getColumnStatus('qty_shipped') && $totalToShip)
{
- $this->printStdColumnContent($pdf, $tab2_top, '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));
+ $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs));
}
$pdf->SetTextColor(0, 0, 0);
@@ -773,7 +797,7 @@
/**
* Show table for lines
*
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y
@@ -815,7 +839,7 @@
$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
if (empty($hidetop)) {
- $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
}
}
@@ -823,8 +847,8 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Expedition $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
@@ -842,7 +866,7 @@
// 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);
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
}
//Prepare next
@@ -862,15 +886,19 @@
{
if (is_readable($logo))
{
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -879,7 +907,9 @@
if (!empty($conf->barcode->enabled))
{
$posx = 105;
- } else {
+ }
+ else
+ {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
@@ -919,10 +949,10 @@
// Date planned delivery
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');
+ $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))
@@ -941,7 +971,7 @@
$origin = $object->origin;
$origin_id = $object->origin_id;
- // TODO move to external function
+ // TODO move to external function
if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{
$outputlangs->load('orders');
@@ -951,7 +981,7 @@
$result = $linkedobject->fetch($origin_id);
if ($result >= 0)
{
- //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+ //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2);
$text = $linkedobject->ref;
@@ -1020,8 +1050,9 @@
$result = $object->fetch_contact($arrayidcontact[0]);
}
- // Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->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)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -1064,9 +1095,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Expedition $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
@@ -1074,14 +1105,14 @@
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $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);
}
/**
* Define Array Column Field
*
- * @param Expedition $object common object
+ * @param object $object common object
* @param Translate $outputlangs langs
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
@@ -1090,21 +1121,21 @@
*/
public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
- global $conf, $hookmanager;
-
- // Default field style for content
- $this->defaultContentsFieldsStyle = array(
- 'align' => 'R', // R,C,L
- 'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- // Default field style for content
- $this->defaultTitlesFieldsStyle = array(
- 'align' => 'C', // R,C,L
- 'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
- );
-
- /*
+ 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
@@ -1122,128 +1153,131 @@
);
*/
- $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;
- }
+ $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_pdf_merou.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_merou.modules.php
@@ -37,71 +37,71 @@
*/
class pdf_merou extends ModelePdfExpedition
{
- /**
- * @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.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
+ /**
+ * @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
- */
+ * @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
- */
+ * @var int marge_droite
+ */
public $marge_droite;
/**
- * @var int marge_haute
- */
+ * @var int marge_haute
+ */
public $marge_haute;
/**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
/**
@@ -142,21 +142,21 @@
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Function to build pdf onto disk
*
- * @param Expedition $object Object expedition to generate (or id if old method)
+ * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ * @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
*/
public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $user, $conf, $langs, $mysoc, $hookmanager;
$object->fetch_thirdparty();
@@ -179,7 +179,7 @@
//Create recipient
$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
- $this->destinataire = new Contact($this->db);
+ $this->destinataire = new Contact($this->db);
if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
//Create deliverer
@@ -192,7 +192,9 @@
{
$dir = $conf->expedition->dir_output."/sending";
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output."/sending/".$expref;
$file = $dir."/".$expref.".pdf";
@@ -225,23 +227,23 @@
$pdf = pdf_getInstance($this->format, 'mm', 'l');
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 0; // Height reserved to output the info and total part
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if (!empty($conf->global->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 (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->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);
+ }
$pdf->Open();
$pagenb = 0;
@@ -285,7 +287,9 @@
$tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6;
- } else {
+ }
+ else
+ {
$height_note = 0;
}
@@ -361,7 +365,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -374,7 +380,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -389,7 +397,9 @@
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@@ -414,21 +424,25 @@
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
- }
-
- if (!empty($conf->global->MAIN_UMASK))
- @chmod($file, octdec($conf->global->MAIN_UMASK));
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
+ }
+
+ if (!empty($conf->global->MAIN_UMASK))
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
return 1;
- } else {
+ }
+ else
+ {
$this->error = $outputlangs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $outputlangs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0;
}
@@ -438,7 +452,7 @@
/**
* Show table for lines
*
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y
@@ -453,7 +467,7 @@
$default_font_size = pdf_getPDFFontSize($outputlangs);
// Translations
- $langs->loadLangs(array("main", "bills", "orders"));
+ $langs->loadLangs(array("main", "bills"));
if (empty($hidetop))
{
@@ -479,9 +493,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Expedition $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return void
@@ -498,19 +512,19 @@
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
// Show page nb only on iso languages (so default Helvetica font)
- //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);
+ //}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Expedition $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
@@ -526,11 +540,11 @@
//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;
+ 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;
$Xoff = 90;
$Yoff = 0;
@@ -547,15 +561,19 @@
{
if (is_readable($logo))
{
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
- } else {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell(70, 3, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -620,12 +638,12 @@
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetTextColor(0, 0, 0);
- $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');
$pdf->SetXY($blSocX - 80, $blSocY + 20);
$pdf->SetFont('', 'B', $default_font_size - 3);
$pdf->SetTextColor(0, 0, 0);
- $pdf->MultiCell(70, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
+ $pdf->MultiCell(50, 8, $outputlangs->transnoentities("TrackingNumber")." : ".$object->tracking_number, '', 'L');
// Deliverer
$pdf->SetXY($blSocX - 80, $blSocY + 23);
@@ -654,7 +672,9 @@
$pdf->writeHTMLCell(50, 8, '', '', $label, '', 'L');
}
}
- } else {
+ }
+ else
+ {
$pdf->MultiCell(50, 8, $outputlangs->transnoentities("Deliverer")." ".$outputlangs->convToOutputCharset($this->livreur->getFullName($outputlangs)), '', 'L');
}
@@ -678,7 +698,8 @@
}
// Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->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)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -691,8 +712,6 @@
$blDestX = $blExpX + 55;
$blW = 54;
$Yoff = $Ydef + 1;
-
- $widthrecbox = $blW;
// Show Recipient frame
$pdf->SetFont('', 'B', $default_font_size - 3);
--- /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/github_pdf_rouget.modules.php
+++ /tmp/dsg/dolibarr/htdocs/core/modules/expedition/doc/client_pdf_rouget.modules.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2012 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2014-2015 Marcos García
- * Copyright (C) 2018-2020 Frédéric France
+ * Copyright (C) 2018 Frédéric France
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,71 +37,71 @@
*/
class pdf_rouget extends ModelePdfExpedition
{
- /**
- * @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.6 = array(5, 6)
- */
- public $phpmin = array(5, 6);
-
- /**
- * Dolibarr version of the loaded document
- * @var string
- */
+ /**
+ * @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
- */
+ * @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
- */
+ * @var int marge_droite
+ */
public $marge_droite;
/**
- * @var int marge_haute
- */
+ * @var int marge_haute
+ */
public $marge_haute;
/**
- * @var int marge_basse
- */
+ * @var int marge_basse
+ */
public $marge_basse;
/**
@@ -142,8 +142,8 @@
// Define position of columns
$this->posxdesc = $this->marge_gauche + 1;
- $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;
$this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
$this->posxpuht = $this->page_largeur - $this->marge_droite;
@@ -159,18 +159,18 @@
$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;
- }
+ // 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;
+ $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
+ $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
+ $this->posxqtyordered = $this->posxqtytoship;
}
}
@@ -178,13 +178,13 @@
/**
* Function to build pdf onto disk
*
- * @param Expedition $object Object expedition to generate (or id if old method)
+ * @param Object $object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object
- * @param string $srctemplatepath Full path of source filename for generator using a template file
- * @param int $hidedetails Do not show line details
- * @param int $hidedesc Do not show desc
- * @param int $hideref Do not show ref
- * @return int 1=OK, 0=KO
+ * @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
*/
public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
@@ -202,15 +202,15 @@
$nblines = count($object->lines);
- // 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;
+ // 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;
$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);
@@ -218,35 +218,41 @@
{
$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 {
+ }
+ else
+ {
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$dir = $conf->product->dir_output.'/'.$pdir;
}
$realpath = '';
- 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;
+ 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)
{
@@ -255,7 +261,9 @@
{
$dir = $conf->expedition->dir_output."/sending";
$file = $dir."/SPECIMEN.pdf";
- } else {
+ }
+ else
+ {
$expref = dol_sanitizeFileName($object->ref);
$dir = $conf->expedition->dir_output."/sending/".$expref;
$file = $dir."/".$expref.".pdf";
@@ -289,23 +297,23 @@
$pdf = pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs);
$heightforinfotot = 8; // Height reserved to output the info and total part
- $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
- $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
- if (!empty($conf->global->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 (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
- {
- $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->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);
+ }
$pdf->Open();
$pagenb = 0;
@@ -338,7 +346,7 @@
// Incoterm
$height_incoterms = 0;
- if (!empty($conf->incoterm->enabled))
+ if ($conf->incoterm->enabled)
{
$desc_incoterms = $object->getIncotermsForPDF();
if ($desc_incoterms)
@@ -365,15 +373,14 @@
$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;
// Tracking number
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();
-
$object->getUrlTrackingStatus($object->tracking_number);
if (!empty($object->tracking_url))
{
@@ -414,7 +421,9 @@
$tab_height = $tab_height - $height_note;
$tab_top = $nexY + 6;
- } else {
+ }
+ else
+ {
$height_note = 0;
}
@@ -454,7 +463,8 @@
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
+ else
+ $showpricebeforepagebreak = 0;
}
if (isset($imglinesize['width']) && isset($imglinesize['height']))
@@ -492,15 +502,19 @@
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposafter + 1);
}
- } else {
+ }
+ else
+ {
// We found a page break
// Allows data in the first page if description is long enough to break in multiples pages
if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
$showpricebeforepagebreak = 1;
- else $showpricebeforepagebreak = 0;
+ else
+ $showpricebeforepagebreak = 0;
}
- } else // No pagebreak
+ }
+ else // No pagebreak
{
$pdf->commitTransaction();
}
@@ -527,12 +541,12 @@
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = '';
- if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight)
{
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
- if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume)
+ if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume)
{
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
@@ -545,8 +559,8 @@
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');
+ $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))
@@ -584,7 +598,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -598,7 +614,9 @@
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf, $object, $outputlangs, 1);
@@ -615,7 +633,9 @@
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
- } else {
+ }
+ else
+ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
@@ -638,8 +658,8 @@
$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0)
{
- $this->error = $hookmanager->error;
- $this->errors = $hookmanager->errors;
+ $this->error = $hookmanager->error;
+ $this->errors = $hookmanager->errors;
}
if (!empty($conf->global->MAIN_UMASK))
@@ -648,11 +668,15 @@
$this->result = array('fullpath'=>$file);
return 1; // No error
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
return 0;
}
- } else {
+ }
+ else
+ {
$this->error = $langs->transnoentities("ErrorConstantNotDefined", "EXP_OUTPUTDIR");
return 0;
}
@@ -663,8 +687,8 @@
/**
* Show total to pay
*
- * @param TCPDF $pdf Object PDF
- * @param Expedition $object Object invoice
+ * @param PDF $pdf Object PDF
+ * @param Facture $object Object invoice
* @param int $deja_regle Montant deja regle
* @param int $posy Position depart
* @param Translate $outputlangs Objet langs
@@ -675,9 +699,9 @@
// phpcs:enable
global $conf, $mysoc;
- $sign = 1;
-
- $default_font_size = pdf_getPDFFontSize($outputlangs);
+ $sign = 1;
+
+ $default_font_size = pdf_getPDFFontSize($outputlangs);
$tab2_top = $posy;
$tab2_hl = 4;
@@ -707,38 +731,38 @@
// Set trueVolume and volume_units not currently stored into database
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;
+ $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 (!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 (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 ($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);
+ $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))
@@ -746,17 +770,17 @@
// Total Weight
if ($totalWeighttoshow)
{
- $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
- $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
-
- $index++;
+ $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++;
+ $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++;
}
@@ -770,7 +794,7 @@
/**
* Show table for lines
*
- * @param TCPDF $pdf Object PDF
+ * @param PDF $pdf Object PDF
* @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle)
* @param int $nexY Y
@@ -817,25 +841,25 @@
}
}
- 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))
- {
+ 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))
+ {
$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
}
- }
+ }
if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
@@ -858,8 +882,8 @@
/**
* Show top header of page.
*
- * @param TCPDF $pdf Object PDF
- * @param Expedition $object Object to show
+ * @param PDF $pdf Object PDF
+ * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output
* @return void
@@ -877,7 +901,7 @@
// 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);
+ pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
}
//Prepare la suite
@@ -897,15 +921,19 @@
{
if (is_readable($logo))
{
- $height = pdf_getHeightForLogo($logo);
- $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
- } else {
+ $height = pdf_getHeightForLogo($logo);
+ $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+ }
+ else
+ {
$pdf->SetTextColor(200, 0, 0);
$pdf->SetFont('', 'B', $default_font_size - 2);
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
$pdf->MultiCell($w, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
}
- } else {
+ }
+ else
+ {
$text = $this->emetteur->name;
$pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
}
@@ -914,7 +942,9 @@
if (!empty($conf->barcode->enabled))
{
$posx = 105;
- } else {
+ }
+ else
+ {
$posx = $this->marge_gauche + 3;
}
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
@@ -954,10 +984,10 @@
// Date planned delivery
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');
+ $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))
@@ -976,7 +1006,7 @@
$origin = $object->origin;
$origin_id = $object->origin_id;
- // TODO move to external function
+ // TODO move to external function
if (!empty($conf->$origin->enabled)) // commonly $origin='commande'
{
$outputlangs->load('orders');
@@ -986,7 +1016,7 @@
$result = $linkedobject->fetch($origin_id);
if ($result >= 0)
{
- //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+ //$linkedobject->fetchObjectLinked() Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
$pdf->SetFont('', '', $default_font_size - 2);
$text = $linkedobject->ref;
@@ -1055,8 +1085,9 @@
$result = $object->fetch_contact($arrayidcontact[0]);
}
- // Recipient name
- if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->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)) {
$thirdparty = $object->contact;
} else {
$thirdparty = $object->thirdparty;
@@ -1099,9 +1130,9 @@
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Show footer of page. Need this->emetteur object
- *
- * @param TCPDF $pdf PDF
- * @param Expedition $object Object to show
+ *
+ * @param PDF $pdf PDF
+ * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
@@ -1109,7 +1140,7 @@
protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{
global $conf;
- $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+ $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);
}
}
|