Merge pull request #1290 from atm-maxime/develop
Fix : SQL error on margin page
This commit is contained in:
commit
b3eec934b8
@ -158,7 +158,7 @@ print '</form>';
|
||||
$sql = "SELECT p.label, p.rowid, p.fk_product_type, p.ref,";
|
||||
$sql.= " d.fk_product,";
|
||||
$sql.= " f.rowid as facid, f.facnumber, f.total as total_ht,";
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut";
|
||||
$sql.= " f.datef, f.paye, f.fk_statut as statut,";
|
||||
$sql.= " sum(d.total_ht) as selling_price,";
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht <=0','d.qty * d.buy_price_ht * -1','d.qty * d.buy_price_ht').") as buying_price,";
|
||||
$sql.= " sum(".$db->ifsql('d.total_ht <=0','-1 * (abs(d.total_ht) - (d.buy_price_ht * d.qty))','d.total_ht - (d.buy_price_ht * d.qty)').") as marge";
|
||||
|
||||
@ -215,7 +215,7 @@ $sql.= ' GROUP BY p.rowid, p.ref, p.label, p.price';
|
||||
$sql.= ', p.price_ttc, p.price_base_type,p.fk_product_type, p.tms';
|
||||
$sql.= ', p.duration, p.tobuy, p.seuil_stock_alerte';
|
||||
$sql.= ', p.desiredstock, s.fk_product';
|
||||
$sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "s.reel", "0").')';
|
||||
$sql.= ' HAVING p.desiredstock > SUM('.$db->ifsql("s.reel IS NULL", "0", "s.reel").')';
|
||||
$sql.= ' AND p.desiredstock > 0';
|
||||
if ($salert == 'on') // Option to see when stock is lower than alert
|
||||
{
|
||||
|
||||
@ -92,7 +92,7 @@ $filter=GETPOST('filter');
|
||||
$statut=GETPOST('statut');
|
||||
|
||||
if (! $sortorder) { $sortorder="ASC"; }
|
||||
if (! $sortfield) { $sortfield="nom"; }
|
||||
if (! $sortfield) { $sortfield="lastname"; }
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user