diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index a689bf4bc53..027dcf630a0 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * 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 @@ -32,29 +32,28 @@ require("./pre.inc.php"); if (!$user->rights->banque->configurer) accessforbidden(); -llxHeader(); /* - * Actions ajout catégorie - */ +* Actions ajout catégorie +*/ if ($_POST["action"] == 'add') { - if ($_POST["label"]) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ (label) VALUES ('".$_POST["label"]."')"; - $result = $db->query($sql); - - if (!$result) + if ($_POST["label"]) { - dolibarr_print_error($db); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_categ (label) VALUES ('".$_POST["label"]."')"; + $result = $db->query($sql); + + if (!$result) + { + dolibarr_print_error($db); + } } - } } /* - * Action suppression catégorie - */ +* Action suppression catégorie +*/ if ( $_REQUEST['action'] == 'delete' ) { if ( $_REQUEST['categid'] ) @@ -64,16 +63,23 @@ if ( $_REQUEST['action'] == 'delete' ) if (!$result) { - dolibarr_print_error($db); + dolibarr_print_error($db); } } } + + /* * Affichage liste des catégories */ -print_titre($langs->trans("Categories")); +llxHeader(); + + +print_fiche_titre($langs->trans("Categories")); + + print '
'; print ""; print ''; @@ -95,9 +101,9 @@ if ($result) $objp = $db->fetch_object($result); $var=!$var; print ""; - print ''; + print ''; print ""; - print ''; + print ''; print ""; $i++; } diff --git a/htdocs/compta/bank/config.php b/htdocs/compta/bank/config.php deleted file mode 100644 index 5811f4e3ae9..00000000000 --- a/htdocs/compta/bank/config.php +++ /dev/null @@ -1,100 +0,0 @@ - - * 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/config.php - \ingroup banque - \brief Page de configuration des comptes bancaires - \version $Revision$ -*/ - -require("./pre.inc.php"); -require_once(DOL_DOCUMENT_ROOT."/lib/bank.lib.php"); - -if (!$user->rights->banque->configurer) - accessforbidden(); - - -llxHeader(); - -print_titre($langs->trans("AccountSetup")); -print '
'; -print '
'.$objp->rowid.''.$objp->rowid.'$objp->label'.img_delete().'
'; -print ''; -print ''; -print ''; -print ''; -print ''; -print "\n"; - -$sql = "SELECT rowid, label, number, bank, courant as type, clos, rappro"; -$sql.= " FROM ".MAIN_DB_PREFIX."bank_account"; -$sql.= " ORDER BY label"; - -$result = $db->query($sql); -$var=false; -if ($result) -{ - $accountstatic=new Account($db); - - $var=True; - $num = $db->num_rows($result); - $i = 0; $total = 0; - - $sep = 0; - - while ($i < $num) - { - $objp = $db->fetch_object($result); - - $var=!$var; - print ''; - $accountstatic->id=$objp->rowid; - $accountstatic->label=$objp->label; - print ''; - print ''; - print ''; - print ''; - print ''; - - $i++; - } - $db->free($result); -} -print "
'.$langs->trans("Ref")."".$langs->trans("Type")."".$langs->trans("Bank").''.$langs->trans("AccountIdShort").''.$langs->trans("Conciliable").''.$langs->trans("Status").'
'.$accountstatic->getNomUrl(1).''.$accountstatic->type_lib[$objp->type].''.$objp->bank.' '.$objp->number.' '.yn($objp->rappro).''.$accountstatic->LibStatut($objp->clos,5).'
"; - - -/* - * Boutons d'actions - */ -print "
\n"; -if ($user->rights->banque->configurer) -{ - print ''.$langs->trans("NewFinancialAccount").''; - print ''.$langs->trans("Categories").''; -} -print "
"; - -$db->close(); - -llxFooter('$Date$ - $Revision$'); -?> diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index 674543bfc43..d5d8e6482ec 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -320,7 +320,9 @@ else print ''.$account->min_desired.''; print ''.$langs->trans("Web").''; - print ''.$account->url.''; + if ($account->url) print ''; + print $account->url; + if ($account->url) print ''; print "\n"; print ''.$langs->trans("Comment").''; diff --git a/htdocs/compta/bank/graph.php b/htdocs/compta/bank/graph.php index eb419cd0dd5..0960b33cf8a 100644 --- a/htdocs/compta/bank/graph.php +++ b/htdocs/compta/bank/graph.php @@ -87,4 +87,9 @@ if ($account > 0) print "\n\n"; } + +$db->close(); + +llxFooter('$Date$ - $Revision$'); + ?> diff --git a/htdocs/compta/bank/pre.inc.php b/htdocs/compta/bank/pre.inc.php index d3c00fe4f10..3bbff2269dc 100644 --- a/htdocs/compta/bank/pre.inc.php +++ b/htdocs/compta/bank/pre.inc.php @@ -56,10 +56,12 @@ function llxHeader($head = "") while ($i < $numr) { $objp = $db->fetch_object($resql); - $menu->add(DOL_URL_ROOT."/compta/bank/account.php?account=".$objp->rowid, $objp->label); + $menu->add(DOL_URL_ROOT."/compta/bank/fiche.php?id=".$objp->rowid, $objp->label); +/* $menu->add_submenu(DOL_URL_ROOT."/compta/bank/annuel.php?account=".$objp->rowid ,$langs->trans("IOMonthlyReporting")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/graph.php?account=".$objp->rowid ,$langs->trans("Graph")); if ($objp->courant != 2) $menu->add_submenu(DOL_URL_ROOT."/compta/bank/releve.php?account=".$objp->rowid ,$langs->trans("AccountStatements")); +*/ $i++; } } @@ -67,6 +69,9 @@ function llxHeader($head = "") } $menu->add(DOL_URL_ROOT."/compta/bank/index.php",$langs->trans("MenuBankCash")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/fiche.php?action=create",$langs->trans("MenuNewFinancialAccount")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/categ.php",$langs->trans("Categories")); + $menu->add_submenu(DOL_URL_ROOT."/compta/bank/search.php",$langs->trans("SearchTransaction")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/budget.php",$langs->trans("ByCategories")); $menu->add_submenu(DOL_URL_ROOT."/compta/bank/bilan.php","Bilan"); @@ -76,11 +81,6 @@ function llxHeader($head = "") $menu->add_submenu(DOL_URL_ROOT."/compta/bank/virement.php",$langs->trans("Virements")); } - if ($user->rights->banque->configurer) - { - $menu->add(DOL_URL_ROOT."/compta/bank/config.php",$langs->trans("MenuSetupBank")); - } - if ($conf->global->COMPTA_ONLINE_PAYMENT_BPLC) { $menu->add(DOL_URL_ROOT."/compta/bank/bplc.php","Transactions BPLC"); diff --git a/htdocs/includes/menus/barre_left/eldy_backoffice.php b/htdocs/includes/menus/barre_left/eldy_backoffice.php index b652a1f2053..a3fce6a7ba3 100644 --- a/htdocs/includes/menus/barre_left/eldy_backoffice.php +++ b/htdocs/includes/menus/barre_left/eldy_backoffice.php @@ -448,8 +448,6 @@ class MenuLeft { if ($leftmenu=="ca") $newmenu->add_submenu(DOL_URL_ROOT."/compta/stats/cabyuser.php?leftmenu=ca",$langs->trans("ByUsers"),2,$user->rights->compta->resultat->lire||$user->rights->comptaexpert->comptarapport->lire); } - $newmenu->add(DOL_URL_ROOT."/compta/bank/config.php",$langs->trans("MenuSetupBank"),0,$user->rights->banque->configurer); - } diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 84d3d5f588e..634855a183e 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -44,6 +44,7 @@ StandingOrderProcessed=Processed NewAccount=New account NewBankAccount=New bank account NewFinancialAccount=New financial account +MenuNewFinancialAccount=New financial account NewCurrentAccount=New current account NewSavingAccount=New saving account NewCashAccount=New cash account diff --git a/htdocs/langs/fr_FR/banks.lang b/htdocs/langs/fr_FR/banks.lang index ae097b2707e..490d3ceb86a 100644 --- a/htdocs/langs/fr_FR/banks.lang +++ b/htdocs/langs/fr_FR/banks.lang @@ -44,6 +44,7 @@ StandingOrderProcessed=Trait NewAccount=Nouveau compte NewBankAccount=Nouveau compte bancaire NewFinancialAccount=Nouveau compte financier +MenuNewFinancialAccount=Nouveau compte NewCurrentAccount=Nouveau compte courant NewSavingAccount=Nouveau compte épargne NewCashAccount=Nouveau compte caisse diff --git a/htdocs/lib/bank.lib.php b/htdocs/lib/bank.lib.php new file mode 100644 index 00000000000..f4e1bf6bc6c --- /dev/null +++ b/htdocs/lib/bank.lib.php @@ -0,0 +1,126 @@ + + * + * 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. + * or see http://www.gnu.org/ + * + * $Id$ + * $Source$ + */ + +/** + \file htdocs/lib/bank.lib.php + \brief Ensemble de fonctions de base pour le module banque + \ingroup banque + \version $Revision$ + + Ensemble de fonctions de base de dolibarr sous forme d'include +*/ + +function bank_prepare_head($obj) +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/fiche.php?id='.$obj->id; + $head[$h][1] = $langs->trans("AccountCard"); + $head[$h][2] = 'bankname'; + $h++; + + if ($obj->type == 0 || $obj->type == 1) + { + $head[$h][0] = DOL_URL_ROOT.'/compta/bank/bankid_fr.php?id='.$obj->id; + $head[$h][1] = $langs->trans("RIB"); + $head[$h][2] = 'bankid'; + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/compta/bank/account.php?account=".$obj->id; + $head[$h][1] = $langs->trans("Transactions"); + $head[$h][2] = 'journal'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/compta/bank/annuel.php?account=".$obj->id; + $head[$h][1] = $langs->trans("IOMonthlyReporting"); + $head[$h][2] = 'annual'; + $h++; + + $head[$h][0] = DOL_URL_ROOT."/compta/bank/graph.php?account=".$obj->id; + $head[$h][1] = $langs->trans("Graph"); + $head[$h][2] = 'graph'; + $h++; + + if ($obj->courant != 2) + { + $head[$h][0] = DOL_URL_ROOT."/compta/bank/releve.php?account=".$obj->id; + $head[$h][1] = $langs->trans("AccountStatement"); + $head[$h][2] = 'statement'; + $h++; + } + + return $head; +} + + +/** + \brief Verifie le RIB d'un compte bancaire grace à sa clé + \param code_banque code banque + \param code_guichet code guichet + \param num_compte numero de compte + \param cle cle + \param iban Ne sert pas pour le calcul de cle mais sert pour determiner le pays + \return int true si les infos sont bonnes, false si la clé ne correspond pas +*/ +function verif_rib($code_banque , $code_guichet , $num_compte , $cle, $iban) +{ + if (eregi("^FR",$iban)) + { // Cas de la France + + $coef = array(62, 34, 3) ; + + // Concatenation des differents codes. + $rib = strtolower(trim($code_banque).trim($code_guichet).trim($num_compte).trim($cle)); + + // On remplace les eventuelles lettres par des chiffres. + + //Ne marche pas + //$rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678912345678"); + + $rib = strtr($rib, "abcdefghijklmnopqrstuvwxyz","12345678912345678923456789"); + + // Separation du rib en 3 groupes de 7 + 1 groupe de 2. + // Multiplication de chaque groupe par les coef du tableau + for ($i=0, $s=0; $i<3; $i++) + { + $code = substr($rib, 7 * $i, 7) ; + $s += (0 + $code) * $coef[$i] ; + } + + // Soustraction du modulo 97 de $s à 97 pour obtenir la clé RIB + $cle_rib = 97 - ($s % 97) ; + + if ($cle_rib == $cle) + { + return true; + } + + return false; + } + + return true; +} + +?> \ No newline at end of file