Permet maintenant de générer les contrats
This commit is contained in:
parent
82363addbb
commit
dc284b989d
@ -31,6 +31,7 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
$this->file = $file;
|
$this->file = $file;
|
||||||
|
|
||||||
$this->client = 0;
|
$this->client = 0;
|
||||||
|
$this->contrat = 0;
|
||||||
$this->titre = "Gain (euros HT)";
|
$this->titre = "Gain (euros HT)";
|
||||||
|
|
||||||
$this->barcolor = "blue";
|
$this->barcolor = "blue";
|
||||||
@ -40,18 +41,17 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
Function GraphDraw()
|
Function GraphDraw()
|
||||||
{
|
{
|
||||||
$num = 0;
|
$num = 0;
|
||||||
$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 = "SELECT date, sum(gain)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
|
||||||
$sql .= " WHERE fk_facture is not null";
|
$sql .= " WHERE fk_facture is not null";
|
||||||
$sql .= " GROUP BY date ASC";
|
$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 = "SELECT date, sum(gain)";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
|
||||||
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";
|
$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as s";
|
||||||
$sql .= " WHERE fk_facture is not null";
|
$sql .= " WHERE fk_facture is not null";
|
||||||
@ -59,6 +59,16 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
$sql .= " AND s.fk_client_comm = ".$this->client;
|
$sql .= " AND s.fk_client_comm = ".$this->client;
|
||||||
$sql .= " GROUP BY date ASC";
|
$sql .= " GROUP BY date ASC";
|
||||||
}
|
}
|
||||||
|
elseif ($this->client == 0 && $this->contrat > 0)
|
||||||
|
{
|
||||||
|
$sql = "SELECT tf.date, sum(tf.gain)";
|
||||||
|
$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";
|
||||||
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
@ -66,29 +76,19 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
{
|
{
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$j = -1;
|
|
||||||
$labels = array();
|
$labels = array();
|
||||||
$cf = array();
|
|
||||||
$cv = array();
|
|
||||||
$gg = array();
|
|
||||||
|
|
||||||
$this->total_gain = 0;
|
$this->total_gain = 0;
|
||||||
$this->total_ca = 0;
|
|
||||||
$this->total_cout = 0;
|
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($i);
|
$row = $this->db->fetch_row();
|
||||||
|
|
||||||
$cf[$i] = $row[3];
|
$g[$i] = $row[1];
|
||||||
$cv[$i] = $row[2];
|
|
||||||
$g[$i] = $row[1];
|
|
||||||
|
|
||||||
$labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2);
|
$labels[$i] = substr($row[0],5,2)."/".substr($row[0],2,2);
|
||||||
|
|
||||||
$this->total_gain += $row[1];
|
$this->total_gain += $row[1];
|
||||||
$this->total_ca += $row[2];
|
|
||||||
$this->total_cout += $row[3];
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,6 @@ class GraphGain extends GraphBrouzouf{
|
|||||||
print $this->client . " " . $g[$i - 1]."\n";
|
print $this->client . " " . $g[$i - 1]."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
$this->GraphMakeGraph($g, $labels);
|
$this->GraphMakeGraph($g, $labels);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user