164 |
} |
} |
165 |
else |
else |
166 |
{ |
{ |
167 |
if ($_GET["id"]) |
if ($_GET["id"]) |
168 |
{ |
{ |
169 |
|
if ($mesg) print $mesg; |
170 |
if ($mesg) print $mesg; |
|
171 |
|
$entrepot = new Entrepot($db); |
172 |
$entrepot = new Entrepot($db); |
$result = $entrepot->fetch($_GET["id"]); |
173 |
$result = $entrepot->fetch($_GET["id"]); |
if (! $result) |
|
if (! $result) |
|
|
{ |
|
|
dolibarr_print_error($db); |
|
|
} |
|
|
|
|
|
/* |
|
|
* Affichage fiche |
|
|
*/ |
|
|
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') |
|
174 |
{ |
{ |
175 |
|
dolibarr_print_error($db); |
|
/* |
|
|
* Affichage onglets |
|
|
*/ |
|
|
$h = 0; |
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; |
|
|
$head[$h][1] = $langs->trans("WarehouseCard"); |
|
|
$hselected=$h; |
|
|
$h++; |
|
|
|
|
|
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; |
|
|
$head[$h][1] = $langs->trans("Info"); |
|
|
$h++; |
|
|
|
|
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle); |
|
|
|
|
|
print '<table class="border" width="100%">'; |
|
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>'; |
|
|
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>'; |
|
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>'; |
|
|
|
|
|
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">'; |
|
|
print $entrepot->address; |
|
|
print '</td></tr>'; |
|
|
|
|
|
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$entrepot->cp.'</td>'; |
|
|
print '<td>'.$langs->trans('Town').'</td><td>'.$entrepot->ville.'</td></tr>'; |
|
|
|
|
|
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; |
|
|
$entrepot->pays; |
|
|
print '</td></tr>'; |
|
|
|
|
|
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->statuts[$entrepot->statut].'</td></tr>'; |
|
|
|
|
|
print '<tr><td valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">'; |
|
|
print $entrepot->nb_products(); |
|
|
print "</td></tr>"; |
|
|
|
|
|
$sql = "SELECT max( ".$db->pdate("m.datem").") as datem"; |
|
|
$sql .= " FROM llx_stock_mouvement as m"; |
|
|
$sql .= " WHERE m.fk_entrepot = '".$entrepot->id."';"; |
|
|
|
|
|
$resql = $db->query($sql); |
|
|
if ($resql) |
|
|
{ |
|
|
$row = $db->fetch_row($resql); |
|
|
} |
|
|
|
|
|
print '<tr><td valign="top"><a href="mouvement.php">'.$langs->trans("DernierMouvement").'</a></td><td colspan="3">'; |
|
|
print strftime("%e %B %Y",$row[0]); |
|
|
print "</td></tr>"; |
|
|
print "</table>"; |
|
|
|
|
|
//affichage de la liste des produits de l\'entrepot |
|
|
print '<table class="noborder" width="100%">'; |
|
|
print "<tr class=\"liste_titre\">"; |
|
|
|
|
|
print_liste_field_titre($langs->trans("Product"),"", "p.ref","","","",$sortfield); |
|
|
|
|
|
print "<td align=\"center\">".$langs->trans("Units")."</td>"; |
|
|
print "</tr>\n"; |
|
|
$sql = "SELECT p.rowid as rowid, p.label as produit, ps.reel as value "; |
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p "; |
|
|
$sql .= " WHERE ps.fk_product = p.rowid "; |
|
|
$sql .= " AND ps.reel >0 AND ps.fk_entrepot = $id"; |
|
|
|
|
|
//$sql .= $db->plimit($limit + 1 ,$offset); |
|
|
|
|
|
$resql = $db->query($sql) ; |
|
|
if ($resql) |
|
|
{$num = $db->num_rows($resql); |
|
|
$i = 0; |
|
|
$var=True; |
|
|
while ($i < $num) |
|
|
{ |
|
|
$objp = $db->fetch_object($resql); |
|
|
$var=!$var; |
|
|
print "<tr $bc[$var]>"; |
|
|
//print '<td>'.dolibarr_print_date($objp->datem).'</td>'; |
|
|
print "<td><a href=\"../fiche.php?id=$objp->rowid\">"; |
|
|
print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; |
|
|
print "</a></td>\n"; |
|
|
print '<td align="center">'.$objp->value.'</td>'; |
|
|
//print "<td><a href=\"fiche.php?id=$objp->entrepot_id\">"; |
|
|
//print img_object($langs->trans("ShowWarehous"),"stock").' '.$objp->stock; |
|
|
//print "</a></td>\n"; |
|
|
print "</tr>\n"; |
|
|
$i++; |
|
|
} |
|
|
$db->free($resql); |
|
|
} |
|
|
print "</table>\n"; |
|
|
print "</div>\n"; |
|
|
|
|
176 |
} |
} |
177 |
|
|
178 |
|
/* |
179 |
/* |
* Affichage fiche |
180 |
* Edition fiche |
*/ |
181 |
*/ |
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') |
|
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1) |
|
182 |
{ |
{ |
183 |
print_fiche_titre('Edition de la fiche entrepot', $mesg); |
|
184 |
|
/* |
185 |
print '<form action="fiche.php" method="POST">'; |
* Affichage onglets |
186 |
print '<input type="hidden" name="action" value="update">'; |
*/ |
187 |
print '<input type="hidden" name="id" value="'.$entrepot->id.'">'; |
$h = 0; |
188 |
|
|
189 |
print '<table class="border" width="100%">'; |
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; |
190 |
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="40" value="'.$entrepot->libelle.'"></td></tr>'; |
$head[$h][1] = $langs->trans("WarehouseCard"); |
191 |
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'; |
$hselected=$h; |
192 |
print '<textarea name="desc" rows="4" cols="60">'; |
$h++; |
193 |
print $entrepot->description; |
|
194 |
print "</textarea></td></tr>"; |
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; |
195 |
|
$head[$h][1] = $langs->trans("Info"); |
196 |
print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$entrepot->lieu.'"></td></tr>'; |
$h++; |
197 |
|
|
198 |
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="60" rows="3" wrap="soft">'; |
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle); |
199 |
print $entrepot->address; |
|
200 |
print '</textarea></td></tr>'; |
print '<table class="border" width="100%">'; |
201 |
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>'; |
202 |
print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$entrepot->cp.'"></td>'; |
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>'; |
203 |
print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$entrepot->ville.'"></td></tr>'; |
|
204 |
|
print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>'; |
205 |
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; |
|
206 |
$form->select_pays($entrepot->pays_id,$entrepot->pays_code); |
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">'; |
207 |
print '</td></tr>'; |
print $entrepot->address; |
208 |
|
print '</td></tr>'; |
209 |
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'; |
|
210 |
print '<select name="statut">'; |
print '<tr><td>'.$langs->trans('Zip').'</td><td>'.$entrepot->cp.'</td>'; |
211 |
print '<option value="0" '.($entrepot->statut == 0?"selected":"").'>'.$langs->trans("WarehouseClosed").'</option>'; |
print '<td>'.$langs->trans('Town').'</td><td>'.$entrepot->ville.'</td></tr>'; |
212 |
print '<option value="1" '.($entrepot->statut == 0?"":"selected").'>'.$langs->trans("WarehouseOpened").'</option>'; |
|
213 |
print '</select>'; |
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'; |
214 |
print '</td></tr>'; |
$entrepot->pays; |
215 |
|
print '</td></tr>'; |
216 |
print '<tr><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Save").'"> '; |
|
217 |
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>'; |
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->statuts[$entrepot->statut].'</td></tr>'; |
218 |
print '</table>'; |
|
219 |
print '</form>'; |
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 |
/* Barre d'action */ |
*/ |
319 |
/* */ |
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1) |
320 |
/* ************************************************************************** */ |
{ |
321 |
|
print_fiche_titre('Edition de la fiche entrepot', $mesg); |
322 |
|
|
323 |
print "<div class=\"tabsAction\">\n"; |
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":"").'>'.$langs->trans("WarehouseClosed").'</option>'; |
350 |
|
print '<option value="1" '.($entrepot->statut == 0?"":"selected").'>'.$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 |
if ($_GET["action"] == '') |
} |
360 |
{ |
} |
|
print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$entrepot->id\">".$langs->trans("Edit")."</a>"; |
|
361 |
} |
} |
362 |
|
|
363 |
print "</div>"; |
|
364 |
|
|
365 |
|
|
366 |
$db->close(); |
$db->close(); |