From b23fc61449dc567aef5aa76a6d2b4129b0cde95a Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 14 Mar 2005 10:42:31 +0000 Subject: [PATCH] Comptage des remises execptionnelles --- htdocs/telephonie/stats/graph/gain.class.php | 34 ++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/telephonie/stats/graph/gain.class.php b/htdocs/telephonie/stats/graph/gain.class.php index f4bbb92dac9..6a479b2e626 100644 --- a/htdocs/telephonie/stats/graph/gain.class.php +++ b/htdocs/telephonie/stats/graph/gain.class.php @@ -99,7 +99,41 @@ class GraphGain extends GraphBrouzouf{ { print $this->db->error() . ' ' . $sql; } + + if ($this->client > 0) + { + /* + * Comptage des remises exceptionnelles + * + */ + $sql = "SELECT sr.amount_ht"; + $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as s"; + $sql .= " , ".MAIN_DB_PREFIX."telephonie_facture as tf"; + $sql .= " , ".MAIN_DB_PREFIX."societe_remise_except as sr"; + + $sql .= " WHERE sr.fk_facture = tf.fk_facture"; + $sql .= " AND s.rowid = tf.fk_ligne"; + $sql .= " AND s.fk_client_comm = ".$this->client; + $sql .= " GROUP BY tf.fk_facture"; + + if ($this->db->query($sql)) + { + $numr = $this->db->num_rows(); + $i = 0; + + while ($i < $numr) + { + $row = $this->db->fetch_row($i); + if ( $row[0] > 0) + { + $this->total_gain = $this->total_gain - $row[0]; + } + $i++; + } + } + } + if ($this->show_console) { print $this->client . " " . $g[$i - 1]."\n";