diff --git a/htdocs/compta/bank/account.php3 b/htdocs/compta/bank/account.php3 index 3ff2c75b492..e409a628277 100644 --- a/htdocs/compta/bank/account.php3 +++ b/htdocs/compta/bank/account.php3 @@ -26,14 +26,11 @@ * */ require("./pre.inc.php3"); - require("./bank.lib.php3"); -$db = new Db(); if ($HTTP_POST_VARS["action"] == 'add' && $account) -{ - +{ if ($credit > 0) { $amount = $credit ; diff --git a/htdocs/compta/bank/bilan.php3 b/htdocs/compta/bank/bilan.php3 index f85fda425fc..375963ad985 100644 --- a/htdocs/compta/bank/bilan.php3 +++ b/htdocs/compta/bank/bilan.php3 @@ -23,16 +23,18 @@ require("./pre.inc.php3"); llxHeader(); -$db = new Db(); -function valeur($sql) { +function valeur($sql) +{ global $db; - if ( $db->query($sql) ) { - if ( $db->num_rows() ) { - $valeur = $db->result(0,0); + if ( $db->query($sql) ) + { + if ( $db->num_rows() ) + { + $valeur = $db->result(0,0); + } + $db->free(); } - $db->free(); - } return $valeur; } diff --git a/htdocs/compta/bank/bplc.php b/htdocs/compta/bank/bplc.php index a2f5491b1c2..8ce26e88181 100644 --- a/htdocs/compta/bank/bplc.php +++ b/htdocs/compta/bank/bplc.php @@ -22,7 +22,6 @@ require("./pre.inc.php3"); require("./bank.lib.php3"); -$db = new Db(); llxHeader(); diff --git a/htdocs/compta/bank/budget.php3 b/htdocs/compta/bank/budget.php3 index 5340458a3f8..6ea251be1fb 100644 --- a/htdocs/compta/bank/budget.php3 +++ b/htdocs/compta/bank/budget.php3 @@ -19,11 +19,9 @@ * $Source$ * */ - require("./pre.inc.php3"); llxHeader(); -$db = new Db(); /* * @@ -34,8 +32,6 @@ $db = new Db(); * exemple remboursement de frais de gestion par la banque * * - * - * */ if ($bid == 0) diff --git a/htdocs/compta/bank/categ.php3 b/htdocs/compta/bank/categ.php3 index ec5c71fec0b..fdb7359885c 100644 --- a/htdocs/compta/bank/categ.php3 +++ b/htdocs/compta/bank/categ.php3 @@ -19,11 +19,9 @@ * $Source$ * */ - require("./pre.inc.php3"); llxHeader(); -$db = new Db(); if ($action == 'add') { diff --git a/htdocs/compta/bank/config.php3 b/htdocs/compta/bank/config.php3 index 0bf22cb54dd..56f0198c3d2 100644 --- a/htdocs/compta/bank/config.php3 +++ b/htdocs/compta/bank/config.php3 @@ -18,12 +18,10 @@ * $Id$ * $Source$ */ - require("./pre.inc.php3"); require("./bank.lib.php3"); llxHeader(); -$db = new Db(); print_titre("Configuration"); diff --git a/htdocs/compta/bank/fiche.php b/htdocs/compta/bank/fiche.php index f02f1fde636..958b1618af8 100644 --- a/htdocs/compta/bank/fiche.php +++ b/htdocs/compta/bank/fiche.php @@ -19,24 +19,19 @@ * $Id$ * $Source$ */ - require("./pre.inc.php3"); llxHeader(); -$db = new Db(); - if ($HTTP_POST_VARS["action"] == 'add') { $account = new Account($db,0); - $account->bank = $HTTP_POST_VARS["bank"]; - $account->label = $HTTP_POST_VARS["label"]; - - $account->courant = $HTTP_POST_VARS["courant"]; - $account->clos = $HTTP_POST_VARS["clos"]; - - $account->code_banque = $HTTP_POST_VARS["code_banque"]; + $account->bank = $HTTP_POST_VARS["bank"]; + $account->label = $HTTP_POST_VARS["label"]; + $account->courant = $HTTP_POST_VARS["courant"]; + $account->clos = $HTTP_POST_VARS["clos"]; + $account->code_banque = $HTTP_POST_VARS["code_banque"]; $account->code_guichet = $HTTP_POST_VARS["code_guichet"]; $account->number = $HTTP_POST_VARS["number"]; $account->cle_rib = $HTTP_POST_VARS["cle_rib"]; @@ -45,7 +40,6 @@ if ($HTTP_POST_VARS["action"] == 'add') $account->domiciliation = $HTTP_POST_VARS["domiciliation"]; $id = $account->create($user->id); - } if ($action == 'update') diff --git a/htdocs/compta/bank/index.php b/htdocs/compta/bank/index.php index 8440dca6da2..5e27481847d 100644 --- a/htdocs/compta/bank/index.php +++ b/htdocs/compta/bank/index.php @@ -19,27 +19,20 @@ * $Source$ * */ - -/* - * - * $viewall - * - */ require("./pre.inc.php3"); require("./bank.lib.php3"); require("../../tva.class.php3"); require("../../chargesociales.class.php3"); llxHeader(); -$db = new Db(); print_titre ("Comptes bancaires"); - $sql = "SELECT rowid, label,number,bank FROM llx_bank_account"; $result = $db->query($sql); -if ($result) { +if ($result) +{ $accounts = array(); $num = $db->num_rows(); diff --git a/htdocs/compta/bank/ligne.php3 b/htdocs/compta/bank/ligne.php3 index fd60727b8f9..220ac83c989 100644 --- a/htdocs/compta/bank/ligne.php3 +++ b/htdocs/compta/bank/ligne.php3 @@ -22,7 +22,6 @@ require("./pre.inc.php3"); llxHeader(); -$db = new Db(); if ($action == 'class') { diff --git a/htdocs/compta/bank/pre.inc.php3 b/htdocs/compta/bank/pre.inc.php3 index e4c59846b04..72185541830 100644 --- a/htdocs/compta/bank/pre.inc.php3 +++ b/htdocs/compta/bank/pre.inc.php3 @@ -20,13 +20,12 @@ * $Source$ * */ - require("../../main.inc.php3"); require("./account.class.php"); function llxHeader($head = "") { - global $user, $conf, $account; + global $db, $user, $conf, $account; /* * @@ -39,7 +38,7 @@ function llxHeader($head = "") $menu->add("index.php","Comptes"); $menu->add_submenu("search.php3","Recherche"); - $db = new Db(); + $sql = "SELECT rowid, label FROM llx_bank_account where clos = 0"; $result = $db->query($sql); if ($result) diff --git a/htdocs/compta/bank/rappro.php3 b/htdocs/compta/bank/rappro.php3 index f9c18c35372..fe7e41ac7c7 100644 --- a/htdocs/compta/bank/rappro.php3 +++ b/htdocs/compta/bank/rappro.php3 @@ -21,10 +21,9 @@ require("./pre.inc.php3"); llxHeader(); -$db = new Db(); - -if ($action == 'rappro') { +if ($action == 'rappro') +{ $author = $GLOBALS["REMOTE_USER"]; if ($num_releve > 0) { $sql = "UPDATE llx_bank set rappro=$rappro, num_releve=$num_releve WHERE rowid=$rowid"; diff --git a/htdocs/compta/bank/releve.php3 b/htdocs/compta/bank/releve.php3 index f0a9cb546ca..54dd204b411 100644 --- a/htdocs/compta/bank/releve.php3 +++ b/htdocs/compta/bank/releve.php3 @@ -26,7 +26,7 @@ require("./pre.inc.php3"); llxHeader(); -$db = new Db(); + if (! strlen($num)) { diff --git a/htdocs/compta/bank/search.php3 b/htdocs/compta/bank/search.php3 index 8320e6ad976..22d95f2548e 100644 --- a/htdocs/compta/bank/search.php3 +++ b/htdocs/compta/bank/search.php3 @@ -24,7 +24,6 @@ require("./pre.inc.php3"); require("./bank.lib.php3"); llxHeader(); -$db = new Db(); if ($vline) { $viewline = $vline; diff --git a/htdocs/compta/bank/virement.php3 b/htdocs/compta/bank/virement.php3 index a0781496b4c..10d0a2bc61a 100644 --- a/htdocs/compta/bank/virement.php3 +++ b/htdocs/compta/bank/virement.php3 @@ -20,11 +20,9 @@ * */ require("./pre.inc.php3"); - require("./bank.lib.php3"); -llxHeader(); -$db = new Db(); +llxHeader(); if ($action == 'add') {