*** empty log message ***

This commit is contained in:
Rodolphe Quiedeville 2002-05-12 13:53:50 +00:00
parent 1793dc2ea2
commit 14cc00bdd9
3 changed files with 43 additions and 26 deletions

View File

@ -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;
}

View File

@ -33,31 +33,18 @@ $db = new Db();
print_titre ("Comptes bancaires");
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR class=\"liste_titre\">";
print "<td>Label</td><td>Banque</TD>";
print "<td align=\"left\">Numéro</a></TD>";
print "</TR>\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 "<tr><td>";
print '<a href="account.php3?account='.$objp->rowid.'">'.$objp->label.'</a>';
print "</td><td>$objp->bank</td><td>$objp->number</td></tr>";
$accounts[$i] = $objp->rowid;
$i++;
}
@ -65,8 +52,35 @@ if ($result) {
}
$acc = new Account($db);
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
print "<TR class=\"liste_titre\">";
print "<td>Label</td><td>Banque</TD>";
print "<td align=\"left\">Numéro</a></TD><td align=\"right\">Solde</td>";
print "</TR>\n";
$total = 0;
for ($i = 0 ; $i < sizeof($accounts) ; $i++) {
$acc = new Account($db);
$acc->fetch($accounts[$i]);
$solde = $acc->solde();
print "<tr><td>";
print '<a href="account.php3?account='.$acc->id.'">'.$acc->label.'</a>';
print "</td><td>$acc->bank</td><td>$acc->number</td>";
print '</td><td align="right">'.price($solde).'</td></tr>';
$total += $solde;
}
print '<tr><td colspan="3" align="right">Total</td><td align="right">'.price($total).'</td></tr>';
print "</table>";

View File

@ -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";