NEW Add option to round weight and volumen on shipment pdf

This commit is contained in:
Laurent Destailleur 2024-11-06 12:50:24 +01:00
parent c8167567ca
commit 37f15cfb42
3 changed files with 11 additions and 5 deletions

View File

@ -686,14 +686,14 @@ class pdf_espadon extends ModelePdfExpedition
// weight
$weighttxt = '';
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);
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_WEIGHT_ON_PDF', 5)).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
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);
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_VOLUME_ON_PDF', 5)).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
// weight and volume
if ($this->getColumnStatus('weight')) {
$this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt);
$nexY = max($pdf->GetY(), $nexY);

View File

@ -580,11 +580,11 @@ class pdf_rouget extends ModelePdfExpedition
$pdf->SetXY($this->posxweightvol, $curY);
$weighttxt = '';
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);
$weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_WEIGHT_ON_PDF', 5)).' '.measuringUnitString(0, "weight", $object->lines[$i]->weight_units, 1);
}
$voltxt = '';
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);
$voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty_shipped, getDolGlobalInt('SHIPMENT_ROUND_VOLUME_ON_PDF', 5)).' '.measuringUnitString(0, "volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
}
if (!getDolGlobalString('SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME')) {

View File

@ -2164,6 +2164,12 @@ class Expedition extends CommonObject
$line->qty_shipped = 4;
$line->fk_product = $this->commande->lines[$xnbp]->fk_product;
$line->weight = 1.123456;
$line->weight_units = 0; // kg
$line->volume = 2.34567;
$line->volume_unit = 0;
$this->lines[] = $line;
$xnbp++;
}