/[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.10 by eldy, Tue Oct 18 14:03:06 2005 UTC revision 1.11 by rodolphe, Sun Nov 13 17:05:59 2005 UTC
# Line 464  foreach ($accounts as $account) Line 464  foreach ($accounts as $account)
464        $graph->Stroke($file);        $graph->Stroke($file);
465      }      }
466  }  }
467    
468    foreach ($accounts as $account)
469    {
470      $labels = array();
471      $datas = array();
472      $amounts = array();
473      $credits = array();
474      $debits = array();
475    
476      $sql = "SELECT date_format(datev,'%m'), sum(amount)";
477      $sql .= " FROM ".MAIN_DB_PREFIX."bank";
478      $sql .= " WHERE fk_account = ".$account;
479      $sql .= " AND date_format(datev,'%Y') = '".$year."'";
480      $sql .= " AND amount > 0";
481      $sql .= " GROUP BY date_format(datev,'%m');";
482    
483      $resql = $db->query($sql);
484      
485      $amounts = array();
486      
487      if ($resql)
488        {
489          $num = $db->num_rows($resql);
490          $i = 0;
491          
492          while ($i < $num)
493            {
494              $row = $db->fetch_row($resql);
495              $credits[$row[0]] = $row[1];
496              $i++;
497            }      
498        }
499      else
500        {
501          print $sql ;
502        }
503    
504      $sql = "SELECT date_format(datev,'%m'), sum(amount)";
505      $sql .= " FROM ".MAIN_DB_PREFIX."bank";
506      $sql .= " WHERE fk_account = ".$account;
507      $sql .= " AND date_format(datev,'%Y') = '".$year."'";
508      $sql .= " AND amount < 0";
509      $sql .= " GROUP BY date_format(datev,'%m');";
510    
511      $resql = $db->query($sql);  
512      if ($resql)
513        {
514          while ($row = $db->fetch_row($resql))
515            {
516              $debits[$row[0]] = abs($row[1]);
517            }      
518        }
519      else
520        {
521          print $sql ;
522        }
523    
524      for ($i = 0 ; $i < 12 ; $i++)
525        {
526          $data_credit[$i] = $credits[substr("0".($i+1),-2)];
527          $data_debit[$i] = $debits[substr("0".($i+1),-2)];
528          $labels[$i] = $i+1;        
529        }
530    
531      $width = 750;
532      $height = 350;
533      
534      $graph = new Graph($width, $height,"auto");    
535      $graph->SetScale("textlin");
536      
537      $graph->yaxis->scale->SetGrace(2);
538      //$graph->SetFrame(1);
539      $graph->img->SetMargin(60,20,20,35);
540      
541      $bsplot = new BarPlot($data_debit);  
542      $bsplot->SetColor("red");
543      
544      $beplot = new BarPlot($data_credit);  
545      $beplot->SetColor("green");
546    
547      $bg = new GroupBarPlot(array($beplot, $bsplot));
548    
549      $graph->title->Set("Mouvements $year");
550      
551      $graph->xaxis->SetTickLabels($labels);  
552      
553      $graph->Add($bg);
554      $graph->img->SetImgFormat("png");
555      
556      $file= DOL_DATA_ROOT."/graph/banque/mouvement.$account.$year.png";
557      
558      $graph->Stroke($file);
559    }
560    
561  ?>  ?>

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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