* 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$ */ require("./pre.inc.php"); $user->getrights('compta'); if (!$user->admin && !$user->rights->compta->bank) accessforbidden(); llxHeader(); if ($action == 'rappro') { if ($num_releve > 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."bank set rappro=$rappro, num_releve=$num_releve WHERE rowid=$rowid"; $result = $db->query($sql); if ($result) { if ($cat1 && $rappro) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)"; $result = $db->query($sql); } } else { print $db->error(); print "

$sql"; } } } if ($action == 'del') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=$rowid"; $result = $db->query($sql); if (!$result) { print $db->error(); print "

$sql"; } } $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label;"; $result = $db->query($sql); $options=""; if ($result) { $var=True; $num = $db->num_rows(); $i = 0; while ($i < $num) { if ($options == "") { $options = ""; } $obj = $db->fetch_object($i); $options .= "\n"; $i++; } $db->free(); } $sql = "SELECT max(num_releve) FROM ".MAIN_DB_PREFIX."bank WHERE fk_account=$account"; if ( $db->query($sql) ) { if ( $db->num_rows() ) { $last_releve = $db->result(0, 0); } $db->free(); } else { print $db->error(); } $acct = new Account($db); $acct->fetch($account); print_titre('Rapprochement bancaire compte : '.$acct->label.''); $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 rappro=0 AND fk_account=$account"; $sql .= " ORDER BY dateo ASC LIMIT 10"; $result = $db->query($sql); if ($result) { $var=True; $num = $db->num_rows(); if ($num == 0) { print "
Pas de transactions saisies en attente de rapprochement, pour ce compte bancaire.
"; } else { print ''; print ""; print ""; print ""; print ""; print ""; print ''; print ''; print "\n"; } $i = 0; while ($i < $num) { $objp = $db->fetch_object( $i); $var=!$var; print ""; print ''; print ""; print "rowid\">"; print "\n"; print ""; if ($objp->amount < 0) { print "\n"; } else { print "\n"; } if ($objp->do <= mktime() ) { print ""; print ""; print ""; } else { print ""; } if ($objp->rappro) { print ""; } else { if ($user->rights->banque->modifier) { print ""; } else { print ""; } } print ""; print ""; print ""; $i++; } $db->free(); if ($num != 0) { print "
DateDescriptionDebitCreditReleveRappro 
".strftime("%d %b %Y",$objp->do)."$objp->label".price($objp->amount * -1)."  ".price($objp->amount).""; print ""; print "Ecriture future. Ne peut pas encore être rapprochée."; print "num_releve&account=$acct->id\">$objp->num_releve"; if ($objp->do <= mktime() ) { print "rowid&account=$acct->id\">"; print img_delete(); print ""; } else { print " "; // On n'empeche la suppression car le raprochement ne pourra se faire qu'après la date passée et que l'écriture apparaissent bien sur le compte. } print " 
 ".$objp->fk_type.($objp->num_chq?" ".$objp->num_chq:"").""; if ($options) { print ""; } else { print " "; } print "
"; } } print '
Dernier relevé : '.$last_releve.''; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>