FIX CA report by product/service : subcategory filter

This commit is contained in:
atm-lena 2020-10-08 10:49:46 +02:00
parent 8d3ebad52b
commit 74ae9a2618

View File

@ -237,10 +237,6 @@ if ($modecompta == 'CREANCES-DETTES')
{ {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
} }
elseif ($selected_cat) // Into a specific category
{
$sql.= ", ".MAIN_DB_PREFIX."categorie as c, ".MAIN_DB_PREFIX."categorie_product as cp";
}
$sql.= " WHERE l.fk_facture = f.rowid"; $sql.= " WHERE l.fk_facture = f.rowid";
$sql.= " AND f.fk_statut in (1,2)"; $sql.= " AND f.fk_statut in (1,2)";
$sql.= " AND l.product_type in (0,1)"; $sql.= " AND l.product_type in (0,1)";
@ -261,10 +257,11 @@ if ($modecompta == 'CREANCES-DETTES')
$sql.=" AND cp.fk_product is null"; $sql.=" AND cp.fk_product is null";
} }
elseif ($selected_cat) { // Into a specific category elseif ($selected_cat) { // Into a specific category
$sql.= " AND (c.rowid = ".$selected_cat; $sql.= " AND (p.rowid IN ";
if ($subcat) $sql.=" OR c.fk_parent = " . $selected_cat; $sql.= " (SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product cp WHERE cp.fk_categorie IN ";
$sql.= ")"; $sql.= " (SELECT rowid FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$selected_cat;
$sql.= " AND cp.fk_categorie = c.rowid AND cp.fk_product = p.rowid"; if ($subcat) $sql.=" OR fk_parent = " . $selected_cat;
$sql.= ")))";
} }
if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc; if($selected_soc > 0) $sql .= " AND soc.rowid=".$selected_soc;
$sql.= " AND f.entity IN (".getEntity('invoice').")"; $sql.= " AND f.entity IN (".getEntity('invoice').")";