Fix: Bad calculation. Missing global.
This commit is contained in:
parent
134187ef94
commit
59c97afeed
@ -95,7 +95,6 @@ class CommandeStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByMonth($year)
|
function getNbByMonth($year)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, count(*) nb";
|
||||||
@ -117,7 +116,6 @@ class CommandeStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByYear()
|
function getNbByYear()
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, count(*), sum(c.".$this->field.")";
|
||||||
@ -138,7 +136,6 @@ class CommandeStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getAmountByMonth($year)
|
function getAmountByMonth($year)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, sum(c.".$this->field.")";
|
||||||
@ -160,7 +157,6 @@ class CommandeStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getAverageByMonth($year)
|
function getAverageByMonth($year)
|
||||||
{
|
{
|
||||||
global $conf;
|
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
|
$sql = "SELECT date_format(c.date_commande,'%m') as dm, avg(c.".$this->field.")";
|
||||||
|
|||||||
@ -92,6 +92,8 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByMonth($year)
|
function getNbByMonth($year)
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT MONTH(f.datef) as dm, COUNT(*)";
|
$sql = "SELECT MONTH(f.datef) as dm, COUNT(*)";
|
||||||
$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";
|
||||||
@ -113,6 +115,8 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getNbByYear()
|
function getNbByYear()
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT YEAR(f.datef) as dm, COUNT(*)";
|
$sql = "SELECT YEAR(f.datef) as dm, COUNT(*)";
|
||||||
$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";
|
||||||
@ -132,6 +136,8 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getAmountByMonth($year)
|
function getAmountByMonth($year)
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")";
|
$sql = "SELECT date_format(datef,'%m') as dm, SUM(f.".$this->field.")";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
@ -153,6 +159,8 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getAverageByMonth($year)
|
function getAverageByMonth($year)
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
|
$sql = "SELECT date_format(datef,'%m') as dm, AVG(f.".$this->field.")";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
@ -171,6 +179,8 @@ class FactureStats extends Stats
|
|||||||
*/
|
*/
|
||||||
function getAllByYear()
|
function getAllByYear()
|
||||||
{
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
$sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg";
|
$sql = "SELECT date_format(datef,'%Y') as year, COUNT(*) as nb, SUM(f.".$this->field.") as total, AVG(f.".$this->field.") as avg";
|
||||||
$sql.= " FROM ".$this->from;
|
$sql.= " FROM ".$this->from;
|
||||||
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user