* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2006 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/compta/bank/fiche.php \ingroup banque \brief Fiche création compte bancaire \version $Revision$ */ require("./pre.inc.php"); $langs->load("banks"); $user->getrights('banque'); if (!$user->admin && !$user->rights->banque) accessforbidden(); /* * Actions */ if ($_POST["action"] == 'add') { // Creation compte $account = new Account($db,0); $account->ref = ereg_replace(' ','',trim($_POST["ref"])); $account->label = trim($_POST["label"]); $account->courant = $_POST["type"]; $account->clos = $_POST["clos"]; $account->rappro = $_POST["norappro"]?1:0; $account->bank = trim($_POST["bank"]); $account->code_banque = $_POST["code_banque"]; $account->code_guichet = $_POST["code_guichet"]; $account->number = $_POST["number"]; $account->cle_rib = $_POST["cle_rib"]; $account->bic = $_POST["bic"]; $account->iban_prefix = $_POST["iban_prefix"]; $account->domiciliation = trim($_POST["domiciliation"]); $account->proprio = trim($_POST["proprio"]); $account->adresse_proprio = trim($_POST["adresse_proprio"]); $account->account_number = trim($_POST["account_number"]); $account->solde = $_POST["solde"]; $account->date_solde = mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); if ($account->label) { $id = $account->create($user->id); if ($id > 0) { $_GET["id"]=$id; // Force chargement page en mode visu } else { $message='
'.$account->error().'
'; $_GET["action"]='create'; // Force chargement page en mode creation } } else { $message='
'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'
'; $_GET["action"]='create'; // Force chargement page en mode creation } } if ($_POST["action"] == 'update' && ! $_POST["cancel"]) { // Modification $account = new Account($db, $_POST["id"]); $account->fetch($_POST["id"]); $account->ref = ereg_replace(' ','',trim($_POST["ref"])); $account->label = trim($_POST["label"]); $account->courant = $_POST["type"]; $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"]=='on')?0:1; $account->bank = trim($_POST["bank"]); $account->code_banque = $_POST["code_banque"]; $account->code_guichet = $_POST["code_guichet"]; $account->number = $_POST["number"]; $account->cle_rib = $_POST["cle_rib"]; $account->bic = $_POST["bic"]; $account->iban_prefix = $_POST["iban_prefix"]; $account->domiciliation = $_POST["domiciliation"]; $account->proprio = $_POST["proprio"]; $account->adresse_proprio = $_POST["adresse_proprio"]; $account->account_number = trim($_POST["account_number"]); if ($account->label) { $result = $account->update($user); if (! $result) { $message='
'.$account->error().'
'; $_GET["action"]='edit'; // Force chargement page edition } else { $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu } } else { $message='
'.$langs->trans("ErrorFieldRequired",$langs->trans("LabelBankCashAccount")).'
'; $_GET["action"]='create'; // Force chargement page en mode creation } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes" && $user->rights->banque->configurer) { // Modification $account = new Account($db, $_GET["id"]); $account->delete($_GET["id"]); header("Location: ".DOL_URL_ROOT."/compta/bank/index.php"); exit; } llxHeader(); $form = new Form($db); /* ************************************************************************** */ /* */ /* Affichage page en mode création */ /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { print_titre($langs->trans("NewFinancialAccount")); print '
'; if ($message) { print "$message
\n"; } print '
'; print ''; print ''; print ''; // Ref print ''; print ''; print ''; print ''; print ''; print ''; // Code compta if ($conf->comptaexpert->enabled) { print ''; print ''; } else { print ''; } print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print '"; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("LabelBankCashAccount").'
'.$langs->trans("AccountType").''; $form=new Form($db); print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); print '
'.$langs->trans("AccountancyCode").'
'.$langs->trans("InitialBankBalance").'
'.$langs->trans("Date").''; $now=time(); print '/'; print '/'; print ''; print '
'.$langs->trans("IfBankAccount").'...
'.$langs->trans("Conciliation").' '.$langs->trans("DisableConciliation").'
'.$langs->trans("Bank").'
Code BanqueCode GuichetNuméroClé RIB
'.$langs->trans("IBAN").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountDomiciliation").''; print "
'.$langs->trans("BankAccountOwner").'
'.$langs->trans("BankAccountOwnerAddress").''; print "
'; } /* ************************************************************************** */ /* */ /* Visu et edition */ /* */ /* ************************************************************************** */ else { if ($_GET["id"] && $_GET["action"] != 'edit') { $account = new Account($db, $_GET["id"]); $account->fetch($_GET["id"]); /* * Affichage onglets */ $h = 0; $head[$h][0] = "fiche.php?id=$account->id"; $head[$h][1] = $langs->trans("AccountCard"); $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("FinancialAccount")); /* * Confirmation de la suppression */ if ($_GET["action"] == 'delete') { $form->form_confirm($_SERVER["PHP_SELF"]."?id=$account->id",$langs->trans("DeleteAccount"),$langs->trans("ConfirmDeleteAccount"),"confirm_delete"); print '
'; } print ''; // Ref print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Code compta if ($conf->comptaexpert->enabled) { print ''; print ''; } if ($account->type == 0 || $account->type == 1) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '\n"; print '\n"; print '\n"; } print '
'.$langs->trans("Ref").''.$account->ref.'
'.$langs->trans("Label").''.$account->label.'
'.$langs->trans("AccountType").''.$account->type_lib[$account->type].'
'.$langs->trans("Status").''.$account->getLibStatut(4).'
'.$langs->trans("Conciliable").''; if ($account->type == 0 || $account->type == 1) print ($account->rappro==1 ? $langs->trans("Yes") : ($langs->trans("No").' ('.$langs->trans("ConciliationDisabled").')')); if ($account->type == 2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; print '
'.$langs->trans("AccountancyCode").''.$account->account_number.'
'.$langs->trans("Bank").''.$account->bank.'
Code BanqueCode GuichetNuméroClé RIB
'.$account->code_banque.''.$account->code_guichet.''.$account->number.''.$account->cle_rib.'
'.$langs->trans("IBAN").''.$account->iban_prefix.'
'.$langs->trans("BIC").''.$account->bic.'
'.$langs->trans("BankAccountDomiciliation").''; print nl2br($account->domiciliation); print "
'.$langs->trans("BankAccountOwner").''; print $account->proprio; print "
'.$langs->trans("BankAccountOwnerAddress").''; print nl2br($account->adresse_proprio); print "
'; print ''; /* * Barre d'actions * */ print '
'; if ($user->rights->banque->configurer) { print ''.$langs->trans("Edit").''; } $canbedeleted=$account->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print ''.$langs->trans("Delete").''; } print '
'; } /* ************************************************************************** */ /* */ /* Edition */ /* */ /* ************************************************************************** */ if ($_GET["id"] && $_GET["action"] == 'edit' && $user->rights->banque->configurer) { $account = new Account($db, $_GET["id"]); $account->fetch($_GET["id"]); print_titre($langs->trans("EditFinancialAccount")); print "
"; if ($message) { print "$message
\n"; } print '
'; print ''; print ''."\n\n"; print ''; // Ref print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; // Code compta if ($conf->comptaexpert->enabled) { print ''; print ''; } else { print ''; } if ($account->type == 0 || $account->type == 1) { print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print '"; } print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("AccountType").''.$account->type_lib[$account->type]; print ''; print '
'.$langs->trans("Status").''; $form->select_array("clos",array(0=>$account->status[0],1=>$account->status[1]),$account->clos); print '
'.$langs->trans("Conciliable").''; if ($account->type == 0 || $account->type == 1) print 'rappro?'':'checked="true"').'"> '.$langs->trans("DisableConciliation"); if ($account->type == 2) print $langs->trans("No").' ('.$langs->trans("CashAccount").')'; print '
'.$langs->trans("AccountancyCode").'
'.$langs->trans("Bank").'
Code BanqueCode GuichetNuméroClé RIB
'.$langs->trans("IBAN").'
'.$langs->trans("BIC").'
'.$langs->trans("BankAccountDomiciliation").''; print "
'.$langs->trans("BankAccountOwner").''; print '
'.$langs->trans("BankAccountOwnerAddress").''; print "
'; print '   '; print '
'; print '
'; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>