Amélioration de la gestion des stocks: Ajout de la localisation (adresse) d'un entrepot et ajout de l'onglet info

This commit is contained in:
Laurent Destailleur 2005-03-28 18:50:47 +00:00
parent faca581285
commit a57cdec131
8 changed files with 463 additions and 276 deletions

View File

@ -9,5 +9,10 @@ Stocks=Stocks
Movement=Movement Movement=Movement
Movements=Movements Movements=Movements
CorrectStock=Correct stock CorrectStock=Correct stock
ListOfWarehouses=List of warehouses
ListOfStockMovements=List of stock movements ListOfStockMovements=List of stock movements
ErrorWarehouseLabelRequired=Warehouse label is required ErrorWarehouseLabelRequired=Warehouse label is required
StocksArea=Stocks area
Location=Lieu
LocationSummary=Short name location
NumberOfProducts=Total number of products

View File

@ -9,5 +9,10 @@ Stocks=Stocks
Movement=Mouvement Movement=Mouvement
Movements=Mouvements Movements=Mouvements
CorrectStock=Corriger stock CorrectStock=Corriger stock
ListOfWarehouses=Liste des entrepôts
ListOfStockMovements=Liste des mouvements de stock ListOfStockMovements=Liste des mouvements de stock
ErrorWarehouseLabelRequired=Le libellé de l'entrepôt est obligatoire ErrorWarehouseLabelRequired=Le libellé de l'entrepôt est obligatoire
StocksArea=Espace stocks
Location=Lieu
LocationSummary=Nom court du lieu
NumberOfProducts=Nombre total de produits

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,7 +21,8 @@
* *
*/ */
/** \file htdocs/product/stock/entrepot.class.php /**
\file htdocs/product/stock/entrepot.class.php
\ingroup stock \ingroup stock
\brief Fichier de la classe de gestion des entrepots \brief Fichier de la classe de gestion des entrepots
\version $Revision$ \version $Revision$
@ -34,12 +35,18 @@
class Entrepot class Entrepot
{ {
var $db ; var $db;
var $error;
var $id ; var $id;
var $libelle; var $libelle;
var $description; var $description;
var $statut; var $statut;
var $lieu;
var $address;
var $cp;
var $ville;
var $pays_id;
/* /*
* \brief Constructeur de l'objet entrepot * \brief Constructeur de l'objet entrepot
@ -62,23 +69,24 @@ class Entrepot
{ {
// Si libelle non defini, erreur // Si libelle non defini, erreur
if ($this->libelle == '') { if ($this->libelle == '') {
$this->mesg_error = "Libellé obligatoire"; $this->error = "Libellé obligatoire";
return 0; return 0;
} }
if ($this->db->begin()) $this->db->begin();
{
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author)";
$sql .= " VALUES (now(),".$user->id.")"; $sql .= " VALUES (now(),".$user->id.")";
if ($this->db->query($sql) ) $result=$this->db->query($sql);
if ($result)
{ {
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot"); $id = $this->db->last_insert_id(MAIN_DB_PREFIX."entrepot");
if ($id > 0) if ($id > 0)
{ {
$this->id = $id; $this->id = $id;
if ( $this->update($id, $user) ) if ( $this->update($id, $user) > 0)
{ {
$this->db->commit(); $this->db->commit();
return $id; return $id;
@ -86,16 +94,21 @@ class Entrepot
else else
{ {
$this->db->rollback(); $this->db->rollback();
return -3;
} }
}
else {
$this->error="Failed to get insert id";
return -2;
} }
} }
else else
{ {
$this->error="Failed to insert warehouse";
$this->db->rollback();
return -1; return -1;
} }
}
} }
/* /*
@ -105,13 +118,25 @@ class Entrepot
*/ */
function update($id, $user) function update($id, $user)
{ {
if (strlen(trim($this->libelle))) $this->libelle=trim($this->libelle);
{ $this->description=trim($this->description);
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET label = '" . trim($this->libelle) ."'";
$sql .= ",description = '" . trim($this->description) ."'";
$sql .= ",statut = " . $this->statut ;
$this->lieu=trim($this->lieu);
$this->address=trim($this->address);
$this->cp=trim($this->cp);
$this->ville=trim($this->ville);
$this->pays_id=trim($this->pays_id);
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET label = '" . $this->libelle ."'";
$sql .= ",description = '" . $this->description ."'";
$sql .= ",statut = " . $this->statut ;
$sql .= ",description = '" . $this->description ."'";
$sql .= ",lieu = '" . $this->lieu ."'";
$sql .= ",address = '" . $this->address ."'";
$sql .= ",cp = '" . $this->cp ."'";
$sql .= ",ville = '" . $this->ville ."'";
$sql .= ",fk_pays = " . $this->pays_id?$this->pays_id:'0' ;
$sql .= " WHERE rowid = " . $id; $sql .= " WHERE rowid = " . $id;
if ( $this->db->query($sql) ) if ( $this->db->query($sql) )
@ -120,15 +145,11 @@ class Entrepot
} }
else else
{ {
$this->error=$this->db->error()." sql=$sql";;
return -1; return -1;
} }
} }
else
{
$this->mesg_error = "Vous devez indiquer une référence";
return 0;
}
}
/** /**
* \brief Recupéeration de la base d'un entrepot * \brief Recupéeration de la base d'un entrepot
@ -136,30 +157,84 @@ class Entrepot
*/ */
function fetch ($id) function fetch ($id)
{ {
$sql = "SELECT rowid, label, description, statut"; $sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot WHERE rowid = $id"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
$sql .= " WHERE rowid = $id";
$result = $this->db->query($sql) ; $result = $this->db->query($sql);
if ($result)
{
$obj=$this->db->fetch_object($result);
if ( $result ) $this->id = $obj->rowid;
$this->ref = $obj->rowid;
$this->libelle = $obj->label;
$this->description = $obj->description;
$this->statut = $obj->statut;
$this->lieu = $obj->lieu;
$this->address = $obj->address;
$this->cp = $obj->cp;
$this->ville = $obj->ville;
$this->pays_id = $obj->pays_id;
$this->db->free($result);
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/*
* \brief Charge les informations d'ordre info dans l'objet entrepot
* \param id id de l'entrepot a charger
*/
function info($id)
{
$sql = "SELECT e.rowid, ".$this->db->pdate("datec")." as datec,";
$sql .= " ".$this->db->pdate("tms")." as datem,";
$sql .= " fk_user_author";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " WHERE e.rowid = ".$id;
$result=$this->db->query($sql);
if ($result)
{ {
$result = $this->db->fetch_array(); if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $result["rowid"]; $this->id = $obj->rowid;
$this->ref = $result["ref"];
$this->libelle = stripslashes($result["label"]); if ($obj->fk_user_author) {
$this->description = stripslashes($result["description"]); $cuser = new User($this->db, $obj->fk_user_author);
$this->statut = $result["statut"]; $cuser->fetch();
$this->user_creation = $cuser;
}
if ($obj->fk_user_valid) {
$vuser = new User($this->db, $obj->fk_user_valid);
$vuser->fetch();
$this->user_validation = $vuser;
}
$this->date_creation = $obj->datec;
$this->date_modification = $obj->datem;
}
$this->db->free($result);
$this->db->free();
return 1;
} }
else else
{ {
print $this->db->error(); dolibarr_print_error($this->db);
return -1;
} }
} }
/** /**
* \brief Renvoie la liste des entrepôts ouverts * \brief Renvoie la liste des entrepôts ouverts

View File

@ -37,7 +37,7 @@ $langs->load("stocks");
$mesg = ''; $mesg = '';
// Ajout entrepot
if ($_POST["action"] == 'add') if ($_POST["action"] == 'add')
{ {
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
@ -45,11 +45,21 @@ if ($_POST["action"] == 'add')
$entrepot->ref = trim($_POST["ref"]); $entrepot->ref = trim($_POST["ref"]);
$entrepot->libelle = trim($_POST["libelle"]); $entrepot->libelle = trim($_POST["libelle"]);
$entrepot->description = trim($_POST["desc"]); $entrepot->description = trim($_POST["desc"]);
$entrepot->statut = $_POST["statut"]; $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) { if ($entrepot->libelle) {
$id = $entrepot->create($user); $id = $entrepot->create($user);
Header("Location: fiche.php?id=$id"); if ($id > 0) {
Header("Location: fiche.php?id=$id");
}
$_GET["action"] = 'create';
$mesg="<div class='error'>".$entrepot->error."</div>";
} }
else { else {
$mesg="<div class='error'>".$langs->trans("ErrorWarehouseLabelRequired")."</div>"; $mesg="<div class='error'>".$langs->trans("ErrorWarehouseLabelRequired")."</div>";
@ -57,30 +67,39 @@ if ($_POST["action"] == 'add')
} }
} }
// Modification entrepot
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel")) if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
{ {
$entrepot = new Entrepot($db); $entrepot = new Entrepot($db);
if ($entrepot->fetch($_GET["id"])) if ($entrepot->fetch($_POST["id"]))
{ {
$entrepot->libelle = $_POST["libelle"]; $entrepot->libelle = trim($_POST["libelle"]);
$entrepot->description = $_POST["desc"]; $entrepot->description = trim($_POST["desc"]);
$entrepot->statut = $_POST["statut"]; $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($_GET["id"], $user)) if ( $entrepot->update($_POST["id"], $user) > 0)
{ {
$_GET["cancel"] = ''; $_GET["action"] = '';
$mesg = 'Fiche mise à jour'; $_GET["id"] = $_POST["id"];
} //$mesg = '<div class="ok">Fiche mise à jour</div>';
else }
{ else
$_GET["cancel"] = 're-edit'; {
$mesg = 'Fiche non mise à jour !' . "<br>" . $entrepot->mesg_error; $_GET["action"] = 'edit';
} $_GET["id"] = $_POST["id"];
$mesg = '<div class="error">Fiche non mise à jour !' . "<br>" . $entrepot->error.'</div>';
}
} }
else else
{ {
$_GET["cancel"] = 're-edit'; $_GET["action"] = 'edit';
$mesg = 'Fiche non mise à jour !' . "<br>" . $entrepot->mesg_error; $_GET["id"] = $_POST["id"];
$mesg = '<div class="error">Fiche non mise à jour !' . "<br>" . $entrepot->error.'</div>';
} }
} }
@ -88,99 +107,154 @@ if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
llxHeader("","",$langs->trans("WarehouseCard")); llxHeader("","",$langs->trans("WarehouseCard"));
$form=new Form($db);
if ($_GET["cancel"] == $langs->trans("Cancel"))
if ($_POST["cancel"] == $langs->trans("Cancel"))
{ {
$_GET["action"] = ''; $_GET["action"] = '';
$_GET["id"] = $_POST["id"];
} }
/* /*
* Affichage fiche en mode création * Affichage fiche en mode création
* *
*/ */
if ($_GET["action"] == 'create') if ($_GET["action"] == 'create')
{ {
print "<form action=\"fiche.php\" method=\"post\">\n"; print "<form action=\"fiche.php\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add">'; print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="type" value="'.$type.'">'."\n"; print '<input type="hidden" name="type" value="'.$type.'">'."\n";
print_titre($langs->trans("NewWarehouse")); print_titre($langs->trans("NewWarehouse"));
if ($mesg) { if ($mesg) {
print $mesg; print $mesg;
} }
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value=""></td></tr>'; print '<tr><td width="20%">'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value=""></td></tr>';
print '<tr><td width="20%" valign="top">'.$langs->trans("Description").'</td><td>'; print '<tr><td width="20%" valign="top">'.$langs->trans("Description").'</td><td>';
print '<textarea name="desc" rows="8" cols="50">'; print '<textarea name="desc" rows="8" cols="50">';
print "</textarea></td></tr>"; print "</textarea></td></tr>";
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>'; print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>';
print '<select name="statut">'; print '<select name="statut">';
print '<option value="0" selected>'.$langs->trans("WarehouseClosed").'</option><option value="1">'.$langs->trans("WarehouseOpened").'</option>'; print '<option value="0" selected>'.$langs->trans("WarehouseClosed").'</option><option value="1">'.$langs->trans("WarehouseOpened").'</option>';
print '</td></tr>'; print '</td></tr>';
print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Create").'"></td></tr>'; print '<tr><td>&nbsp;</td><td><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
print '</table>'; print '</table>';
print '</form>'; print '</form>';
} }
else else
{ {
if ($_GET["id"]) if ($_GET["id"])
{ {
if ($_GET["action"] <> 're-edit')
{
$entrepot = new Entrepot($db);
$result = $entrepot->fetch($_GET["id"]);
}
if ( $result ) if ($mesg) {
{ print $mesg;
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') }
{
print_fiche_titre('Fiche entrepot', $mesg);
print '<table class="border" width="100%">'; $entrepot = new Entrepot($db);
print '<tr><td width="20%">'.$langs->trans("Label").'</td><td>'.$entrepot->libelle.'</td>'; $result = $entrepot->fetch($_GET["id"]);
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($entrepot->description).'</td></tr>'; if (! $result)
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>'.$entrepot->statuts[$entrepot->statut].'</td></tr>'; {
print '<tr><td valign="top">Nb de produits</td><td>'; dolibarr_print_error($db);
print $entrepot->nb_products(); }
print "</td></tr>";
print "</table>"; /*
} * 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->id);
print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Label").'</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("Status").'</td><td colspan="3">'.$entrepot->statuts[$entrepot->statut].'</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 valign="top">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
print $entrepot->nb_products();
print "</td></tr>";
print "</table>";
print "<br></div>\n";
}
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1) /*
{ * Edition fiche
print_fiche_titre('Edition de la fiche entrepot', $mesg); */
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1)
{
print_fiche_titre('Edition de la fiche entrepot', $mesg);
print "<form action=\"fiche.php?id=$entrepot->id\" method=\"post\">\n"; print '<form action="fiche.php" method="POST">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$entrepot->id.'">';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td width="20%">'.$langs->trans("Label").'</td><td colspan="2"><input name="libelle" size="40" value="'.$entrepot->libelle.'"></td></tr>'; print '<tr><td width="20%">'.$langs->trans("Label").'</td><td colspan="3"><input name="libelle" size="40" value="'.$entrepot->libelle.'"></td></tr>';
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="3">';
print '<textarea name="desc" rows="8" cols="50">'; print '<textarea name="desc" rows="4" cols="60">';
print $entrepot->description; print $entrepot->description;
print "</textarea></td></tr>"; print "</textarea></td></tr>";
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="2">'; print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">';
print '<select name="statut">'; print '<select name="statut">';
print '<option value="0" '.($entrepot->statut == 0?"selected":"").'>'.$langs->trans("WarehouseClosed").'</option>'; print '<option value="0" '.($entrepot->statut == 0?"selected":"").'>'.$langs->trans("WarehouseClosed").'</option>';
print '<option value="1" '.($entrepot->statut == 0?"":"selected").'>'.$langs->trans("WarehouseOpened").'</option>'; print '<option value="1" '.($entrepot->statut == 0?"":"selected").'>'.$langs->trans("WarehouseOpened").'</option>';
print '</select>'; print '</select>';
print '</td></tr>'; print '</td></tr>';
print "<tr>".'<td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;'; print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$entrepot->lieu.'"></td></tr>';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>'; print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="40" rows="3" wrap="soft">';
print '</form>'; print $entrepot->address;
} print '</textarea></td></tr>';
}
else print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$entrepot->cp.'"></td>';
{ print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$entrepot->ville.'"></td></tr>';
dolibarr_print_error($db);
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
$form->select_pays($entrepot->pays_id,$entrepot->pays_code);
print '</td></tr>';
print '<tr><td colspan="4" align="center"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;';
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
print '</table>';
print '</form>';
}
} }
} }
@ -191,11 +265,11 @@ else
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
print "<br><div class=\"tabsAction\">\n"; print "<div class=\"tabsAction\">\n";
if ($_GET["action"] == '') if ($_GET["action"] == '')
{ {
print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$entrepot->id\">".$langs->trans("Edit")."</a>"; print "<a class=\"tabAction\" href=\"fiche.php?action=edit&id=$entrepot->id\">".$langs->trans("Edit")."</a>";
} }
print "</div>"; print "</div>";

View File

@ -31,19 +31,37 @@
require_once("./pre.inc.php"); require_once("./pre.inc.php");
require_once("./entrepot.class.php"); require_once("./entrepot.class.php");
/* $user->getrights("stocks");
* $langs->load("stocks");
*
*/ if (!$user->rights->stock->lire)
accessforbidden();
llxHeader("","",$langs->trans("Stocks")); llxHeader("","",$langs->trans("Stocks"));
print_titre($langs->trans("Stocks")); print_titre($langs->trans("StocksArea"));
print '<br>'; print '<br>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr><td valign="top" width="30%">'; print '<tr><td valign="top" width="30%">';
/*
* Zone recherche entrepot
*/
print '<form method="post" action="liste.php">';
print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">";
print '<td colspan="3">'.$langs->trans("Search").'</td></tr>';
print "<tr $bc[0]><td>";
print $langs->trans("Ref").' :</td><td><input class="flat" type="text" size="20" name="sf_ref"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
print "</table></form><br>";
$sql = "SELECT e.label, e.rowid, e.statut FROM ".MAIN_DB_PREFIX."entrepot as e"; $sql = "SELECT e.label, e.rowid, e.statut FROM ".MAIN_DB_PREFIX."entrepot as e";
$sql .= " ORDER BY e.statut DESC "; $sql .= " ORDER BY e.statut DESC ";
$sql .= $db->plimit(15 ,0); $sql .= $db->plimit(15 ,0);
@ -51,37 +69,36 @@ $result = $db->query($sql) ;
if ($result) if ($result)
{ {
$num = $db->num_rows($result); $num = $db->num_rows($result);
$i = 0; $i = 0;
if ($num > 0) print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Warehouses").'</td></tr>';
if ($num)
{ {
$entrepot=new Entrepot($db); $entrepot=new Entrepot($db);
print '<table class="noborder" width="100%">'; $var=True;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->rowid\">".img_object($langs->trans("ShowStock"),"stock")." ".$objp->label."</a></td>\n";
print '<td align="right">'.$entrepot->LibStatut($objp->statut).'</td>';
print "</tr>\n";
$i++;
}
$db->free($result);
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("Warehouses").'</td></tr>';
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object($result);
$var=!$var;
print "<tr $bc[$var]>";
print "<td><a href=\"fiche.php?id=$objp->rowid\">".img_object($langs->trans("ShowStock"),"stock")." ".$objp->label."</a></td>\n";
print '<td align="right">'.$entrepot->LibStatut($objp->statut).'</td>';
print "</tr>\n";
$i++;
}
$db->free($result);
print "</table>";
} }
print "</table>";
} }
else else
{ {
dolibarr_print_error($db); dolibarr_print_error($db);
} }
print '</td><td valign="top" width="70%">'; print '</td><td valign="top" width="70%">';

