mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 09:01:40 +01:00
Fix generation of ODT (test if temporary directory is writable)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user