[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * $Id: rappro.php,v 1.31 2005/11/10 21:04:46 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/bank/rappro.php,v $ 21 */ 22 23 /** 24 \file htdocs/compta/bank/rappro.php 25 \ingroup banque 26 \brief Page de rapprochement bancaire 27 \version $Revision: 1.31 $ 28 */ 29 30 require ("./pre.inc.php"); 31 32 $langs->load("banks"); 33 34 $user->getrights('compta'); 35 36 if (! $user->rights->banque->modifier) accessforbidden(); 37 38 39 llxHeader(); 40 41 42 /* 43 * Action rapprochement 44 */ 45 if ($_POST["action"] == 'rappro') 46 { 47 if ($_POST["num_releve"] > 0) 48 { 49 $db->begin(); 50 51 $valrappro=1; 52 $sql = "UPDATE ".MAIN_DB_PREFIX."bank"; 53 $sql.= " set rappro=".$valrappro.", num_releve=".$_POST["num_releve"].","; 54 $sql.= " fk_user_rappro=".$user->id; 55 $sql.= " WHERE rowid=".$_POST["rowid"]; 56 57 $resql = $db->query($sql); 58 if ($resql) 59 { 60 if ($cat1 && $_POST["action"]) 61 { 62 $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_class (lineid, fk_categ) VALUES ($rowid, $cat1)"; 63 $resql = $db->query($sql); 64 65 if ($resql) 66 { 67 $db->commit(); 68 } 69 else 70 { 71 $db->rollback(); 72 dolibarr_print_error($db); 73 } 74 } 75 else 76 { 77 $db->commit(); 78 } 79 } 80 else 81 { 82 $db->rollback(); 83 dolibarr_print_error($db); 84 } 85 } 86 else { 87 $msg="Erreur: Saisissez le relevé qui référence la transaction pour la rapprocher."; 88 } 89 } 90 91 /* 92 * Action suppression ecriture 93 */ 94 if ($_GET["action"] == 'del') { 95 $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank WHERE rowid=".$_GET["rowid"]; 96 $resql = $db->query($sql); 97 if (! $resql) { 98 dolibarr_print_error($db); 99 } 100 } 101 102 $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ ORDER BY label"; 103 $resql = $db->query($sql); 104 $options=""; 105 if ($resql) { 106 $var=True; 107 $num = $db->num_rows($resql); 108 $i = 0; 109 while ($i < $num) { 110 if ($options == "") { $options = "<option value=\"0\" selected=\"true\"> </option>"; } 111 $obj = $db->fetch_object($resql); 112 $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++; 113 } 114 $db->free($resql); 115 } 116 117 118 /* 119 * Affichage liste des transactions à rapprocher 120 */ 121 $acct = new Account($db); 122 $acct->fetch($_GET["account"]); 123 124 $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"; 125 $sql.= " FROM ".MAIN_DB_PREFIX."bank as b"; 126 $sql.= " WHERE rappro=0 AND fk_account=".$_GET["account"]; 127 $sql.= " ORDER BY dateo"; 128 $sql.= " ASC LIMIT ".$conf->liste_limit; 129 130 $resql = $db->query($sql); 131 if ($resql) 132 { 133 $var=True; 134 $num = $db->num_rows($resql); 135 136 print_titre($langs->trans("Reconciliation").': <a href="account.php?account='.$_GET["account"].'">'.$acct->label.'</a>'); 137 print '<br>'; 138 139 if ($msg) { 140 print "$msg<br><br>"; 141 } 142 143 // Affiche nom des derniers relevés 144 $nbmax=5; 145 $liste=""; 146 147 $sql = "SELECT distinct num_releve FROM ".MAIN_DB_PREFIX."bank"; 148 $sql.= " WHERE fk_account=".$_GET["account"]; 149 $sql.= " ORDER BY num_releve DESC"; 150 $sql.= " LIMIT ".($nbmax+1); 151 print $langs->trans("LastAccountStatements").' : '; 152 $resqlr=$db->query($sql); 153 if ($resqlr) 154 { 155 $numr=$db->num_rows($resqlr); 156 $i=0; 157 while (($i < $numr) && ($i < $nbmax)) 158 { 159 $objr = $db->fetch_object($resqlr); 160 $last_releve = $objr->num_releve; 161 $i++; 162 $liste='<a href="releve.php?account='.$_GET["account"].'&num='.$objr->num_releve.'">'.$objr->num_releve.'</a> '.$liste; 163 } 164 if ($num >= $nbmax) $liste="... ".$liste; 165 print "$liste"; 166 if ($num > 0) print '<br><br>'; 167 else print $langs->trans("None").'<br><br>'; 168 } 169 else 170 { 171 dolibarr_print_error($db); 172 } 173 174 print '<table class="border" width="100%">'; 175 print "<tr class=\"liste_titre\">\n"; 176 print '<td align="center">'.$langs->trans("DateOperationShort").'</td>'; 177 print '<td align="center">'.$langs->trans("DateValueShort").'</td>'; 178 print '<td>'.$langs->trans("Type").'</td>'; 179 print '<td>'.$langs->trans("Description").'</td>'; 180 print '<td align="right" width="60" nowrap>'.$langs->trans("Debit").'</td>'; 181 print '<td align="right" width="60" nowrap>'.$langs->trans("Credit").'</td>'; 182 print '<td align="center" width="40">'.$langs->trans("Action").'</td>'; 183 print '<td align="center">'.$langs->trans("AccountStatement").'<br>(Ex: YYYYMM)</td>'; 184 print "</tr>\n"; 185 186 187 $i = 0; 188 while ($i < $num) 189 { 190 $objp = $db->fetch_object($resql); 191 192 $var=!$var; 193 print "<tr $bc[$var]>"; 194 print '<form method="post" action="rappro.php?account='.$_GET["account"].'">'; 195 print "<input type=\"hidden\" name=\"action\" value=\"rappro\">"; 196 print "<input type=\"hidden\" name=\"account\" value=\"".$_GET["account"]."\">"; 197 print "<input type=\"hidden\" name=\"rowid\" value=\"".$objp->rowid."\">"; 198 199 print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->do,"%d/%m/%Y").'</td>'; 200 print '<td align="center" nowrap="nowrap">'.dolibarr_print_date($objp->dv,"%d/%m/%Y").'</td>'; 201 print '<td nowrap="nowrap">'.$objp->type.($objp->num_chq?' '.$objp->num_chq:'').'</td>'; 202 print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$acct->id.'">'.$objp->label.'</a>'; 203 204 /* 205 * Ajout les liens (societe, company...) 206 */ 207 $newline=1; 208 $links = $acct->get_url($objp->rowid); 209 foreach($links as $key=>$val) 210 { 211 if (! $newline) print ' - '; 212 else print '<br>'; 213 if ($links[$key]['type']=='payment') { 214 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">'; 215 print img_object($langs->trans('ShowPayment'),'payment').' '; 216 print $langs->trans("Payment"); 217 print '</a>'; 218 $newline=0; 219 } 220 elseif ($links[$key]['type']=='company') { 221 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">'; 222 print img_object($langs->trans('ShowCustomer'),'company').' '; 223 print dolibarr_trunc($links[$key]['label'],24); 224 print '</a>'; 225 $newline=0; 226 } 227 else { 228 print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">'; 229 print $links[$key]['label']; 230 print '</a>'; 231 $newline=0; 232 } 233 } 234 print '</td>'; 235 236 if ($objp->amount < 0) 237 { 238 print "<td align=\"right\" nowrap>".price($objp->amount * -1)."</td><td> </td>\n"; 239 } 240 else 241 { 242 print "<td> </td><td align=\"right\" nowrap>".price($objp->amount)."</td>\n"; 243 } 244 245 if ($objp->rappro) 246 { 247 // Si ligne déjà rapprochée, on affiche relevé. 248 print "<td align=\"center\" nowrap=\"nowrap\"><a href=\"releve.php?num=$objp->num_releve&account=$acct->id\">$objp->num_releve</a></td>"; 249 } 250 else 251 { 252 // Si pas encore rapprochée 253 if ($user->rights->banque->modifier) 254 { 255 print '<td align="center" width="30" nowrap="nowrap">'; 256 257 print '<a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$acct->id.'&orig_account='.$acct->id.'">'; 258 print img_edit(); 259 print '</a> '; 260 261 if ($objp->do <= mktime() ) { 262 print '<a href="'.DOL_URL_ROOT.'/compta/bank/rappro.php?action=del&rowid='.$objp->rowid.'&account='.$acct->id.'">'; 263 print img_delete(); 264 print '</a>'; 265 } 266 else { 267 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. 268 } 269 print "</td>"; 270 } 271 else 272 { 273 print "<td align=\"center\"> </td>"; 274 } 275 } 276 277 278 // Affiche zone saisie relevé + bouton "Rapprocher" 279 if ($objp->do <= mktime()) 280 { 281 print '<td align="center" nowrap="nowrap">'; 282 print "<input class=\"flat\" name=\"num_releve\" type=\"text\" value=\"\" size=\"8\">"; 283 print ' '; 284 print "<input class=\"button\" type=\"submit\" value=\"".$langs->trans("Rapprocher")."\">"; 285 if ($options) 286 { 287 print "<br><select class=\"flat\" name=\"cat1\">$options"; 288 print "</select>"; 289 } 290 print "</td>"; 291 } 292 else 293 { 294 print '<td align="left">'; 295 print 'Ecriture future. Ne peut pas encore être rapprochée.'; 296 print '</td>'; 297 } 298 299 print "</tr>\n"; 300 print "</form>\n"; 301 $i++; 302 } 303 $db->free($resql); 304 305 if ($num != 0) 306 { 307 print "</table><br>\n"; 308 } 309 310 } 311 else 312 { 313 dolibarr_print_error($db); 314 } 315 316 $db->close(); 317 318 llxFooter('$Date: 2005/11/10 21:04:46 $ - $Revision: 1.31 $'); 319 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |