[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/compta/bank/ -> annuel.php (source)

   1  <?php
   2  /* Copyright (C) 2005      Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: annuel.php,v 1.9 2005/08/21 18:46:50 rodolphe Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/bank/annuel.php,v $
  21   *
  22   */
  23  
  24  /**
  25     \file        htdocs/compta/bank/annuel.php
  26     \ingroup     banque
  27     \brief       Page reporting mensuel Entrées/Sorties d'un compte bancaire
  28     \version     $Revision: 1.9 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  if (!$user->rights->banque->lire) accessforbidden();
  34  
  35  $year_start=isset($_GET["year_start"])?$_GET["year_start"]:$_POST["year_start"];
  36  $year_current = strftime("%Y",time());
  37  if (! $year_start)
  38  {
  39    $year_start = $year_current - 2;
  40    $year_end = $year_current;
  41  }
  42  else
  43  {
  44    $year_end=$year_start+2;   
  45  }
  46  
  47  
  48  llxHeader();
  49  
  50  // Récupère info du compte
  51  $acct = new Account($db);
  52  $acct->fetch($_GET["account"]);
  53  
  54  /*
  55   * Sécurité accés client
  56   */
  57  if ($user->societe_id > 0) 
  58  {
  59    $socidp = $user->societe_id;
  60  }
  61  $title=$langs->trans("IOMonthlyReporting").", ".$langs->trans("FinancialAccount")." : <a href=\"account.php?account=".$acct->id."\">".$acct->label."</a>";
  62  $lien=($year_start?"<a href='annuel.php?account=".$acct->id."&year_start=".($year_start-1)."'>".img_previous()."</a> <a href='annuel.php?account=".$acct->id."&year_start=".($year_start+1)."'>".img_next()."</a>":"");
  63  print_fiche_titre($title,$lien);
  64  print '<br>';
  65  
  66  # Ce rapport de trésorerie est basé sur llx_bank (car doit inclure les transactions sans facture)
  67  # plutot que sur llx_paiement + llx_paiementfourn
  68  
  69  $sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm";
  70  $sql .= " FROM llx_bank as f";
  71  $sql .= " WHERE f.amount >= 0";
  72  if ($_GET["account"]) { $sql .= " AND fk_account = ".$_GET["account"]; }
  73  $sql .= " GROUP BY dm";
  74  
  75  $resql=$db->query($sql);
  76  if ($resql)
  77  {
  78    $num = $db->num_rows($resql);
  79    $i = 0; 
  80    while ($i < $num)
  81      {
  82        $row = $db->fetch_row($resql);
  83        $encaiss[$row[1]] = $row[0];
  84        $i++;
  85      }
  86  } else {
  87      dolibarr_print_error($db);
  88  }
  89  
  90  $sql = "SELECT sum(f.amount), date_format(f.dateo,'%Y-%m') as dm";
  91  $sql .= " FROM llx_bank as f";
  92  $sql .= " WHERE f.amount <= 0";
  93  if ($_GET["account"]) { $sql .= " AND fk_account = ".$_GET["account"]; }
  94  $sql .= " GROUP BY dm";
  95  $resql=$db->query($sql);
  96  if ($resql)
  97  {
  98    $num = $db->num_rows($resql);
  99    $i = 0;
 100    while ($i < $num)
 101      {
 102        $row = $db->fetch_row($resql);
 103        $decaiss[$row[1]] = -$row[0];
 104        $i++;
 105      }
 106  } else {
 107      dolibarr_print_error($db);
 108  }
 109  
 110  
 111  // Affiche tableau
 112  print '<table class="noborder" width="100%">';
 113  print '<tr class="liste_titre"><td rowspan=2>'.$langs->trans("Month").'</td>';
 114  
 115  for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 116  {
 117    print '<td align="center" width="20%" colspan="2">'.$annee.'</td>';
 118  }
 119  print '</tr>';
 120  print '<tr class="liste_titre">';
 121  for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 122  { 
 123    print '<td align="right">'.$langs->trans("Debit").'</td><td align="right">'.$langs->trans("Credit").'</td>';
 124  }
 125  print '</tr>';
 126  
 127  $var=true;
 128  for ($mois = 1 ; $mois < 13 ; $mois++)
 129  {
 130      $var=!$var;
 131      print '<tr '.$bc[$var].'>';
 132      print "<td>".strftime("%B",mktime(1,1,1,$mois,1,2000))."</td>";
 133      for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 134      {
 135          print '<td align="right" width="10%">&nbsp;';
 136          $case = strftime("%Y-%m",mktime(1,1,1,$mois,1,$annee));
 137          if ($decaiss[$case]>0)
 138          {
 139              print price($decaiss[$case]);
 140              $totsorties[$annee]+=$decaiss[$case];
 141          }
 142          print "</td>";
 143  
 144          print '<td align="right" width="10%">&nbsp;';
 145          $case = strftime("%Y-%m",mktime(1,1,1,$mois,1,$annee));
 146          if ($encaiss[$case]>0)
 147          {
 148              print price($encaiss[$case]);
 149              $totentrees[$annee]+=$encaiss[$case];
 150          }
 151          print "</td>";
 152      }
 153      print '</tr>';
 154  }
 155  
 156  // Total debit-credit
 157  print '<tr class="liste_total"><td><b>'.$langs->trans("Total")."</b></td>";
 158  for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 159  {
 160    print '<td align="right"><b>'.price($totsorties[$annee]).'</b></td><td align="right"><b>'.price($totentrees[$annee]).'</b></td>';
 161  }
 162  print "</tr>\n";
 163  
 164  // Ligne vierge
 165  print '<tr><td>&nbsp;</td>';
 166  $nbcol=0;
 167  for ($annee = $year_start ; $annee <= $year_end ; $annee++)
 168  {
 169      $nbcol+=2;
 170  }
 171  print "</tr>\n";
 172  print '<td colspan="'.$nbcol.'">&nbsp;</td>';
 173  
 174  // Solde actuel
 175  $balance=0;
 176  $sql = "SELECT sum(f.amount) as total";
 177  $sql .= " FROM llx_bank as f";
 178  if ($_GET["account"]) { $sql .= " WHERE fk_account = ".$_GET["account"]; }
 179  $resql=$db->query($sql);
 180  if ($resql)
 181  {
 182      $obj = $db->fetch_object($resql);
 183      if ($obj) $balance=$obj->total;
 184  }
 185  else {
 186      dolibarr_print_error($db);
 187  }
 188  print '<tr class="liste_total"><td><b>'.$langs->trans("CurrentBalance")."</b></td>";
 189  print '<td colspan="'.($nbcol).'" align="right">'.price($balance).'</td>';
 190  print "</tr>\n";
 191  
 192  print "</table>";
 193  
 194  
 195  $db->close();
 196  
 197  llxFooter('$Date: 2005/08/21 18:46:50 $ - $Revision: 1.9 $');
 198  
 199  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics