New: Statistics support filtering on user.
This commit is contained in:
parent
455edddd5b
commit
f46492befe
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user