View File

@ -0,0 +1,73 @@
<?php
/* Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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/info.php
\ingroup facture
\brief Page des informations d'un entrepot
\version $Revision$
*/
require("./pre.inc.php");
$langs->load("stocks");
llxHeader();
/*
* Visualisation de la fiche
*
*/
$entrepot = new Entrepot($db);
$entrepot->fetch($_GET["id"]);
$entrepot->info($_GET["id"]);
/*
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("Info");
$hselected=$h;
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->id);
print '<table width="100%"><tr><td>';
dolibarr_print_object_info($entrepot);
print '</td></tr></table>';
print "<br></div>";
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
?>

View File

@ -21,77 +21,34 @@
* *
*/ */
/** \file htdocs/product/stock/liste.php /**
\file htdocs/product/stock/liste.php
\ingroup stock \ingroup stock
\brief Page liste des stocks \brief Page liste des stocks
\version $Revision$ \version $Revision$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
$user->getrights('produit'); require_once("./entrepot.class.php");
if (!$user->rights->produit->lire) $user->getrights('stocks');
$langs->load("stocks");
if (!$user->rights->stock->lire)
accessforbidden(); accessforbidden();
if ($action == 'update')
{
$sql = "UPDATE llx_product SET description='$desc' where rowid = $rowid";
$db->query($sql);
}
/*
*
*
*/
if ($page < 0) {
$page = 0 ; }
if ($page < 0) $page = 0;
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
$offset = $limit * $page ; $offset = $limit * $page ;
if ($sortfield == "") { if (! $sortfield) $sortfield="e.label";
$sortfield="p.tms"; } if (! $sortorder) $sortorder="ASC";
if ($sortorder == "")
{
$sortorder="DESC";
}
$sql = "SELECT p.rowid, p.label, p.price, p.ref FROM llx_product as p"; $sql = "SELECT e.rowid as ref, e.label, e.statut, e.lieu, e.address, e.cp, e.ville, e.fk_pays";
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e";
if ($_POST["sall"]) $sql .= " ORDER BY $sortfield $sortorder";
{
$sql .= " WHERE lower(p.ref) like '%".strtolower($sall)."%'";
$sql .= " OR lower(p.label) like '%".strtolower($sall)."%'";
}
else
{
if (strlen($type) == 0)
{
$type = 0;
}
$sql .= " WHERE p.fk_product_type = $type";
if ($sref)
{
$sql .= " AND lower(p.ref) like '%".strtolower($sref)."%'";
}
if ($snom)
{
$sql .= " AND lower(p.label) like '%".strtolower($snom)."%'";
}
if (isset($envente) && strlen($envente) > 0)
{
$sql .= " AND p.envente = $envente";
}
else
{
$sql .= " AND p.envente = 1";
}
}
$sql .= " ORDER BY $sortfield $sortorder ";
$sql .= $db->plimit($limit + 1 ,$offset); $sql .= $db->plimit($limit + 1 ,$offset);
$result = $db->query($sql) ; $result = $db->query($sql) ;
@ -101,57 +58,37 @@ if ($result)
$i = 0; $i = 0;
if ($num == 1 && (isset($sall) or isset($snom) or isset($sref))) llxHeader("","",$langs->trans("ListOfWarehouses"));
{
$objp = $db->fetch_object($result);
Header("Location: fiche.php?id=$objp->rowid");
}
if ($ref || $snom || $sall) print_barre_liste($langs->trans("ListOfWarehouses"), $page, "liste.php", "", $sortfield, $sortorder,'',$num);
{
llxHeader("","","Recherche Produit/Service");
print_barre_liste("Recherche d'un produit ou service", $page, "liste.php", "&sref=$sref&snom=$snom&envente=$envente", $sortfield, $sortorder,'',$num);
}
else
{
$texte = "Liste des ".$types[$type]."s";
llxHeader("","",$texte);
if (isset($envente) && $envente == 0)
{
$texte .= " hors vente";
}
print_barre_liste($texte, $page, "liste.php", "&sref=$sref&snom=$snom", $sortfield, $sortorder,'',$num);
}
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print "<tr class=\"liste_titre\">"; print "<tr class=\"liste_titre\">";
print_liste_field_titre($langs->trans("Ref"),"liste.php", "p.ref","&envente=$envente&type=$type"); print_liste_field_titre($langs->trans("Ref"),"liste.php", "e.ref","");
print_liste_field_titre($langs->trans("Label"),"liste.php", "p.label","&envente=$envente&type=$type"); print_liste_field_titre($langs->trans("Label"),"liste.php", "e.label","");
print "<td align=\"right\">Prix de vente</td>"; print_liste_field_titre($langs->trans("Status"),"liste.php", "e.statut","");
print_liste_field_titre($langs->trans("LocationSummary"),"liste.php", "e.lieu","");
print "</tr>\n"; print "</tr>\n";
print '<tr class="liste_titre">'; if ($num) {
print '<form action="liste.php?type='.$type.'" method="post">'; $entrepot=new Entrepot($db);
print '<td><input class="flat" type="text" size="10" name="sref">&nbsp;<input class="flat" type="submit" value="go"></td>';
print '</form><form action="liste.php" method="post">';
print '<td><input class="flat" type="text" size="20" name="snom">&nbsp;<input class="flat" type="submit" value="go"></td>';
print '</form><td>&nbsp;</td></tr>';
$var=True;
$var=True; while ($i < min($num,$limit))
while ($i < min($num,$limit)) {
{ $objp = $db->fetch_object($result);
$objp = $db->fetch_object($result); $var=!$var;
$var=!$var; print "<tr $bc[$var]>";
print "<TR $bc[$var]>"; print '<td><a href="fiche.php?id='.$objp->ref.'">'.img_object($langs->trans("ShowWarehouse"),'stock').' '.$objp->ref.'</a></td>';
print "<TD><a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></TD>\n"; print '<td>'.$objp->label.'</td>';
print "<TD>$objp->label</TD>\n"; print '<td>'.$entrepot->LibStatut($objp->statut).'</td>';
print '<TD align="right">'.price($objp->price).'</TD>'; print '<td>'.$entrepot->lieu.'</td>';
print "</TR>\n"; print "</tr>\n";
$i++; $i++;
}
} }
$db->free($result); $db->free($result);
print "</table>"; print "</table>";

View File

@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "", $title="")
$menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock"));
$menu->add_submenu(DOL_URL_ROOT."/product/stock/fiche.php?action=create", $langs->trans("NewWarehouse")); $menu->add_submenu(DOL_URL_ROOT."/product/stock/fiche.php?action=create", $langs->trans("NewWarehouse"));
$menu->add_submenu(DOL_URL_ROOT."/product/stock/liste.php", $langs->trans("List"));
$menu->add(DOL_URL_ROOT."/product/stock/mouvement.php", $langs->trans("Movements")); $menu->add(DOL_URL_ROOT."/product/stock/mouvement.php", $langs->trans("Movements"));