Fix: Use order date for stats, not valid date.
This commit is contained in:
parent
a1bd60a614
commit
66740071fd
@ -28,8 +28,7 @@ include_once DOL_DOCUMENT_ROOT . "/fourn/class/fournisseur.commande.class.php";
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class CommandeStats
|
* Class to manage order statistics
|
||||||
* \brief Classe permettant la gestion des stats des commandes
|
|
||||||
*/
|
*/
|
||||||
class CommandeStats extends Stats
|
class CommandeStats extends Stats
|
||||||
{
|
{
|
||||||
@ -66,7 +65,7 @@ class CommandeStats extends Stats
|
|||||||
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
|
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
|
||||||
$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
$this->field='total_ht';
|
$this->field='total_ht';
|
||||||
$this->where.= " c.fk_statut > 0";
|
$this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
|
||||||
}
|
}
|
||||||
if ($mode == 'supplier')
|
if ($mode == 'supplier')
|
||||||
{
|
{
|
||||||
@ -74,7 +73,7 @@ class CommandeStats extends Stats
|
|||||||
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
|
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
|
||||||
$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
$this->field='total_ht';
|
$this->field='total_ht';
|
||||||
$this->where.= " c.fk_statut > 0";
|
$this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
|
||||||
}
|
}
|
||||||
$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||||
|
|
||||||
@ -97,10 +96,10 @@ class CommandeStats extends Stats
|
|||||||
global $conf;
|
global $conf;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_valid,'%m') as dm, count(*) nb";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'";
|
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||||
$sql.= " AND ".$this->where;
|
$sql.= " AND ".$this->where;
|
||||||
$sql.= " GROUP BY dm";
|
$sql.= " GROUP BY dm";
|
||||||
$sql.= $this->db->order('dm','DESC');
|
$sql.= $this->db->order('dm','DESC');
|
||||||
@ -119,7 +118,7 @@ class CommandeStats extends Stats
|
|||||||
global $conf;
|
global $conf;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, count(*), sum(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.".$this->field.")";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE ".$this->where;
|
$sql.= " WHERE ".$this->where;
|
||||||
@ -140,10 +139,10 @@ class CommandeStats extends Stats
|
|||||||
global $conf;
|
global $conf;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_valid,'%m') as dm, sum(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'";
|
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||||
$sql.= " AND ".$this->where;
|
$sql.= " AND ".$this->where;
|
||||||
$sql.= " GROUP BY dm";
|
$sql.= " GROUP BY dm";
|
||||||
$sql.= $this->db->order('dm','DESC');
|
$sql.= $this->db->order('dm','DESC');
|
||||||
@ -162,10 +161,10 @@ class CommandeStats extends Stats
|
|||||||
global $conf;
|
global $conf;
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_valid,'%m') as dm, avg(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE date_format(c.date_valid,'%Y') = '".$year."'";
|
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||||
$sql.= " AND ".$this->where;
|
$sql.= " AND ".$this->where;
|
||||||
$sql.= " GROUP BY dm";
|
$sql.= " GROUP BY dm";
|
||||||
$sql.= $this->db->order('dm','DESC');
|
$sql.= $this->db->order('dm','DESC');
|
||||||
@ -182,7 +181,7 @@ class CommandeStats extends Stats
|
|||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_valid,'%Y') as year, count(*) as nb, sum(c.".$this->field.") as total, avg(".$this->field.") as avg";
|
$sql = "SELECT date_format(c.date_commande,'%Y') as year, count(*) as nb, sum(c.".$this->field.") as total, avg(".$this->field.") as avg";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
$sql.= " WHERE ".$this->where;
|
$sql.= " WHERE ".$this->where;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user