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

   1  <?php
   2  /* Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   3   *
   4   * This program is free software; you can redistribute it and/or modify
   5   * it under the terms of the GNU General Public License as published by
   6   * the Free Software Foundation; either version 2 of the License, or
   7   * (at your option) any later version.
   8   *
   9   * This program is distributed in the hope that it will be useful,
  10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12   * GNU General Public License for more details.
  13   *
  14   * You should have received a copy of the GNU General Public License
  15   * along with this program; if not, write to the Free Software
  16   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17   *
  18   * $Id: charges.php,v 1.19 2005/08/11 20:24:58 eldy Exp $
  19   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/sociales/charges.php,v $
  20   *
  21   */
  22  
  23  /**    
  24          \file       htdocs/compta/sociales/charges.php
  25          \ingroup    compta
  26          \brief      Fiche d'une charge sociale
  27          \version    $Revision: 1.19 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  $langs->load("compta");
  33  $langs->load("bills");
  34  
  35  
  36  $user->getrights('compta');
  37  
  38  if (!$user->admin && !$user->rights->compta->charges)
  39    accessforbidden();
  40  
  41  require ("../../chargesociales.class.php");
  42  
  43  llxHeader();
  44  
  45  
  46  $chid=isset($_GET["id"])?$_GET["id"]:$_POST["id"];
  47  
  48  
  49  /* *************************************************************************** */
  50  /*                                                                             */
  51  /* Action Classer Payé                                                         */
  52  /*                                                                             */
  53  /* *************************************************************************** */
  54  if ($_GET["action"] == 'payed')
  55  {
  56    $cha = new ChargeSociales($db);
  57    $result = $cha->set_payed($chid);
  58  }
  59      
  60  
  61  
  62  /* *************************************************************************** */
  63  /*                                                                             */
  64  /* Mode fiche                                                                  */
  65  /*                                                                             */
  66  /* *************************************************************************** */
  67  if ($chid > 0)
  68      {      
  69        $html = new Form($db);
  70  
  71        $cha = new ChargeSociales($db);
  72  
  73        if ( $cha->fetch($chid) > 0)
  74      {      
  75        /*
  76         *   Charge
  77         */
  78  
  79        //$head[0][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
  80        $head[0][1] = $langs->trans("SocialContribution").": $cha->id";
  81        $h = 1;
  82        $a = 0;
  83  
  84        dolibarr_fiche_head($head, $a);
  85          
  86        /*
  87         * Confirmation de la suppression de la charge
  88         *
  89         */
  90        if ($_GET["action"] == 'delete')
  91          {
  92            $html->form_confirm("index.php?id=$cha->id&amp;action=del","Supprimer la charge sociale","Etes-vous sûr de vouloir supprimer cette charge sociale ?","confirm_delete");
  93          }
  94  
  95        print "<form action=\"charges.php?id=$cha->id&amp;action=update\" method=\"post\">";
  96  
  97        print '<table class="border" width="100%">';
  98  
  99        print "<tr><td>".$langs->trans("Type")."</td><td>$cha->type_libelle</td><td>".$langs->trans("Payments")."</td></tr>";
 100  
 101        print "<tr><td>".$langs->trans("Period")."</td><td>".dolibarr_print_date($cha->periode,"%Y")."</td>";
 102        print '<td rowspan="5" valign="top">';
 103              
 104            /*
 105             * Paiements
 106             */
 107          $sql = "SELECT ".$db->pdate("datep")." as dp, p.amount,";
 108          $sql .= "c.libelle as paiement_type, p.num_paiement, p.rowid";
 109          $sql .= " FROM ".MAIN_DB_PREFIX."paiementcharge as p, ".MAIN_DB_PREFIX."c_paiement as c ";
 110          $sql .= " WHERE p.fk_charge = ".$chid." AND p.fk_typepaiement = c.id";
 111          $sql .= " ORDER BY dp DESC";
 112          
 113          $result = $db->query($sql);
 114          if ($result)
 115            {
 116              $num = $db->num_rows($result);
 117              $i = 0; $total = 0;
 118              echo '<table class="noborder" width="100%">';
 119              print '<tr class="liste_titre">';
 120              print '<td>'.$langs->trans("Date").'</td><td>'.$langs->trans("Type").'</td>';
 121              print '<td align="right">'.$langs->trans("Amount").'</td><td>&nbsp;</td></tr>';
 122          
 123              $var=True;
 124              while ($i < $num)
 125                {
 126              $objp = $db->fetch_object($result);
 127              $var=!$var;
 128              print "<tr $bc[$var]><td>";
 129                 print img_object($langs->trans("Payment"),"payment").' ';
 130              print dolibarr_print_date($objp->dp)."</td>\n";
 131              print "<td>$objp->paiement_type $objp->num_paiement</td>\n";
 132              print '<td align="right">'.price($objp->amount)."</td><td>".$langs->trans("Currency".$conf->monnaie)."</td>\n";
 133              print "</tr>";
 134              $totalpaye += $objp->amount;
 135              $i++;
 136                }
 137      
 138              if ($fac->paye == 0)
 139                {
 140              print "<tr><td colspan=\"2\" align=\"right\">Total payé:</td><td align=\"right\"><b>".price($totalpaye)."</b></td><td>".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
 141              print "<tr><td colspan=\"2\" align=\"right\">Réclamé :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($cha->amount)."</td><td bgcolor=\"#d0d0d0\">".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
 142              
 143              $resteapayer = $cha->amount - $totalpaye;
 144      
 145              print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
 146              print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($resteapayer)."</b></td><td bgcolor=\"#f0f0f0\">".$langs->trans("Currency".$conf->monnaie)."</td></tr>\n";
 147                }
 148              print "</table>";
 149              $db->free();
 150            } else {
 151              dolibarr_print_error($db);
 152            }
 153            print "</td>";
 154  
 155        print "</tr>";
 156  
 157        if ($cha->paye==0) {
 158            print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="desc" size="40" value="'.stripslashes($cha->lib).'"></td></tr>';
 159            print '<tr><td>'.$langs->trans("DateDue")."</td><td><input type=\"text\" name=\"amount\" value=\"".strftime("%Y%m%d",$cha->date_ech)."\"></td></tr>";
 160            print '<tr><td>'.$langs->trans("AmountTTC")."</td><td><b><input type=\"text\" name=\"amount\" value=\"$cha->amount\"></b></td></tr>";
 161          }
 162        else {
 163            print '<tr><td>'.$langs->trans("Label").'</td><td>'.$cha->lib.'</td></tr>';
 164            print "<tr><td>".$langs->trans("DateDue")."</td><td>".dolibarr_print_date($cha->date_ech)."</td></tr>";
 165            print '<tr><td>'.$langs->trans("AmountTTC").'</td><td><b>'.price($cha->amount).'</b></td></tr>';
 166        }
 167  
 168  
 169        print '<tr><td>'.$langs->trans("Status").'</td><td>'.$cha->getLibStatut().'</td></tr>';
 170        print '</table>';
 171      
 172      
 173       print "</form>\n";
 174  
 175      print '</div>';
 176  
 177      if (! $_GET["action"]) {
 178  
 179        /*
 180         *   Boutons actions
 181         */
 182  
 183          print "<div class=\"tabsAction\">\n";
 184  
 185          // Supprimer
 186          if ($cha->paye == 0 && $totalpaye <=0 && $user->rights->compta->charges)
 187            {
 188          print "<a class=\"butDelete\" href=\"charges.php?id=$cha->id&amp;action=delete\">".$langs->trans("Delete")."</a>";
 189            } 
 190  
 191          // Emettre paiement 
 192          if ($cha->paye == 0 && round($resteapayer) > 0 && $user->rights->compta->charges)
 193            {
 194          print "<a class=\"tabAction\" href=\"../paiement_charge.php?id=$cha->id&amp;action=create\">".$langs->trans("DoPaiement")."</a>";
 195            }
 196          
 197          // Classer 'payé'
 198          if ($cha->paye == 0 && round($resteapayer) <=0 && $user->rights->compta->charges)
 199            {
 200          print "<a class=\"tabAction\" href=\"charges.php?id=$cha->id&amp;action=payed\">".$langs->trans("ClassifyPayed")."</a>";
 201            }
 202          
 203          print "</div>";
 204      }
 205  
 206    }
 207    else
 208    {
 209        /* Charge non trouvée */
 210      print "Charge inexistante ou accés refusé";
 211    }
 212  }
 213  
 214  $db->close();
 215  
 216  llxFooter("<em>Derni&egrave;re modification $Date: 2005/08/11 20:24:58 $ r&eacute;vision $Revision: 1.19 $</em>");
 217  ?>


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