Fix generation of ODT (test if temporary directory is writable)

This commit is contained in:
Laurent Destailleur
2021-06-20 05:11:46 +02:00
parent 1a6647e690
commit e3e2dfd764
26 changed files with 162 additions and 57 deletions

View File

@@ -4334,37 +4334,41 @@ abstract class CommonObject
/**
* Function that returns the total amount HT of discounts applied for all lines.
*
* @return float
* @return float|string Total amout of discount
*/
public function getTotalDiscount()
{
$total_discount = 0.00;
if (!empty($this->table_element_line) ) {
$total_discount = 0.00;
$sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element."det";
$sql .= " WHERE ".$this->fk_element." = ".$this->id;
$sql = "SELECT subprice as pu_ht, qty, remise_percent, total_ht";
$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element_line;
$sql .= " WHERE ".$this->fk_element." = ".$this->id;
dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
dol_syslog(get_class($this).'::getTotalDiscount', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql) {
$num = $this->db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $this->db->fetch_object($resql);
$pu_ht = $obj->pu_ht;
$qty = $obj->qty;
$total_ht = $obj->total_ht;
$pu_ht = $obj->pu_ht;
$qty = $obj->qty;
$total_ht = $obj->total_ht;
$total_discount_line = floatval(price2num(($pu_ht * $qty) - $total_ht, 'MT'));
$total_discount += $total_discount_line;
$total_discount_line = floatval(price2num(($pu_ht * $qty) - $total_ht, 'MT'));
$total_discount += $total_discount_line;
$i++;
$i++;
}
}
//print $total_discount; exit;
return price2num($total_discount);
}
//print $total_discount; exit;
return price2num($total_discount);
return null;
}