* Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2005 Simon Tosser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ * */ /** \file htdocs/product/stock/fiche.php \ingroup stock \brief Page fiche entrepot \version $Revision$ */ require("./pre.inc.php"); $langs->load("products"); $langs->load("stocks"); $mesg = ''; // Ajout entrepot if ($_POST["action"] == 'add') { $entrepot = new Entrepot($db); $entrepot->ref = trim($_POST["ref"]); $entrepot->libelle = trim($_POST["libelle"]); $entrepot->description = trim($_POST["desc"]); $entrepot->statut = trim($_POST["statut"]); $entrepot->lieu = trim($_POST["lieu"]); $entrepot->address = trim($_POST["address"]); $entrepot->cp = trim($_POST["cp"]); $entrepot->ville = trim($_POST["ville"]); $entrepot->pays_id = trim($_POST["pays_id"]); if ($entrepot->libelle) { $id = $entrepot->create($user); if ($id > 0) { Header("Location: fiche.php?id=$id"); } $_GET["action"] = 'create'; $mesg="
".$entrepot->error."
"; } else { $mesg="
".$langs->trans("ErrorWarehouseRefRequired")."
"; $_GET["action"]="create"; // Force retour sur page création } } // Modification entrepot if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel")) { $entrepot = new Entrepot($db); if ($entrepot->fetch($_POST["id"])) { $entrepot->libelle = trim($_POST["libelle"]); $entrepot->description = trim($_POST["desc"]); $entrepot->statut = trim($_POST["statut"]); $entrepot->lieu = trim($_POST["lieu"]); $entrepot->address = trim($_POST["address"]); $entrepot->cp = trim($_POST["cp"]); $entrepot->ville = trim($_POST["ville"]); $entrepot->pays_id = trim($_POST["pays_id"]); if ( $entrepot->update($_POST["id"], $user) > 0) { $_GET["action"] = ''; $_GET["id"] = $_POST["id"]; //$mesg = '
Fiche mise à jour
'; } else { $_GET["action"] = 'edit'; $_GET["id"] = $_POST["id"]; $mesg = '
Fiche non mise à jour !' . "
" . $entrepot->error.'
'; } } else { $_GET["action"] = 'edit'; $_GET["id"] = $_POST["id"]; $mesg = '
Fiche non mise à jour !' . "
" . $entrepot->error.'
'; } } llxHeader("","",$langs->trans("WarehouseCard")); $form=new Form($db); if ($_POST["cancel"] == $langs->trans("Cancel")) { $_GET["action"] = ''; $_GET["id"] = $_POST["id"]; } /* * Affichage fiche en mode création * */ if ($_GET["action"] == 'create') { print "
\n"; print ''; print ''."\n"; print_titre($langs->trans("NewWarehouse")); if ($mesg) { print $mesg; } print ''; print ''; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Description").''; print '
'.$langs->trans("LocationSummary").'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('Country').''; $form->select_pays($entrepot->pays_id,$entrepot->pays_code); print '
'.$langs->trans("Status").''; print '
'; print '
'; } else { if ($_GET["id"]) { if ($mesg) print $mesg; $entrepot = new Entrepot($db); $result = $entrepot->fetch($_GET["id"]); if (! $result) { dolibarr_print_error($db); } /* * Affichage fiche */ if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') { /* * 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 ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '"; $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 '"; print "
'.$langs->trans("Ref").''.$entrepot->libelle.'
'.$langs->trans("Description").''.nl2br($entrepot->description).'
'.$langs->trans("LocationSummary").''.$entrepot->lieu.'
'.$langs->trans('Address').''; print $entrepot->address; print '
'.$langs->trans('Zip').''.$entrepot->cp.''.$langs->trans('Town').''.$entrepot->ville.'
'.$langs->trans('Country').''; $entrepot->pays; print '
'.$langs->trans("Status").''.$entrepot->statuts[$entrepot->statut].'
'.$langs->trans("NumberOfProducts").''; print $entrepot->nb_products(); print "
'.$langs->trans("DernierMouvement").''; print strftime("%e %B %Y",$row[0]); print "
"; //affichage de la liste des produits de l\'entrepot print ''; print ""; print_liste_field_titre($langs->trans("Product"),"", "p.ref","","","",$sortfield); print ""; print "\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 ""; //print ''; print "\n"; print ''; //print "\n"; print "\n"; $i++; } $db->free($resql); } print "
".$langs->trans("Units")."
'.dolibarr_print_date($objp->datem).'rowid\">"; print img_object($langs->trans("ShowProduct"),"product").' '.$objp->produit; print "'.$objp->value.'entrepot_id\">"; //print img_object($langs->trans("ShowWarehous"),"stock").' '.$objp->stock; //print "
\n"; print "\n"; } /* * Edition fiche */ if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1) { print_fiche_titre('Edition de la fiche entrepot', $mesg); print '
'; print ''; print ''; print ''; print ''; print '"; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Description").''; print '
'.$langs->trans("LocationSummary").'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('Country').''; $form->select_pays($entrepot->pays_id,$entrepot->pays_code); print '
'.$langs->trans("Status").''; print ''; print '
 '; print '
'; print '
'; } } } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print "
\n"; if ($_GET["action"] == '') { print "id\">".$langs->trans("Edit").""; } print "
"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>