diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index d960cedc1c0..ac120ef6d4d 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -35,27 +35,32 @@ include_once DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php"; */ class PropaleStats extends Stats { - var $db ; + var $db; - var $socid; - var $where; + var $socid; + var $userid; - var $table_element; - var $field; + var $table_element; + var $from; + var $field; + var $where; /** * Constructor * - * @param $DB Database handler - * @param $socid Id third party + * @param $DB Database handler + * @param $socid Id third party + * @param $userid Id user for filter * @return PropaleStats */ - function PropaleStats($DB, $socid=0) + function PropaleStats($DB, $socid=0, $userid=0) { global $user, $conf; $this->db = $DB; + $this->socid = $socid; + $this->userid = $userid; $object=new Propal($this->db); @@ -64,7 +69,6 @@ class PropaleStats extends Stats $this->field='total'; - $this->socid = $socid; $this->where.= " fk_statut > 0"; $this->where.= " AND p.fk_soc = s.rowid AND s.entity = ".$conf->entity; if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; @@ -72,6 +76,7 @@ class PropaleStats extends Stats { $this->where .= " AND p.fk_soc = ".$this->socid; } + if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } diff --git a/htdocs/comm/propal/stats/index.php b/htdocs/comm/propal/stats/index.php index 8fde9b2cfff..527a5593d25 100644 --- a/htdocs/comm/propal/stats/index.php +++ b/htdocs/comm/propal/stats/index.php @@ -60,7 +60,7 @@ $dir=$conf->propale->dir_temp; create_exdir($dir); -$stats = new PropaleStats($db, $socid); +$stats = new PropaleStats($db, $socid, $userid); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index da46f0dcf9b..95ab36d59ff 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -38,27 +38,31 @@ class CommandeStats extends Stats var $db ; var $socid; - var $where; + var $userid; var $table_element; + var $from; var $field; + var $where; /** * Constructor * - * @param $DB Database handler - * @param $socid Id third party - * @param $mode Option + * @param $DB Database handler + * @param $socid Id third party for filter + * @param $mode Option + * @param $userid Id user for filter * @return CommandeStats */ - function CommandeStats($DB, $socid=0, $mode) + function CommandeStats($DB, $socid=0, $mode, $userid=0) { global $user, $conf; $this->db = $DB; $this->socid = $socid; + $this->userid = $userid; if ($mode == 'customer') { @@ -83,7 +87,7 @@ class CommandeStats extends Stats { $this->where .= " AND c.fk_soc = ".$this->socid; } - + if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; } /** diff --git a/htdocs/commande/stats/index.php b/htdocs/commande/stats/index.php index 142af42bcb4..7e15ba15a86 100644 --- a/htdocs/commande/stats/index.php +++ b/htdocs/commande/stats/index.php @@ -50,6 +50,7 @@ $year = strftime("%Y", time()); $startyear=$year-2; $endyear=$year; +$langs->load("orders"); /* @@ -73,7 +74,7 @@ print_fiche_titre($title, $mesg); create_exdir($dir); -$stats = new CommandeStats($db, $socid, $mode); +$stats = new CommandeStats($db, $socid, $mode, $userid); // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear); diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 77b4805bcd5..eb317b6d5f5 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -33,38 +33,43 @@ include_once DOL_DOCUMENT_ROOT . "/compta/deplacement/class/deplacement.class.ph */ class DeplacementStats extends Stats { - var $db ; + var $db; - var $socid; - var $where; + var $socid; + var $userid; - var $table_element; - var $field; + var $table_element; + var $from; + var $field; + var $where; /** * Constructor * - * @param $DB Database handler - * @param $socid Id third party + * @param $DB Database handler + * @param $socid Id third party + * @param $userid Id user for filter * @return DeplacementStats */ - function DeplacementStats($DB, $socid=0) + function DeplacementStats($DB, $socid=0, $userid=0) { global $conf; $this->db = $DB; + $this->socid = $socid; + $this->userid = $userid; $object=new Deplacement($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element; $this->field='km'; - $this->socid = $socid; $this->where = " fk_statut > 0"; $this->where.= " AND entity = ".$conf->entity; if ($this->socid) { $this->where.=" AND fk_soc = ".$this->socid; } + if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } diff --git a/htdocs/compta/deplacement/stats/index.php b/htdocs/compta/deplacement/stats/index.php index 2e8cdcd52b1..5f68a5101e9 100755 --- a/htdocs/compta/deplacement/stats/index.php +++ b/htdocs/compta/deplacement/stats/index.php @@ -63,7 +63,7 @@ print_fiche_titre($title, $mesg); create_exdir($dir); -$stats = new DeplacementStats($db, $socid); +$stats = new DeplacementStats($db, $socid, $userid); // Build graphic number of object diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 7cf5984b1b1..2953c14ba19 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -35,27 +35,34 @@ include_once DOL_DOCUMENT_ROOT . "/lib/date.lib.php"; */ class FactureStats extends Stats { - var $db ; + var $db; - var $socid; - var $where; + var $socid; + var $userid; + + var $table_element; + var $from; + var $field; + var $where; - var $table_element; - var $field; /** * Constructor * - * @param $DB Database handler - * @param $socid Id third party - * @param $mode Option + * @param $DB Database handler + * @param $socid Id third party + * @param $mode Option + * @param $userid Id user for filter * @return FactureStats */ - function FactureStats($DB, $socid=0, $mode) + function FactureStats($DB, $socid=0, $mode, $userid=0) { global $conf; $this->db = $DB; + $this->socid = $socid; + $this->userid = $userid; + if ($mode == 'customer') { $object=new Facture($this->db); @@ -69,7 +76,6 @@ class FactureStats extends Stats $this->field='total_ht'; } - $this->socid = $socid; $this->where = " fk_statut > 0"; $this->where.= " AND entity = ".$conf->entity; if ($mode == 'customer') $this->where.=" AND (fk_statut != 3 OR close_code != 'replaced')"; // Exclude replaced invoices as they are duplicated (we count closed invoices for other reasons) @@ -77,7 +83,7 @@ class FactureStats extends Stats { $this->where.=" AND fk_soc = ".$this->socid; } - + if ($this->userid > 0) $this->where.=' AND fk_user_author = '.$this->userid; } diff --git a/htdocs/compta/facture/stats/index.php b/htdocs/compta/facture/stats/index.php index 8287d058ffe..96f4c04e4de 100644 --- a/htdocs/compta/facture/stats/index.php +++ b/htdocs/compta/facture/stats/index.php @@ -31,11 +31,13 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facturestats.class.php"); $WIDTH=500; $HEIGHT=200; -// Securite acces client +$userid=GETPOST('userid'); +$socid=GETPOST('socid'); +// Security check if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } $year = strftime("%Y", time()); @@ -67,7 +69,7 @@ print_fiche_titre($title, $mesg); create_exdir($dir); -$stats = new FactureStats($db, $socid, $mode); +$stats = new FactureStats($db, $socid, $mode, $userid); // Build graphic number of object