[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2002 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: search.php,v 1.18 2005/09/17 00:53:50 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/bank/search.php,v $ 21 */ 22 23 /** 24 \file htdocs/compta/bank/search.php 25 \ingroup banque 26 \brief Page de recherche de transactions bancaires 27 \version $Revision: 1.18 $ 28 */ 29 30 require ("./pre.inc.php"); 31 require ("./bank.lib.php"); 32 33 $user->getrights('banque'); 34 35 if (!$user->rights->banque->lire) 36 accessforbidden(); 37 38 $description=$_POST["description"]; 39 $debit=$_POST["debit"]; 40 $credit=$_POST["credit"]; 41 $type=$_POST["type"]; 42 $account=$_POST["account"]; 43 44 45 llxHeader(); 46 47 if ($vline) $viewline = $vline; 48 else $viewline = 50; 49 50 51 print_titre($langs->trans("SearchBankMovement")); 52 print '<br>'; 53 54 print '<table class="liste" width="100%">'; 55 print '<tr class="liste_titre">'; 56 print '<td class="liste_titre">'.$langs->trans("Date").'</td>'; 57 print '<td class="liste_titre">'.$langs->trans("Description").'</td>'; 58 print '<td class="liste_titre" align="right">'.$langs->trans("Debit").'</td>'; 59 print '<td class="liste_titre" align="right">'.$langs->trans("Credit").'</td>'; 60 print '<td class="liste_titre" align="center">'.$langs->trans("Type").'</td>'; 61 print '<td class="liste_titre" align="left">'.$langs->trans("Account").'</td>'; 62 print "</tr>\n"; 63 ?> 64 65 <form method="post" action="search.php"> 66 <tr class="liste_titre"> 67 <td class="liste_titre"> </td> 68 <td class="liste_titre"> 69 <input type="text" class="flat" name="description" size="40" value=<?php echo $description ?>> 70 </td> 71 <td class="liste_titre" align="right"> 72 <input type="text" class="flat" name="debit" size="6" value=<?php echo $debit ?>> 73 </td> 74 <td class="liste_titre" align="right"> 75 <input type="text" class="flat" name="credit" size="6" value=<?php echo $credit ?>> 76 </td> 77 <td class="liste_titre" align="center"> 78 <select class="flat" name="type"> 79 <option value="%">Toutes</option> 80 <option value="CHQ">CHQ</option> 81 <option value="CB">CB</option> 82 <option value="VIR">VIR</option> 83 <option value="PRE">PRE</option> 84 </select> 85 </td> 86 <?php 87 print '<td class="liste_titre" align="right">'; 88 print '<input type="hidden" name="action" value="search">'; 89 print '<input type="image" class="liste_titre" name="submit" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" alt="'.$langs->trans("Search").'">'; 90 print '</td>'; 91 print '</tr>'; 92 93 94 // Compte le nombre total d'écritures 95 $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."bank"; 96 if ($account) { $sql .= " WHERE b.fk_account=$account"; } 97 98 $resql=$db->query($sql); 99 if ($resql) 100 { 101 $nbline = $db->result (0, 0); 102 $db->free($resql); 103 } 104 else { 105 dolibarr_print_error($db); 106 } 107 108 // Defini la liste des catégories dans $options 109 $sql = "SELECT rowid, label FROM ".MAIN_DB_PREFIX."bank_categ;"; 110 $result = $db->query($sql); 111 if ($result) { 112 $var=True; 113 $num = $db->num_rows($result); 114 $i = 0; 115 $options = "<option value=\"0\" selected=\"true\"> </option>"; 116 while ($i < $num) { 117 $obj = $db->fetch_object($result); 118 $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++; 119 } 120 $db->free($result); 121 } 122 else { 123 dolibarr_print_error($db); 124 } 125 126 $sql = "SELECT b.rowid,".$db->pdate("b.dateo")." as do, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_account, b.fk_type, ba.label as labelaccount"; 127 $sql .= " FROM ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba"; 128 $sql .= " WHERE b.fk_account=ba.rowid"; 129 $sql .= " AND fk_type like '" . $type . "'"; 130 131 $si=0; 132 133 $debit = ereg_replace(',','.',$debit); 134 $credit = ereg_replace(',','.',$credit); 135 if (is_numeric($debit)) { 136 $si++; 137 $sqlw[$si] .= " b.amount = " . -$debit; 138 } 139 if (is_numeric($credit)) { 140 $si++; 141 $sqlw[$si] .= " b.amount = " . $credit; 142 } 143 if ($description) { 144 $si++; 145 $sqlw[$si] .= " b.label like '%" . $description . "%'"; 146 } 147 148 for ($i = 1 ; $i <= $si; $i++) { 149 $sql .= " AND " . $sqlw[$i]; 150 } 151 152 $sql .= " ORDER BY b.dateo ASC"; 153 154 $result = $db->query($sql); 155 if ($result) 156 { 157 $var=True; 158 $num = $db->num_rows($result); 159 $i = 0; 160 161 while ($i < $num) { 162 $objp = $db->fetch_object($result); 163 164 $var=!$var; 165 166 print "<tr $bc[$var]>"; 167 print "<td>".strftime("%d %b %y",$objp->do)."</td>\n"; 168 169 print "<td><a href=\"ligne.php?rowid=$objp->rowid&account=$objp->fk_account\">$objp->label</a> "; 170 171 if ($objp->amount < 0) 172 { 173 print "<td align=\"right\">".price($objp->amount * -1)."</td><td> </td>\n"; 174 } 175 else 176 { 177 print "<td> </td><td align=\"right\">".price($objp->amount)."</td>\n"; 178 } 179 180 print "<td align=\"center\">".$objp->fk_type."</td>\n"; 181 182 183 print "<td align=\"left\"><small>".$objp->labelaccount."</small></td>\n"; 184 print "</tr>"; 185 186 $i++; 187 } 188 189 $db->free($result); 190 } 191 else 192 { 193 dolibarr_print_error($db); 194 } 195 196 print "</table>"; 197 198 // Si accès issu d'une recherche et rien de trouvé 199 if ($_POST["action"] == "search" && ! $num) { 200 print "Aucune écriture bancaire répondant aux critères n'a été trouvée."; 201 } 202 203 204 $db->close(); 205 206 llxFooter('$Date: 2005/09/17 00:53:50 $ - $Revision: 1.18 $'); 207 ?>
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 |
![]() |