Avoid php errors if negative var in Receipt Module

Solved in develop branch with PR https://github.com/Dolibarr/dolibarr/pull/15994/files
After testing we introduce it in version 13
This commit is contained in:
andreubisquerra 2021-03-01 23:09:07 +01:00 committed by GitHub
parent b8bd5cd0ee
commit 15cc0f8775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -634,7 +634,7 @@ class dolReceiptPrinter extends Printer
if ($line->fk_product)
{
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd);
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->ref.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n");
}