* Copyright (C) 2004 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$ */ /* $num * $rel * $ve */ require("./pre.inc.php"); if (!$user->rights->banque->lire) accessforbidden(); llxHeader(); // Récupère info du compte $acct = new Account($db); $acct->fetch($_GET["account"]); if (! isset($_GET["num"])) { /* * * Vue liste * * */ if ($page == -1) { $page = 0 ; } $limit = $conf->liste_limit; $offset = $limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; $sql = "SELECT distinct(b.num_releve) as numr"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b WHERE fk_account = ".$_GET["account"]." ORDER BY numr DESC"; $sql .= $db->plimit($limit,$offset); $result = $db->query($sql); if ($result) { $var=True; $numrows = $db->num_rows(); $i = 0; print_barre_liste("Relevés bancaires, compte : id."\">".$acct->label."", $page, $PHP_SELF,"&account=$account",$sortfield,$sortorder,'',$numrows); print ''; print ""; print ""; while ($i < min($numrows,$limit)) { $objp = $db->fetch_object( $i); $var=!$var; if (! $objp->numr) { // print "\n"; } else { print "\n"; } $i++; } print "
Relevé
Ecritures rapprochées à aucun relevé
numr&account=".$_GET["account"]."\">$objp->numr
\n"; } } else { /* * Vue d'un releves * */ if ($rel == 'prev') { $sql = "SELECT distinct(num_releve) FROM ".MAIN_DB_PREFIX."bank WHERE num_releve < ".$_GET["num"]." AND fk_account = $account ORDER BY num_releve DESC"; $result = $db->query($sql); if ($result) { $var=True; $numrows = $db->num_rows(); $i = 0; if ($numrows > 0) { $row = $db->fetch_row(0); $num = $row[0]; } } } elseif ($rel == 'next') { $sql = "SELECT distinct(num_releve) FROM ".MAIN_DB_PREFIX."bank WHERE num_releve > ".$_GET["num"]." AND fk_account = $account ORDER BY num_releve ASC"; $result = $db->query($sql); if ($result) { $var=True; $numrows = $db->num_rows(); $i = 0; if ($numrows > 0) { $row = $db->fetch_row(0); $num = $row[0]; } } } print_titre('Relevé numéro '.$_GET["num"].', compte : '.$acct->label.''); print ""; print ""; print "
 id\"><- Relevé précédent"; print "  -  id\">Relevé suivant ->
"; print "
"; print ""; print ''; print ""; print ''; print ''; print ''; print ''; print ''; print "\n"; $sql = "SELECT sum(amount) FROM ".MAIN_DB_PREFIX."bank WHERE num_releve < ".$_GET["num"]." AND fk_account = ".$acct->id; if ( $db->query($sql) ) { $total = $db->result (0, 0); $db->free(); } $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b WHERE"; $sql .= " num_releve='".$_GET["num"]."'"; if (! $_GET["num"]) { $sql .= " or num_releve is null"; } $sql .= " AND fk_account = ".$acct->id; $sql .= " ORDER BY dateo ASC"; $result = $db->query($sql); if ($result) { $var=True; $numrows = $db->num_rows(); $i = 0; print ""; print "\n"; while ($i < $numrows) { $objp = $db->fetch_object( $i); $total = $total + $objp->amount; $var=!$var; print ""; print "\n"; print ''; print ""; if ($objp->amount < 0) { $totald = $totald + abs($objp->amount); print '\n"; } else { $totalc = $totalc + abs($objp->amount); print "\n"; } print "\n"; if ($user->rights->banque->modifier) { print ""; } else { print ""; } print ""; $i++; } $db->free(); } print ""; print "\n"; print "
DateTypeDescriptionDebitCreditSolde 
id."\">Vue etendue ".price($total)." 
".strftime("%d %b %Y",$objp->do)."'.$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'').'$objp->label"; if ($ve) { $dc = $db->clone(); $sql = "SELECT label FROM ".MAIN_DB_PREFIX."bank_categ as ct, ".MAIN_DB_PREFIX."bank_class as cl WHERE ct.rowid=cl.fk_categ AND cl.lineid=$objp->rowid"; $resc = $dc->query($sql); if ($resc) { $numc = $dc->num_rows(); $ii = 0; while ($ii < $numc) { $objc = $dc->fetch_object($ii); print "
$objc->label"; $ii++; } } else { print $dc->error(); } } print "
'.price($objp->amount * -1)."  ".price($objp->amount)."".price($total)."rowid&account=".$acct->id."\">"; print img_edit(); print " 
Total :".price($totald)."".price($totalc)." 
Solde :".price($total)." 
\n"; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>