From 352dac766ca731d80916c6b7c7eac1b05184b159 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 15 Mar 2005 12:26:47 +0000 Subject: [PATCH] =?UTF-8?q?Ajoute=20la=20possibilit=E9=20de=20grapher=20le?= =?UTF-8?q?s=20contrats?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/telephonie/stats/graph/ca.class.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/htdocs/telephonie/stats/graph/ca.class.php b/htdocs/telephonie/stats/graph/ca.class.php index 73259a7da5f..f8d73034b41 100644 --- a/htdocs/telephonie/stats/graph/ca.class.php +++ b/htdocs/telephonie/stats/graph/ca.class.php @@ -31,6 +31,7 @@ class GraphCa extends GraphBrouzouf $this->file = $file; $this->client = 0; + $this->contrat = 0; $this->titre = "Chiffre d'affaire (euros HT)"; $this->barcolor = "green"; @@ -39,16 +40,14 @@ class GraphCa extends GraphBrouzouf Function GraphDraw() { - $ligne = new LigneTel($this->db); - - if ($this->client == 0) + if ($this->client == 0 && $this->contrat == 0) { $sql = "SELECT date, sum(gain), sum(cout_vente), sum(fourn_montant)"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture"; $sql .= " WHERE fk_facture is not null"; $sql .= " GROUP BY date ASC"; } - else + elseif ($this->client > 0 && $this->contrat == 0) { $sql = "SELECT date, sum(gain), sum(cout_vente), sum(fourn_montant)"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture"; @@ -58,7 +57,17 @@ class GraphCa extends GraphBrouzouf $sql .= " AND s.fk_client_comm = ".$this->client; $sql .= " GROUP BY date ASC"; } - + elseif ($this->client == 0 && $this->contrat > 0) + { + $sql = "SELECT tf.date, sum(tf.gain), sum(tf.cout_vente), sum(tf.fourn_montant)"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf"; + $sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; + $sql .= " WHERE tf.fk_facture is not null"; + $sql .= " AND s.rowid = tf.fk_ligne"; + $sql .= " AND s.fk_contrat = ".$this->contrat; + $sql .= " GROUP BY tf.date ASC"; + } + if ($this->db->query($sql)) { $num = $this->db->num_rows();