Meilleur formatage du rapport mensuel des actions
This commit is contained in:
parent
82eedce4b6
commit
453e7d5304
@ -45,6 +45,7 @@ class CommActionRapport
|
|||||||
function CommActionRapport($db=0, $month, $year)
|
function CommActionRapport($db=0, $month, $year)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
$langs->load("commercial");
|
||||||
|
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
$this->description = "";
|
$this->description = "";
|
||||||
|
|||||||
@ -49,13 +49,17 @@ class Product
|
|||||||
var $duration_value;
|
var $duration_value;
|
||||||
var $duration_unit;
|
var $duration_unit;
|
||||||
|
|
||||||
|
var $stats_propale=array();
|
||||||
|
var $stats_commande=array();
|
||||||
|
var $stats_contrat=array();
|
||||||
|
var $stats_facture=array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de la classe
|
* \brief Constructeur de la classe
|
||||||
* \param DB handler accès base de données
|
* \param DB Handler accès base de données
|
||||||
* \param id id produit (0 par defaut)
|
* \param id Id produit (0 par defaut)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function Product($DB, $id=0)
|
function Product($DB, $id=0)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
@ -360,12 +364,10 @@ class Product
|
|||||||
* \param id id du produit/service à modifier
|
* \param id id du produit/service à modifier
|
||||||
* \param user utilisateur qui modifie le prix
|
* \param user utilisateur qui modifie le prix
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function update_price($id, $user)
|
function update_price($id, $user)
|
||||||
{
|
{
|
||||||
if (strlen(trim($this->price)) > 0 )
|
if (strlen(trim($this->price)) > 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product ";
|
||||||
$sql .= " SET price = " . ereg_replace(",",".",$this->price);
|
$sql .= " SET price = " . ereg_replace(",",".",$this->price);
|
||||||
$sql .= " WHERE rowid = " . $id;
|
$sql .= " WHERE rowid = " . $id;
|
||||||
@ -393,7 +395,6 @@ class Product
|
|||||||
* \brief Charge le produit/service en mémoire
|
* \brief Charge le produit/service en mémoire
|
||||||
* \param id id du produit/service à charger
|
* \param id id du produit/service à charger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function fetch ($id)
|
function fetch ($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration, seuil_stock_alerte";
|
$sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration, seuil_stock_alerte";
|
||||||
@ -471,92 +472,142 @@ class Product
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie le nombre de propale incluant le produit/service
|
* \brief Charge tableau des stats propale pour le produit/service
|
||||||
* \param socid id societe
|
* \param socid Id societe
|
||||||
* \return int nombre d'inclusion
|
* \return array Tableau des stats
|
||||||
*/
|
*/
|
||||||
|
function load_stats_propale($socid=0)
|
||||||
function count_propale($socid=0)
|
|
||||||
{
|
{
|
||||||
$sql = "SELECT pd.fk_propal";
|
$sql = "SELECT COUNT(DISTINCT pr.fk_soc) as nb_customers, COUNT(DISTINCT pr.rowid) as nb,";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."propal as pr";
|
$sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
|
||||||
$sql .= " WHERE pr.rowid = pd.fk_propal AND p.rowid = pd.fk_product AND p.rowid = ".$this->id;
|
|
||||||
if ($socid > 0)
|
|
||||||
{
|
|
||||||
$sql .= " AND pr.fk_soc = $socid";
|
|
||||||
}
|
|
||||||
$sql .= " GROUP BY pd.fk_propal";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
|
||||||
|
|
||||||
if ( $result )
|
|
||||||
{
|
|
||||||
return $this->db->num_rows();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Renvoie le nombre de client avec propale incluant le produit/service
|
|
||||||
* \param socid id societe
|
|
||||||
* \return int nombre d'inclusion
|
|
||||||
*/
|
|
||||||
|
|
||||||
function count_propale_client($socid=0)
|
|
||||||
{
|
|
||||||
$sql = "SELECT pr.fk_soc";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."propal as pr";
|
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."product as p, ".MAIN_DB_PREFIX."propal as pr";
|
||||||
$sql.= " WHERE p.rowid = pd.fk_product AND pd.fk_propal = pr.rowid AND p.rowid = ".$this->id;
|
$sql.= " WHERE p.rowid = pd.fk_product AND pd.fk_propal = pr.rowid AND p.rowid = ".$this->id;
|
||||||
|
//$sql.= " AND pr.fk_statut != 0";
|
||||||
if ($socid > 0)
|
if ($socid > 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND pr.fk_soc = $socid";
|
$sql .= " AND pr.fk_soc = $socid";
|
||||||
}
|
}
|
||||||
$sql .= " GROUP BY pr.fk_soc";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
|
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
return $this->db->num_rows();
|
$obj=$this->db->fetch_object($result);
|
||||||
|
$this->stats_propale['customers']=$obj->nb_customers;
|
||||||
|
$this->stats_propale['nb']=$obj->nb;
|
||||||
|
$this->stats_propale['rows']=$obj->nb_rows;
|
||||||
|
$this->stats_propale['qty']=$obj->qty?$obj->qty:0;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie le nombre de facture incluant le produit/service
|
* \brief Charge tableau des stats commande pour le produit/service
|
||||||
* \param socid id societe
|
* \param socid Id societe
|
||||||
* \return int nombre d'inclusion
|
* \return array Tableau des stats
|
||||||
*/
|
*/
|
||||||
|
function load_stats_commande($socid=0)
|
||||||
function count_facture($socid=0)
|
|
||||||
{
|
{
|
||||||
$sql = "SELECT pd.fk_facture";
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
||||||
|
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."product as p,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."commande as c";
|
||||||
|
$sql.= " WHERE c.rowid = cd.fk_commande AND p.rowid = cd.fk_product AND p.rowid = ".$this->id;
|
||||||
|
//$sql.= " AND c.fk_statut != 0";
|
||||||
|
if ($socid > 0)
|
||||||
|
{
|
||||||
|
$sql .= " AND c.fk_soc = $socid";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ( $result )
|
||||||
|
{
|
||||||
|
$obj=$this->db->fetch_object($result);
|
||||||
|
$this->stats_commande['customers']=$obj->nb_customers;
|
||||||
|
$this->stats_commande['nb']=$obj->nb;
|
||||||
|
$this->stats_commande['rows']=$obj->nb_rows;
|
||||||
|
$this->stats_commande['qty']=$obj->qty?$obj->qty:0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge tableau des stats contrat pour le produit/service
|
||||||
|
* \param socid Id societe
|
||||||
|
* \return array Tableau des stats
|
||||||
|
*/
|
||||||
|
function load_stats_contrat($socid=0)
|
||||||
|
{
|
||||||
|
$sql = "SELECT COUNT(DISTINCT c.fk_soc) as nb_customers, COUNT(DISTINCT c.rowid) as nb,";
|
||||||
|
$sql.= " COUNT(cd.rowid) as nb_rows, SUM(cd.qty) as qty";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."contratdet as cd, ".MAIN_DB_PREFIX."product as p,";
|
||||||
|
$sql.= " ".MAIN_DB_PREFIX."contrat as c";
|
||||||
|
$sql.= " WHERE c.rowid = cd.fk_contrat AND p.rowid = cd.fk_product AND p.rowid = ".$this->id;
|
||||||
|
//$sql.= " AND c.statut != 0";
|
||||||
|
if ($socid > 0)
|
||||||
|
{
|
||||||
|
$sql .= " AND c.fk_soc = $socid";
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = $this->db->query($sql) ;
|
||||||
|
if ( $result )
|
||||||
|
{
|
||||||
|
$obj=$this->db->fetch_object($result);
|
||||||
|
$this->stats_contrat['customers']=$obj->nb_customers;
|
||||||
|
$this->stats_contrat['nb']=$obj->nb;
|
||||||
|
$this->stats_contrat['rows']=$obj->nb_rows;
|
||||||
|
$this->stats_contrat['qty']=$obj->qty?$obj->qty:0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Charge tableau des stats facture pour le produit/service
|
||||||
|
* \param socid Id societe
|
||||||
|
* \return array Tableau des stats
|
||||||
|
*/
|
||||||
|
function load_stats_facture($socid=0)
|
||||||
|
{
|
||||||
|
$sql = "SELECT COUNT(DISTINCT f.fk_soc) as nb_customers, COUNT(DISTINCT f.rowid) as nb,";
|
||||||
|
$sql.= " COUNT(pd.rowid) as nb_rows, SUM(pd.qty) as qty";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as pd, ".MAIN_DB_PREFIX."product as p";
|
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as pd, ".MAIN_DB_PREFIX."product as p";
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
$sql.= ", ".MAIN_DB_PREFIX."facture as f";
|
||||||
$sql.= " WHERE f.rowid = pd.fk_facture AND p.rowid = pd.fk_product AND p.rowid = ".$this->id;
|
$sql.= " WHERE f.rowid = pd.fk_facture AND p.rowid = pd.fk_product AND p.rowid = ".$this->id;
|
||||||
|
//$sql.= " AND f.fk_statut != 0";
|
||||||
if ($socid > 0)
|
if ($socid > 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND f.fk_soc = $socid";
|
$sql .= " AND f.fk_soc = $socid";
|
||||||
}
|
}
|
||||||
$sql .= " GROUP BY pd.fk_facture";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
|
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
return $this->db->num_rows();
|
$obj=$this->db->fetch_object($result);
|
||||||
|
$this->stats_facture['customers']=$obj->nb_customers;
|
||||||
|
$this->stats_facture['nb']=$obj->nb;
|
||||||
|
$this->stats_facture['rows']=$obj->nb_rows;
|
||||||
|
$this->stats_facture['qty']=$obj->qty?$obj->qty:0;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
$this->error=$this->db->error();
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user