[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-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: fiche.php,v 1.18 2005/12/18 22:55:38 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/commande/fiche.php,v $ 21 */ 22 23 /** 24 \file htdocs/compta/fiche.php 25 \ingroup commande 26 \brief Fiche commande 27 \version $Revision: 1.18 $ 28 */ 29 30 require ("./pre.inc.php"); 31 32 $langs->load("orders"); 33 $langs->load("sendings"); 34 $langs->load("companies"); 35 $langs->load("bills"); 36 $langs->load("propal"); 37 38 $user->getrights('facture'); 39 40 if (! $user->rights->commande->lire) accessforbidden(); 41 42 require_once(DOL_DOCUMENT_ROOT."/project.class.php"); 43 require_once (DOL_DOCUMENT_ROOT."/propal.class.php"); 44 45 46 /* 47 * Sécurité accés client 48 */ 49 if ($user->societe_id > 0) 50 { 51 $action = ''; 52 $socidp = $user->societe_id; 53 } 54 /* 55 * 56 */ 57 58 if ($_GET["action"] == 'facturee') 59 { 60 $commande = new Commande($db); 61 $commande->fetch($_GET["id"]); 62 $commande->classer_facturee(); 63 } 64 65 66 llxHeader('',$langs->trans("OrderCard"),"Commande"); 67 68 69 70 $html = new Form($db); 71 72 /* *************************************************************************** */ 73 /* */ 74 /* Mode vue et edition */ 75 /* */ 76 /* *************************************************************************** */ 77 78 if ($_GET["id"] > 0) 79 { 80 $commande = new Commande($db); 81 if ( $commande->fetch($_GET["id"]) > 0) 82 { 83 $soc = new Societe($db); 84 $soc->fetch($commande->soc_id); 85 $author = new User($db); 86 $author->id = $commande->user_author_id; 87 $author->fetch(); 88 89 $h=0; 90 91 if ($conf->commande->enabled && $user->rights->commande->lire) 92 { 93 $head[$h][0] = DOL_URL_ROOT.'/commande/fiche.php?id='.$commande->id; 94 $head[$h][1] = $langs->trans("OrderCard"); 95 $h++; 96 } 97 98 if ($conf->expedition->enabled && $user->rights->expedition->lire) 99 { 100 $head[$h][0] = DOL_URL_ROOT.'/expedition/commande.php?id='.$commande->id; 101 $head[$h][1] = $langs->trans("SendingCard"); 102 $h++; 103 } 104 105 if ($conf->compta->enabled) 106 { 107 $head[$h][0] = DOL_URL_ROOT.'/compta/commande/fiche.php?id='.$commande->id; 108 $head[$h][1] = $langs->trans("ComptaCard"); 109 $hselected = $h; 110 $h++; 111 } 112 113 $head[$h][0] = DOL_URL_ROOT.'/commande/info.php?id='.$commande->id; 114 $head[$h][1] = $langs->trans("Info"); 115 $h++; 116 117 dolibarr_fiche_head($head, $hselected, $langs->trans("Order").": $commande->ref"); 118 119 /* 120 * Commande 121 */ 122 123 $nbrow=8; 124 if ($conf->projet->enabled) $nbrow++; 125 126 print '<table class="border" width="100%">'; 127 128 // Reference 129 print '<tr><td width="15%">'.$langs->trans("Ref")."</td>"; 130 print '<td colspan="2">'.$commande->ref.'</td>'; 131 print '<td width="50%">'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ; 132 if ($commande->source == 0) 133 { 134 // Propale 135 $propal = new Propal($db); 136 $propal->fetch($commande->propale_id); 137 print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>'; 138 } 139 print "</td></tr>"; 140 141 // Ref cde client 142 print '<tr><td>'; 143 print '<table class="nobordernopadding" width="100%"><tr><td nowrap>'; 144 print $langs->trans('RefCustomer').'</td><td align="left">'; 145 print '</td>'; 146 print '</tr></table>'; 147 print '</td>'; 148 print '<td colspan="2">'; 149 print $commande->ref_client; 150 print '</td>'; 151 print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>'; 152 if ($commande->brouillon == 1 && $user->rights->commande->creer) 153 { 154 print '<form action="fiche.php?id='.$id.'" method="post">'; 155 print '<input type="hidden" name="action" value="setnote">'; 156 print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>'; 157 print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>'; 158 print '</form>'; 159 } 160 else 161 { 162 print nl2br($commande->note); 163 } 164 print '</td>'; 165 print '</tr>'; 166 167 // Client 168 print "<tr><td>".$langs->trans("Customer")."</td>"; 169 print '<td colspan="2">'; 170 print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>'; 171 print '</td>'; 172 print '</tr>'; 173 174 // Statut 175 print '<tr><td>'.$langs->trans("Status").'</td>'; 176 print "<td colspan=\"2\">".$commande->statuts[$commande->statut]."</td>\n"; 177 print '</tr>'; 178 179 // Date 180 print '<tr><td>'.$langs->trans("Date").'</td>'; 181 print "<td colspan=\"2\">".dolibarr_print_date($commande->date,"%A %d %B %Y")."</td>\n"; 182 print '</tr>'; 183 184 // Projet 185 if ($conf->projet->enabled) 186 { 187 print '<tr>'; 188 $langs->load("projects"); 189 print '<td>'; 190 print '<table class="nobordernopadding" width="100%"><tr><td>'; 191 print $langs->trans("Project"); 192 print '</td>'; 193 //if ($_GET["action"] != "classer") print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&id='.$commande->id.'">'.img_edit($langs->trans("SetProject")).'</a></td>'; 194 print '</tr></table>'; 195 print '</td><td colspan="2">'; 196 if ($_GET["action"] == "classer") 197 { 198 $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"projetid"); 199 } 200 else 201 { 202 $html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"none"); 203 } 204 print "</td>"; 205 print '</tr>'; 206 } 207 208 // Lignes de 3 colonnes 209 210 // Discount 211 print '<tr><td>'.$langs->trans("GlobalDiscount").'</td><td align="right">'; 212 print $commande->remise_percent.'%</td><td> '; 213 print '</td></tr>'; 214 215 // Total HT 216 print '<tr><td>'.$langs->trans("TotalHT").'</td>'; 217 print '<td align="right"><b>'.price($commande->total_ht).'</b></td>'; 218 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 219 220 // Total VAT 221 print '<tr><td>'.$langs->trans("TotalVAT").'</td><td align="right">'.price($commande->total_tva).'</td>'; 222 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 223 224 // Total TTC 225 print '<tr><td>'.$langs->trans("TotalTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>'; 226 print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>'; 227 228 print '</table>'; 229 230 /* 231 * Lignes de commandes 232 * 233 */ 234 $sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice,'; 235 $sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid'; 236 $sql.= ' FROM '.MAIN_DB_PREFIX."commandedet as l"; 237 $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; 238 $sql.= " WHERE l.fk_commande = ".$commande->id; 239 $sql.= " ORDER BY l.rowid"; 240 241 $resql = $db->query($sql); 242 if ($resql) 243 { 244 $num = $db->num_rows($resql); 245 $i = 0; $total = 0; 246 247 if ($num) print '<br>'; 248 print '<table class="noborder" width="100%">'; 249 if ($num) 250 { 251 print '<tr class="liste_titre">'; 252 print '<td>'.$langs->trans('Description').'</td>'; 253 print '<td align="right" width="50">'.$langs->trans('VAT').'</td>'; 254 print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>'; 255 print '<td align="right" width="50">'.$langs->trans('Qty').'</td>'; 256 print '<td align="right">'.$langs->trans('Discount').'</td>'; 257 print '<td align="right">'.$langs->trans('AmountHT').'</td>'; 258 print '<td> </td><td> </td>'; 259 print "</tr>\n"; 260 } 261 262 $var=true; 263 while ($i < $num) 264 { 265 $objp = $db->fetch_object($resql); 266 267 $var=!$var; 268 print '<tr '.$bc[$var].'>'; 269 if ($objp->fk_product > 0) 270 { 271 print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">'; 272 if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service'); 273 else print img_object($langs->trans('ShowProduct'),'product'); 274 print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product)); 275 print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:''; 276 print '</td>'; 277 } 278 else 279 { 280 print '<td>'.stripslashes(nl2br($objp->description)); 281 print "</td>\n"; 282 } 283 print '<td align="right">'.$objp->tva_tx.'%</td>'; 284 285 print '<td align="right">'.price($objp->subprice)."</td>\n"; 286 287 print '<td align="right">'.$objp->qty.'</td>'; 288 289 if ($objp->remise_percent > 0) 290 { 291 print '<td align="right">'.$objp->remise_percent."%</td>\n"; 292 } 293 else 294 { 295 print '<td> </td>'; 296 } 297 298 print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n"; 299 300 print '<td> </td><td> </td>'; 301 print '</tr>'; 302 303 $i++; 304 } 305 $db->free($resql); 306 } 307 else 308 { 309 dolibarr_print_error($db); 310 } 311 print '</table>'; 312 313 print '</div>'; 314 315 316 /* 317 * Boutons actions 318 */ 319 320 if (! $user->societe_id && ! $commande->facturee) 321 { 322 print "<div class=\"tabsAction\">\n"; 323 324 if ($commande->statut > 0 && $user->rights->facture->creer) 325 { 326 print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&commandeid='.$commande->id.'&socidp='.$commande->soc_id.'">'.$langs->trans("CreateBill").'</a>'; 327 } 328 329 if ($user->rights->commande->creer) 330 { 331 print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/commande/fiche.php?action=facturee&id='.$commande->id.'">'.$langs->trans("ClassifyBilled").'</a>'; 332 } 333 print '</div>'; 334 } 335 336 337 print "<table width=\"100%\"><tr><td width=\"50%\" valign=\"top\">"; 338 339 340 /* 341 * Documents générés 342 * 343 */ 344 $file = $conf->facture->dir_output . "/" . $commande->ref . "/" . $commande->ref . ".pdf"; 345 $relativepath = $commande->ref."/".$commande->ref.".pdf"; 346 347 $var=true; 348 349 if (file_exists($file)) 350 { 351 print_titre($langs->trans("Documents")); 352 print '<table width="100%" class="border">'; 353 354 print "<tr $bc[$var]><td>".$langs->trans("Order")." PDF</td>"; 355 print '<td><a href="'.DOL_URL_ROOT.'/document.php?modulepart=commande&file='.urlencode($relativepath).'">'.$commande->ref.'.pdf</a></td>'; 356 print '<td align="right">'.filesize($file). ' bytes</td>'; 357 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'</td>'; 358 print '</tr>'; 359 360 print "</table>\n"; 361 362 } 363 364 /* 365 * Liste des factures 366 */ 367 $sql = "SELECT f.rowid,f.facnumber, f.total_ttc, ".$db->pdate("f.datef")." as df"; 368 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."co_fa as cf"; 369 $sql .= " WHERE f.rowid = cf.fk_facture AND cf.fk_commande = ". $commande->id; 370 371 $result = $db->query($sql); 372 if ($result) 373 { 374 $num = $db->num_rows($result); 375 if ($num) 376 { 377 print '<br>'; 378 print_titre($langs->trans("RelatedBills")); 379 $i = 0; $total = 0; 380 print '<table class="noborder" width="100%">'; 381 print '<tr class="liste_titre"><td>'.$langs->trans("Ref")."</td>"; 382 print '<td align="center">'.$langs->trans("Date").'</td>'; 383 print '<td align="right">'.$langs->trans("Price").'</td>'; 384 print "</tr>\n"; 385 386 $var=True; 387 while ($i < $num) 388 { 389 $objp = $db->fetch_object($result); 390 $var=!$var; 391 print "<tr $bc[$var]>"; 392 print '<td><a href="../facture.php?facid='.$objp->rowid.'">'.img_object($langs->trans("ShowBill"),"bill").' '.$objp->facnumber.'</a></td>'; 393 print '<td align="center">'.dolibarr_print_date($objp->df).'</td>'; 394 print '<td align="right">'.$objp->total_ttc.'</td></tr>'; 395 $i++; 396 } 397 print "</table>"; 398 } 399 } 400 else 401 { 402 dolibarr_print_error($db); 403 } 404 405 print '</td><td valign="top" width="50%">'; 406 407 /* 408 * Liste des expéditions 409 */ 410 $sql = "SELECT e.rowid,e.ref,".$db->pdate("e.date_expedition")." as de"; 411 $sql .= " FROM ".MAIN_DB_PREFIX."expedition as e"; 412 $sql .= " WHERE e.fk_commande = ". $commande->id; 413 414 $result = $db->query($sql); 415 if ($result) 416 { 417 $num = $db->num_rows($result); 418 if ($num) 419 { 420 print_titre($langs->trans("Sendings")); 421 $i = 0; $total = 0; 422 print '<table class="border" width="100%">'; 423 print "<tr $bc[$var]><td>".$langs->trans("Sendings")."</td><td>".$langs->trans("Date")."</td></tr>\n"; 424 425 $var=True; 426 while ($i < $num) 427 { 428 $objp = $db->fetch_object($result); 429 $var=!$var; 430 print "<tr $bc[$var]>"; 431 print '<td><a href="../../expedition/fiche.php?id='.$objp->rowid.'">'.img_object($langs->trans("ShowSending"),"sending").' '.$objp->ref.'</a></td>'; 432 print "<td>".dolibarr_print_date($objp->de)."</td></tr>\n"; 433 $i++; 434 } 435 print "</table>"; 436 } 437 } 438 else 439 { 440 dolibarr_print_error($db); 441 } 442 443 print "</td></tr></table>"; 444 445 } 446 else 447 { 448 // Commande non trouvée 449 print "Commande inexistante"; 450 } 451 } 452 453 $db->close(); 454 455 llxFooter('$Date: 2005/12/18 22:55:38 $ - $Revision: 1.18 $'); 456 ?>
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 |
![]() |