[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> 5 * Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com> 6 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * 22 * $Id: product.php,v 1.37 2005/12/07 15:24:14 hregis Exp $ 23 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stock/product.php,v $ 24 */ 25 26 /** 27 \file htdocs/product/stock/product.php 28 \ingroup product 29 \brief Page de la fiche produit 30 \version $Revision: 1.37 $ 31 */ 32 33 require ("./pre.inc.php"); 34 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 35 36 $langs->load("products"); 37 $langs->load("bills"); 38 39 $user->getrights('produit'); 40 $mesg = ''; 41 42 if (!$user->rights->produit->lire) 43 { 44 accessforbidden(); 45 } 46 47 48 $types[0] = $langs->trans("Product"); 49 $types[1] = $langs->trans("Service"); 50 51 52 llxHeader("","",$langs->trans("CardProduct0")); 53 54 if ($_POST["action"] == "create_stock") 55 { 56 $product = new Product($db); 57 $product->id = $_GET["id"]; 58 $product->create_stock($_POST["id_entrepot"], $_POST["nbpiece"]); 59 } 60 61 if ($_POST["action"] == "correct_stock" && $_POST["cancel"] <> $langs->trans("Cancel")) 62 { 63 if (is_numeric($_POST["nbpiece"])) 64 { 65 66 $product = new Product($db); 67 $product->id = $_GET["id"]; 68 $product->correct_stock($user, 69 $_POST["id_entrepot"], 70 $_POST["nbpiece"], 71 $_POST["mouvement"]); 72 } 73 } 74 75 if ($_POST["action"] == "transfert_stock" && $_POST["cancel"] <> $langs->trans("Cancel")) 76 { 77 if ($_POST["id_entrepot_source"] <> $_POST["id_entrepot_destination"]) 78 { 79 if (is_numeric($_POST["nbpiece"])) 80 { 81 82 $product = new Product($db); 83 $product->id = $_GET["id"]; 84 85 $product->correct_stock($user, 86 $_POST["id_entrepot_source"], 87 $_POST["nbpiece"], 88 1); 89 90 $product->correct_stock($user, 91 $_POST["id_entrepot_destination"], 92 $_POST["nbpiece"], 93 0); 94 } 95 } 96 } 97 98 /* 99 * Fiche stock 100 * 101 */ 102 if ($_GET["id"] || $_GET["ref"]) 103 { 104 $product = new Product($db); 105 if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); 106 if ($_GET["id"]) $result = $product->fetch($_GET["id"]); 107 108 if ($result > 0) 109 { 110 $h=0; 111 112 $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; 113 $head[$h][1] = $langs->trans("Card"); 114 $h++; 115 116 $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; 117 $head[$h][1] = $langs->trans("Price"); 118 $h++; 119 120 if($product->type == 0) 121 { 122 if ($user->rights->barcode->lire) 123 { 124 if ($conf->barcode->enabled) 125 { 126 $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; 127 $head[$h][1] = $langs->trans("BarCode"); 128 $h++; 129 } 130 } 131 } 132 133 $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; 134 $head[$h][1] = $langs->trans("Photos"); 135 $h++; 136 137 if ($product->type == 0) 138 { 139 if ($conf->stock->enabled) 140 { 141 $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; 142 $head[$h][1] = $langs->trans("Stock"); 143 $hselected = $h; 144 $h++; 145 } 146 } 147 if ($conf->fournisseur->enabled) { 148 $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; 149 $head[$h][1] = $langs->trans("Suppliers"); 150 $h++; 151 } 152 153 $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; 154 $head[$h][1] = $langs->trans("Statistics"); 155 $h++; 156 157 //erics: pour créer des produits composés de x 'sous' produits 158 /* 159 $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id; 160 $head[$h][1] = $langs->trans('Packs'); 161 $h++; 162 */ 163 164 $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; 165 $head[$h][1] = $langs->trans('Referers'); 166 $h++; 167 168 $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; 169 $head[$h][1] = $langs->trans('Documents'); 170 $h++; 171 172 $titre=$langs->trans("CardProduct".$product->type); 173 dolibarr_fiche_head($head, $hselected, $titre); 174 175 print($mesg); 176 177 print '<table class="border" width="100%">'; 178 179 // Reference 180 print '<tr>'; 181 print '<td width="15%">'.$langs->trans("Ref").'</td><td>'; 182 $product->load_previous_next_ref(); 183 $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':''; 184 $next_ref = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':''; 185 if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">'; 186 print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>'; 187 if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>'; 188 print '</td>'; 189 print '</tr>'; 190 191 // Libellé 192 print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>'; 193 print '</tr>'; 194 195 // Prix 196 print '<tr><td>'.$langs->trans("SellingPrice").'</td><td>'.price($product->price).'</td>'; 197 print '</tr>'; 198 199 // Statut 200 print '<tr><td>'.$langs->trans("Status").'</td><td>'; 201 if ($product->envente) print $langs->trans("OnSell"); 202 else print $langs->trans("NotOnSell"); 203 print '</td></tr>'; 204 205 // TVA 206 $langs->load("bills"); 207 print '<tr><td>'.$langs->trans("VATRate").'</td><td>'.$product->tva_tx.'%</td></tr>'; 208 209 // Stock 210 if ($product->type == 0 && $conf->stock->enabled) 211 { 212 print '<tr><td><a href="'.DOL_URL_ROOT.'/product/stock/product.php?id='.$product->id.'">'.$langs->trans("Stock").'</a></td>'; 213 if ($product->no_stock) 214 { 215 print "<td>Pas de définition de stock pour ce produit"; 216 } 217 else 218 { 219 if ($product->stock_reel <= $product->seuil_stock_alerte) 220 { 221 print '<td class="alerte">'.$product->stock_reel.' Seuil : '.$product->seuil_stock_alerte; 222 } 223 else 224 { 225 print "<td>".$product->stock_reel; 226 } 227 } 228 print '</td></tr>'; 229 } 230 231 print "</table>"; 232 233 /* 234 * Contenu des stocks 235 */ 236 print '<br><table class="noborder" width="100%">'; 237 print '<tr class="liste_titre"><td width="40%">'.$langs->trans("Warehouse").'</td><td width="60%">Valeur du stock</td></tr>'; 238 $sql = "SELECT e.rowid, e.label, ps.reel FROM ".MAIN_DB_PREFIX."entrepot as e, ".MAIN_DB_PREFIX."product_stock as ps"; 239 $sql .= " WHERE ps.fk_entrepot = e.rowid AND ps.fk_product = ".$product->id; 240 $sql .= " ORDER BY lower(e.label)"; 241 242 $resql=$db->query($sql); 243 if ($resql) 244 { 245 $num = $db->num_rows($resql); 246 $i = 0; $total = 0; 247 while ($i < $num) 248 { 249 $obj = $db->fetch_object($resql); 250 print '<tr><td width="40%">'.$obj->label.'</td><td>'.$obj->reel.'</td></tr>'; ; 251 $total = $total + $obj->reel; 252 $i++; 253 } 254 } 255 print '<tr class="liste_total"><td align="right" class="liste_total">'.$langs->trans("Total").':</td><td class="liste_total">'.$total."</td></tr></table>"; 256 257 } 258 print '</div>'; 259 260 /* 261 * Correction du stock 262 */ 263 if ($_GET["action"] == "correction") 264 { 265 print_titre ("Correction du stock"); 266 print "<form action=\"product.php?id=$product->id\" method=\"post\">\n"; 267 print '<input type="hidden" name="action" value="correct_stock">'; 268 print '<table class="border" width="100%"><tr>'; 269 print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="20%"><select name="id_entrepot">'; 270 271 $sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e"; 272 $sql .= " WHERE statut = 1"; 273 $sql .= " ORDER BY lower(e.label)"; 274 275 $resql=$db->query($sql); 276 if ($resql) 277 { 278 $num = $db->num_rows($resql); 279 $i = 0; 280 while ($i < $num) 281 { 282 $obj = $db->fetch_object($resql); 283 print '<option value="'.$obj->rowid.'">'.$obj->label ; 284 $i++; 285 } 286 } 287 print '</select></td>'; 288 print '<td width="20%"><select name="mouvement">'; 289 print '<option value="0">'.$langs->trans("Add").'</option>'; 290 print '<option value="1">'.$langs->trans("Delete").'</option>'; 291 print '</select></td>'; 292 print '<td width="20%">Nb de pièce</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>'; 293 print '<tr><td colspan="5" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"> '; 294 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; 295 print '</table>'; 296 print '</form>'; 297 298 } 299 300 /* 301 * Transfert de pièces 302 */ 303 if ($_GET["action"] == "transfert") 304 { 305 print_titre ("Transfert de stock"); 306 print "<form action=\"product.php?id=$product->id\" method=\"post\">\n"; 307 print '<input type="hidden" name="action" value="transfert_stock">'; 308 print '<table class="border" width="100%"><tr>'; 309 print '<td width="20%">'.$langs->trans("Source").'</td><td width="20%"><select name="id_entrepot_source">'; 310 311 $sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e"; 312 $sql .= " WHERE statut = 1"; 313 $sql .= " ORDER BY lower(e.label)"; 314 315 $resql=$db->query($sql); 316 if ($resql) 317 { 318 $num = $db->num_rows($resql); 319 $i = 0; 320 while ($i < $num) 321 { 322 $obj = $db->fetch_object($resql); 323 print '<option value="'.$obj->rowid.'">'.$obj->label ; 324 $i++; 325 } 326 } 327 print '</select></td>'; 328 329 print '<td width="20%">'.$langs->trans("Target").'</td><td width="20%"><select name="id_entrepot_destination">'; 330 331 $sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e"; 332 $sql .= " WHERE statut = 1"; 333 $sql .= " ORDER BY lower(e.label)"; 334 335 $resql=$db->query($sql); 336 if ($resql) 337 { 338 $num = $db->num_rows($resql); 339 $i = 0; 340 while ($i < $num) 341 { 342 $obj = $db->fetch_object($resql); 343 print '<option value="'.$obj->rowid.'">'.$obj->label ; 344 $i++; 345 } 346 } 347 print '</select></td>'; 348 print '<td width="20%">Nb de pièce</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>'; 349 print '<tr><td colspan="6" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"> '; 350 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; 351 print '</table>'; 352 print '</form>'; 353 354 } 355 356 /* 357 * 358 */ 359 if ($_GET["action"] == "definir") 360 { 361 print_titre($langs->trans("SetStock")); 362 print "<form action=\"product.php?id=$product->id\" method=\"post\">\n"; 363 print '<input type="hidden" name="action" value="create_stock">'; 364 print '<table class="border" width="100%"><tr>'; 365 print '<td width="20%">'.$langs->trans("Warehouse").'</td><td width="40%"><select name="id_entrepot">'; 366 367 $sql = "SELECT e.rowid, e.label FROM ".MAIN_DB_PREFIX."entrepot as e"; 368 $sql .= " ORDER BY lower(e.label)"; 369 370 $resql=$db->query($sql); 371 if ($resql) 372 { 373 $num = $db->num_rows($resql); 374 $i = 0; 375 while ($i < $num) 376 { 377 $obj = $db->fetch_object($resql); 378 print '<option value="'.$obj->rowid.'">'.$obj->label ; 379 $i++; 380 } 381 } 382 print '</select></td><td width="20%">Nb de pièce</td><td width="20%"><input name="nbpiece" size="10" value=""></td></tr>'; 383 print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans('Save').'"> '; 384 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td></tr>'; 385 print '</table>'; 386 print '</form>'; 387 } 388 } 389 else 390 { 391 dolibarr_print_error(); 392 } 393 394 395 /* ************************************************************************** */ 396 /* */ 397 /* Barre d'action */ 398 /* */ 399 /* ************************************************************************** */ 400 401 print "<div class=\"tabsAction\">\n"; 402 403 if ($_GET["action"] == '' ) 404 { 405 if ($user->rights->stock->mouvement->creer) 406 { 407 print '<a class="tabAction" href="product.php?id='.$product->id.'&action=transfert">Transfert</a>'; 408 } 409 410 if ($user->rights->stock->creer) 411 { 412 print '<a class="tabAction" href="product.php?id='.$product->id.'&action=correction">Correction stock</a>'; 413 } 414 } 415 print '</div>'; 416 417 418 $db->close(); 419 420 421 llxFooter('$Date: 2005/12/07 15:24:14 $ - $Revision: 1.37 $'); 422 ?>
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 |
![]() |