/[dolibarr]/dolibarr/htdocs/telephonie/stats/graph/comm.nbminutes.class.php
ViewVC logotype

Diff of /dolibarr/htdocs/telephonie/stats/graph/comm.nbminutes.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by rodolphe, Thu Oct 20 19:22:53 2005 UTC revision 1.6 by rodolphe, Wed Nov 9 10:35:19 2005 UTC
# Line 56  class GraphCommNbMinutes extends GraphBa Line 56  class GraphCommNbMinutes extends GraphBa
56    Function GetDatas()    Function GetDatas()
57    {    {
58    
59      $sql = "SELECT date_format(td.date,'%Y%m'), sum(duree)";      $sql = "SELECT ym, sum(duree)";
60      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";      $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details as td";
61    
62      if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)      if ($this->client == 0 && $this->contrat == 0 && $this->ligne == 0)
63        {        {
64          $sql .= " GROUP BY date_format(td.date, '%Y%m') ASC";          $sql .= " GROUP BY ym ASC";
65        }        }
66      elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0)      elseif ($this->client > 0 && $this->contrat == 0 && $this->ligne == 0)
67        {        {
# Line 70  class GraphCommNbMinutes extends GraphBa Line 70  class GraphCommNbMinutes extends GraphBa
70          $sql .= " WHERE td.ligne = s.ligne";          $sql .= " WHERE td.ligne = s.ligne";
71          $sql .= " AND s.fk_client_comm = ".$this->client;          $sql .= " AND s.fk_client_comm = ".$this->client;
72    
73          $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";          $sql .= " GROUP BY ym ASC ";
74        }            }    
75      elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0)      elseif ($this->client == 0 && $this->contrat > 0 && $this->ligne == 0)
76        {        {
# Line 79  class GraphCommNbMinutes extends GraphBa Line 79  class GraphCommNbMinutes extends GraphBa
79          $sql .= " WHERE td.ligne = s.ligne";          $sql .= " WHERE td.ligne = s.ligne";
80          $sql .= " AND s.fk_contrat = ".$this->contrat;          $sql .= " AND s.fk_contrat = ".$this->contrat;
81    
82          $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";          $sql .= " GROUP BY ym ASC ";
83        }            }    
84      elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0)      elseif ($this->client == 0 && $this->contrat == 0 && $this->ligne > 0)
85        {        {
86          $sql .= " WHERE td.fk_ligne = ".$this->ligne;          $sql .= " WHERE td.fk_ligne = ".$this->ligne;
87    
88          $sql .= " GROUP BY date_format(td.date,'%Y%m') ASC ";          $sql .= " GROUP BY ym ASC ";
89        }            }    
90    
91      if ($this->db->query($sql))      $resql = $this->db->query($sql);
92    
93        if ($resql)
94        {        {
95          $num = $this->db->num_rows();          $num = $this->db->num_rows($resql);
96          $i = 0;          $i = 0;
97                                    
98          while ($i < $num)          while ($i < $num)
99            {            {
100              $row = $this->db->fetch_row();                    $row = $this->db->fetch_row($resql);        
101                            
102              $this->labels[$i] = substr($row[0],4,2);              $this->labels[$i] = substr($row[0],2,2);
103              $this->datas[$i] = ceil($row[1] / 60);              $this->datas[$i] = ceil($row[1] / 60);
104                            
105              $i++;              $i++;
106            }                }    
107          $this->db->free();          $this->db->free($resql);
108        }        }
109      else      else
110        {        {

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26