* Copyright (C) 2003 Jean-Louis Bergamo * Copyright (C) 2004-2008 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. */ /** \file htdocs/compta/bank/fiche.php \ingroup banque \brief Fiche creation compte bancaire \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); $langs->load("banks"); if (!$user->admin && !$user->rights->banque) accessforbidden(); /* * Actions */ if ($_POST["action"] == 'add') { // Creation compte $account = new Account($db,0); $account->ref = sanitizeFileName(trim($_POST["ref"])); $account->label = trim($_POST["label"]); $account->courant = $_POST["type"]; $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; $account->url = $_POST["url"]; $account->account_number = trim($_POST["account_number"]); $account->solde = $_POST["solde"]; $account->date_solde = dolibarr_mktime(12,0,0,$_POST["remonth"],$_POST["reday"],$_POST["reyear"]); $account->currency_code = trim($_POST["account_currency_code"]); $account->country_code = trim($_POST["account_country_code"]); $account->min_allowed = $_POST["account_min_allowed"]; $account->min_desired = $_POST["account_min_desired"]; $account->comment = trim($_POST["account_comment"]); 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->transnoentities("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 = dol_string_nospecial(trim($_POST["ref"])); $account->label = trim($_POST["label"]); $account->courant = $_POST["type"]; $account->clos = $_POST["clos"]; $account->rappro = (isset($_POST["norappro"]) && $_POST["norappro"])?0:1; $account->url = trim($_POST["url"]); $account->bank = trim($_POST["bank"]); $account->code_banque = trim($_POST["code_banque"]); $account->code_guichet = trim($_POST["code_guichet"]); $account->number = trim($_POST["number"]); $account->cle_rib = trim($_POST["cle_rib"]); $account->bic = trim($_POST["bic"]); $account->iban_prefix = trim($_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->currency_code = trim($_POST["account_currency_code"]); $account->country_code = trim($_POST["account_country_code"]); $account->min_allowed = $_POST["account_min_allowed"]; $account->min_desired = $_POST["account_min_desired"]; $account->comment = trim($_POST["account_comment"]); if ($account->label) { $result = $account->update($user); if ($result >= 0) { $_GET["id"]=$_POST["id"]; // Force chargement page en mode visu } else { $message='
'.$account->error().'
'; $_GET["action"]='edit'; // Force chargement page edition } } else { $message='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentities("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 creation */ /* */ /* ************************************************************************** */ if ($_GET["action"] == 'create') { print_fiche_titre($langs->trans("NewFinancialAccount")); 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 ''; } // Currency print ''; print ''; // Pays print ''; print ''; // Web print ''; print ''; // Comment print ''; print ''; // Solde print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("LabelBankCashAccount").'
'.$langs->trans("AccountType").''; print $form->select_type_comptes_financiers(isset($_POST["type"])?$_POST["type"]:1,"type"); print '
'.$langs->trans("AccountancyCode").'
'.$langs->trans("Currency").''; /* $selectedcode=$account->account_currency_code; if (! $selectedcode) $selectedcode=$conf->monnaie; $form->select_currency($selectedcode, 'account_currency_code'); */ print $langs->trans("Currency".$conf->monnaie); print ''; print '
'.$langs->trans("Country").''; $selectedcode=$account->account_country_code; if (! $selectedcode) $selectedcode=$mysoc->pays_code; $form->select_pays($selectedcode, 'account_country_code'); print '
'.$langs->trans("Web").'
'.$langs->trans("Comment").''; // �diteur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('account_comment',$account->comment,200,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print '
'.$langs->trans("InitialBankBalance").'...
'.$langs->trans("InitialBankBalance").'
'.$langs->trans("Date").''; $form->select_date(time(), 're', 0, 0, 0, 'createbankaccount'); print '
'.$langs->trans("BalanceMinimalAllowed").'
'.$langs->trans("BalanceMinimalDesired").'
'; } /* ************************************************************************** */ /* */ /* Visu et edition */ /* */ /* ************************************************************************** */ else { if (($_GET["id"] || $_GET["ref"]) && $_GET["action"] != 'edit') { $account = new Account($db); if ($_GET["id"]) { $account->fetch($_GET["id"]); } if ($_GET["ref"]) { $account->fetch(0,$_GET["ref"]); $_GET["id"]=$account->id; } /* * Affichage onglets */ // Onglets $head=bank_prepare_head($account); dolibarr_fiche_head($head, 'bankname', $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 ''; } // Currency print ''; print ''; print ''; print ''; print ''; print ''; print '\n"; print ''; print ''; print '
'.$langs->trans("Ref").''; print $form->showrefnav($account,'ref','',1,'ref'); print '
'.$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("Currency").''; /* $selectedcode=$account->account_currency_code; if (! $selectedcode) $selectedcode=$conf->monnaie; $form->select_currency($selectedcode, 'account_currency_code'); */ print $langs->trans("Currency".$conf->monnaie); print ''; print '
'.$langs->trans("BalanceMinimalAllowed").''.$account->min_allowed.'
'.$langs->trans("BalanceMinimalDesired").''.$account->min_desired.'
'.$langs->trans("Web").''; if ($account->url) print ''; print $account->url; if ($account->url) print ''; print "
'.$langs->trans("Comment").''.$account->comment.'
'; print ''; /* * Barre d'actions * */ print '
'; if ($user->rights->banque->configurer) { print 'id.'">'.$langs->trans("Modify").''; } $canbedeleted=$account->can_be_deleted(); // Renvoi vrai si compte sans mouvements if ($user->rights->banque->configurer && $canbedeleted) { print 'id.'">'.$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 ''; } // Currency print ''; print ''; print ''; print ''; print ''; print ''; // Web print ''; print ''; // Comment print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("AccountType").''; print $form->select_type_comptes_financiers($account->type,"type"); 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("Currency"); print ''; print ''; /* $selectedcode=$account->account_currency_code; if (! $selectedcode) $selectedcode=$conf->monnaie; $form->select_currency($selectedcode, 'account_currency_code'); */ print $langs->trans("Currency".$conf->monnaie); print ''; print '
'.$langs->trans("BalanceMinimalAllowed").'
'.$langs->trans("BalanceMinimalDesired").'
'.$langs->trans("Web").''; print '
'.$langs->trans("Comment").''; // �diteur wysiwyg if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_MAILING) { require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $doleditor=new DolEditor('account_comment',$account->comment,200,'dolibarr_notes','',false); $doleditor->Create(); } else { print ''; } print '
'; print '   '; print '
'; print '
'; } } $db->close(); llxFooter('$Date$ - $Revision$'); ?>