| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004 Éric Seigne <eric.seigne@ryxeo.com> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * 20 * $Id: prelevement.php,v 1.18.2.1 2005/12/26 13:04:59 hregis Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/facture/prelevement.php,v $ 22 */ 23 24 /** 25 \file htdocs/compta/facture/prelevement.php 26 \ingroup facture 27 \brief Gestion des prelevement d'une facture 28 \version $Revision: 1.18.2.1 $ 29 */ 30 31 require ("./pre.inc.php"); 32 require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); 33 require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); 34 35 $user->getrights('facture'); 36 if (!$user->rights->facture->lire) 37 accessforbidden(); 38 39 $langs->load("bills"); 40 $langs->load("banks"); 41 $langs->load("withdrawals"); 42 43 // Sécurité accés client 44 if ($user->societe_id > 0) 45 { 46 $action = ''; 47 $socidp = $user->societe_id; 48 } 49 50 51 /* 52 * Actions 53 */ 54 55 if ($_GET["action"] == "new") 56 { 57 $fact = new Facture($db); 58 if ($fact->fetch($_GET["facid"])) 59 { 60 $result = $fact->demande_prelevement($user); 61 if ($result > 0) 62 { 63 Header("Location: prelevement.php?facid=".$fact->id); 64 exit; 65 } 66 else 67 { 68 $mesg='<div class="error">'.$fact->error.'</div>'; 69 } 70 } 71 } 72 73 if ($_GET["action"] == "delete") 74 { 75 $fact = new Facture($db); 76 if ($fact->fetch($_GET["facid"])) 77 { 78 $result = $fact->demande_prelevement_delete($user,$_GET["did"]); 79 if ($result == 0) 80 { 81 Header("Location: prelevement.php?facid=".$fact->id); 82 } 83 } 84 } 85 86 87 88 llxHeader('',$langs->trans("Bill")); 89 90 $html = new Form($db); 91 92 /* *************************************************************************** */ 93 /* */ 94 /* Mode fiche */ 95 /* */ 96 /* *************************************************************************** */ 97 98 if ($_GET["facid"] > 0) 99 { 100 $fac = New Facture($db); 101 if ( $fac->fetch($_GET["facid"], $user->societe_id) > 0) 102 { 103 if ($mesg) print $mesg.'<br>'; 104 105 $soc = new Societe($db, $fac->socidp); 106 $soc->fetch($fac->socidp); 107 108 $author = new User($db); 109 if ($fac->user_author) 110 { 111 $author->id = $fac->user_author; 112 $author->fetch(); 113 } 114 115 $head = facture_prepare_head($fac); 116 $hselected = 2; 117 if ($conf->use_preview_tabs) $hselected++; 118 dolibarr_fiche_head($head, $hselected, $langs->trans('Bill').' : '.$fac->ref); 119 120 /* 121 * Facture 122 */ 123 print '<table class="border" width="100%">'; 124 125 // Reference du facture 126 print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'; 127 print $fac->ref; 128 print "</td></tr>"; 129 130 // Societe 131 print '<tr><td width="20%">'.$langs->trans("Company").'</td>'; 132 print '<td colspan="5">'; 133 print '<a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>'; 134 print '</tr>'; 135 136 // Dates 137 print '<tr><td>'.$langs->trans("Date").'</td>'; 138 print '<td colspan="3">'.dolibarr_print_date($fac->date,"%A %d %B %Y").'</td>'; 139 print '<td>'.$langs->trans("DateClosing").'</td><td>' . dolibarr_print_date($fac->date_lim_reglement,"%A %d %B %Y"); 140 if ($fac->date_lim_reglement < (time() - $conf->facture->client->warning_delay) && ! $fac->paye && $fac->statut == 1 && ! $fac->am) print img_warning($langs->trans("Late")); 141 print "</td></tr>"; 142 143 // Conditions et modes de réglement 144 print '<tr><td>'.$langs->trans("PaymentConditions").'</td><td colspan="3">'; 145 $html->form_conditions_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->cond_reglement_id,"none"); 146 print '</td>'; 147 print '<td width="25%">'.$langs->trans("PaymentMode").'</td><td width="25%">'; 148 $html->form_modes_reglement($_SERVER["PHP_SELF"]."?facid=$fac->id",$fac->mode_reglement_id,"none"); 149 print '</td></tr>'; 150 151 print '<tr><td>'.$langs->trans("AmountHT").'</td>'; 152 print '<td align="right" colspan="2"><b>'.price($fac->total_ht).'</b></td>'; 153 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="2"> </td></tr>'; 154 155 print '<tr><td>'.$langs->trans("AmountTTC").'</td>'; 156 print '<td align="right" colspan="2"><b>'.price($fac->total_ttc).'</b></td>'; 157 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td><td colspan="2"> </td></tr>'; 158 159 print '<tr><td>RIB</td><td colspan="5">'; 160 print $soc->display_rib(); 161 print '</td></tr>'; 162 163 print '</table>'; 164 print '</div>'; 165 166 /* 167 * Demande de prélèvement 168 * 169 */ 170 171 $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; 172 $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; 173 $sql .= " , pfd.amount"; 174 $sql .= " , u.rowid as user_id, u.name, u.firstname, u.code"; 175 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; 176 $sql .= " , ".MAIN_DB_PREFIX."user as u"; 177 $sql .= " WHERE fk_facture = ".$fac->id; 178 $sql .= " AND pfd.fk_user_demande = u.rowid"; 179 $sql .= " AND pfd.traite = 0"; 180 $sql .= " ORDER BY pfd.date_demande DESC"; 181 182 $result_sql = $db->query($sql); 183 if ($result_sql) 184 { 185 $num = $db->num_rows($result_sql); 186 } 187 188 189 print "<div class=\"tabsAction\">\n"; 190 191 // Valider 192 if ($fac->statut > 0 && $fac->paye == 0 && $fac->mode_reglement_code == 'PRE' && $num == 0) 193 { 194 if ($user->rights->facture->creer) 195 { 196 print '<a class="butAction" href="prelevement.php?facid='.$fac->id.'&action=new">Faire une demande de prélèvement</a>'; 197 } 198 } 199 print "</div><br/>"; 200 201 202 /* 203 * Prélèvement 204 */ 205 print '<table class="noborder" width="100%">'; 206 207 print '<tr class="liste_titre">'; 208 print '<td align="center">'.$langs->trans("DateRequest").'</td>'; 209 print '<td align="center">'.$langs->trans("DateProcess").'</td>'; 210 print '<td align="center">'.$langs->trans("Amount").'</td>'; 211 print '<td align="center">'.$langs->trans("WithdrawalReceipt").'</td>'; 212 print '<td align="center">'.$langs->trans("User").'</td><td> </td><td> </td>'; 213 print '</tr>'; 214 $var=True; 215 216 if ($result_sql) 217 { 218 $i = 0; 219 220 while ($i < $num) 221 { 222 $obj = $db->fetch_object($result_sql); 223 $var=!$var; 224 225 print "<tr $bc[$var]>"; 226 print '<td align="center">'.dolibarr_print_date($obj->date_demande)."</td>\n"; 227 print '<td align="center">En attente de traitement</td>'; 228 print '<td align="center">'.price($obj->amount).'</td>'; 229 print '<td align="center">-</td>'; 230 print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</a></td>'; 231 print '<td> </td>'; 232 print '<td>'; 233 print '<a href="prelevement.php?facid='.$fac->id.'&action=delete&did='.$obj->rowid.'">'; 234 print img_delete(); 235 print '</a></td>'; 236 print "</tr>\n"; 237 $i++; 238 } 239 240 $db->free($result_sql); 241 } 242 else 243 { 244 dolibarr_print_error($db); 245 } 246 247 $sql = "SELECT pfd.rowid, pfd.traite,".$db->pdate("pfd.date_demande")." as date_demande"; 248 $sql .= " ,".$db->pdate("pfd.date_traite")." as date_traite"; 249 $sql .= " , pfd.fk_prelevement_bons, pfd.amount"; 250 $sql .= " , u.rowid as user_id, u.name, u.firstname, u.code"; 251 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_facture_demande as pfd"; 252 $sql .= " , ".MAIN_DB_PREFIX."user as u"; 253 $sql .= " WHERE fk_facture = ".$fac->id; 254 $sql .= " AND pfd.fk_user_demande = u.rowid"; 255 $sql .= " AND pfd.traite = 1"; 256 $sql .= " ORDER BY pfd.date_demande DESC"; 257 258 $result = $db->query($sql); 259 if ($result) 260 { 261 $num = $db->num_rows($result); 262 $i = 0; 263 264 while ($i < $num) 265 { 266 $obj = $db->fetch_object($result); 267 $var=!$var; 268 269 print "<tr $bc[$var]>"; 270 271 print '<td align="center">'.dolibarr_print_date($obj->date_demande)."</td>\n"; 272 273 print '<td align="center">'.dolibarr_print_date($obj->date_traite)."</td>\n"; 274 275 print '<td align="center">'.price($obj->amount).'</td>'; 276 277 print '<td align="center">'; 278 print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/fiche.php?id='.$obj->fk_prelevement_bons; 279 print '">'.$obj->fk_prelevement_bons."</a></td>\n"; 280 281 print '<td align="center"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</a></td>'; 282 283 print '<td> </td>'; 284 print '<td> </td>'; 285 286 print "</tr>\n"; 287 $i++; 288 } 289 290 $db->free($result); 291 } 292 else 293 { 294 dolibarr_print_error($db); 295 } 296 297 print "</table>"; 298 299 } 300 else 301 { 302 /* Facture non trouvée */ 303 print $langs->trans("ErrorBillNotFound",$_GET["facid"]); 304 } 305 } 306 307 print '</div>'; 308 309 $db->close(); 310 311 llxFooter('$Date: 2005/12/26 13:04:59 $ - $Revision: 1.18.2.1 $'); 312 ?>
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 |
|