Fix some php warning (#30753)

* Fix php warning on send email

* Fix php warning on getTotalWeightVolume when no lines.

* Fix totalOrdered totalToShip should be int
This commit is contained in:
Francis Appels 2024-08-27 04:52:47 +02:00 committed by GitHub
parent c03617d5b7
commit a8ddeff35c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 10 deletions

View file

@ -579,7 +579,7 @@ class CMailFile
if (!empty($this->atleastonefile)) {
foreach ($filename_list as $i => $val) {
$content = file_get_contents($filename_list[$i]);
$smtps->setAttachment($content, $mimefilename_list[$i], $mimetype_list[$i], $cid_list[$i]);
$smtps->setAttachment($content, $mimefilename_list[$i], $mimetype_list[$i], (empty($cid_list[$i]) ? '' : $cid_list[$i]));
}
}

View file

@ -4970,25 +4970,19 @@ abstract class CommonObject
$totalWeight = 0;
$totalVolume = 0;
// defined for shipment only
$totalOrdered = '';
$totalOrdered = 0;
// defined for shipment only
$totalToShip = '';
$totalToShip = 0;
if (empty($this->lines)) {
return array();
return array('weight' => $totalWeight, 'volume' => $totalVolume, 'ordered' => $totalOrdered, 'toship' => $totalToShip);
}
foreach ($this->lines as $line) {
if (isset($line->qty_asked)) {
if (empty($totalOrdered)) {
$totalOrdered = 0; // Avoid warning because $totalOrdered is ''
}
$totalOrdered += $line->qty_asked; // defined for shipment only
}
if (isset($line->qty_shipped)) {
if (empty($totalToShip)) {
$totalToShip = 0; // Avoid warning because $totalToShip is ''
}
$totalToShip += $line->qty_shipped; // defined for shipment only
} elseif ($line->element == 'commandefournisseurdispatch' && isset($line->qty)) {
if (empty($totalToShip)) {