Fix: limit to products and services

This commit is contained in:
Regis Houssin 2012-08-15 10:31:45 +02:00
parent f03e0965e2
commit b2ff7b5ea1

View File

@ -87,16 +87,21 @@ report_header($nom,$nomlink,$period,$periodlink,$description,$builddate,$exportl
$p = explode(":", $conf->global->MAIN_INFO_SOCIETE_PAYS);
$idpays = $p[0];
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client , fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
$sql.= " p.accountancy_code_sell, s.code_compta , ct.accountancy_code";
$sql = "SELECT f.rowid, f.facnumber, f.type, f.datef, f.ref_client,";
$sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc,";
$sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,";
$sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,";
$sql.= " ct.accountancy_code";
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product";
$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture";
$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '".$idpays."'";
$sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity;
$sql.= " WHERE f.entity = ".$conf->entity;
$sql.= " AND f.fk_statut > 0";
$sql.= " AND fd.product_type IN (0,1)";
if ($date_start && $date_end) $sql .= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql .= " order by f.rowid";
$sql.= " ORDER BY f.rowid";
$result = $db->query($sql);
if ($result)