Commit 14d5fb05 authored by Ayolo's avatar Ayolo
Browse files

fix

parent 3522c38f
......@@ -63,60 +63,52 @@ $cts->add($frm,true);
if ( $_REQUEST["action"] == "view" )
{
$conds = array();
$condsnb = array();
$comptoir = false;
if ( $_REQUEST["debut"] )
$condsnb[] = "cpt_debitfacture.date_facture >= '".date("Y-m-d H:i:s",$_REQUEST["debut"])."'";
if ( $_REQUEST["fin"] )
$condsnb[] = "cpt_debitfacture.date_facture <= '".date("Y-m-d H:i:s",$_REQUEST["fin"])."'";
if ( isset($comptoirs[$_REQUEST["id_comptoir"]]) && $_REQUEST["id_comptoir"] )
{
$conds[] = "cpt_mise_en_vente.id_comptoir='".intval($_REQUEST["id_comptoir"])."'";
$comptoir=true;
}
$condsnb = array();
$comptoir = false;
if ( $_REQUEST["debut"] )
$condsnb[] = "cpt_debitfacture.date_facture >= '".date("Y-m-d H:i:s",$_REQUEST["debut"])."'";
if ( $_REQUEST["fin"] )
$condsnb[] = "cpt_debitfacture.date_facture <= '".date("Y-m-d H:i:s",$_REQUEST["fin"])."'";
if ( isset($comptoirs[$_REQUEST["id_comptoir"]]) && $_REQUEST["id_comptoir"] )
{
$conds[] = "cpt_mise_en_vente.id_comptoir='".intval($_REQUEST["id_comptoir"])."'";
$comptoir=true;
}
if ( $comptoir || $site->user->is_in_group("gestion_ae") )
{
if ( $_REQUEST["id_assocpt"] )
{
if ( $_REQUEST["id_assocpt"] && !empty($_REQUEST["id_assocpt"]))
$conds[] = "cpt_produits.id_assocpt='".intval($_REQUEST["id_assocpt"])."'";
}
if ( count($conds) )
{
{
$req = new requete($site->db,
"SELECT `cpt_produits`.`nom_prod`,`cpt_produits`.`id_produit`, " .
"`asso`.`nom_asso`, " .
"`cpt_type_produit`.`nom_typeprod`, " .
"(SELECT SUM(`cpt_vendu`.`quantite`) AS `ventes` FROM `cpt_vendu` WHERE `cpt_vendu`.`id_produit`=`cpt_produits`.`id_produit` ) AS `ventes` ".
"(SELECT SUM(`cpt_vendu`.`quantite`) AS `ventes` FROM `cpt_vendu` WHERE `cpt_vendu`.`id_produit`=`cpt_produits`.`id_produit` ) AS `ventes` ".
"FROM `cpt_produits` " .
"INNER JOIN `cpt_type_produit` ON `cpt_type_produit`.`id_typeprod`=`cpt_produits`.`id_typeprod` " .
"INNER JOIN `asso` ON `asso`.`id_asso`=`cpt_produits`.`id_assocpt` " .
"INNER JOIN cpt_mise_en_vente ON `cpt_mise_en_vente`.`id_produit`=`cpt_produits`.`id_produit` " .
"WHERE " .implode(" AND ",$conds).
"ORDER BY `ventes` DESC");
$tbl = new table("Produits");
$tbl->add_row(array("Nombre de ventes","Type","Nom du produit","Association"));
while ( list($nom_prod,$id_prod,$nom_asso,$nom_typeprod,$ventes) = $req->get_row() )
{
$reqnb = new requete($site->db, "SELECT " .
"SUM(`cpt_vendu`.`quantite`) " .
"FROM `cpt_vendu` " .
"INNER JOIN `cpt_debitfacture` ON `cpt_debitfacture`.`id_facture` =`cpt_vendu`.`id_facture` " .
"WHERE `cpt_vendu`.`id_produit`=".$id_prod." AND " .implode(" AND ",$condsnb));
$ventes = $req->get_row();
print_r($ventes);
$tbl->add_row(array($ventes,$nom_typeprod,$nom_prod,$nom_asso));
}
"ORDER BY `ventes` DESC");
$tbl = new sqltable("products",
"Produits",
$reg,
"",
"id_produit",
array("ventes"=>"Nombre de ventes",
"nom_typeprod"=>"Type",
"nom_prod"=>"Nom du produit",
"nom_asso"=>"Association"),
array(),
array(),
array());
$cts->add($tbl,true);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment