[ 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/sociales/ -> 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.31 2005/09/06 20:58:15 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/sociales/index.php,v $
  21   */
  22  
  23  /** 
  24          \file       htdocs/compta/sociales/index.php
  25          \ingroup    compta
  26          \brief      Ecran des charges sociales
  27          \version    $Revision: 1.31 $
  28  */
  29  
  30  
  31  require ("./pre.inc.php");
  32  
  33  $user->getrights('facture');
  34  $user->getrights('compta');
  35  
  36  if (!$user->admin && !$user->rights->compta->charges->lire)
  37    accessforbidden();
  38  
  39  
  40  llxHeader();
  41  
  42  
  43  $sortfield = isset($_GET["sortfield"])?$_GET["sortfield"]:$_POST["sortfield"];
  44  $sortorder = isset($_GET["sortorder"])?$_GET["sortorder"]:$_POST["sortorder"];
  45  $page = $_GET["page"];
  46  if ($page < 0) $page = 0;
  47  
  48  $limit = $conf->liste_limit;
  49  $offset = $limit * $page ;
  50    
  51  if (! $sortfield) $sortfield="c.id";
  52  if (! $sortorder) $sortorder="DESC";
  53  
  54  
  55  /*
  56   * Ajout d'une charge sociale
  57   */
  58  
  59  if ($_POST["action"] == 'add')
  60  {
  61    if (! $_POST["date"] || ! $_POST["periode"] || ! $_POST["amount"]) {
  62      $mesg="<div class=\"error\">Erreur: Tous les champs date et montant doivent etre renseignés avec une valeur non vide.</div>";
  63    }
  64    else {
  65  
  66        $sql = "INSERT INTO ".MAIN_DB_PREFIX."chargesociales (fk_type, libelle, date_ech, periode, amount) ";
  67        $sql .= " VALUES (".$_POST["type"].",'".addslashes($_POST["libelle"])."','".$_POST["date"]."','".$_POST["periode"]."','".$_POST["amount"]."');";
  68      
  69        if (! $db->query($sql) )
  70          {
  71            dolibarr_print_error($db);
  72          }
  73        else {
  74          $mesg="<div class=\"ok\">La charge a été ajoutée.</div>";
  75        }
  76    }
  77  }
  78  
  79  /*
  80   * Suppression d'une charge sociale
  81   */
  82  
  83  if ($_GET["action"] == 'del')
  84  {
  85    $sql = "DELETE FROM ".MAIN_DB_PREFIX."chargesociales where rowid='".$_GET["id"]."'";
  86  
  87    if (! $db->query($sql) )
  88      {
  89            dolibarr_print_error($db);
  90      }
  91  }
  92  
  93  
  94  
  95  /*
  96   *  Affichage liste et formulaire des charges.
  97   */
  98  
  99  $year=$_GET["year"];
 100  $filtre=$_GET["filtre"];
 101  //if (! $year) { $year=date("Y", time()); }
 102  
 103  print_fiche_titre($langs->trans("SocialContributions"),($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>":""));
 104  print "<br>\n";
 105  
 106  if ($mesg) {
 107      print "$mesg<br>";
 108  }
 109  
 110  print "<table class=\"noborder\" width=\"100%\">";
 111  
 112  /*
 113   * Forumalaire d'ajout d'une charge
 114   *
 115   */
 116  if ($user->rights->compta->charges->creer) {
 117      $var=false;
 118  
 119      print "<tr class=\"liste_titre\">";
 120      print '<td>';
 121      print '&nbsp;';
 122      print '</td><td align="left">';
 123      print $langs->trans("DateDue");
 124      print '</td><td align="left">';
 125      print $langs->trans("Period");
 126      print '</td><td align="left">';
 127      print $langs->trans("Type");
 128      print '</td><td align="left">';
 129      print $langs->trans("Label");
 130      print '</td><td align="right">';
 131      print $langs->trans("Amount");
 132      print '</td><td align="center">';
 133      print '&nbsp;';
 134      print '</td>';
 135      print "</tr>\n";
 136  
 137      print '<form method="post" action="index.php">';
 138      print '<tr '.$bc[$var].' valign="top">';
 139      print '<input type="hidden" name="action" value="add">';
 140      print '<td>&nbsp;</td>';
 141      print '<td><input type="text" size="8" name="date"><br>YYYYMMDD</td>';
 142      print '<td><input type="text" size="8" name="periode"><br>YYYYMMDD</td>';
 143      
 144      print '<td align="left"><select name="type">';
 145      
 146      $sql = "SELECT c.id, c.libelle as type FROM ".MAIN_DB_PREFIX."c_chargesociales as c";
 147      $sql .= " ORDER BY lower(c.libelle) ASC";
 148      
 149      if ( $db->query($sql) )
 150      {
 151        $num = $db->num_rows();
 152        $i = 0;
 153      
 154        while ($i < $num)
 155          {
 156            $obj = $db->fetch_object();
 157            print '<option value="'.$obj->id.'">'.$obj->type;
 158            $i++;
 159          }
 160      }
 161      print '</select>';
 162      print '</td>';
 163      print '<td align="left"><input type="text" size="34" name="libelle"></td>';
 164      print '<td align="right"><input type="text" size="6" name="amount"></td>';
 165      
 166      print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
 167      print '</tr>';
 168  
 169      print '</form>';
 170  
 171      print '<tr><td colspan="7">&nbsp;</td></tr>';
 172  
 173  }
 174  
 175  print "<tr class=\"liste_titre\">";
 176  print_liste_field_titre($langs->trans("Ref"),"index.php","id","","","",$sortfield);
 177  print_liste_field_titre($langs->trans("DateDue"),"index.php","de","","","",$sortfield);
 178  print_liste_field_titre($langs->trans("Period"),"index.php","periode","","","",$sortfield);
 179  print_liste_field_titre($langs->trans("Type"),"index.php","type","","",'align="left"',$sortfield);
 180  print_liste_field_titre($langs->trans("Label"),"index.php","s.libelle","","",'align="left"',$sortfield);
 181  print_liste_field_titre($langs->trans("Amount"),"index.php","s.amount","","",'align="right"',$sortfield);
 182  print_liste_field_titre($langs->trans("Status"),"index.php","s.paye","","",'align="center"',$sortfield);
 183  print "</tr>\n";
 184  
 185  
 186  $sql = "SELECT s.rowid as id, s.fk_type as type, c.libelle as type_lib, s.amount,".$db->pdate("s.date_ech")." as de, s.date_pai, s.libelle, s.paye,".$db->pdate("s.periode")." as periode,".$db->pdate("s.date_pai")." as dp";
 187  $sql .= " FROM ".MAIN_DB_PREFIX."c_chargesociales as c, ".MAIN_DB_PREFIX."chargesociales as s";
 188  $sql .= " WHERE s.fk_type = c.id";
 189  if ($year > 0)
 190  {
 191      $sql .= " AND (";
 192      // Si period renseigné on l'utilise comme critere de date, sinon on prend date échéance,
 193      // ceci afin d'etre compatible avec les cas ou la période n'etait pas obligatoire
 194      $sql .= "   (s.periode is not null and date_format(s.periode, '%Y') = $year) ";
 195      $sql .= "or (s.periode is null     and date_format(s.date_ech, '%Y') = $year)";
 196      $sql .= ")";
 197  }
 198  if ($filtre) {
 199      $filtre=ereg_replace(":","=",$filtre);
 200      $sql .= " AND $filtre";
 201  }
 202  if ($_GET["sortfield"]) {
 203      $sql .= " ORDER BY ".$_GET["sortfield"];    
 204  }
 205  else {
 206      $sql .= " ORDER BY lower(s.date_ech)";
 207  }
 208  if ($_GET["sortorder"]) {
 209      $sql .= " ".$_GET["sortorder"];
 210  }
 211  else {
 212      $sql .= " DESC";
 213  }
 214  
 215  
 216  
 217  if ( $db->query($sql) )
 218  {
 219    $num = $db->num_rows();
 220    $i = 0;
 221    $var=true;
 222  
 223    while ($i < $num)
 224      {
 225        $obj = $db->fetch_object();
 226  
 227        $var = !$var;
 228        print "<tr $bc[$var]>";
 229        print '<td width="60">';
 230        print '<a href="charges.php?id='.$obj->id.'">'.img_file().' '.$obj->id.'</a>';
 231        print '</td>';
 232  
 233        print '<td width="110">'.dolibarr_print_date($obj->de).'</td>';
 234        print '<td>';
 235        if ($obj->periode) {
 236            print '<a href="index.php?year='.strftime("%Y",$obj->periode).'">'.strftime("%Y",$obj->periode).'</a>';
 237        } else {
 238            print '&nbsp;';
 239        }
 240        print '</td>';
 241        print '<td>'.$obj->type_lib.'</td><td>'.dolibarr_trunc($obj->libelle,36).'</td>';
 242        print '<td align="right" width="100">'.price($obj->amount).'</td>';
 243        
 244        if ($obj->paye)
 245      {
 246        print '<td align="center" class="normal"><a class="payee" href="index.php?filtre=paye:1">Payé</a></td>';
 247      } else {
 248        print '<td align="center"><a class="impayee" href="index.php?filtre=paye:0">Impayé</a></td>';
 249      }
 250        print '</tr>';
 251        $i++;
 252      }
 253  }
 254  else
 255  {
 256    dolibarr_print_error($db);
 257  }
 258  
 259  print '</table>';
 260  
 261  
 262  
 263  $db->close();
 264   
 265  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/06 20:58:15 $ r&eacute;vision $Revision: 1.31 $</em>");
 266  ?>


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