[ 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/charges/ -> index.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2003 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: index.php,v 1.15 2005/05/23 11:18:28 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/charges/index.php,v $
  21   *
  22   */
  23  
  24  /**
  25          \file       htdocs/compta/charges/index.php
  26          \ingroup    compta
  27          \brief      Page liste des charges
  28          \version    $Revision: 1.15 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  llxHeader();
  34  
  35  $user->getrights('compta');
  36  
  37  if (!$user->admin && !$user->rights->compta->charges)
  38    accessforbidden();
  39  
  40  
  41  $year=$_GET["year"];
  42  $filtre=$_GET["filtre"];
  43  if (! $year) { $year=date("Y", time()); }
  44  
  45  print_fiche_titre($langs->trans("Charges"),($year?"<a href='index.php?year=".($year-1)."'>".img_previous()."</a> ".$langs->trans("Year")." $year <a href='index.php?year=".($year+1)."'>".img_next()."</a>":""));
  46  
  47  print "<br>";
  48  print '<table class="noborder" width="100%">';
  49  print "<tr class=\"liste_titre\">";
  50  print "<td>".$langs->trans("Group")."</td>";
  51  print "<td align=\"right\">".$langs->trans("Nb")."</td>";
  52  print "<td align=\"right\">".$langs->trans("AmountTTC")."</td>";
  53  print "<td align=\"right\">".$langs->trans("AlreadyPayed")."</td>";
  54  print "</tr>\n";
  55  
  56  /*
  57   * Charges sociales
  58   */
  59  $sql = "SELECT c.libelle as lib, s.fk_type as type, count(s.rowid) as nb, sum(s.amount) as total, sum(IF(paye=1,s.amount,0)) as totalpaye";
  60  $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
  61  $sql .= " WHERE s.fk_type = c.id";
  62  if ($year > 0)
  63  {
  64      $sql .= " AND (";
  65      // Si period renseigné on l'utilise comme critere de date, sinon on prend date échéance,
  66      // ceci afin d'etre compatible avec les cas ou la période n'etait pas obligatoire
  67      $sql .= "   (s.periode is not null and date_format(s.periode, '%Y') = $year) ";
  68      $sql .= "or (s.periode is null     and date_format(s.date_ech, '%Y') = $year)";
  69      $sql .= ")";
  70  }
  71  $sql .= " GROUP BY lower(c.libelle) ASC";
  72  
  73  if ( $db->query($sql) )
  74  {
  75    $num = $db->num_rows();
  76    $i = 0;
  77    $var=true;
  78    
  79    while ($i < $num) {
  80      $obj = $db->fetch_object();
  81      $var = !$var;
  82      print "<tr $bc[$var]>";
  83      print '<td><a href="../sociales/index.php?filtre=s.fk_type:'.$obj->type.'">'.$obj->lib.'</a></td>';
  84      print '<td align="right">'.$obj->nb.'</td>';
  85      print '<td align="right">'.price($obj->total).'</td>';
  86      print '<td align="right">'.price($obj->totalpaye).'</td>';
  87      print '</tr>';
  88      $i++;
  89    }
  90  } else {
  91    dolibarr_print_error($db);
  92  }
  93  
  94  /**
  95   * Factures fournisseurs
  96   */
  97  $sql = "SELECT count(f.rowid) as nb, sum(total_ttc) as total, sum(IF(paye=1,total_ttc,0)) as totalpaye";
  98  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
  99  if ($year > 0)
 100  {
 101      $sql .= " WHERE date_format(f.datef, '%Y') = $year";
 102  }
 103  
 104  if ( $db->query($sql) ) {
 105  
 106    $langs->load("compta");
 107    
 108    $num = $db->num_rows();
 109    $i = 0;
 110  
 111    while ($i < $num) {
 112      $obj = $db->fetch_object();
 113      $var = !$var;
 114      print "<tr $bc[$var]>";
 115      print '<td>'.$langs->trans("BillsForSuppliers").'</td>';
 116      print '<td align="right">'.$obj->nb.'</td>';
 117      print '<td align="right">'.price($obj->total).'</td>';
 118      print '<td align="right">'.price($obj->totalpaye).'</td>';
 119      print '</tr>';
 120      $i++;
 121    }
 122  } else {
 123      dolibarr_print_error($db);
 124  }
 125  
 126  print "</table><br>";
 127  
 128  
 129  $db->close();
 130   
 131  llxFooter("<em>Derni&egrave;re modification $Date: 2005/05/23 11:18:28 $ r&eacute;vision $Revision: 1.15 $</em>");
 132  ?>


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