Clean code

This commit is contained in:
Laurent Destailleur
2024-01-09 13:08:22 +01:00
parent e6dbcf2f82
commit 910a541c60
109 changed files with 709 additions and 1078 deletions

View File

@@ -123,7 +123,7 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%m') as dm, COUNT(*) as nb";
$sql .= " FROM ".$this->from;
if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
@@ -148,7 +148,7 @@ class CommandeStats extends Stats
$sql = "SELECT date_format(c.date_commande,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
$sql .= " FROM ".$this->from;
if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
@@ -172,7 +172,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->hasRight('societe', 'client', 'voir') && !$this->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
@@ -197,7 +197,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->hasRight('societe', 'client', 'voir') && !$this->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
@@ -220,7 +220,7 @@ class CommandeStats extends Stats
$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;
if (!$user->hasRight('societe', 'client', 'voir') && !$this->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;
@@ -246,7 +246,7 @@ class CommandeStats extends Stats
$sql .= " FROM ".$this->from;
$sql .= " INNER JOIN ".$this->from_line." ON c.rowid = tl.fk_commande";
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."product as product ON tl.fk_product = product.rowid";
if (!$user->hasRight('societe', 'client', 'voir') && !$user->socid) {
if (!$user->hasRight('societe', 'client', 'voir')) {
$sql .= " INNER JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON c.fk_soc = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
}
$sql .= $this->join;