/[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.5 by rodolphe, Mon Aug 1 08:52:03 2005 UTC revision 1.6 by rodolphe, Wed Aug 10 10:00:24 2005 UTC
# Line 196  foreach ($accounts as $account) Line 196  foreach ($accounts as $account)
196    $graph->Stroke($file);    $graph->Stroke($file);
197  }  }
198    
199    foreach ($accounts as $account)
200    {
201      $labels = array();
202      $datas = array();
203      $amounts = array();
204      
205      $sql = "SELECT sum(amount)";
206      $sql .= " FROM ".MAIN_DB_PREFIX."bank";
207      $sql .= " WHERE fk_account = ".$account;
208      $sql .= " AND datev < '".$year."-01-01';";
209      
210      $resql = $db->query($sql);
211      if ($resql)
212        {
213          $row = $db->fetch_row($resql);
214          $solde = $row[0];
215        }
216      else
217        {
218          print $sql ;
219        }
220    
221      $sql = "SELECT date_format(datev,'%Y%m%d'), sum(amount)";
222      $sql .= " FROM ".MAIN_DB_PREFIX."bank";
223      $sql .= " WHERE fk_account = ".$account;
224      $sql .= " AND date_format(datev,'%Y') = '".$year."'";
225      $sql .= " GROUP BY date_format(datev,'%Y%m%d');";
226    
227      $resql = $db->query($sql);
228      
229      $amounts = array();
230      
231      if ($resql)
232        {
233          $num = $db->num_rows($resql);
234          $i = 0;
235          
236          while ($i < $num)
237            {
238              $row = $db->fetch_row($resql);
239              $amounts[$row[0]] = $row[1];
240              $i++;
241            }      
242        }
243      else
244        {
245          dolibarr_syslog("graph-solde.php Error");
246        }
247      
248      $subtotal = 0;
249      
250      $day = mktime(1,1,1,1,1,$year);
251      
252      $xyear = strftime("%Y",$day);
253      $i = 0;
254      while ($xyear == $year)
255        {
256          //print strftime ("%e %d %m %y",$day)."\n";
257          
258          $subtotal = $subtotal + $amounts[strftime("%Y%m%d",$day)];
259    
260          if ($day > time())
261            {      
262              $datas[$i] = 0;
263            }
264          else
265            {
266              $datas[$i] = $solde + $subtotal;
267            }
268    
269          if (strftime("%d",$day) == 1)
270            {
271              $labels[$i] = strftime("%d",$day);
272            }
273          else
274            {
275    
276            }
277          
278          $day += 86400;
279          $xyear = strftime("%Y",$day);
280          $i++;
281        }
282        
283      $width = 750;
284      $height = 350;
285      
286      $graph = new Graph($width, $height,"auto");    
287      $graph->SetScale("textlin");
288      
289      $graph->yaxis->scale->SetGrace(2);
290      $graph->SetFrame(1);
291      $graph->img->SetMargin(40,20,20,35);
292      
293      $b2plot = new LinePlot($datas);
294      
295      $b2plot->SetColor("blue");
296      //$b2plot->SetWeight(2);
297      
298      $graph->title->Set("Solde $year");
299      
300      $graph->xaxis->SetTickLabels($labels);
301    
302      $graph->xaxis->Hide();
303      //$graph->xaxis->HideTicks();
304    
305    
306      //$graph->xaxis->title->Set(strftime("%d/%m/%y %H:%M:%S", time()));
307      
308      $graph->Add($b2plot);
309      $graph->img->SetImgFormat("png");
310      
311      $file= DOL_DATA_ROOT."/graph/banque/solde.$account.$year.png";
312      
313      $graph->Stroke($file);
314    }
315    
316    
317  ?>  ?>

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