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

   1  <?php
   2  /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2003      Jean-Louis Bergamo   <jlb@j1b.org>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   *
   6   * This program is free software; you can redistribute it and/or modify
   7   * it under the terms of the GNU General Public License as published by
   8   * the Free Software Foundation; either version 2 of the License, or
   9   * (at your option) any later version.
  10   *
  11   * This program is distributed in the hope that it will be useful,
  12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14   * GNU General Public License for more details.
  15   *
  16   * You should have received a copy of the GNU General Public License
  17   * along with this program; if not, write to the Free Software
  18   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19   *
  20   * $Id: fiche.php,v 1.30 2005/10/25 19:32:04 eldy Exp $
  21   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/bank/fiche.php,v $
  22   */
  23  
  24  /**
  25          \file       htdocs/compta/bank/fiche.php
  26          \ingroup    banque
  27          \brief      Fiche création compte bancaire
  28          \version    $Revision: 1.30 $
  29  */
  30  
  31  require ("./pre.inc.php");
  32  
  33  $langs->load("banks");
  34  
  35  $user->getrights('banque');
  36  
  37  if (!$user->admin && !$user->rights->banque)
  38    accessforbidden();
  39  
  40  
  41  /*
  42   * Actions
  43   */
  44  if ($_POST["action"] == 'add')
  45  {
  46      // Creation compte
  47      $account = new Account($db,0);
  48      
  49      $account->label         = trim($_POST["label"]);
  50      $account->courant       = $_POST["type"];
  51      $account->clos          = $_POST["clos"];
  52      $account->rappro        = $_POST["norappro"]?1:0;
  53      
  54      $account->bank          = trim($_POST["bank"]);
  55      $account->code_banque   = $_POST["code_banque"];
  56      $account->code_guichet  = $_POST["code_guichet"];
  57      $account->number        = $_POST["number"];
  58      $account->cle_rib       = $_POST["cle_rib"];
  59      $account->bic           = $_POST["bic"];
  60      $account->iban_prefix   = $_POST["iban_prefix"];
  61      $account->domiciliation = $_POST["domiciliation"];
  62      
  63      $account->proprio       = $_POST["proprio"];
  64      $account->adresse_proprio = $_POST["adresse_proprio"];
  65      
  66      $account->solde         = $_POST["solde"];
  67      $account->date_solde    = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]);
  68      
  69      if ($account->label) {
  70          $id = $account->create($user->id);
  71          if ($id > 0) {
  72              $_GET["id"]=$id;            // Force chargement page en mode visu
  73          }
  74          else {
  75              $message='<div class="error">'.$account->error().'</div>';
  76              $_GET["action"]='create';   // Force chargement page en mode creation
  77          }
  78      } else {
  79          $message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'</div>';
  80          $_GET["action"]='create';       // Force chargement page en mode creation
  81      }
  82  }
  83  
  84  if ($_POST["action"] == 'update' && ! $_POST["cancel"])
  85  {
  86      // Modification
  87      $account = new Account($db, $_POST["id"]);
  88      $account->fetch($_POST["id"]);
  89  
  90      $account->label           = trim($_POST["label"]);
  91      $account->courant         = $_POST["type"];
  92      $account->clos            = $_POST["clos"];
  93      $account->rappro          = (isset($_POST["norappro"]) && $_POST["norappro"]=='on')?0:1;
  94  
  95      $account->bank            = $_POST["bank"];
  96      $account->code_banque     = $_POST["code_banque"];
  97      $account->code_guichet    = $_POST["code_guichet"];
  98      $account->number          = $_POST["number"];
  99      $account->cle_rib         = $_POST["cle_rib"];
 100      $account->bic             = $_POST["bic"];
 101      $account->iban_prefix     = $_POST["iban_prefix"];
 102      $account->domiciliation   = $_POST["domiciliation"];
 103      $account->proprio         = $_POST["proprio"];
 104      $account->adresse_proprio = $_POST["adresse_proprio"];
 105  
 106      if ($account->label)
 107      {
 108          $result = $account->update($user);
 109          if (! $result)
 110          {
 111              $message='<div class="error">'.$account->error().'</div>';
 112              $_GET["action"]='edit';     // Force chargement page edition
 113          }
 114          else
 115          {
 116              $_GET["id"]=$_POST["id"];   // Force chargement page en mode visu
 117          }
 118      } else {
 119          $message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'</div>';
 120          $_GET["action"]='create';       // Force chargement page en mode creation
 121      }
 122  }
 123  
 124  if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer)
 125  {
 126      // Modification
 127      $account = new Account($db, $_GET["id"]);
 128      $account->delete($_GET["id"]);
 129  
 130      header("Location: ".DOL_URL_ROOT."/compta/bank/index.php");
 131      exit;
 132  }
 133  
 134  
 135  llxHeader();
 136  
 137  $form = new Form($db);
 138  
 139  /* ************************************************************************** */
 140  /*                                                                            */
 141  /* Affichage page en mode création                                            */
 142  /*                                                                            */
 143  /* ************************************************************************** */
 144  
 145  if ($_GET["action"] == 'create')
 146  {
 147    print_titre($langs->trans("NewFinancialAccount"));
 148    print '<br>';
 149    
 150    if ($message) { print "$message<br>\n"; }
 151  
 152    print '<form action="fiche.php" method="post">';
 153    print '<input type="hidden" name="action" value="add">';
 154    print '<input type="hidden" name="clos" value="0">';
 155  
 156    print '<table class="border" width="100%">';
 157  
 158    print '<tr><td valign="top">'.$langs->trans("LabelBankCashAccount").'</td>';
 159    print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.$_POST["label"].'"></td></tr>';
 160  
 161    print '<tr><td valign="top">'.$langs->trans("AccountType").'</td>';
 162    print '<td colspan="3">';
 163    $form=new Form($db);
 164    print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type");
 165    print '</td></tr>';
 166  
 167    print '<tr><td valign="top">'.$langs->trans("InitialBankBalance").'</td>';
 168    print '<td colspan="3"><input size="12" type="text" class="flat" name="solde" value="0.00"></td></tr>';
 169  
 170    print '<tr><td valign="top">'.$langs->trans("Date").'</td>';
 171    print '<td colspan="3">'; $now=time();
 172    print '<input type="text" size="2" maxlength="2" name="reday" value="'.strftime("%d",$now).'">/';
 173    print '<input type="text" size="2" maxlength="2" name="remonth" value="'.strftime("%m",$now).'">/';
 174    print '<input type="text" size="4" maxlength="4" name="reyear" value="'.strftime("%Y",$now).'">';
 175    print '</td></tr>';
 176    
 177    print '<tr><td colspan="4"><b>'.$langs->trans("IfBankAccount").'...</b></td></tr>';
 178  
 179    print '<tr><td valign="top">'.$langs->trans("Conciliation").'</td>';
 180    print '<td colspan="3"><input type="checkbox" name="norappro" value="'.$_POST["norappro"].'"> '.$langs->trans("DisableConciliation").'</td></tr>';
 181  
 182    print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
 183    print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$_POST["bank"].'"></td></tr>';
 184  
 185    print '<tr><td>Code Banque</td><td>Code Guichet</td><td>Numéro</td><td>Clé RIB</td></tr>';
 186    print '<tr><td><input size="8" type="text" class="flat" name="code_banque" value="'.$_POST["code_banque"].'"></td>';
 187    print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$_POST["code_guichet"].'"></td>';
 188    print '<td><input size="15" type="text" class="flat" name="number" value="'.$_POST["number"].'"></td>';
 189    print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$_POST["cle_rib"].'"></td></tr>';
 190    
 191    print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
 192    print '<td colspan="3"><input size="24" type="text" class="flat" name="iban_prefix" value="'.$_POST["iban_prefix"].'"></td></tr>';
 193  
 194    print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
 195    print '<td colspan="3"><input size="24" type="text" class="flat" name="bic" value="'.$_POST["bic"].'"></td></tr>';
 196  
 197    print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
 198    print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">".$_POST["domiciliation"];
 199    print "</textarea></td></tr>";
 200  
 201    print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
 202    print '<td colspan="3"><input size="12" type="text" class="flat" name="proprio" value="'.$_POST["proprio"].'"></td></tr>';
 203  
 204    print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
 205    print "<textarea class=\"flat\" name=\"adresse_proprio\" rows=\"2\" cols=\"40\">".$_POST["adresse_proprio"];
 206    print "</textarea></td></tr>";
 207  
 208    print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("CreateAccount").'" type="submit" class="button"></td></tr>';
 209    print '</form>';
 210    print '</table>';
 211  }
 212  /* ************************************************************************** */
 213  /*                                                                            */
 214  /* Visu et edition                                                            */
 215  /*                                                                            */
 216  /* ************************************************************************** */
 217  else
 218  {
 219      if ($_GET["id"] && $_GET["action"] != 'edit') 
 220      {
 221        $account = new Account($db, $_GET["id"]);
 222        $account->fetch($_GET["id"]);
 223  
 224      /*
 225       * Affichage onglets
 226       */
 227      $h = 0;
 228      
 229      $head[$h][0] = "fiche.php?id=$account->id";
 230      $head[$h][1] = $langs->trans("AccountCard");
 231      $h++;
 232  
 233      dolibarr_fiche_head($head, $hselected, $langs->trans("FinancialAccount")." ".($account->number?$account->number:$account->label));
 234  
 235      /*
 236       * Confirmation de la suppression
 237       */
 238      if ($_GET["action"] == 'delete')
 239      {
 240          $form->form_confirm($_SERVER["PHP_SELF"]."?id=$account->id",$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete");
 241          print '<br />';
 242      }
 243  
 244      print '<table class="border" width="100%">';
 245        
 246      print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
 247      print '<td colspan="3">'.$account->label.'</td></tr>';
 248      
 249      print '<tr><td valign="top">'.$langs->trans("AccountType").'</td>';
 250      print '<td colspan="3">'.$account->type_lib[$account->type].'</td></tr>';
 251      
 252      print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
 253      print '<td colspan="3">'.$account->status[$account->clos].'</td></tr>';
 254  
 255      print '<tr><td valign="top">'.$langs->trans("Conciliable").'</td>';
 256      print '<td colspan="3">';
 257      if ($account->type == 0 || $account->type == 1) print ($account->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')'));
 258      if ($account->type == 2)                        print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
 259      print '</td></tr>';
 260  
 261      if ($account->type == 0 || $account->type == 1)
 262      {
 263          print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
 264          print '<td colspan="3">'.$account->bank.'</td></tr>';
 265      
 266          print '<tr><td>Code Banque</td><td>Code Guichet</td><td>Numéro</td><td>Clé RIB</td></tr>';
 267          print '<tr><td>'.$account->code_banque.'</td>';
 268          print '<td>'.$account->code_guichet.'</td>';
 269          print '<td>'.$account->number.'</td>';
 270          print '<td>'.$account->cle_rib.'</td></tr>';
 271          
 272          print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
 273          print '<td colspan="3">'.$account->iban_prefix.'</td></tr>';
 274          
 275          print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
 276          print '<td colspan="3">'.$account->bic.'</td></tr>';
 277          
 278          print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
 279          print nl2br($account->domiciliation);
 280          print "</td></tr>\n";
 281          
 282          print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td><td colspan="3">';
 283          print $account->proprio;
 284          print "</td></tr>\n";
 285          
 286          print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
 287          print nl2br($account->adresse_proprio);
 288          print "</td></tr>\n";
 289      }
 290          
 291      print '</table>';
 292      
 293      print '</div>';
 294  
 295  
 296      /*
 297       * Barre d'actions
 298       *
 299       */
 300      print '<div class="tabsAction">';
 301  
 302      if ($user->rights->banque->configurer) 
 303      {
 304        print '<a class="butAction" href="fiche.php?action=edit&id='.$account->id.'">'.$langs->trans("Edit").'</a>';
 305      }
 306  
 307      $canbedeleted=$account->can_be_deleted();   // Renvoi vrai si compte sans mouvements
 308      if ($user->rights->banque->configurer && $canbedeleted) 
 309      {
 310        print '<a class="butActionDelete" href="fiche.php?action=delete&id='.$account->id.'">'.$langs->trans("Delete").'</a>';
 311      }
 312  
 313      print '</div>';
 314  
 315      }
 316  
 317      /* ************************************************************************** */
 318      /*                                                                            */
 319      /* Edition                                                                    */
 320      /*                                                                            */
 321      /* ************************************************************************** */
 322        
 323      if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configurer) 
 324      {
 325          $account = new Account($db, $_GET["id"]);
 326          $account->fetch($_GET["id"]);
 327          
 328          print_titre($langs->trans("EditFinancialAccount"));
 329          print "<br>";
 330          
 331          if ($message) { print "$message<br>\n"; }
 332          
 333          print '<form action="fiche.php?id='.$account->id.'" method="post">';
 334          print '<input type="hidden" name="action" value="update">';
 335          print '<input type="hidden" name="id" value="'.$_GET["id"].'">'."\n\n";
 336          
 337          print '<table class="border" width="100%">';
 338          
 339          print '<tr><td valign="top">'.$langs->trans("Label").'</td>';
 340          print '<td colspan="3"><input size="30" type="text" class="flat" name="label" value="'.$account->label.'"></td></tr>';
 341          
 342          print '<tr><td valign="top">'.$langs->trans("AccountType").'</td>';
 343          print '<td colspan="3">'.$account->type_lib[$account->type];
 344          print '<input type="hidden" name="type" value="'.$account->type.'">';
 345          print '</td></tr>';
 346          
 347          print '<tr><td valign="top">'.$langs->trans("Status").'</td>';
 348          print '<td colspan="3">';
 349          $form->select_array("clos",array(0=>$account->status[0],1=>$account->status[1]),$account->clos);
 350          print '</td></tr>';
 351          
 352          print '<tr><td valign="top">'.$langs->trans("Conciliable").'</td>';
 353          print '<td colspan="3">';
 354          if ($account->type == 0 || $account->type == 1) print '<input type="checkbox" class="flat" name="norappro" '.($account->rappro?'':'checked="true"').'"> '.$langs->trans("DisableConciliation");
 355          if ($account->type == 2)                        print $langs->trans("No").' ('.$langs->trans("CashAccount").')';
 356          print '</td></tr>';
 357          
 358          if ($account->type == 0 || $account->type == 1)
 359          {
 360              print '<tr><td valign="top">'.$langs->trans("Bank").'</td>';
 361              print '<td colspan="3"><input size="30" type="text" class="flat" name="bank" value="'.$account->bank.'"></td></tr>';
 362          
 363              print '<tr><td>Code Banque</td><td>Code Guichet</td><td>Numéro</td><td>Clé RIB</td></tr>';
 364              print '<tr><td><input size="8" type="text" class="flat" name="code_banque" value="'.$account->code_banque.'"></td>';
 365              print '<td><input size="8" type="text" class="flat" name="code_guichet" value="'.$account->code_guichet.'"></td>';
 366              print '<td><input size="15" type="text" class="flat" name="number" value="'.$account->number.'"></td>';
 367              print '<td><input size="3" type="text" class="flat" name="cle_rib" value="'.$account->cle_rib.'"></td></tr>';
 368          
 369              print '<tr><td valign="top">'.$langs->trans("IBAN").'</td>';
 370              print '<td colspan="3"><input size="24" type="text" class="flat" name="iban_prefix" value="'.$account->iban_prefix.'"></td></tr>';
 371          
 372              print '<tr><td valign="top">'.$langs->trans("BIC").'</td>';
 373              print '<td colspan="3"><input size="24" type="text" class="flat" name="bic" value="'.$account->bic.'"></td></tr>';
 374          
 375              print '<tr><td valign="top">'.$langs->trans("BankAccountDomiciliation").'</td><td colspan="3">';
 376              print "<textarea class=\"flat\" name=\"domiciliation\" rows=\"2\" cols=\"40\">";
 377              print $account->domiciliation;
 378              print "</textarea></td></tr>";
 379          
 380              print '<tr><td valign="top">'.$langs->trans("BankAccountOwner").'</td>';
 381              print '<td colspan="3"><input size="30" type="text" class="flat" name="proprio" value="'.$account->proprio.'">';
 382              print '</td></tr>';
 383          
 384              print '<tr><td valign="top">'.$langs->trans("BankAccountOwnerAddress").'</td><td colspan="3">';
 385              print "<textarea class=\"flat\" name=\"adresse_proprio\" rows=\"2\" cols=\"40\">";
 386              print $account->adresse_proprio;
 387              print "</textarea></td></tr>";
 388          }
 389          
 390          print '<tr><td align="center" colspan="4"><input value="'.$langs->trans("Modify").'" type="submit" class="button">';
 391          print ' &nbsp; <input name="cancel" value="'.$langs->trans("Cancel").'" type="submit" class="button">';
 392          print '</td></tr>';
 393          print '</table>';
 394  
 395          print '</form>';
 396      }
 397        
 398  }
 399  
 400  
 401  
 402  $db->close();
 403  
 404  llxFooter('$Date: 2005/10/25 19:32:04 $ - $Revision: 1.30 $');
 405  ?>


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