[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com> 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: fiche.php,v 1.25 2005/09/21 23:43:08 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/stock/fiche.php,v $ 22 */ 23 24 /** 25 \file htdocs/product/stock/fiche.php 26 \ingroup stock 27 \brief Page fiche entrepot 28 \version $Revision: 1.25 $ 29 */ 30 31 require ("./pre.inc.php"); 32 33 $langs->load("products"); 34 $langs->load("stocks"); 35 36 37 $mesg = ''; 38 39 40 // Ajout entrepot 41 if ($_POST["action"] == 'add') 42 { 43 $entrepot = new Entrepot($db); 44 45 $entrepot->ref = trim($_POST["ref"]); 46 $entrepot->libelle = trim($_POST["libelle"]); 47 $entrepot->description = trim($_POST["desc"]); 48 $entrepot->statut = trim($_POST["statut"]); 49 $entrepot->lieu = trim($_POST["lieu"]); 50 $entrepot->address = trim($_POST["address"]); 51 $entrepot->cp = trim($_POST["cp"]); 52 $entrepot->ville = trim($_POST["ville"]); 53 $entrepot->pays_id = trim($_POST["pays_id"]); 54 55 if ($entrepot->libelle) { 56 $id = $entrepot->create($user); 57 if ($id > 0) { 58 Header("Location: fiche.php?id=$id"); 59 } 60 61 $_GET["action"] = 'create'; 62 $mesg="<div class='error'>".$entrepot->error."</div>"; 63 } 64 else { 65 $mesg="<div class='error'>".$langs->trans("ErrorWarehouseRefRequired")."</div>"; 66 $_GET["action"]="create"; // Force retour sur page création 67 } 68 } 69 70 // Modification entrepot 71 if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel")) 72 { 73 $entrepot = new Entrepot($db); 74 if ($entrepot->fetch($_POST["id"])) 75 { 76 $entrepot->libelle = trim($_POST["libelle"]); 77 $entrepot->description = trim($_POST["desc"]); 78 $entrepot->statut = trim($_POST["statut"]); 79 $entrepot->lieu = trim($_POST["lieu"]); 80 $entrepot->address = trim($_POST["address"]); 81 $entrepot->cp = trim($_POST["cp"]); 82 $entrepot->ville = trim($_POST["ville"]); 83 $entrepot->pays_id = trim($_POST["pays_id"]); 84 85 if ( $entrepot->update($_POST["id"], $user) > 0) 86 { 87 $_GET["action"] = ''; 88 $_GET["id"] = $_POST["id"]; 89 //$mesg = '<div class="ok">Fiche mise à jour</div>'; 90 } 91 else 92 { 93 $_GET["action"] = 'edit'; 94 $_GET["id"] = $_POST["id"]; 95 $mesg = '<div class="error">Fiche non mise à jour !' . "<br>" . $entrepot->error.'</div>'; 96 } 97 } 98 else 99 { 100 $_GET["action"] = 'edit'; 101 $_GET["id"] = $_POST["id"]; 102 $mesg = '<div class="error">Fiche non mise à jour !' . "<br>" . $entrepot->error.'</div>'; 103 } 104 } 105 106 107 108 llxHeader("","",$langs->trans("WarehouseCard")); 109 110 $form=new Form($db); 111 112 113 if ($_POST["cancel"] == $langs->trans("Cancel")) 114 { 115 $_GET["action"] = ''; 116 $_GET["id"] = $_POST["id"]; 117 } 118 119 120 /* 121 * Affichage fiche en mode création 122 * 123 */ 124 125 if ($_GET["action"] == 'create') 126 { 127 print "<form action=\"fiche.php\" method=\"post\">\n"; 128 print '<input type="hidden" name="action" value="add">'; 129 print '<input type="hidden" name="type" value="'.$type.'">'."\n"; 130 print_titre($langs->trans("NewWarehouse")); 131 132 if ($mesg) { 133 print $mesg; 134 } 135 136 print '<table class="border" width="100%">'; 137 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="40" value=""></td></tr>'; 138 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'; 139 print '<textarea name="desc" rows="4" cols="60">'; 140 print "</textarea></td></tr>"; 141 142 print '<tr><td >'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$entrepot->lieu.'"></td></tr>'; 143 144 print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">'; 145 print $entrepot->address; 146 print '</textarea></td></tr>'; 147 148 print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%"><input size="6" type="text" name="cp" value="'.$entrepot->cp.'"></td>'; 149 print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%"><input type="text" name="ville" value="'.$entrepot->ville.'"></td></tr>'; 150 151 print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; 152 $form->select_pays($entrepot->pays_id,$entrepot->pays_code); 153 print '</td></tr>'; 154 155 print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'; 156 print '<select name="statut">'; 157 print '<option value="0" selected="true">'.$langs->trans("WarehouseClosed").'</option><option value="1">'.$langs->trans("WarehouseOpened").'</option>'; 158 print '</td></tr>'; 159 160 print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Create").'"></td></tr>'; 161 162 print '</table>'; 163 print '</form>'; 164 } 165 else 166 { 167 if ($_GET["id"]) 168 { 169 if ($mesg) print $mesg; 170 171 $entrepot = new Entrepot($db); 172 $result = $entrepot->fetch($_GET["id"]); 173 if (! $result) 174 { 175 dolibarr_print_error($db); 176 } 177 178 /* 179 * Affichage fiche 180 */ 181 if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') 182 { 183 184 /* 185 * Affichage onglets 186 */ 187 $h = 0; 188 189 $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; 190 $head[$h][1] = $langs->trans("WarehouseCard"); 191 $hselected=$h; 192 $h++; 193 194 $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; 195 $head[$h][1] = $langs->trans("Info"); 196 $h++; 197 198 dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle); 199 200 print '<table class="border" width="100%">'; 201 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>'; 202 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>'; 203 204 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>'; 205 206 print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">'; 207 print $entrepot->address; 208 print '</td></tr>'; 209 210 print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->cp.'</td>'; 211 print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->ville.'</td></tr>'; 212 213 print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; 214 $entrepot->pays; 215 print '</td></tr>'; 216 217 print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->statuts[$entrepot->statut].'</td></tr>'; 218 219 print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">'; 220 print $entrepot->nb_products(); 221 print "</td></tr>"; 222 223 // Dernier mouvement 224 $sql = "SELECT max( ".$db->pdate("m.datem").") as datem"; 225 $sql .= " FROM llx_stock_mouvement as m"; 226 $sql .= " WHERE m.fk_entrepot = '".$entrepot->id."';"; 227 $resql = $db->query($sql); 228 if ($resql) 229 { 230 $row = $db->fetch_row($resql); 231 } 232 else 233 { 234 dolibarr_print_error($db); 235 } 236 237 print '<tr><td valign="top"><a href="mouvement.php">'.$langs->trans("LastMovement").'</a></td><td colspan="3">'; 238 print dolibarr_print_date($row[0]); 239 print "</td></tr>"; 240 print "</table>"; 241 242 print '</div>'; 243 244 245 /* ************************************************************************** */ 246 /* */ 247 /* Barre d'action */ 248 /* */ 249 /* ************************************************************************** */ 250 251 print "<div class=\"tabsAction\">\n"; 252 253 if ($_GET["action"] == '') 254 { 255 print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=".$entrepot->id."\">".$langs->trans("Edit")."</a>"; 256 } 257 258 print "</div>"; 259 260 261 /* ************************************************************************** */ 262 /* */ 263 /* Affichage de la liste des produits de l'entrepot */ 264 /* */ 265 /* ************************************************************************** */ 266 print '<br>'; 267 268 print '<table class="noborder" width="100%">'; 269 print "<tr class=\"liste_titre\">"; 270 271 print_liste_field_titre($langs->trans("Product"),"", "p.ref","","","",$sortfield); 272 273 print "<td align=\"center\">".$langs->trans("Units")."</td>"; 274 print "</tr>\n"; 275 $sql = "SELECT p.rowid as rowid, p.label as produit, ps.reel as value "; 276 $sql .= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p "; 277 $sql .= " WHERE ps.fk_product = p.rowid "; 278 $sql .= " AND ps.reel >0 AND ps.fk_entrepot = ".$entrepot->id; 279 280 //$sql .= $db->plimit($limit + 1 ,$offset); 281 282 $resql = $db->query($sql) ; 283 if ($resql) 284 { 285 $num = $db->num_rows($resql); 286 $i = 0; 287 $var=True; 288 while ($i < $num) 289 { 290 $objp = $db->fetch_object($resql); 291 $var=!$var; 292 print "<tr $bc[$var]>"; 293 //print '<td>'.dolibarr_print_date($objp->datem).'</td>'; 294 print "<td><a href=\"../fiche.php?id=$objp->rowid\">"; 295 print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; 296 print "</a></td>\n"; 297 print '<td align="center">'.$objp->value.'</td>'; 298 //print "<td><a href=\"fiche.php?id=$objp->entrepot_id\">"; 299 //print img_object($langs->trans("ShowWarehous"),"stock").' '.$objp->stock; 300 //print "</a></td>\n"; 301 print "</tr>\n"; 302 $i++; 303 } 304 $db->free($resql); 305 } 306 else 307 { 308 dolibarr_print_error($db); 309 } 310 print "</table>\n"; 311 print "</div>\n"; 312 313 } 314 315 316 /* 317 * Edition fiche 318 */ 319 if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1) 320 { 321 print_fiche_titre('Edition de la fiche entrepot', $mesg); 322 323 print '<form action="fiche.php" method="POST">'; 324 print '<input type="hidden" name="action" value="update">'; 325 print '<input type="hidden" name="id" value="'.$entrepot->id.'">'; 326 327 print '<table class="border" width="100%">'; 328 print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="40" value="'.$entrepot->libelle.'"></td></tr>'; 329 print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'; 330 print '<textarea name="desc" rows="4" cols="60">'; 331 print $entrepot->description; 332 print "</textarea></td></tr>"; 333 334 print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$entrepot->lieu.'"></td></tr>'; 335 336 print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">'; 337 print $entrepot->address; 338 print '</textarea></td></tr>'; 339 340 print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$entrepot->cp.'"></td>'; 341 print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$entrepot->ville.'"></td></tr>'; 342 343 print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; 344 $form->select_pays($entrepot->pays_id,$entrepot->pays_code); 345 print '</td></tr>'; 346 347 print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'; 348 print '<select name="statut">'; 349 print '<option value="0" '.($entrepot->statut == 0?'selected="true"':'').'>'.$langs->trans("WarehouseClosed").'</option>'; 350 print '<option value="1" '.($entrepot->statut == 0?'':'selected="true"').'>'.$langs->trans("WarehouseOpened").'</option>'; 351 print '</select>'; 352 print '</td></tr>'; 353 354 print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; 355 print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; 356 print '</table>'; 357 print '</form>'; 358 359 } 360 } 361 } 362 363 364 365 366 $db->close(); 367 368 llxFooter('$Date: 2005/09/21 23:43:08 $ - $Revision: 1.25 $'); 369 ?>
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 |
![]() |