* Copyright (C) 2004-2005 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$ */ /** \file htdocs/compta/bank/rappro.php \ingroup banque \brief Page de rapprochement bancaire \version $Revision$ */ require("./pre.inc.php"); $langs->load("banks"); $user->getrights('compta'); if (! $user->rights->banque->modifier) accessforbidden(); /* * Action rapprochement */ if ($_POST["action"] == 'rappro') { // Definition, nettoyage parametres $valrappro=1; $num_releve=trim($_POST["num_releve"]); if ($num_releve) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; $sql.= " set rappro=".$valrappro.", num_releve='".$_POST["num_releve"]."',"; $sql.= " fk_user_rappro=".$user->id; $sql.= " WHERE rowid=".$_POST["rowid"]; $resql = $db->query($sql); if ($resql) { if ($cat1 && $_POST["action"]) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ)"; $sql.= " VALUES ($rowid, $cat1)"; $resql = $db->query($sql); if ($resql) { $db->commit(); } else { $db->rollback(); dolibarr_print_error($db); } } else { $db->commit(); } } else { $db->rollback(); dolibarr_print_error($db); } } else { $msg="Erreur: Saisissez le relevé qui référence la transaction pour la rapprocher."; } } /* * Action suppression ecriture */ if ($_GET["action"] == 'del') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$_GET["rowid"]; $resql = $db->query($sql); if (! $resql) { dolibarr_print_error($db); } } // Charge categories $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label"; $resql = $db->query($sql); $options=""; if ($resql) { $var=True; $num = $db->num_rows($resql); $i = 0; while ($i < $num) { if ($options == "") { $options = ""; } $obj = $db->fetch_object($resql); $options .= "\n"; $i++; } $db->free($resql); } llxHeader(); /* * Affichage liste des transactions à rapprocher */ $acct = new Account($db); $acct->fetch($_GET["account"]); $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, ".$db->pdate("b.datev")." as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"]; $sql.= " ORDER BY dateo"; $sql.= " ASC LIMIT ".$conf->liste_limit; $resql = $db->query($sql); if ($resql) { $var=True; $num = $db->num_rows($resql); print_titre($langs->trans("Reconciliation").': '.$acct->label.''); print '
'; if ($msg) { print "$msg

"; } // Affiche nom des derniers relevés $nbmax=5; $liste=""; $sql = "SELECT distinct num_releve FROM ".MAIN_DB_PREFIX."bank"; $sql.= " WHERE fk_account=".$_GET["account"]; $sql.= " ORDER BY num_releve DESC"; $sql.= " LIMIT ".($nbmax+1); print $langs->trans("LastAccountStatements").' : '; $resqlr=$db->query($sql); if ($resqlr) { $numr=$db->num_rows($resqlr); $i=0; while (($i < $numr) && ($i < $nbmax)) { $objr = $db->fetch_object($resqlr); $last_releve = $objr->num_releve; $i++; $liste=''.$objr->num_releve.'   '.$liste; } if ($num >= $nbmax) $liste="...   ".$liste; print "$liste"; if ($num > 0) print '

'; else print $langs->trans("None").'

'; } else { dolibarr_print_error($db); } print ''; print "\n"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $i = 0; while ($i < $num) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print ''; print ""; print ""; print "rowid."\">"; print ''; print ''; print ''; // Description print ''; if ($objp->amount < 0) { print "\n"; } else { print "\n"; } if ($objp->rappro) { // Si ligne déjà rapprochée, on affiche relevé. print ""; } else { // Si pas encore rapprochée if ($user->rights->banque->modifier) { print '"; } else { print ""; } } // Affiche zone saisie relevé + bouton "Rapprocher" if ($objp->do <= mktime()) { print '"; } else { print ''; } print "\n"; print "\n"; $i++; } $db->free($resql); if ($num != 0) { print "
'.$langs->trans("DateOperationShort").''.$langs->trans("DateValueShort").''.$langs->trans("Type").''.$langs->trans("Description").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Action").''.$langs->trans("AccountStatement").'
(Ex: YYYYMM)
'.dolibarr_print_date($objp->do,"%d/%m/%Y").''.dolibarr_print_date($objp->dv,"%d/%m/%Y").''.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').''; $reg=array(); eregi('\((.+)\)',$objp->label,$reg); // Si texte entouré de parenthèe on tente recherche de traduction if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) print $langs->trans($reg[1]); else print $objp->label; print ''; /* * Ajout les liens (societe, company...) */ $newline=1; $links = $acct->get_url($objp->rowid); foreach($links as $key=>$val) { if (! $newline) print ' - '; else print '
'; if ($links[$key]['type']=='payment') { print ''; print img_object($langs->trans('ShowPayment'),'payment').' '; print $langs->trans("Payment"); print ''; $newline=0; } elseif ($links[$key]['type']=='company') { print ''; print img_object($langs->trans('ShowCustomer'),'company').' '; print dolibarr_trunc($links[$key]['label'],24); print ''; $newline=0; } else { print ''; print $links[$key]['label']; print ''; $newline=0; } } print '
".price($objp->amount * -1)."  ".price($objp->amount)."num_releve&account=$acct->id\">$objp->num_releve'; print ''; print img_edit(); print '  '; if ($objp->do <= mktime() ) { print ''; 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 apparaisse bien sur le compte. } print " '; print ""; print '   '; print "trans("Rapprocher")."\">"; if ($options) { print "
"; } print "
'; print 'Ecriture future. Ne peut pas encore être rapprochée.'; print '

\n"; } } else { dolibarr_print_error($db); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>