/[dolibarr]/dolibarr/scripts/banque/graph-solde.php
ViewVC logotype

Diff of /dolibarr/scripts/banque/graph-solde.php

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

revision 1.2 by rodolphe, Sun Jul 31 18:33:29 2005 UTC revision 1.3 by rodolphe, Sun Jul 31 18:36:05 2005 UTC
# Line 31  include_once (JPGRAPH_DIR."jpgraph_canva Line 31  include_once (JPGRAPH_DIR."jpgraph_canva
31    
32  $error = 0;  $error = 0;
33    
34  $labels = array();  
 $datas = array();  
35    
36  $datetime = time();  $datetime = time();
37  $month = strftime("%m", $datetime);  $month = strftime("%m", $datetime);
# Line 64  $sql .= " WHERE date_format(datev,'%Y%m' Line 63  $sql .= " WHERE date_format(datev,'%Y%m'
63    
64  $resql = $db->query($sql);  $resql = $db->query($sql);
65    
66  $amounts = array();  $accounts = array();
67    
68  if ($resql)  if ($resql)
69  {  {
# Line 85  $account = 1; Line 84  $account = 1;
84  foreach ($accounts as $account)  foreach ($accounts as $account)
85  {  {
86    
87      $labels = array();
88      $datas = array();
89      $amounts = array();
90      
91    
92    $sql = "SELECT sum(amount)";    $sql = "SELECT sum(amount)";
93    $sql .= " FROM ".MAIN_DB_PREFIX."bank";    $sql .= " FROM ".MAIN_DB_PREFIX."bank";
# Line 105  foreach ($accounts as $account) Line 106  foreach ($accounts as $account)
106      }      }
107    
108    
109  $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";    $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
110  $sql .= " FROM ".MAIN_DB_PREFIX."bank";    $sql .= " FROM ".MAIN_DB_PREFIX."bank";
111  $sql .= " WHERE fk_account = ".$account;    $sql .= " WHERE fk_account = ".$account;
112  $sql .= " AND date_format(datev,'%Y%m') = '".$year.$month."'";    $sql .= " AND date_format(datev,'%Y%m') = '".$year.$month."'";
113  $sql .= " GROUP BY date_format(datev,'%Y%m%d');";    $sql .= " GROUP BY date_format(datev,'%Y%m%d');";
   
 $resql = $db->query($sql);  
   
 $amounts = array();  
114    
115  if ($resql)    $resql = $db->query($sql);
116  {    
117    $num = $db->num_rows($resql);    $amounts = array();
118      
119      if ($resql)
120        {
121          $num = $db->num_rows($resql);
122          $i = 0;
123          
124          while ($i < $num)
125            {
126              $row = $db->fetch_row($resql);
127              $amounts[$row[0]] = $row[1];
128              $i++;
129            }
130          
131        }
132      else
133        {
134          print $sql ;
135        }
136      
137      $subtotal = 0;
138      
139      
140      $day = mktime(1,1,1,$month,1,$year);
141      
142      $xmonth = substr("00".strftime("%m",$day), -2);
143    $i = 0;    $i = 0;
144      while ($xmonth == $month)
   while ($i < $num)  
145      {      {
146        $row = $db->fetch_row($resql);        //print strftime ("%e %d %m %y",$day)."\n";
147        $amounts[$row[0]] = $row[1];        
148          $subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
149          
150          $datas[$i] = $solde + $subtotal;
151          $labels[$i] = strftime("%d",$day);
152          
153          $day += 86400;
154          $xmonth = substr("00".strftime("%m",$day), -2);
155        $i++;        $i++;
156      }      }
157      
158  }    
159  else    $width = 750;
160  {    $height = 350;
161    print $sql ;    
162  }    $graph = new Graph($width, $height,"auto");    
163      $graph->SetScale("textlin");
164  $subtotal = 0;    
165      $graph->yaxis->scale->SetGrace(2);
166      $graph->SetFrame(1);
167  $day = mktime(1,1,1,$month,1,$year);    $graph->img->SetMargin(40,20,20,35);
168      
169  $xmonth = substr("00".strftime("%m",$day), -2);    $b2plot = new BarPlot($datas);
170  $i = 0;    
171  while ($xmonth == $month)    $b2plot->SetColor("blue");
172  {    //$b2plot->SetWeight(2);
173    //print strftime ("%e %d %m %y",$day)."\n";    
174      $graph->title->Set("Solde");
175    $subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];    
176      $graph->xaxis->SetTickLabels($labels);  
177    $datas[$i] = $solde + $subtotal;    //$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));
178    $labels[$i] = strftime("%d",$day);    
179      $graph->Add($b2plot);
180    $day += 86400;    $graph->img->SetImgFormat("png");
181    $xmonth = substr("00".strftime("%m",$day), -2);    
182    $i++;    $file= DOL_DATA_ROOT."/graph/banque/solde.$account.png";
183  }    
184      $graph->Stroke($file);
                 
 $width = 750;  
 $height = 350;  
                 
 $graph = new Graph($width, $height,"auto");      
 $graph->SetScale("textlin");  
   
 $graph->yaxis->scale->SetGrace(2);  
 $graph->SetFrame(1);  
 $graph->img->SetMargin(40,20,20,35);  
   
 $b2plot = new BarPlot($datas);  
   
 $b2plot->SetColor("blue");  
 //$b2plot->SetWeight(2);  
   
 $graph->title->Set("Solde");  
   
 $graph->xaxis->SetTickLabels($labels);    
 //$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));  
   
 $graph->Add($b2plot);  
 $graph->img->SetImgFormat("png");  
   
 $file= DOL_DATA_ROOT."/graph/banque/solde.$account.png";  
   
 $graph->Stroke($file);  
185  }  }
186    
187  ?>  ?>

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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