diff --git a/htdocs/compta/bank/account.class.php3 b/htdocs/compta/bank/account.class.php3 index 9e0831247c9..1a1329a21e5 100644 --- a/htdocs/compta/bank/account.class.php3 +++ b/htdocs/compta/bank/account.class.php3 @@ -24,7 +24,7 @@ class Account { var $rowid; var $bank; var $label; - var $name; + var $number; Function Account($DB, $rowid=0) { global $config; @@ -35,9 +35,10 @@ class Account { return 1; } - Function fetch() { - $sql = "SELECT s.idp, s.nom,".$this->db->pdate("s.datec"); - $sql .= " AND s.idp = ".$this->id; + Function fetch($id) { + $this->id = $id; + $sql = "SELECT rowid, label, bank, number FROM llx_bank_account"; + $sql .= " WHERE rowid = ".$id; $result = $this->db->query($sql); @@ -45,20 +46,22 @@ class Account { if ($this->db->num_rows()) { $obj = $this->db->fetch_object($result , 0); - $this->nom = $obj->nom; + $this->bank = $obj->bank; + $this->label = $obj->label; + $this->number = $obj->number; } $this->db->free(); } } Function solde() { - $sql = "SELECT sum(amount) FROM llx_bank WHERE rowid=$this->id"; + $sql = "SELECT sum(amount) FROM llx_bank WHERE fk_account=$this->id AND dateo <" . $this->db->idate(time() ); $result = $this->db->query($sql); if ($result) { if ($this->db->num_rows()) { - $solde = $this->db->fetch_result(0,0); + $solde = $this->db->result(0,0); return $solde; } diff --git a/htdocs/compta/bank/index.php3 b/htdocs/compta/bank/index.php3 index 41193533bda..e07353fac4c 100644 --- a/htdocs/compta/bank/index.php3 +++ b/htdocs/compta/bank/index.php3 @@ -33,31 +33,18 @@ $db = new Db(); print_titre ("Comptes bancaires"); -print ""; -print ""; -print ""; -print ""; -print "\n"; $sql = "SELECT rowid, label,number,bank FROM llx_bank_account"; $result = $db->query($sql); if ($result) { - $var=True; + $accounts = array(); + $num = $db->num_rows(); - $i = 0; $total = 0; - - $sep = 0; - + $i = 0; while ($i < $num) { $objp = $db->fetch_object( $i); - - - print ""; - + $accounts[$i] = $objp->rowid; $i++; } @@ -65,8 +52,35 @@ if ($result) { } -$acc = new Account($db); + +print "
LabelBanqueNuméro
"; - print ''.$objp->label.''; - - print "$objp->bank$objp->number
"; +print ""; +print ""; +print ""; +print "\n"; +$total = 0; +for ($i = 0 ; $i < sizeof($accounts) ; $i++) { + $acc = new Account($db); + $acc->fetch($accounts[$i]); + + $solde = $acc->solde(); + + + print ""; + + + + print ''; + + $total += $solde; + +} + +print ''; print "
LabelBanqueNuméroSolde
"; + print ''.$acc->label.''; + + print "$acc->bank$acc->number'.price($solde).'
Total'.price($total).'
"; diff --git a/htdocs/compta/bank/pre.inc.php3 b/htdocs/compta/bank/pre.inc.php3 index ff65dbb1edb..eaedbf68bc0 100644 --- a/htdocs/compta/bank/pre.inc.php3 +++ b/htdocs/compta/bank/pre.inc.php3 @@ -33,7 +33,7 @@ function llxHeader($head = "") { $menu = new Menu(); - $menu->add("account.php3","Comptes"); + $menu->add("index.php3","Comptes"); $db = new Db(); $sql = "SELECT rowid, label FROM llx_bank_account";