Browse Source

FIX: order supplier stats by category now display figures

Florian HENRY 4 years ago
parent
commit
c91b9d613a
1 changed files with 3 additions and 1 deletions
  1. 3 1
      htdocs/commande/class/commandestats.class.php

+ 3 - 1
htdocs/commande/class/commandestats.class.php

@@ -78,6 +78,7 @@ class CommandeStats extends Stats
 			$this->field = 'total_ht';
 			$this->field_line = 'total_ht';
 			$this->where .= " c.fk_statut > 0"; // Not draft and not cancelled
+			$this->categ_link=MAIN_DB_PREFIX.'categorie_societe';
 		}
 		elseif ($mode == 'supplier')
 		{
@@ -87,6 +88,7 @@ class CommandeStats extends Stats
 			$this->field = 'total_ht';
 			$this->field_line = 'total_ht';
 			$this->where .= " c.fk_statut > 2"; // Only approved & ordered
+			$this->categ_link=MAIN_DB_PREFIX.'categorie_fournisseur';
 		}
 		//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
 		$this->where .= ' AND c.entity IN ('.getEntity('commande').')';
@@ -106,7 +108,7 @@ class CommandeStats extends Stats
 
         if ($categid)
         {
-            $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie_societe as cats ON cats.fk_soc = c.fk_soc';
+            $this->join .= ' LEFT JOIN '.$this->categ_link.' as cats ON cats.fk_soc = c.fk_soc';
             $this->join .= ' LEFT JOIN '.MAIN_DB_PREFIX.'categorie as cat ON cat.rowid = cats.fk_categorie';
             $this->where .= ' AND cat.rowid = '.$categid;
         }