Merge pull request #20280 from Achicken7301/develop

Add unit price for {DOL_PRINT_OBJECT_LINES}
This commit is contained in:
Laurent Destailleur 2022-03-07 13:44:03 +01:00 committed by GitHub
commit 403db246bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -642,14 +642,14 @@ class dolReceiptPrinter extends Printer
case 'DOL_PRINT_OBJECT_LINES':
foreach ($object->lines as $line) {
if ($line->fk_product) {
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - 10 - 1;
$spacestoadd = $nbcharactbyline - strlen($line->ref) - strlen($line->qty) - strlen($line->subprice) - 10 - 1;
$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");
$this->printer->text($line->ref . $spaces . $line->qty . str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT) . ' ' . str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT) . "\n");
$this->printer->text(strip_tags(htmlspecialchars_decode($line->product_label))."\n \n");
} else {
$spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - 10 - 1;
$spacestoadd = $nbcharactbyline - strlen($line->description) - strlen($line->qty) - strlen($line->subprice) - 10 - 1;
$spaces = str_repeat(' ', $spacestoadd > 0 ? $spacestoadd : 0);
$this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
$this->printer->text($line->description.$spaces.$line->qty.' '.str_pad(price($line->subprice), 10, ' ', STR_PAD_LEFT).' '.str_pad(price($line->total_ttc), 10, ' ', STR_PAD_LEFT)."\n");
}
}
break;