196 lines
5.6 KiB
PHP
196 lines
5.6 KiB
PHP
<?PHP
|
|
/*
|
|
* $Id$
|
|
* $Source$
|
|
*
|
|
*
|
|
* $viewall
|
|
*
|
|
*/
|
|
require("./pre.inc.php3");
|
|
require("../../lib/functions.inc.php3");
|
|
require("../../lib/bank.lib.php3");
|
|
llxHeader();
|
|
$db = new Db();
|
|
|
|
$bc[0]="bgcolor=\"#b0cba0\"";
|
|
$bc[1]="bgcolor=\"#b0e0b0\"";
|
|
|
|
if ($action == 'add') {
|
|
$author = $GLOBALS["REMOTE_USER"];
|
|
if ($credit > 0) {
|
|
$amount = $credit ;
|
|
} else {
|
|
$amount = - $debit ;
|
|
}
|
|
|
|
if ($num_chq) {
|
|
|
|
$sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author, num_chq)";
|
|
$sql .= " VALUES (now(), $dateo, '$label', $amount,'$author',$num_chq)";
|
|
} else {
|
|
$sql = "INSERT INTO llx_bank (datec, dateo, label, amount, author)";
|
|
$sql .= " VALUES (now(), $dateo, '$label', $amount,'$author')";
|
|
}
|
|
|
|
$result = $db->query($sql);
|
|
if (!$result) {
|
|
print $db->error();
|
|
print "<p>$sql";
|
|
}
|
|
}
|
|
if ($action == 'del') {
|
|
bank_delete_line($db, $rowid);
|
|
}
|
|
|
|
if ($vline) {
|
|
$viewline = $vline;
|
|
} else {
|
|
$viewline = 20;
|
|
}
|
|
|
|
print "<b>Bank</b> - <a href=\"$PHP_SELF\">Reload</a> -";
|
|
print "<a href=\"$PHP_SELF?viewall=1\">Voir tout</a>";
|
|
|
|
print "<form method=\"post\" action=\"$PHP_SELF?viewall=$viewall&vline=$vline\">";
|
|
print "<input type=\"hidden\" name=\"action\" value=\"add\">";
|
|
print "<TABLE border=\"1\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">";
|
|
print "<TR bgcolor=\"orange\">";
|
|
print "<td>Date</td><td>Description</TD>";
|
|
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=debit\">Debit</a></TD>";
|
|
print "<td align=\"right\"><a href=\"$PHP_SELF?vue=credit\">Credit</a></TD>";
|
|
print "<td align=\"right\">Solde</TD>";
|
|
print "<td align=\"right\">Francs</td>";
|
|
print "</TR>\n";
|
|
|
|
$sql = "SELECT count(*) FROM llx_bank";
|
|
if ( $db->query($sql) ) {
|
|
$nbline = $db->result (0, 0);
|
|
$db->free();
|
|
|
|
if ($nbline > $viewline ) {
|
|
$limit = $nbline - $viewline ;
|
|
} else {
|
|
$limit = $viewline;
|
|
}
|
|
}
|
|
|
|
if ($viewall) { $nbline=0; }
|
|
|
|
/* Another solution
|
|
* create temporary table solde type=heap select amount from llx_bank limit 100 ;
|
|
* select sum(amount) from solde ;
|
|
*/
|
|
|
|
$sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq";
|
|
$sql .= " FROM llx_bank as b";
|
|
if ($vue) {
|
|
if ($vue == 'credit') {
|
|
$sql .= " WHERE b.amount >= 0 ";
|
|
} else {
|
|
$sql .= " WHERE b.amount < 0 ";
|
|
}
|
|
}
|
|
$sql .= " ORDER BY b.dateo ASC";
|
|
|
|
$result = $db->query($sql);
|
|
if ($result) {
|
|
$var=True;
|
|
$num = $db->num_rows();
|
|
$i = 0; $total = 0;
|
|
|
|
$sep = 0;
|
|
|
|
while ($i < $num) {
|
|
$objp = $db->fetch_object( $i);
|
|
$total = $total + $objp->amount;
|
|
$time = time();
|
|
if ($i > ($nbline - $viewline)) {
|
|
|
|
if (!$psol) {
|
|
print "<tr $bc[$var]><td colspan=\"4\"> </td><td align=\"right\">".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
|
|
$psol = 1;
|
|
|
|
} else {
|
|
$var=!$var;
|
|
|
|
if ($objp->do > $time && !$sep) {
|
|
$sep = 1 ;
|
|
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
|
|
print "<td align=\"right\"><b>".price($total - $objp->amount)."</b></td><td align=\"right\">".francs($total - $objp->amount)."</td></tr>\n";
|
|
print "<tr>";
|
|
print "<td><input name=\"dateo\" type=\"text\" size=8 maxlength=8></td>";
|
|
print "<td>CHQ<input name=\"num_chq\" type=\"text\" size=4> -";
|
|
print "<input name=\"label\" type=\"text\" size=40></td>";
|
|
print "<td><input name=\"debit\" type=\"text\" size=8></td>";
|
|
print "<td><input name=\"credit\" type=\"text\" size=8></td>";
|
|
print "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"ajouter\"</td>";
|
|
print "</tr><tr><td colspan=\"2\">Format : YYYYMMDD - 20010826</td><td colspan=\"2\">0000.00</td></tr>";
|
|
}
|
|
|
|
print "<tr $bc[$var]>";
|
|
print "<td>".strftime("%d %b %y",$objp->do)."</TD>\n";
|
|
|
|
if ($objp->num_chq) {
|
|
print "<td>CHQ $objp->num_chq - $objp->label</td>";
|
|
} else {
|
|
print "<td>$objp->label</td>";
|
|
}
|
|
|
|
if ($objp->amount < 0) {
|
|
print "<td align=\"right\">".price($objp->amount * -1)."</TD><td> </td>\n";
|
|
} else {
|
|
print "<td> </td><td align=\"right\">".price($objp->amount)."</TD>\n";
|
|
}
|
|
|
|
if ($total > 0) {
|
|
print "<td align=\"right\">".price($total)."</TD>\n";
|
|
} else {
|
|
print "<td align=\"right\"><b>".price($total)."</b></TD>\n";
|
|
}
|
|
|
|
if ($objp->rappro) {
|
|
print "<td align=\"center\"><a href=\"releve.php3?num=$objp->num_releve\">$objp->num_releve</a></td>";
|
|
} else {
|
|
print "<td align=\"center\"><a href=\"$PHP_SELF?action=del&rowid=$objp->rowid\">[Del]</a></td>";
|
|
}
|
|
|
|
print "<td align=\"right\"><small>".francs($objp->amount)."</small></TD>\n";
|
|
print "</tr>";
|
|
|
|
}
|
|
}
|
|
|
|
|
|
$i++;
|
|
}
|
|
$db->free();
|
|
}
|
|
|
|
if ($sep) {
|
|
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
|
|
print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
|
|
} else {
|
|
|
|
print "<tr><td align=\"right\" colspan=\"4\">Total :</td>";
|
|
print "<td align=\"right\"><b>".price($total)."</b></td><td align=\"right\">".francs($total)."</td></tr>\n";
|
|
print "<tr>";
|
|
print "<td><input name=\"dateo\" type=\"text\" size=8 maxlength=8></td>";
|
|
print "<td>CHQ<input name=\"num_chq\" type=\"text\" size=4> -";
|
|
print "<input name=\"label\" type=\"text\" size=40></td>";
|
|
print "<td><input name=\"debit\" type=\"text\" size=8></td>";
|
|
print "<td><input name=\"credit\" type=\"text\" size=8></td>";
|
|
print "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"ajouter\"</td>";
|
|
print "</tr><tr><td colspan=\"2\">Format : YYYYMMDD - 20010826</td><td colspan=\"2\">0000.00</td></tr>";
|
|
}
|
|
|
|
print "</table></form>";
|
|
|
|
print "<a href=\"categ.php3\">Edit Categories</a>";
|
|
print " <a href=\"budget.php3\">Budgets</a>";
|
|
|
|
$db->close();
|
|
|
|
llxFooter(strftime("%H:%M",time()). " - <em>Dernière modification $Date$ révision $Revision$</em>");
|
|
?>
|