mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-13 11:15:21 +01:00
Fix: Several bugs into filter on statistics pages.
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.commande.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||
|
||||
|
||||
/**
|
||||
@@ -49,7 +50,7 @@ class CommandeStats extends Stats
|
||||
* @param DoliDB $db Database handler
|
||||
* @param int $socid Id third party for filter
|
||||
* @param string $mode Option
|
||||
* @param int $userid Id user for filter
|
||||
* @param int $userid Id user for filter (creation user)
|
||||
*/
|
||||
function __construct($db, $socid, $mode, $userid=0)
|
||||
{
|
||||
@@ -57,7 +58,7 @@ class CommandeStats extends Stats
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
$this->socid = $socid;
|
||||
$this->socid = ($socid > 0 ? $socid : 0);
|
||||
$this->userid = $userid;
|
||||
|
||||
if ($mode == 'customer')
|
||||
@@ -100,7 +101,7 @@ class CommandeStats extends Stats
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
|
||||
$sql.= " FROM ".$this->from;
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||
$sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||
$sql.= " AND ".$this->where;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= $this->db->order('dm','DESC');
|
||||
@@ -143,7 +144,7 @@ class CommandeStats extends Stats
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
|
||||
$sql.= " FROM ".$this->from;
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||
$sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||
$sql.= " AND ".$this->where;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= $this->db->order('dm','DESC');
|
||||
@@ -165,7 +166,7 @@ class CommandeStats extends Stats
|
||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
|
||||
$sql.= " FROM ".$this->from;
|
||||
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||
$sql.= " WHERE date_format(c.date_commande,'%Y') = '".$year."'";
|
||||
$sql.= " WHERE c.date_commande BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||
$sql.= " AND ".$this->where;
|
||||
$sql.= " GROUP BY dm";
|
||||
$sql.= $this->db->order('dm','DESC');
|
||||
|
||||
@@ -36,8 +36,8 @@ $mode=GETPOST("mode")?GETPOST("mode"):'customer';
|
||||
if ($mode == 'customer' && ! $user->rights->commande->lire) accessforbidden();
|
||||
if ($mode == 'supplier' && ! $user->rights->fournisseur->commande->lire) accessforbidden();
|
||||
|
||||
$userid=GETPOST('userid','int'); if ($userid < 0) $userid=0;
|
||||
$socid=GETPOST('socid','int'); if ($socid < 0) $socid=0;
|
||||
$userid=GETPOST('userid','int');
|
||||
$socid=GETPOST('socid','int');
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
@@ -77,7 +77,7 @@ print_fiche_titre($title);
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
$stats = new CommandeStats($db, $socid, $mode, $userid);
|
||||
$stats = new CommandeStats($db, $socid, $mode, ($userid>0?$userid:0));
|
||||
|
||||
// Build graphic number of object
|
||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||
@@ -255,12 +255,13 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
print $form->select_company($socid,'socid',$filter,1);
|
||||
print '</td></tr>';
|
||||
// User
|
||||
print '<tr><td align="left">'.$langs->trans("User").'/'.$langs->trans("SalesRepresentative").'</td><td align="left">';
|
||||
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
|
||||
print $form->select_users($userid,'userid',1);
|
||||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
|
||||
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
|
||||
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
|
||||
arsort($arrayyears);
|
||||
print $form->selectarray('year',$arrayyears,$year,0);
|
||||
print '</td></tr>';
|
||||
|
||||
Reference in New Issue
Block a user