From 7dad1ce5a126a12d62a2228993b41ca6f5a21ff6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 13:10:39 +0200 Subject: [PATCH 01/22] Module agenda is enabled by default --- htdocs/core/modules/modAgenda.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 1db2acde3d87b..3fb800731baab 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -74,6 +74,7 @@ public function __construct($db) $this->conflictwith = array(); // List of module class names as string this module is in conflict with $this->langfiles = array("companies","project"); $this->phpmin = array(7, 0); // Minimum version of PHP required by module + $this->enabled_bydefault = true; // Will be enabled during install // Module parts $this->module_parts = array(); From ba96924afdb7aaa1a5c814b4b030a66e13a8e00b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 13:13:06 +0200 Subject: [PATCH 02/22] Doc --- htdocs/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index d6af48f77fbab..dac6678384432 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -59,7 +59,7 @@ header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } -if ($nbmodulesnotautoenabled <= getDolGlobalString('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only user module enabled +if ($nbmodulesnotautoenabled <= getDolGlobalString('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only autoenabled modules (property ->enabled_bydefault in modules) are activated header("Location: ".DOL_URL_ROOT."/admin/index.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete"); exit; } From 3576127d65dc24f4e0975a0c93db9098618ec53e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 13:27:49 +0200 Subject: [PATCH 03/22] Complete tooltip of modules --- htdocs/admin/modulehelp.php | 10 ++++++++-- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 6c16bba00f545..bc0b433bfdf7a 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -366,10 +366,16 @@ $textexternal .= ($objMod->editor_name != 'dolibarr' ? ' - ' : '').img_picto('', 'globe').' '.$objMod->editor_url.''; } $text .= $textexternal; - $text .= '
'; } else { - $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core").'
'; + $text .= '
'.$langs->trans("Origin").': '.$langs->trans("Core"); + if (empty($objMod->numero)) { + $text .= '   ('.$langs->trans("AlwaysEnabled").')'; + } elseif (!empty($objMod->enabled_bydefault)) { + $text .= '   ('.$langs->trans("EnabledByDefaultAtInstall").')'; + } + $text .= '
'; } + $text .= '
'; $moduledesclong = $objMod->getDescLong(); if ($moduledesclong) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 364d08a90051c..69feebc3d081e 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2486,3 +2486,4 @@ TestWebhookTarget=Test triggerable event DataToSendTrigger=Data sent to Url SendToUrl=Send to Url WebsiteTemplateWasCopied=The website template(s) "%s" provided by this module has been saved into the directory of website templates (/doctemplates/websites) and is ready to be imported as a new web site. +EnabledByDefaultAtInstall=Enabled by default at install From dc8b79e0d4e3a9ac1eef56c1a5b8bb407d825cae Mon Sep 17 00:00:00 2001 From: atm-etienne <163015166+atm-etienne@users.noreply.github.com> Date: Wed, 22 May 2024 13:30:44 +0200 Subject: [PATCH 04/22] New classify billed order without invoice (#29614) * Add new conf in admin page for supplier order classify billed without invoice * Add translations en_US * Add check on new config to allow or not the classify billed button * Add possibility to set the hidden conf to disallow classify billed button from order, from the admin page * Update conf names and move code to right parts, according to PR returns --- ChangeLog | 2 +- htdocs/admin/invoice.php | 1 + htdocs/admin/order.php | 9 +++++++++ htdocs/admin/supplier_order.php | 8 ++++++++ htdocs/commande/card.php | 4 ++-- htdocs/fourn/commande/card.php | 2 +- htdocs/langs/en_US/admin.lang | 5 +++++ 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4056f0740a03..47794be259509 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9775,7 +9775,7 @@ For developers: - New: Can add a link on title field of added dictionary. - New: Uniformize code. - New: Add option WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER and - WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER. + ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER. - New: A module can add several css and js. - New: removed deprecated methods ldap::connect, formadmin::select_lang, diff --git a/htdocs/admin/invoice.php b/htdocs/admin/invoice.php index aa17b9cf8df72..cb50a2f15c0b1 100644 --- a/htdocs/admin/invoice.php +++ b/htdocs/admin/invoice.php @@ -826,6 +826,7 @@ print ajax_constantonoff('INVOICE_CHECK_POSTERIOR_DATE'); print ''; + // Allow external download print ''; print ''.$langs->trans("AllowExternalDownload").''; diff --git a/htdocs/admin/order.php b/htdocs/admin/order.php index 687c91f07dbe1..c4cbb354d7fd2 100644 --- a/htdocs/admin/order.php +++ b/htdocs/admin/order.php @@ -685,6 +685,15 @@ print ''; print ''; +// Disallow to classify billed an order without invoice, only if module invoice is enable +if (isModEnabled('invoice')) { + print ''.$langs->trans("InvoiceClassifyBilledSupplierOrderWithoutInvoice"). ' ' ; + print $form->textwithpicto('', $langs->trans("InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp"), 1, 'help') . ''; + print ''; + print ajax_constantonoff('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER'); + print ''; +} + /* // Seems to be not so used. So kept hidden for the moment to avoid dangerous options inflation. // TODO Must be implemented by PDF templates diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index a3eb2dd468d7a..1fee99724e471 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -547,6 +547,14 @@ print "\n"; print "\n"; + +// Disallow to classify billed a supplier order without invoice +print ''.$langs->trans("SupplierOrderClassifyBilledWithoutInvoice"). ' ' ; +print $form->textwithpicto('', $langs->trans("SupplierOrderClassifyBilledWithoutInvoiceHelp"), 1, 'help') . ''; +print ''; +print ajax_constantonoff('SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER'); +print ''; + print '
'; print ''; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 53812891f11cd..37f228b8ada88 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -3055,12 +3055,12 @@ // Set billed or unbilled // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" if ($object->statut > Commande::STATUS_DRAFT && !$object->billed && $object->total_ttc >= 0) { - if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { print dolGetButtonAction('', $langs->trans('ClassifyBilled'), 'default', $_SERVER["PHP_SELF"].'?action=classifybilled&token='.newToken().'&id='.$object->id, ''); } } if ($object->statut > Commande::STATUS_DRAFT && $object->billed) { - if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { + if ($usercancreate && $object->statut >= Commande::STATUS_VALIDATED && !getDolGlobalString('ORDER_DISABLE_CLASSIFY_BILLED_FROM_ORDER') && !getDolGlobalString('WORKFLOW_BILL_ON_SHIPMENT')) { print dolGetButtonAction('', $langs->trans('ClassifyUnBilled'), 'delete', $_SERVER["PHP_SELF"].'?action=classifyunbilled&token='.newToken().'&id='.$object->id, ''); } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index b2d373d427b46..064a1511850be 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -2685,7 +2685,7 @@ if (!isModEnabled('invoice')) { print ''.$langs->trans("ClassifyBilled").''; } else { - if (!empty($object->linkedObjectsIds['invoice_supplier'])) { + if (!empty($object->linkedObjectsIds['invoice_supplier']) || (empty($object->linkedObjectsIds['invoice_supplier']) && !getDolGlobalInt('SUPPLIER_ORDER_DISABLE_CLASSIFY_BILLED_FROM_SUPPLIER_ORDER'))) { if ($user->hasRight('fournisseur', 'facture', 'creer') || $user->hasRight("supplier_invoice", "creer")) { print ''.$langs->trans("ClassifyBilled").''; } diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 69feebc3d081e..32934370964d6 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1488,6 +1488,11 @@ InvoiceOptionCategoryOfOperations=Display the mention "category of operations" o InvoiceOptionCategoryOfOperationsHelp=Depending on the situation, the mention will appear in the form:
- Category of operations: Delivery of goods
- Category of operations: Provision of services
- Category of operations: Mixed - Delivery of goods & provision of services InvoiceOptionCategoryOfOperationsYes1=Yes, below the address block InvoiceOptionCategoryOfOperationsYes2=Yes, in the lower left-hand corner +InvoiceClassifyBilledSupplierOrderWithoutInvoice=Disallow to classify billed an order without invoice. +InvoiceClassifyBilledSupplierOrderWithoutInvoiceHelp=Classify billed an order without invoice is allow by default. If this conf is set to true, it will be not. +##### Supplier Orders ##### +SupplierOrderClassifyBilledWithoutInvoice=Disallow to classify billed a supplier order without invoice. +SupplierOrderClassifyBilledWithoutInvoiceHelp=Classify billed a supplier order without invoice is allow by default. If this conf is set to true, it will be not. ##### Proposals ##### PropalSetup=Commercial proposals module setup ProposalsNumberingModules=Commercial proposal numbering models From 1cccc808e7c271227920a389076cbeb1c612204f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 15:49:33 +0200 Subject: [PATCH 05/22] Clean code for barcode generators --- htdocs/core/actions_setmoduleoptions.inc.php | 4 +- htdocs/core/lib/barcode.lib.php | 53 ++++++++++--------- .../barcode/doc/phpbarcode.modules.php | 44 +++++++-------- .../barcode/doc/tcpdfbarcode.modules.php | 28 +++++----- .../modules/barcode/modules_barcode.class.php | 15 ++++++ 5 files changed, 84 insertions(+), 60 deletions(-) diff --git a/htdocs/core/actions_setmoduleoptions.inc.php b/htdocs/core/actions_setmoduleoptions.inc.php index 27fb7649100ac..e71f68f8ce31f 100644 --- a/htdocs/core/actions_setmoduleoptions.inc.php +++ b/htdocs/core/actions_setmoduleoptions.inc.php @@ -23,7 +23,7 @@ // $error must have been initialized to 0 // $action must be defined -// $arrayofparameters must be set for action 'update' +// $arrayofparameters must be set to list of parameters to update for action 'update' on constants // $nomessageinupdate can be set to 1 // $nomessageinsetmoduleoptions can be set to 1 // $formSetup may be defined @@ -35,7 +35,7 @@ } -if ($action == 'update' && is_array($arrayofparameters) && !empty($user->admin)) { +if ($action == 'update' && !empty($arrayofparameters) && is_array($arrayofparameters) && !empty($user->admin)) { $db->begin(); foreach ($arrayofparameters as $key => $val) { diff --git a/htdocs/core/lib/barcode.lib.php b/htdocs/core/lib/barcode.lib.php index f56000ae53211..18149483157c2 100644 --- a/htdocs/core/lib/barcode.lib.php +++ b/htdocs/core/lib/barcode.lib.php @@ -73,13 +73,14 @@ /** * Print barcode * - * @param string $code Code - * @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...) - * @param int<1,max> $scale Scale - * @param string $mode 'png' or 'jpg' ... + * @param string $code Code + * @param string $encoding Encoding ('EAN13', 'ISBN', 'C128', 'UPC', 'CBR', 'QRCODE', 'DATAMATRIX', 'ANY'...) + * @param int<1,max> $scale Scale + * @param string $mode 'png', 'gif', 'jpg', 'jpeg' ... + * @param string $filebarcode Filename to store barcode image file if defined * @return array{encoding:string,bars:string,text:string}|string $bars array('encoding': the encoding which has been used, 'bars': the bars, 'text': text-positioning info) or string with error message */ -function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png") +function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png", $filebarcode = '') { dol_syslog("barcode.lib.php::barcode_print $code $encoding $scale $mode"); @@ -100,7 +101,9 @@ function barcode_print($code, $encoding = "ANY", $scale = 2, $mode = "png") //if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']); //elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0); //else - barcode_outimage($bars['text'], $bars['bars'], $scale, $mode); + + barcode_outimage($bars['text'], $bars['bars'], $scale, $mode, 0, [], $filebarcode); + return $bars; } @@ -399,20 +402,20 @@ function barcode_encode_genbarcode($code, $encoding) } /** - * Output image onto standard output, or onto disk if global filebarcode is defined + * Output image onto standard output, or onto disk if $filebarcode is defined * - * @param string $text the text-line (:: ...) - * @param string $bars where to place the bars (...) - * @param int<1,max> $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!)) - * @param string $mode png,gif,jpg (default='png') - * @param int $total_y the total height of the image ( default: scale * 60 ) + * @param string $text the text-line (:: ...) + * @param string $bars where to place the bars (...) + * @param int<1,max> $scale scale factor ( 1 < scale < unlimited (scale 50 will produce 5400x300 pixels when using EAN-13!!!)) + * @param string $mode Mime 'png', 'gif', 'jpg', 'jpeg' (default='png') or file disk if empty. + * @param int $total_y the total height of the image ( default: scale * 60 ) * @param array{}|array{top:int,bottom:int,left:int,right:int} $space default: $space[top] = 2 * $scale; $space[bottom]= 2 * $scale; $space[left] = 2 * $scale; $space[right] = 2 * $scale; - * @return string|void + * @param string $filebarcode Filename to store barcode image file + * @return void */ -function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = []) +function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $space = [], $filebarcode = '') { - global $bar_color, $bg_color, $text_color; - global $font_loc, $filebarcode; + global $bar_color, $bg_color, $text_color, $font_loc; //print "$text, $bars, $scale, $mode, $total_y, $space, $font_loc, $filebarcode
"; @@ -452,7 +455,7 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, $xpos = $space['left']; if (!function_exists("imagecreate")) { print "You don't have the gd2 extension enabled
\n"; - return ""; + return; } $im = imagecreate($total_x, $total_y); /* create two images */ @@ -496,17 +499,17 @@ function barcode_outimage($text, $bars, $scale = 1, $mode = "png", $total_y = 0, /* output the image */ $mode = strtolower($mode); - if ($mode == 'jpg' || $mode == 'jpeg') { - header("Content-Type: image/jpeg; name=\"barcode.jpg\""); + if (!empty($filebarcode) && (empty($mode) || $mode == 'png')) { + // To write into a file onto disk + imagepng($im, $filebarcode); + } elseif ($mode == 'jpg' || $mode == 'jpeg') { + top_httphead('image/jpeg; name="barcode.jpg"'); imagejpeg($im); } elseif ($mode == 'gif') { - header("Content-Type: image/gif; name=\"barcode.gif\""); + top_httphead('image/gif; name="barcode.gif"'); imagegif($im); - } elseif (!empty($filebarcode)) { - // To write into a file onto disk - imagepng($im, $filebarcode); - } else { - header("Content-Type: image/png; name=\"barcode.png\""); + } elseif ($mode == 'png') { + top_httphead('image/png; name="barcode.png"'); imagepng($im); } diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index 52156a479de16..3ef61f9e1e36d 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -124,19 +124,17 @@ public function encodingIsSupported($encoding) } /** - * Return an image file on the fly (no need to write on disk) + * Return an image file on the fly (no need to write on disk) with the HTTP content-type of image. * - * @param string $code Value to encode - * @param string $encoding Mode of encoding - * @param string $readable Code can be read (What is this ? is this used ?) - * @param integer $scale Scale - * @param integer $nooutputiferror No output if error - * @return int Return integer <0 if KO, >0 if OK + * @param string $code Value to encode + * @param string $encoding Mode of encoding + * @param string $readable Code can be read (What is this ? is this used ?) + * @param integer $scale Scale + * @param integer $nooutputiferror No output if error + * @return int Return integer <0 if KO, >0 if OK */ public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { - global $genbarcode_loc, $bar_color, $bg_color, $text_color, $font_loc; - if (!$this->encodingIsSupported($encoding)) { return -1; } @@ -155,9 +153,14 @@ public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $noo $_GET["scale"] = $scale; $_GET["mode"] = $mode; - dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode"); + global $filebarcode; // Retrieve variable where to store filename + if (empty($filebarcode)) { + $filebarcode = ''; + } + + dol_syslog(get_class($this)."::buildBarCode $code,$encoding,$scale,$mode,$filebarcode"); if ($code) { - $result = barcode_print($code, $encoding, $scale, $mode); + $result = barcode_print($code, $encoding, $scale, $mode, $filebarcode); } if (!is_array($result)) { @@ -174,16 +177,16 @@ public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $noo /** * Save an image file on disk (with no output) * - * @param string $code Value to encode - * @param string $encoding Mode of encoding - * @param string $readable Code can be read - * @param integer $scale Scale - * @param integer $nooutputiferror No output if error - * @return int Return integer <0 if KO, >0 if OK + * @param string $code Value to encode + * @param string $encoding Mode of encoding + * @param string $readable Code can be read + * @param integer $scale Scale + * @param integer $nooutputiferror No output if error + * @return int Return integer <0 if KO, >0 if OK */ public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { - global $conf, $filebarcode, $langs; + global $conf, $langs; dol_mkdir($conf->barcode->dir_temp); if (!is_writable($conf->barcode->dir_temp)) { @@ -201,9 +204,8 @@ public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $noo $newcode = dol_hash($newcode, 'md5'); // No need for security here, we can use md5 } - $file = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - - $filebarcode = $file; // global var to be used in barcode_outimage called by barcode_print in buildBarCode + global $filebarcode; + $filebarcode = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; $result = $this->buildBarCode($code, $encoding, $readable, $scale, $nooutputiferror); diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index fa798524f458e..c114ab8d6945a 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -95,16 +95,17 @@ public function encodingIsSupported($encoding) } /** - * Return an image file on the fly (no need to write on disk) + * Return an image file on the fly (no need to write on disk) with the HTTP content-type (generated by TCPDF) of image. * - * @param string $code Value to encode - * @param string $encoding Mode of encoding - * @param string $readable Code can be read (What is this ? is this used ?) - * @param integer $scale Scale (not used with this engine) - * @param integer $nooutputiferror No output if error (not used with this engine) - * @return int Return integer <0 if KO, >0 if OK + * @param string $code Value to encode + * @param string $encoding Mode of encoding + * @param string $readable Code can be read (What is this ? is this used ?) + * @param integer $scale Scale (not used with this engine) + * @param integer $nooutputiferror No output if error (not used with this engine) + * @param string $filebarcode Filename to store barcode image file (instead of output it). Not supported by this driver. + * @return int Return integer <0 if KO, >0 if OK */ - public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0, $filebarcode = '') { $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { @@ -178,7 +179,7 @@ public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $noo $newcode = dol_hash($newcode, 'md5'); // No need for security here, we can use md5 } - $file = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + $filebarcode = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { @@ -205,13 +206,16 @@ public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $noo $barcodeobj = new TCPDFBarcode($code, $tcpdfEncoding); } - dol_syslog("writeBarCode::TCPDF.getBarcodePngData file=".$file); + dol_syslog("writeBarCode::TCPDF.getBarcodePngData file=".$filebarcode); + + $imageData = (string) $barcodeobj->getBarcodePngData($width, $height, $color); + // Note: We can avoid to generate an image and add it into PDF by using vectorial instructions directly into PDF with TCPDF->write2DBarcode() - if ($imageData = (string) $barcodeobj->getBarcodePngData($width, $height, $color)) { + if ($imageData) { if (function_exists('imagecreate')) { $imageData = imagecreatefromstring($imageData); } - if (imagepng($imageData, $file)) { + if (imagepng($imageData, $filebarcode)) { return 1; } else { return -3; diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 58d0e79e9bdee..c531c97aeed0d 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -47,6 +47,21 @@ public function isEnabled() { return true; } + + /** + * Save an image file on disk (with no output) + * + * @param string $code Value to encode + * @param string $encoding Mode of encoding ('QRCODE', 'EAN13', ...) + * @param string $readable Code can be read + * @param integer $scale Scale (not used with this engine) + * @param integer $nooutputiferror No output if error (not used with this engine) + * @return int Return integer <0 if KO, >0 if OK + */ + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + { + return -1; // Error by default, this method must be implemented by the driver + } } From 4f0cbb61881d62cb0e309cdd3ef23e0e41331983 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 22 May 2024 16:04:18 +0200 Subject: [PATCH 06/22] NEW functionality for display codebar on pdf files (#29623) * NEW functionality for display codebar on pdf files * update encoding and add option to set pdf * fix CI/phan * fix CI/phan * fix CI/phan * Update pdf_rouget.modules.php * Update pdf_eagle.modules.php * Update pdf_rouget.modules.php * Update pdf_rouget.modules.php * fix undeclared variables * Update pdf_rouget.modules.php * Update pdf_espadon.modules.php * Update pdf_eagle.modules.php --------- Co-authored-by: Laurent Destailleur Co-authored-by: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> --- htdocs/admin/pdf_other.php | 15 +++++ .../expedition/doc/pdf_espadon.modules.php | 27 ++++++-- .../expedition/doc/pdf_rouget.modules.php | 64 +++++++++++++++---- .../stocktransfer/doc/pdf_eagle.modules.php | 27 ++++++-- htdocs/langs/en_US/admin.lang | 1 + 5 files changed, 115 insertions(+), 19 deletions(-) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index f73b095c8afb7..921a9af6e5d93 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -104,6 +104,10 @@ dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity); } + if (GETPOSTISSET('BARCODE_RECEPTION_INVOICE')) { + dolibarr_set_const($db, "BARCODE_RECEPTION_INVOICE", GETPOSTINT("BARCODE_RECEPTION_INVOICE"), 'chaine', 0, '', $conf->entity); + } + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -343,6 +347,17 @@ } print ''; + print ''; + print $langs->trans("BARCODE_RECEPTION_INVOICE"); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('BARCODE_RECEPTION_INVOICE'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("BARCODE_RECEPTION_INVOICE", $arrval, getDolGlobalString('BARCODE_RECEPTION_INVOICE')); + } + print ''; + print ''; print ''; } diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 4c2977a752286..31eb5e90f50ed 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -991,10 +991,29 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode')) { - // 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); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); + } else { + $this->error = 'Failed to generate barcode'; + } } $pdf->SetDrawColor(128, 128, 128); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index bb974011dfad3..25598f39e94ed 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -393,11 +393,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } else { $height_note = 0; } - - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; - + $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); + $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); + $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -594,7 +592,33 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - + // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + // require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + // $encoding = 'QRCODE'; + // $module = new modTcpdfbarcode($this->db); + // if ($module->encodingIsSupported($encoding)) { + // $result = $module->writeBarCode($object->ref, $encoding); + + // // get path of qrcode image + // $newcode = $object->ref; + // if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + // $newcode = dol_hash($newcode, 'md5'); + // } + // $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + // } + + // if ($result > 0) { + // $pdf->Image($barcode_path, $this->marge_gauche, $tab_top -5,20,20); + // } else { + // $this->error = 'Failed to generate barcode'; + // } + // } + + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + $tab_top = $tab_top +18; + $heightforfooter = $heightforfooter - 5; + } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); @@ -901,12 +925,30 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode')) { - // 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); - } + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $result = 0; + $barcode_path = ''; + $module = new modTcpdfbarcode(); + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + if ($result > 0) { + $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); + } else { + $this->error = 'Failed to generate barcode'; + } + } $pdf->SetDrawColor(128, 128, 128); $posx = $this->page_largeur - $w - $this->marge_droite; diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 9ad9d72821a53..edc941a30511e 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -1001,10 +1001,29 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode')) { - // 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); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $result = 0; + $barcode_path = ''; + $module = new modTcpdfbarcode(); + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); + } else { + $this->error = 'Failed to generate barcode'; + } } $pdf->SetDrawColor(128, 128, 128); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 32934370964d6..c8293a669c136 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2480,6 +2480,7 @@ AIPromptForFeatures=AI custom prompts for features EnterAnIP=Enter an IP address ConvertInto=Convert into YouAreHere=You are here +BARCODE_RECEPTION_INVOICE=Show the barcode on the reception invoices Unstable=Unstable ModuleZapierForDolibarrName=Zapier for Dolibarr ModuleZapierForDolibarrDesc=Zapier for Dolibarr module From 73cada0dc5bcce7c265734b319011dcf3ccccec4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 16:12:56 +0200 Subject: [PATCH 07/22] Debug v20 --- htdocs/admin/pdf_other.php | 53 +++++++++++++++++-- .../expedition/doc/pdf_rouget.modules.php | 12 ++--- htdocs/langs/en_US/admin.lang | 4 +- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 921a9af6e5d93..6d6b9073359be 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -104,8 +104,14 @@ dolibarr_del_const($db, "INVOICE_SHOW_SHIPPING_ADDRESS", $conf->entity); } - if (GETPOSTISSET('BARCODE_RECEPTION_INVOICE')) { - dolibarr_set_const($db, "BARCODE_RECEPTION_INVOICE", GETPOSTINT("BARCODE_RECEPTION_INVOICE"), 'chaine', 0, '', $conf->entity); + if (GETPOSTISSET('BARCODE_ON_SHIPPING_PDF')) { + dolibarr_set_const($db, "BARCODE_ON_SHIPPING_PDF", GETPOSTINT("BARCODE_ON_SHIPPING_PDF"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('BARCODE_ON_RECEPTION_PDF')) { + dolibarr_set_const($db, "BARCODE_ON_RECEPTION_PDF", GETPOSTINT("BARCODE_ON_RECEPTION_PDF"), 'chaine', 0, '', $conf->entity); + } + if (GETPOSTISSET('BARCODE_ON_STOCKTRANSFER_PDF')) { + dolibarr_set_const($db, "BARCODE_ON_STOCKTRANSFER_PDF", GETPOSTINT("BARCODE_ON_STOCKTRANSFER_PDF"), 'chaine', 0, '', $conf->entity); } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -316,6 +322,24 @@ print ''; } +if (isModEnabled('shipping')) { + print load_fiche_titre($langs->trans("Shipments"), '', 'shipment'); + + print '
'; + print ''; + print ''; + + print ''; +} if (isModEnabled('reception')) { @@ -348,13 +372,32 @@ print ''; print ''; +} + +if (isModEnabled('stocktransfer')) { + print load_fiche_titre($langs->trans("StockTransfer"), '', 'stock'); + + print '
'; + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print $langs->trans("BARCODE_ON_SHIPPING_PDF"); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('BARCODE_ON_SHIPPING_PDF'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("BARCODE_ON_SHIPPING_PDF", $arrval, getDolGlobalString('BARCODE_ON_SHIPPING_PDF')); + } + print '
'; - print $langs->trans("BARCODE_RECEPTION_INVOICE"); + print $langs->trans("BARCODE_ON_RECEPTION_PDF"); + print ''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('BARCODE_ON_RECEPTION_PDF'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("BARCODE_ON_RECEPTION_PDF", $arrval, getDolGlobalString('BARCODE_ON_RECEPTION_PDF')); + } + print '
'; + print ''; + + print ''; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 25598f39e94ed..a5adf4d279348 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -393,9 +393,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } else { $height_note = 0; } - $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); - $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); - $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_RECEPTION_INVOICE") ? 30 : 7); + $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); + $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); + $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -592,7 +592,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { // require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; // $encoding = 'QRCODE'; @@ -615,7 +615,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // } // } - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { $tab_top = $tab_top +18; $heightforfooter = $heightforfooter - 5; } @@ -925,7 +925,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_RECEPTION_INVOICE')) { + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; $encoding = 'QRCODE'; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index c8293a669c136..168d5f6f1d22f 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2480,7 +2480,9 @@ AIPromptForFeatures=AI custom prompts for features EnterAnIP=Enter an IP address ConvertInto=Convert into YouAreHere=You are here -BARCODE_RECEPTION_INVOICE=Show the barcode on the reception invoices +BARCODE_ON_SHIPPING_PDF=Show the barcode on the shipping PDF document +BARCODE_ON_RECEPTION_PDF=Show the barcode on the reception PDF document +BARCODE_ON_STOCKTRANSFER_PDF=Show the barcode on the stock transfer PDF document Unstable=Unstable ModuleZapierForDolibarrName=Zapier for Dolibarr ModuleZapierForDolibarrDesc=Zapier for Dolibarr module From 48c878e39168af8a890e415203f10f1f6b9060af Mon Sep 17 00:00:00 2001 From: data-mloe <157358552+data-mloe@users.noreply.github.com> Date: Wed, 22 May 2024 16:18:10 +0200 Subject: [PATCH 08/22] Fixed an issue where text extrafields in contract lines where not updated if they contained an empty string (#29736) --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4e6d8c1762cd6..8222022389f32 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2555,7 +2555,7 @@ public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $ke } $value_key = dol_htmlcleanlastbr(GETPOST($keysuffix."options_".$key.$keyprefix, 'restricthtml')); } else { - if (!GETPOST($keysuffix."options_".$key.$keyprefix)) { + if (!GETPOSTISSET($keysuffix."options_".$key.$keyprefix)) { continue; // Value was not provided, we should not set it. } $value_key = GETPOST($keysuffix."options_".$key.$keyprefix); From a5c5b7a2ee08d400859ca974afd1812f2f157c27 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 16:44:48 +0200 Subject: [PATCH 09/22] Fix check translation file --- dev/translation/sanity_check_trans_missing_unused.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dev/translation/sanity_check_trans_missing_unused.sh b/dev/translation/sanity_check_trans_missing_unused.sh index 326cd0bce163c..f54e9c6b4ef15 100755 --- a/dev/translation/sanity_check_trans_missing_unused.sh +++ b/dev/translation/sanity_check_trans_missing_unused.sh @@ -123,12 +123,14 @@ fi # > yyy # Some output is already compatible with message extraction for github annotation (logToCs.py) # + diff "${AVAILABLE_FILE}" "${EXPECTED_FILE}" \ | grep -E "^[<>]" \ | grep -v -P "^< ${EXPECTED_REGEX}$" \ | sort \ > "${MISSING_AND_UNUSED_FILE}" +rm -f "${UNUSED_FILE}.grep" >/dev/null 2>&1 sed -n 's@< \(.*\)@^\1\\s*=@p' \ < "${MISSING_AND_UNUSED_FILE}" \ > "${UNUSED_FILE}.grep" @@ -137,13 +139,14 @@ sed -n 's@< \(.*\)@^\1\\s*=@p' \ # Prepare file with exact matches for use with `git grep`, supposing " quotes # REPL_STR="" -for t in trans transnoentities transnoentitiesnoconv ; do +for t in trans transnoentities transnoentitiesnoconv newItem buttonsSaveCancel; do REPL_STR="${REPL_STR}\n->${t}(\"\\1\"," REPL_STR="${REPL_STR}\n->${t}('\\1'," REPL_STR="${REPL_STR}\n->${t}(\"\\1\")" REPL_STR="${REPL_STR}\n->${t}('\\1')" done +rm -f "${MISSING_FILE}.grep" >/dev/null 2>&1 sed -n 's@> \(.*\)'"@${REPL_STR}@p" \ < "${MISSING_AND_UNUSED_FILE}" \ | grep -v -E '^$' \ From 275a6eb6bb6971d3d1a4bdbed515ad855435f98c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 16:48:18 +0200 Subject: [PATCH 10/22] Show content if error --- dev/translation/sanity_check_trans_missing_unused.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/translation/sanity_check_trans_missing_unused.sh b/dev/translation/sanity_check_trans_missing_unused.sh index f54e9c6b4ef15..c9f3b296e4d83 100755 --- a/dev/translation/sanity_check_trans_missing_unused.sh +++ b/dev/translation/sanity_check_trans_missing_unused.sh @@ -189,6 +189,8 @@ if [ -s "${MISSING_FILE}.grep" ] ; then | sort -t: -k 4 \ | sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @' + cat "${MISSING_FILE}.grep" + echo "##[endgroup]" fi From c0f3ea0a1199d494e2166f47f5952b1bf45fa7c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 17:01:21 +0200 Subject: [PATCH 11/22] Better error message --- dev/translation/sanity_check_trans_missing_unused.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dev/translation/sanity_check_trans_missing_unused.sh b/dev/translation/sanity_check_trans_missing_unused.sh index c9f3b296e4d83..5b29f5b9460f2 100755 --- a/dev/translation/sanity_check_trans_missing_unused.sh +++ b/dev/translation/sanity_check_trans_missing_unused.sh @@ -171,7 +171,7 @@ if [ -s "${UNUSED_FILE}.grep" ] ; then git grep -n --column -r -f "${UNUSED_FILE}.grep" -- "${LANG_DIR}"'/*.lang' \ | sort -t: -k 4 \ - | sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Not used, translated; @' + | sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@Warning Not used, translated; @' echo "##[endgroup]" echo @@ -179,17 +179,18 @@ fi if [ -s "${MISSING_FILE}.grep" ] ; then - exit_code=1 - # Report missing translation in recognizable format echo "##[group]List missing translations (used by code but not found into lang files) - Generate CTI errors" git grep -n --column -r -F -f "${MISSING_FILE}.grep" -- ':*.php' ':*.html' \ | sort -t: -k 4 \ - | sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @' + | sed 's@^\([^:]*:[^:]*:[^:]*:\)\s*@\1 Missing translation; @' > "${MISSING_FILE}.result" - cat "${MISSING_FILE}.grep" + if [ -s "${MISSING_FILE}.result" ] ; then + exit_code=1 + cat "${MISSING_FILE}.result" + fi echo "##[endgroup]" fi From 699ce89bfca7d8a828b2ba2d27636e0e328eb770 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 22 May 2024 17:03:44 +0200 Subject: [PATCH 12/22] fix display in other pdf admin page (#29738) --- htdocs/admin/pdf_other.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 6d6b9073359be..882277ffd8cbb 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -339,6 +339,8 @@ print $form->selectarray("BARCODE_ON_SHIPPING_PDF", $arrval, getDolGlobalString('BARCODE_ON_SHIPPING_PDF')); } print ''; + print '
'.$langs->trans("Parameters").''.$langs->trans("Value").'
'; + print $langs->trans("BARCODE_ON_STOCKTRANSFER_PDF"); print ''; if ($conf->use_javascript_ajax) { - print ajax_constantonoff('BARCODE_RECEPTION_INVOICE'); + print ajax_constantonoff('BARCODE_ON_STOCKTRANSFER_PDF'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("BARCODE_RECEPTION_INVOICE", $arrval, getDolGlobalString('BARCODE_RECEPTION_INVOICE')); + print $form->selectarray("BARCODE_ON_STOCKTRANSFER_PDF", $arrval, getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')); } print '
'; + print '
'; } @@ -381,6 +383,8 @@ print $form->selectarray("BARCODE_ON_RECEPTION_PDF", $arrval, getDolGlobalString('BARCODE_ON_RECEPTION_PDF')); } print ''; + print ''; + print ''; } if (isModEnabled('stocktransfer')) { From 8b4f94ac2207dc9d9370951ff8559f325ab85cf2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 17:10:43 +0200 Subject: [PATCH 13/22] Debug v20 --- htdocs/admin/pdf_other.php | 4 ++-- .../modules/expedition/doc/pdf_rouget.modules.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/admin/pdf_other.php b/htdocs/admin/pdf_other.php index 882277ffd8cbb..5279d9f5a2f75 100644 --- a/htdocs/admin/pdf_other.php +++ b/htdocs/admin/pdf_other.php @@ -358,7 +358,7 @@ print ajax_constantonoff('RECEPTION_PDF_HIDE_ORDERED'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("RECEPTION_PDF_HIDE_ORDERED", $arrval, $conf->global->RECEPTION_PDF_HIDE_ORDERED); + print $form->selectarray("RECEPTION_PDF_HIDE_ORDERED", $arrval, getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')); } print ''; @@ -369,7 +369,7 @@ print ajax_constantonoff('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT'); } else { $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); - print $form->selectarray("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT", $arrval, $conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT); + print $form->selectarray("MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT", $arrval, getDolGlobalString('MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT')); } print ''; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index a5adf4d279348..398574b35a7f0 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -393,9 +393,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } else { $height_note = 0; } - $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); - $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); - $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 30 : 7); + $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); + $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); + $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -592,7 +592,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { // require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; // $encoding = 'QRCODE'; @@ -615,7 +615,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // } // } - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { $tab_top = $tab_top +18; $heightforfooter = $heightforfooter - 5; } @@ -925,7 +925,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; $encoding = 'QRCODE'; From d7b9e7b4ef506377c63ec862663fd599421b9f52 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 17:25:31 +0200 Subject: [PATCH 14/22] Fix warnings --- htdocs/core/class/commonobject.class.php | 4 +++ htdocs/core/lib/pdf.lib.php | 2 +- .../stocktransfer/doc/pdf_eagle.modules.php | 29 ++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 4f8be6575359d..087668ae982f8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4960,6 +4960,10 @@ public function getTotalWeightVolume() // defined for shipment only $totalToShip = ''; + if (empty($this->lines)) { + return array(); + } + foreach ($this->lines as $line) { if (isset($line->qty_asked)) { if (empty($totalOrdered)) { diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 54099abdb34f3..9e288a0521a63 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -651,7 +651,7 @@ function pdf_build_address($outputlangs, $sourcecompany, $targetcompany = '', $t if (!empty($targetcontact->thirdparty->id) && $targetcontact->thirdparty->tva_intra) { $stringaddress .= ($stringaddress ? "\n" : '') . $outputlangs->transnoentities("VATIntraShort") . ': ' . $outputlangs->convToOutputCharset($targetcontact->thirdparty->tva_intra); } - } elseif ($targetcompany->tva_intra) { + } elseif (!empty($targetcompany->tva_intra)) { $stringaddress .= ($stringaddress ? "\n" : '').$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($targetcompany->tva_intra); } } diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index edc941a30511e..61079dd820bfb 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -100,7 +100,7 @@ class pdf_eagle extends ModelePDFStockTransfer */ public function __construct($db) { - global $conf, $langs, $mysoc; + global $langs, $mysoc; $this->db = $db; $this->name = $langs->trans("StockTransferSheet"); @@ -344,7 +344,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Incoterm $height_incoterms = 0; - if ($conf->incoterm->enabled) { + if (isModEnabled('incoterm')) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { $tab_top = 88; @@ -721,10 +721,6 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable - global $conf, $mysoc; - - $sign = 1; - $default_font_size = pdf_getPDFFontSize($outputlangs); $tab2_top = $posy; @@ -747,13 +743,17 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $useborder = 0; $index = 0; + $totalWeight = ''; + $totalVolume = ''; $totalWeighttoshow = ''; $totalVolumetoshow = ''; // Load dim data $tmparray = $object->getTotalWeightVolume(); - $totalWeight = $tmparray['weight']; - $totalVolume = $tmparray['volume']; + if (!empty($tmparray)) { + $totalWeight = $tmparray['weight']; + $totalVolume = $tmparray['volume']; + } $totalQty = 0; if (!empty($object->lines)) { foreach ($object->lines as $line) { @@ -923,17 +923,17 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ */ public function atLeastOneBatch($object) { - global $conf; - - $atLeastOneBatch = false; + //$atLeastOneBatch = false; if (!isModEnabled('productbatch')) { return false; } - foreach ($object->lines as $line) { - if (!empty($line->batch)) { - return true; + if (!empty($object->lines)) { + foreach ($object->lines as $line) { + if (!empty($line->batch)) { + return true; + } } } @@ -1190,6 +1190,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $thirdparty = $object->thirdparty; } + $carac_client_name = ''; if (!empty($thirdparty)) { $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); } From 6de9418302647e07473aecd380243ca3256796ed Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 22 May 2024 17:29:08 +0200 Subject: [PATCH 15/22] Small review Recruitment module (#29735) * NEW Accountancy - Add possibility for specific format FEC to sort with the fec name * Fix language key Recruitment not traduced & remove unused key * Remove old file ChangeLog * Update recruitment readme --------- Co-authored-by: Laurent Destailleur --- htdocs/langs/en_US/recruitment.lang | 6 ++---- htdocs/recruitment/ChangeLog.md | 5 ----- htdocs/recruitment/README.md | 5 ++--- 3 files changed, 4 insertions(+), 12 deletions(-) delete mode 100644 htdocs/recruitment/ChangeLog.md diff --git a/htdocs/langs/en_US/recruitment.lang b/htdocs/langs/en_US/recruitment.lang index f2be7734ad53f..04919e2a1b29f 100644 --- a/htdocs/langs/en_US/recruitment.lang +++ b/htdocs/langs/en_US/recruitment.lang @@ -22,9 +22,7 @@ RecruitmentSetupPage = Enter here the setup of main options for the recruitment RecruitmentArea=Recruitement area PublicInterfaceRecruitmentDesc=Public pages of jobs are public URLs to show and answer to open jobs. There is one different link for each open job, found on each job record. EnablePublicRecruitmentPages=Enable public pages of open jobs -# About page -RecruitmentAbout = About Recruitment -RecruitmentAboutPage = Recruitment about page + NbOfEmployeesExpected=Expected nb of employees JobLabel=Label of job position WorkPlace=Work place @@ -65,4 +63,4 @@ WeAreRecruiting=We are recruiting. This is a list of open positions to be filled NoPositionOpen=No positions open at the moment ConfirmClose=Confirm cancellation ConfirmCloseAsk=Are you sure you want to cancel this recruitment candidature -recruitment=Recruitment +Recruitment=Recruitment diff --git a/htdocs/recruitment/ChangeLog.md b/htdocs/recruitment/ChangeLog.md deleted file mode 100644 index e1a12aa2f52ec..0000000000000 --- a/htdocs/recruitment/ChangeLog.md +++ /dev/null @@ -1,5 +0,0 @@ -# CHANGELOG RECRUITMENT FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) - -## 1.0 - -Initial version diff --git a/htdocs/recruitment/README.md b/htdocs/recruitment/README.md index 190362bafc0a8..25fd20762ebec 100644 --- a/htdocs/recruitment/README.md +++ b/htdocs/recruitment/README.md @@ -1,5 +1,4 @@ -# RECRUITMENT FOR [DOLIBARR ERP CRM](https://www.dolibarr.org) - -## Features +Recruitment +========== Manage and follow recruitment campaigns for new job positions. From 5945fd8c7f0161da612e1c8bb2fbbbeddf81ea0d Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 22 May 2024 20:31:11 +0200 Subject: [PATCH 16/22] Fix display Qrcode on reception pdf (#29742) * Fix display Qrcode on reception pdf * Fix run phan --- htdocs/core/class/commonobject.class.php | 2 +- .../reception/doc/pdf_squille.modules.php | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 087668ae982f8..fe58017f57ae9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4949,7 +4949,7 @@ public function getTotalDiscount() * Return into unit=0, the calculated total of weight and volume of all lines * qty * Calculate by adding weight and volume of each product line, so properties ->volume/volume_units/weight/weight_units must be loaded on line. * - * @return array{weight:int|float,volume:int|float,ordered:int|float,toship:int|float} array('weight'=>...,'volume'=>...) + * @return array{weight:int|float,volume:int|float,ordered:int|float,toship:int|float}|array{} array('weight'=>...,'volume'=>...) */ public function getTotalWeightVolume() { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 275ccce6b4f72..712602aac8c7a 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -317,7 +317,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms; + $tab_top = 88 + $height_incoterms + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 20 : 0); $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); @@ -370,9 +370,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = 0; } - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; + $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); + $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); + $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); $fk_commandefourndet = 0; $totalOrdered = 0; $totalAmount = 0; @@ -587,7 +587,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagenb++; } } - + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + $heightforfooter = $heightforfooter - 5; + } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object); @@ -901,10 +903,29 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posx = $this->marge_gauche + 3; } //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode')) { - // TODO Build code bar with function writeBarCode of barcode module for reception ref $object->ref - //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); - //$pdf->Image($logo,10, 5, 0, 24); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); + } else { + $this->error = 'Failed to generate barcode'; + } } $pdf->SetDrawColor(128, 128, 128); From 01f584a43b409f2c51f553b1fa83d3da8cf4e345 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 20:40:11 +0200 Subject: [PATCH 17/22] Debug v20 --- .../modules/reception/doc/pdf_squille.modules.php | 15 +++++++++------ htdocs/reception/class/reception.class.php | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 712602aac8c7a..6ffd341ebcc4e 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -154,7 +154,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "propal", "deliveries", "receptions", "productbatch", "sendings")); // Show Draft Watermark - if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('RECEPTION_DRAFT_WATERMARK'))) { + if ($object->status == $object::STATUS_DRAFT && (getDolGlobalString('RECEPTION_DRAFT_WATERMARK'))) { $this->watermark = getDolGlobalString('RECEPTION_DRAFT_WATERMARK'); } @@ -316,8 +316,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } + // Barcode + $height_barcode = (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 20 : 0); + if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 20 : 0); + $tab_top = 88 + $height_incoterms + $height_barcode; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); @@ -370,9 +373,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = 0; } - $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); - $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); - $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 9 : 7); + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; $fk_commandefourndet = 0; $totalOrdered = 0; $totalAmount = 0; @@ -922,7 +925,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) } if ($result > 0) { - $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); + $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute + 80 -5, 20, 20); } else { $this->error = 'Failed to generate barcode'; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 36be9b86706f6..d1293236a9249 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1438,6 +1438,7 @@ public function initAsSpecimen() $this->ref = 'SPECIMEN'; $this->specimen = 1; $this->statut = 1; + $this->status = 1; $this->date = $now; $this->date_creation = $now; $this->date_valid = $now; @@ -1454,6 +1455,10 @@ public function initAsSpecimen() $this->note_private = 'Private note'; $this->note_public = 'Public note'; + if (isModEnabled('incoterms')) { + $this->fk_incoterms = 1; + } + $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { From 393e8baa7a1ed455e4f924a9fe7594bd3b964d99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 20:58:13 +0200 Subject: [PATCH 18/22] Better position of barcode --- .../reception/doc/pdf_squille.modules.php | 83 +++++++++---------- htdocs/reception/class/reception.class.php | 6 +- 2 files changed, 44 insertions(+), 45 deletions(-) diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 6ffd341ebcc4e..4a51ebe52ff34 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -290,7 +290,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90; + $tab_top = 90; // position of top tab $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -299,6 +299,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_incoterms = 0; if (isModEnabled('incoterm')) { $desc_incoterms = $object->getIncotermsForPDF(); + if ($desc_incoterms) { $tab_top -= 2; @@ -316,11 +317,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } - // Barcode - $height_barcode = (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_RECEPTION_PDF") ? 20 : 0); - + // Public note and Tracking code if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms + $height_barcode; $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); @@ -373,6 +371,41 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = 0; } + // Show barcode + $height_barcode = 0; + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $tab_top -= 2; + + $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20); + + $nexY = $pdf->GetY(); + $height_barcode = $nexY - $tab_top; + + $tab_top += 22; + } else { + $this->error = 'Failed to generate barcode'; + } + } + $iniY = $tab_top + 7; $curY = $tab_top + 7; $nexY = $tab_top + 7; @@ -508,11 +541,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Description $pdf->SetXY($this->posxweightvol, $curY); $weighttxt = ''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) { + if ($object->lines[$i]->fk_product_type == 0 && is_object($object->lines[$i]->product) && $object->lines[$i]->product->weight) { $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->product->weight_units, 1); } $voltxt = ''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) { + if ($object->lines[$i]->fk_product_type == 0 && is_object($object->lines[$i]->product) && $object->lines[$i]->product->volume) { $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, 1); } @@ -590,9 +623,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pagenb++; } } - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { - $heightforfooter = $heightforfooter - 5; - } + // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object); @@ -899,38 +930,6 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - // Show barcode - if (isModEnabled('barcode')) { - $posx = 105; - } else { - $posx = $this->marge_gauche + 3; - } - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_RECEPTION_PDF')) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; - - $encoding = 'QRCODE'; - $module = new modTcpdfbarcode(); - $barcode_path = ''; - $result = 0; - if ($module->encodingIsSupported($encoding)) { - $result = $module->writeBarCode($object->ref, $encoding); - - // get path of qrcode image - $newcode = $object->ref; - if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { - $newcode = dol_hash($newcode, 'md5'); - } - $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - } - - if ($result > 0) { - $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute + 80 -5, 20, 20); - } else { - $this->error = 'Failed to generate barcode'; - } - } - $pdf->SetDrawColor(128, 128, 128); $posx = $this->page_largeur - $w - $this->marge_droite; diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index d1293236a9249..53906da6b9e3f 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1455,9 +1455,9 @@ public function initAsSpecimen() $this->note_private = 'Private note'; $this->note_public = 'Public note'; - if (isModEnabled('incoterms')) { - $this->fk_incoterms = 1; - } + $this->tracking_number = 'TRACKID-ABC123'; + + $this->fk_incoterms = 1; $nbp = 5; $xnbp = 0; From a924b0c0143e9972c6e92ef0b9cb3a8356db985f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 21:30:56 +0200 Subject: [PATCH 19/22] Close #29741 --- .../expedition/doc/pdf_espadon.modules.php | 90 +++++------ .../expedition/doc/pdf_rouget.modules.php | 148 +++++++++--------- .../reception/doc/pdf_squille.modules.php | 40 +++-- 3 files changed, 145 insertions(+), 133 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 31eb5e90f50ed..5ba1ab59f5b50 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -25,7 +25,7 @@ /** * \file htdocs/core/modules/expedition/doc/pdf_espadon.modules.php * \ingroup expedition - * \brief Class file allowing Espadons shipping template generation + * \brief Class file allowing Espadon shipping template generation */ require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php'; @@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; /** - * Class to build sending documents with model espadon + * Class to build sending documents with model Espadon */ class pdf_espadon extends ModelePdfExpedition { @@ -63,16 +63,16 @@ class pdf_espadon extends ModelePdfExpedition */ public $type; - public $posxweightvol; - public $posxqtytoship; - public $posxqtyordered; - /** * Dolibarr version of the loaded document * @var string */ public $version = 'dolibarr'; + public $posxweightvol; + public $posxqtytoship; + public $posxqtyordered; + /** * Constructor @@ -115,7 +115,7 @@ public function __construct(DoliDB $db) /** * Function to build pdf onto disk * - * @param Expedition $object Object expedition to generate (or id if old method) + * @param Expedition $object Object shipping 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 @@ -180,7 +180,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $realpath = ''; 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 CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo if ($obj['photo_vignette']) { $filename = $obj['photo_vignette']; } else { @@ -289,7 +290,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90; + $tab_top = 90; // position of top tab $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -317,7 +318,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } - // display note + // Public note and Tracking code $notetoshow = empty($object->note_public) ? '' : $object->note_public; // Extrafields in note @@ -336,8 +337,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $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(); + $object->getUrlTrackingStatus($object->tracking_number); if (!empty($object->tracking_url)) { if ($object->shipping_method_id > 0) { @@ -362,7 +363,6 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $tab_top = $pdf->GetY(); } - // Notes $pagenb = $pdf->getPage(); if (!empty($notetoshow) || !empty($object->tracking_number)) { @@ -503,6 +503,40 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } + // Show barcode + $height_barcode = 0; + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $tab_top -= 2; + + $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20); + + $nexY = $pdf->GetY(); + $height_barcode = 20; + + $tab_top += 22; + } else { + $this->error = 'Failed to generate barcode'; + } + } // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); @@ -984,38 +1018,6 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - // Show barcode - if (isModEnabled('barcode')) { - $posx = 105; - } else { - $posx = $this->marge_gauche + 3; - } - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; - - $encoding = 'QRCODE'; - $module = new modTcpdfbarcode(); - $barcode_path = ''; - $result = 0; - if ($module->encodingIsSupported($encoding)) { - $result = $module->writeBarCode($object->ref, $encoding); - - // get path of qrcode image - $newcode = $object->ref; - if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { - $newcode = dol_hash($newcode, 'md5'); - } - $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - } - - if ($result > 0) { - $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); - } else { - $this->error = 'Failed to generate barcode'; - } - } - $pdf->SetDrawColor(128, 128, 128); $posx = $this->page_largeur - $w - $this->marge_droite; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 398574b35a7f0..9adf9c5c37345 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -148,7 +148,7 @@ public function __construct(DoliDB $db) /** * Function to build pdf onto disk * - * @param Expedition $object Object expedition to generate (or id if old method) + * @param Expedition $object Object shipping 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 @@ -172,13 +172,21 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } // Load traductions files required by page - $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "other")); + $outputlangs->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "other")); // Show Draft Watermark if ($object->statut == $object::STATUS_DRAFT && (getDolGlobalString('SHIPPING_DRAFT_WATERMARK'))) { $this->watermark = getDolGlobalString('SHIPPING_DRAFT_WATERMARK'); } + global $outputlangsbis; + $outputlangsbis = null; + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); + $outputlangsbis->loadLangs(array("main", "bills", "orders", "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 @@ -277,7 +285,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { + if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -313,7 +321,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90; + $tab_top = 90; // position of top tab $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -339,17 +347,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } + // Public note and Tracking code if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms; $tab_top_alt = $tab_top; - $pdf->SetFont('', 'B', $default_font_size - 2); - //$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'); + $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(); $object->getUrlTrackingStatus($object->tracking_number); @@ -367,12 +376,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $label .= " : "; $label .= $object->tracking_url; } - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); + $height_trackingnumber += 4; + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); } } + $tab_top = $pdf->GetY(); } // Notes @@ -393,9 +403,47 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } else { $height_note = 0; } - $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); - $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); - $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_SHIPPING_PDF") ? 30 : 7); + + // Show barcode + $height_barcode = 0; + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $tab_top -= 2; + + $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20); + + $nexY = $pdf->GetY(); + $height_barcode = 20; + + $tab_top += 22; + } else { + $this->error = 'Failed to generate barcode'; + } + } + + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; + // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -415,6 +463,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $showpricebeforepagebreak = 1; $posYAfterImage = 0; $posYAfterDescription = 0; + $heightforsignature = 0; // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page @@ -487,7 +536,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $posYAfterDescription = $pdf->GetY(); - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $posYAfterImage); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); @@ -506,7 +555,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font + + // weight $pdf->SetXY($this->posxweightvol, $curY); $weighttxt = ''; @@ -592,33 +643,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - // if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { - // require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; - - // $encoding = 'QRCODE'; - // $module = new modTcpdfbarcode($this->db); - // if ($module->encodingIsSupported($encoding)) { - // $result = $module->writeBarCode($object->ref, $encoding); - - // // get path of qrcode image - // $newcode = $object->ref; - // if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { - // $newcode = dol_hash($newcode, 'md5'); - // } - // $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - // } - - // if ($result > 0) { - // $pdf->Image($barcode_path, $this->marge_gauche, $tab_top -5,20,20); - // } else { - // $this->error = 'Failed to generate barcode'; - // } - // } - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { - $tab_top = $tab_top +18; - $heightforfooter = $heightforfooter - 5; - } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); @@ -716,6 +741,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $totalVolume = $tmparray['volume']; $totalOrdered = $tmparray['ordered']; $totalToShip = $tmparray['toship']; + // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0); @@ -816,6 +842,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); + // Description if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); @@ -918,37 +945,6 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - // Show barcode - if (isModEnabled('barcode')) { - $posx = 105; - } else { - $posx = $this->marge_gauche + 3; - } - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_SHIPPING_PDF')) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; - - $encoding = 'QRCODE'; - $result = 0; - $barcode_path = ''; - $module = new modTcpdfbarcode(); - if ($module->encodingIsSupported($encoding)) { - $result = $module->writeBarCode($object->ref, $encoding); - - // get path of qrcode image - $newcode = $object->ref; - if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { - $newcode = dol_hash($newcode, 'md5'); - } - $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - } - - if ($result > 0) { - $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); - } else { - $this->error = 'Failed to generate barcode'; - } - } $pdf->SetDrawColor(128, 128, 128); $posx = $this->page_largeur - $w - $this->marge_droite; @@ -994,7 +990,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $object->fetch_origin(); // TODO move to external function - if (!empty($conf->$origin->enabled)) { // commonly $origin='commande' + if (isModEnabled($origin)) { // commonly $origin='commande' $outputlangs->load('orders'); $classname = ucfirst($origin); @@ -1005,7 +1001,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $text = $linkedobject->ref; - if ($linkedobject->ref_client) { + if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) { $text .= ' ('.$linkedobject->ref_client.')'; } $Yoff = $Yoff + 8; @@ -1133,8 +1129,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posy = $pdf->getY(); // Show recipient information - $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 4a51ebe52ff34..f59c84f19c300 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -110,7 +110,8 @@ public function __construct(DoliDB $db) $this->posxpicture = $this->posxweightvol - getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH', 20); // width of images - if ($this->page_largeur < 210) { // To work with US executive format + // To work with US executive format + if ($this->page_largeur < 210) { $this->posxweightvol -= 20; $this->posxpicture -= 20; $this->posxqtyordered -= 20; @@ -321,14 +322,14 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (!empty($object->note_public) || !empty($object->tracking_number)) { $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->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(); + $object->getUrlTrackingStatus($object->tracking_number); if (!empty($object->tracking_url)) { if ($object->reception_method_id > 0) { @@ -398,7 +399,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20); $nexY = $pdf->GetY(); - $height_barcode = $nexY - $tab_top; + $height_barcode = 20; $tab_top += 22; } else { @@ -549,8 +550,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, 1); } - $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, 0, 0, false, true, 'C'); - //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); + if (!getDolGlobalString('RECEPTION_PDF_HIDE_WEIGHT_AND_VOLUME')) { + $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ? '
' : '').$voltxt, 0, 0, false, true, 'C'); + //$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'
':'').$voltxt,'','C'); + } // Qty ordered if (!getDolGlobalString('RECEPTION_PDF_HIDE_ORDERED')) { @@ -658,6 +661,8 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede dolChmod($file); + $this->result = array('fullpath' => $file); + return 1; // No error } else { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); @@ -721,11 +726,10 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $totalVolume = $tmparray['volume']; $totalToShip = $tmparray['toship']; - // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = ((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth); - $object->volume_units = $object->size_units * 3; + $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0); + $object->volume_units = (float) $object->size_units * 3; } if ($totalWeight != '') { @@ -914,8 +918,16 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetXY($this->marge_gauche, $posy); // Logo - $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; 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) @@ -998,6 +1010,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) } } + $top_shift = 0; + if ($showaddress) { // Sender properties $carac_emetteur = ''; @@ -1110,7 +1124,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetTextColor(0, 0, 0); - return 0; + return $top_shift; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore From e9e7c1e4fead411e9d878b9050001fb473903170 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 21:39:32 +0200 Subject: [PATCH 20/22] Debug v20 --- .../expedition/doc/pdf_espadon.modules.php | 23 +++++++-------- .../expedition/doc/pdf_rouget.modules.php | 28 ++++++++++--------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 5ba1ab59f5b50..73ab8a400345e 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -254,7 +254,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { + if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -663,11 +663,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // weight $weighttxt = ''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { + if (empty($object->lines[$i]->fk_product_type) && $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 ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { + if (empty($object->lines[$i]->fk_product_type) && $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); } @@ -854,7 +854,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $totalToShip = $tmparray['toship']; // Set trueVolume and volume_units not currently stored into database if ($object->trueWidth && $object->trueHeight && $object->trueDepth) { - $object->trueVolume = (float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth; + $object->trueVolume = price(((float) $object->trueWidth * (float) $object->trueHeight * (float) $object->trueDepth), 0, $outputlangs, 0, 0); $object->volume_units = (float) $object->size_units * 3; } @@ -864,10 +864,10 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs if ($totalVolume != '') { $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); } - if ($object->trueWeight) { + if (!empty($object->trueWeight)) { $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } - if ($object->trueVolume) { + if (!empty($object->trueVolume)) { if ($object->volume_units < 50) { $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); } else { @@ -942,7 +942,6 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetFont('', '', $default_font_size - 2); if (empty($hidetop)) { - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; 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'))); } @@ -1073,7 +1072,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $text = $linkedobject->ref; - if ($linkedobject->ref_client) { + if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) { $text .= ' ('.$linkedobject->ref_client.')'; } $Yoff = $Yoff + 8; @@ -1087,11 +1086,13 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $top_shift = 0; // Show list of linked objects - /*$current_y = $pdf->getY(); + /* + $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) { // Sender properties @@ -1199,8 +1200,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posy = $pdf->getY(); // Show recipient information - $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 9adf9c5c37345..80bf13eabf7cf 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -191,6 +191,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // 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); @@ -224,6 +225,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $realpath = $dir.$filename; + $this->atleastonephoto = true; break; } @@ -238,7 +240,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } if ($conf->expedition->dir_output) { - // Definition de $dir et $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->expedition->dir_output."/sending"; $file = $dir."/SPECIMEN.pdf"; @@ -316,13 +318,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->useTemplate($tplidx); } $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); $tab_top = 90; // position of top tab - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift: 10); $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; @@ -653,10 +655,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone totaux + // Display total area $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); @@ -696,12 +698,12 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede /** * Show total to pay * - * @param TCPDF $pdf Object PDF - * @param Expedition $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart + * @param TCPDF $pdf Object PDF + * @param Expedition $object Object expedition + * @param int $deja_regle Amount already paid + * @param int $posy Start Position * @param Translate $outputlangs Object langs - * @return int Position pour suite + * @return int Position for suite */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { @@ -716,7 +718,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $tab2_hl = 4; $pdf->SetFont('', 'B', $default_font_size - 1); - // Tableau total + // Total table $col1x = $this->posxweightvol - 50; $col2x = $this->posxweightvol; /*if ($this->page_largeur < 210) // To work with US executive format @@ -909,7 +911,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -1031,7 +1033,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) if (!empty($origin) && is_object($object->origin_object)) { $arrayidcontact = $object->origin_object->getIdContact('internal', 'SALESREPFOLL'); } - if (count($arrayidcontact) > 0) { + 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)); From 7c02a468c534f339b742a4320e32314b3db24e58 Mon Sep 17 00:00:00 2001 From: lamrani abdelwadoud Date: Wed, 22 May 2024 21:39:59 +0200 Subject: [PATCH 21/22] Fix qr code in stock transf (#29743) * Fix display Qrcode on stock transfer pdf * Fix php run --- .../modules/stocktransfer/doc/pdf_eagle.modules.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 61079dd820bfb..957d9d6c12f37 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -364,7 +364,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms; + $tab_top = 88 + $height_incoterms + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 20 : 0); $tab_top_alt = $tab_top; $pdf->SetFont('', 'B', $default_font_size - 2); @@ -418,9 +418,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = 0; } - $iniY = $tab_top + 7; - $curY = $tab_top + 7; - $nexY = $tab_top + 7; + $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); + $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); + $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); $TCacheEntrepots = array(); // Loop on each lines @@ -658,7 +658,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')) { + $heightforfooter = $heightforfooter - 5; + } // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); From c8e457c73cc39b0c86a67b81eab585dfc75609d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 22 May 2024 22:21:02 +0200 Subject: [PATCH 22/22] Debug v20 --- .../expedition/doc/pdf_espadon.modules.php | 4 +- .../expedition/doc/pdf_rouget.modules.php | 6 +- .../stocktransfer/doc/pdf_eagle.modules.php | 177 ++++++++++-------- 3 files changed, 106 insertions(+), 81 deletions(-) diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 73ab8a400345e..25d455b4b00b5 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -181,7 +181,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede 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 CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo + // 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 { @@ -236,7 +236,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook - $nblines = count($object->lines); + $nblines = is_array($object->lines) ? count($object->lines) : 0; $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 80bf13eabf7cf..20a809ea36ae8 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -187,7 +187,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); } - $nblines = count($object->lines); + $nblines = is_array($object->lines) ? count($object->lines) : 0; // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); @@ -269,7 +269,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks // Set nblines with the new facture lines content after hook - $nblines = count($object->lines); + $nblines = is_array($object->lines) ? count($object->lines) : 0; $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -824,6 +824,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { + // phpcs:enable global $conf; // Force to disable hidetop and hidebottom @@ -903,6 +904,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { + // phpcs:enable global $conf, $langs, $mysoc; $langs->load("orders"); diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 957d9d6c12f37..c25ac994df5f8 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -98,7 +98,7 @@ class pdf_eagle extends ModelePDFStockTransfer * * @param DoliDB $db Database handler */ - public function __construct($db) + public function __construct(DoliDB $db) { global $langs, $mysoc; @@ -122,7 +122,7 @@ public function __construct($db) $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); - } // By default if not defined + } // Define position of columns $this->posxdesc = $this->marge_gauche + 1; @@ -178,7 +178,7 @@ public function __construct($db) public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $db, $user, $conf, $langs, $hookmanager; + global $user, $conf, $langs, $hookmanager; $object->fetch_thirdparty(); @@ -195,10 +195,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Load traductions files required by page $outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch", "stocks", "stocktransfer@stocktransfer")); + global $outputlangsbis; + $outputlangsbis = null; + if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')) { + $outputlangsbis = new Translate('', $conf); + $outputlangsbis->setDefaultLang(getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE')); + $outputlangsbis->loadLangs(array("main", "bills", "orders", "products", "dict", "companies", "propal", "deliveries", "sendings", "productbatch")); + } + $nblines = is_array($object->lines) ? count($object->lines) : 0; // Loop on each lines to detect if there is at least one image to show $realpatharray = array(); + $this->atleastonephoto = false; if (getDolGlobalString('MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE')) { $objphoto = new Product($this->db); @@ -232,6 +241,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $realpath = $dir.$filename; + $this->atleastonephoto = true; break; } @@ -290,7 +300,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $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 (getDolGlobalInt('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS') > 0) { + if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { $heightforfooter += 6; } $pdf->SetAutoPageBreak(1, 0); @@ -301,7 +311,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $pdf->SetFont(pdf_getPDFFont($outputlangs)); // Set path to the background PDF File - if (getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { + if (!getDolGlobalString('MAIN_DISABLE_FPDI') && getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')) { $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/' . getDolGlobalString('MAIN_ADD_PDF_BACKGROUND')); $tplidx = $pdf->importPage(1); } @@ -332,14 +342,16 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->useTemplate($tplidx); } $pagenb++; - $this->_pagehead($pdf, $object, 1, $outputlangs); + $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->SetTextColor(0, 0, 0); - $tab_top = 90; - $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10); - $tab_height = 130; + $tab_top = 90; // position of top tab + $tab_top_newpage = (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift: 10); + + $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $tab_height_newpage = 150; // Incoterm @@ -347,7 +359,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (isModEnabled('incoterm')) { $desc_incoterms = $object->getIncotermsForPDF(); if ($desc_incoterms) { - $tab_top = 88; + $tab_top -= 2; $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); @@ -363,17 +375,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } + // Public note and Tracking code if (!empty($object->note_public) || !empty($object->tracking_number)) { - $tab_top = 88 + $height_incoterms + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 20 : 0); $tab_top_alt = $tab_top; - $pdf->SetFont('', 'B', $default_font_size - 2); - //$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'); + $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(); $object->getUrlTrackingStatus($object->tracking_number); @@ -391,12 +404,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $label .= " : "; $label .= $object->tracking_url; } - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); - $tab_top_alt = $pdf->GetY(); + $height_trackingnumber += 4; + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->writeHTMLCell(60, $height_trackingnumber, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1, false, true, 'L'); } } + $tab_top = $pdf->GetY(); } // Notes @@ -418,9 +432,44 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $height_note = 0; } - $iniY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); - $curY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); - $nexY = $tab_top + (isModEnabled("barcode") && getDolGlobalInt("BARCODE_ON_STOCKTRANSFER_PDF") ? 9 : 7); + // Show barcode + $height_barcode = 0; + //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); + if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')) { + require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; + + $encoding = 'QRCODE'; + $module = new modTcpdfbarcode(); + $barcode_path = ''; + $result = 0; + if ($module->encodingIsSupported($encoding)) { + $result = $module->writeBarCode($object->ref, $encoding); + + // get path of qrcode image + $newcode = $object->ref; + if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { + $newcode = dol_hash($newcode, 'md5'); + } + $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; + } + + if ($result > 0) { + $tab_top -= 2; + + $pdf->Image($barcode_path, $this->marge_gauche, $tab_top, 20, 20); + + $nexY = $pdf->GetY(); + $height_barcode = 20; + + $tab_top += 22; + } else { + $this->error = 'Failed to generate barcode'; + } + } + + $iniY = $tab_top + 7; + $curY = $tab_top + 7; + $nexY = $tab_top + 7; $TCacheEntrepots = array(); // Loop on each lines @@ -442,6 +491,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $showpricebeforepagebreak = 1; $posYAfterImage = 0; $posYAfterDescription = 0; + $heightforsignature = 0; // We start with Photo of product line if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page @@ -531,7 +581,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } $posYAfterDescription = $pdf->GetY(); - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $posYAfterImage); $pageposafter = $pdf->getPage(); $pdf->setPage($pageposbefore); @@ -550,7 +600,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $curY = $tab_top_newpage; } - $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par default + $pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font // Lot / série if (isModEnabled('productbatch')) { @@ -558,14 +608,15 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch, '', 'C'); } - // Weight + // weight + $pdf->SetXY($this->posxweightvol, $curY); $weighttxt = ''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) { + if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->weight) { $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1); } $voltxt = ''; - if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) { + if (empty($object->lines[$i]->fk_product_type) && $object->lines[$i]->volume) { $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1); } @@ -639,6 +690,9 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (!getDolGlobalInt('MAIN_PDF_DONOTREPEAT_HEAD')) { $this->_pagehead($pdf, $object, 0, $outputlangs); } + if (!empty($tplidx)) { + $pdf->useTemplate($tplidx); + } } if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) { if ($pagenb == 1) { @@ -658,9 +712,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede } } } - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')) { - $heightforfooter = $heightforfooter - 5; - } + // Show square if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); @@ -670,10 +722,10 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } - // Affiche zone totaux + // Display total area $posy = $this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs); - // Pied de page + // Pagefoot $this->_pagefoot($pdf, $object, $outputlangs); if (method_exists($pdf, 'AliasNbPages')) { $pdf->AliasNbPages(); @@ -714,11 +766,11 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede * Show total to pay * * @param TCPDF $pdf Object PDF - * @param StockTransfer $object Object invoice - * @param int $deja_regle Montant deja regle - * @param int $posy Position depart + * @param StockTransfer $object Object StockTransfer + * @param int $deja_regle Amount already paid + * @param int $posy Start Position * @param Translate $outputlangs Object langs - * @return int Position pour suite + * @return int Position for suite */ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { @@ -729,7 +781,7 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs $tab2_hl = 4; $pdf->SetFont('', 'B', $default_font_size - 1); - // Tableau total + // Total table $col1x = $this->posxqty - 50; $col2x = $this->posxqty; /*if ($this->page_largeur < 210) // To work with US executive format @@ -774,10 +826,10 @@ protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs if ($totalVolume != '') { $totalVolumetoshow = showDimensionInBestUnit($totalVolume, 0, "volume", $outputlangs); } - if ($object->trueWeight) { + if (!empty($object->trueWeight)) { $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs); } - if ($object->trueVolume) { + if (!empty($object->trueVolume)) { $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs); } @@ -858,6 +910,7 @@ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $ $pdf->SetDrawColor(128, 128, 128); $pdf->SetFont('', '', $default_font_size - 1); + // Description if (empty($hidetop)) { $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); @@ -968,7 +1021,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK); } - //Prepare la suite + //Prepare next $pdf->SetTextColor(0, 0, 60); $pdf->SetFont('', 'B', $default_font_size + 3); @@ -996,38 +1049,6 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } - // Show barcode - if (isModEnabled('barcode')) { - $posx = 105; - } else { - $posx = $this->marge_gauche + 3; - } - //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); - if (isModEnabled('barcode') && getDolGlobalString('BARCODE_ON_STOCKTRANSFER_PDF')) { - require_once DOL_DOCUMENT_ROOT.'/core/modules/barcode/doc/tcpdfbarcode.modules.php'; - - $encoding = 'QRCODE'; - $result = 0; - $barcode_path = ''; - $module = new modTcpdfbarcode(); - if ($module->encodingIsSupported($encoding)) { - $result = $module->writeBarCode($object->ref, $encoding); - - // get path of qrcode image - $newcode = $object->ref; - if (!preg_match('/^\w+$/', $newcode) || dol_strlen($newcode) > 32) { - $newcode = dol_hash($newcode, 'md5'); - } - $barcode_path = $conf->barcode->dir_temp . '/barcode_' . $newcode . '_' . $encoding . '.png'; - } - - if ($result > 0) { - $pdf->Image($barcode_path, $this->marge_gauche, $this->marge_haute +80 -5, 20, 20); - } else { - $this->error = 'Failed to generate barcode'; - } - } - $pdf->SetDrawColor(128, 128, 128); $posx = $this->page_largeur - $w - $this->marge_droite; @@ -1089,7 +1110,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $origin_id = $object->origin_id; // TODO move to external function - if (!empty($conf->$origin->enabled)) { // commonly $origin='commande' + if (isModEnabled($origin)) { // commonly $origin='commande' $outputlangs->load('orders'); $classname = ucfirst($origin); @@ -1100,7 +1121,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $pdf->SetFont('', '', $default_font_size - 2); $text = $linkedobject->ref; - if ($linkedobject->ref_client) { + if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) { $text .= ' ('.$linkedobject->ref_client.')'; } $Yoff = $Yoff + 8; @@ -1112,6 +1133,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) } } + $top_shift = 0; + if ($showaddress) { // Sender properties $carac_emetteur = ''; @@ -1157,7 +1180,7 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $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->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("Sender").":", 0, 'L'); $pdf->SetXY($posx, $posy); $pdf->SetFillColor(230, 230, 230); $pdf->MultiCell($widthrecbox, $hautcadre, "", 0, 'R', 1); @@ -1202,8 +1225,8 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) // Show recipient $widthrecbox = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 92 : 100; if ($this->page_largeur < 210) { - $widthrecbox = 84; - } // To work with US executive format + $widthrecbox = 84; // To work with US executive format + } $posy = getDolGlobalString('MAIN_PDF_USE_ISO_LOCATION') ? 40 : 42; $posx = $this->page_largeur - $this->marge_droite - $widthrecbox; if (getDolGlobalString('MAIN_INVERT_SENDER_RECIPIENT')) { @@ -1225,14 +1248,14 @@ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs) $posy = $pdf->getY(); // Show recipient information - $pdf->SetFont('', '', $default_font_size - 1); $pdf->SetXY($posx + 2, $posy); + $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); } $pdf->SetTextColor(0, 0, 0); - return 0; + return $top_shift; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore