Am閘ioration de la gestion des stocks: Ajout de la localisation (adresse) d'un entrepot et ajout de l'onglet info
This commit is contained in:
parent
faca581285
commit
a57cdec131
@ -9,5 +9,10 @@ Stocks=Stocks
|
||||
Movement=Movement
|
||||
Movements=Movements
|
||||
CorrectStock=Correct stock
|
||||
ListOfWarehouses=List of warehouses
|
||||
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
|
||||
@ -9,5 +9,10 @@ Stocks=Stocks
|
||||
Movement=Mouvement
|
||||
Movements=Mouvements
|
||||
CorrectStock=Corriger stock
|
||||
ListOfWarehouses=Liste des entrep么ts
|
||||
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
|
||||
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-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
|
||||
@ -21,7 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/product/stock/entrepot.class.php
|
||||
/**
|
||||
\file htdocs/product/stock/entrepot.class.php
|
||||
\ingroup stock
|
||||
\brief Fichier de la classe de gestion des entrepots
|
||||
\version $Revision$
|
||||
@ -34,12 +35,18 @@
|
||||
|
||||
class Entrepot
|
||||
{
|
||||
var $db ;
|
||||
|
||||
var $id ;
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
var $id;
|
||||
var $libelle;
|
||||
var $description;
|
||||
var $statut;
|
||||
var $lieu;
|
||||
var $address;
|
||||
var $cp;
|
||||
var $ville;
|
||||
var $pays_id;
|
||||
|
||||
/*
|
||||
* \brief Constructeur de l'objet entrepot
|
||||
@ -62,23 +69,24 @@ class Entrepot
|
||||
{
|
||||
// Si libelle non defini, erreur
|
||||
if ($this->libelle == '') {
|
||||
$this->mesg_error = "Libell茅 obligatoire";
|
||||
$this->error = "Libell茅 obligatoire";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($this->db->begin())
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (datec, fk_user_author)";
|
||||
$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");
|
||||
if ($id > 0)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
if ( $this->update($id, $user) )
|
||||
if ( $this->update($id, $user) > 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $id;
|
||||
@ -86,16 +94,21 @@ class Entrepot
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -3;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
$this->error="Failed to get insert id";
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Failed to insert warehouse";
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -105,13 +118,25 @@ class Entrepot
|
||||
*/
|
||||
function update($id, $user)
|
||||
{
|
||||
if (strlen(trim($this->libelle)))
|
||||
{
|
||||
$this->libelle=trim($this->libelle);
|
||||
$this->description=trim($this->description);
|
||||
|
||||
$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 = '" . trim($this->libelle) ."'";
|
||||
$sql .= ",description = '" . trim($this->description) ."'";
|
||||
$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;
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
@ -120,15 +145,11 @@ class Entrepot
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error()." sql=$sql";;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->mesg_error = "Vous devez indiquer une r茅f茅rence";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Recup茅eration de la base d'un entrepot
|
||||
@ -136,30 +157,84 @@ class Entrepot
|
||||
*/
|
||||
function fetch ($id)
|
||||
{
|
||||
$sql = "SELECT rowid, label, description, statut";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot WHERE rowid = $id";
|
||||
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||
$sql .= " WHERE rowid = $id";
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj=$this->db->fetch_object($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;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
|
||||
if ( $result )
|
||||
/*
|
||||
* \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->ref = $result["ref"];
|
||||
$this->libelle = stripslashes($result["label"]);
|
||||
$this->description = stripslashes($result["description"]);
|
||||
$this->statut = $result["statut"];
|
||||
$this->id = $obj->rowid;
|
||||
|
||||
if ($obj->fk_user_author) {
|
||||
$cuser = new User($this->db, $obj->fk_user_author);
|
||||
$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
|
||||
{
|
||||
print $this->db->error();
|
||||
return -1;
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Renvoie la liste des entrep么ts ouverts
|
||||
|
||||
@ -37,50 +37,69 @@ $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 = $_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) {
|
||||
$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 {
|
||||
$mesg="<div class='error'>".$langs->trans("ErrorWarehouseLabelRequired")."</div>";
|
||||
$mesg="<div class='error'>".$langs->trans("ErrorWarehouseLabelRequired")."</div>";
|
||||
$_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($_GET["id"]))
|
||||
$entrepot = new Entrepot($db);
|
||||
if ($entrepot->fetch($_POST["id"]))
|
||||
{
|
||||
$entrepot->libelle = $_POST["libelle"];
|
||||
$entrepot->description = $_POST["desc"];
|
||||
$entrepot->statut = $_POST["statut"];
|
||||
|
||||
if ( $entrepot->update($_GET["id"], $user))
|
||||
{
|
||||
$_GET["cancel"] = '';
|
||||
$mesg = 'Fiche mise 脿 jour';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_GET["cancel"] = 're-edit';
|
||||
$mesg = 'Fiche non mise 脿 jour !' . "<br>" . $entrepot->mesg_error;
|
||||
}
|
||||
$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 = '<div class="ok">Fiche mise 脿 jour</div>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_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';
|
||||
$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>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,114 +107,169 @@ if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
||||
|
||||
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')
|
||||
{
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
|
||||
print_titre($langs->trans("NewWarehouse"));
|
||||
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
}
|
||||
|
||||
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%" valign="top">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print "</textarea></td></tr>";
|
||||
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>';
|
||||
print '<select name="statut">';
|
||||
print '<option value="0" selected>'.$langs->trans("WarehouseClosed").'</option><option value="1">'.$langs->trans("WarehouseOpened").'</option>';
|
||||
print '</td></tr>';
|
||||
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print "<form action=\"fiche.php\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
|
||||
print_titre($langs->trans("NewWarehouse"));
|
||||
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
}
|
||||
|
||||
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%" valign="top">'.$langs->trans("Description").'</td><td>';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print "</textarea></td></tr>";
|
||||
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td>';
|
||||
print '<select name="statut">';
|
||||
print '<option value="0" selected>'.$langs->trans("WarehouseClosed").'</option><option value="1">'.$langs->trans("WarehouseOpened").'</option>';
|
||||
print '</td></tr>';
|
||||
print '<tr><td> </td><td><input type="submit" value="'.$langs->trans("Create").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($_GET["id"])
|
||||
if ($_GET["id"])
|
||||
{
|
||||
if ($_GET["action"] <> 're-edit')
|
||||
{
|
||||
$entrepot = new Entrepot($db);
|
||||
$result = $entrepot->fetch($_GET["id"]);
|
||||
}
|
||||
|
||||
if ( $result )
|
||||
{
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
print_fiche_titre('Fiche entrepot', $mesg);
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td width="20%">'.$langs->trans("Label").'</td><td>'.$entrepot->libelle.'</td>';
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($entrepot->description).'</td></tr>';
|
||||
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>';
|
||||
print $entrepot->nb_products();
|
||||
print "</td></tr>";
|
||||
print "</table>";
|
||||
}
|
||||
}
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
}
|
||||
|
||||
|
||||
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1)
|
||||
{
|
||||
print_fiche_titre('Edition de la fiche entrepot', $mesg);
|
||||
$entrepot = new Entrepot($db);
|
||||
$result = $entrepot->fetch($_GET["id"]);
|
||||
if (! $result)
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print "<form action=\"fiche.php?id=$entrepot->id\" method=\"post\">\n";
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
|
||||
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 valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||
print '<textarea name="desc" rows="8" cols="50">';
|
||||
print $entrepot->description;
|
||||
print "</textarea></td></tr>";
|
||||
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="2">';
|
||||
print '<select name="statut">';
|
||||
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 '</select>';
|
||||
print '</td></tr>';
|
||||
/*
|
||||
* Affichage fiche
|
||||
*/
|
||||
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
|
||||
{
|
||||
|
||||
print "<tr>".'<td colspan="3" align="center"><input type="submit" value="'.$langs->trans("Save").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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->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";
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Edition fiche
|
||||
*/
|
||||
if (($_GET["action"] == 'edit' || $_GET["action"] == 're-edit') && 1)
|
||||
{
|
||||
print_fiche_titre('Edition de la fiche entrepot', $mesg);
|
||||
|
||||
print '<form action="fiche.php" method="POST">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$entrepot->id.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
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="3">';
|
||||
print '<textarea name="desc" rows="4" cols="60">';
|
||||
print $entrepot->description;
|
||||
print "</textarea></td></tr>";
|
||||
print '<tr><td width="20%">'.$langs->trans("Status").'</td><td colspan="3">';
|
||||
print '<select name="statut">';
|
||||
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 '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td width="20%">'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$entrepot->lieu.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="address" cols="40" rows="3" wrap="soft">';
|
||||
print $entrepot->address;
|
||||
print '</textarea></td></tr>';
|
||||
|
||||
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>';
|
||||
|
||||
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").'"> ';
|
||||
print '<input type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* */
|
||||
/* Barre d'action */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
print "<br><div class=\"tabsAction\">\n";
|
||||
print "<div class=\"tabsAction\">\n";
|
||||
|
||||
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>";
|
||||
|
||||
@ -31,19 +31,37 @@
|
||||
require_once("./pre.inc.php");
|
||||
require_once("./entrepot.class.php");
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
$user->getrights("stocks");
|
||||
$langs->load("stocks");
|
||||
|
||||
if (!$user->rights->stock->lire)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
llxHeader("","",$langs->trans("Stocks"));
|
||||
|
||||
print_titre($langs->trans("Stocks"));
|
||||
print_titre($langs->trans("StocksArea"));
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
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 .= " ORDER BY e.statut DESC ";
|
||||
$sql .= $db->plimit(15 ,0);
|
||||
@ -51,37 +69,36 @@ $result = $db->query($sql) ;
|
||||
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ($num > 0)
|
||||
$i = 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);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
$entrepot=new Entrepot($db);
|
||||
|
||||
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);
|
||||
$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
|
||||
{
|
||||
dolibarr_print_error($db);
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
print '</td><td valign="top" width="70%">';
|
||||
|
||||
73
htdocs/product/stock/info.php
Normal file
73
htdocs/product/stock/info.php
Normal 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ère modification $Date$ révision $Revision$</em>");
|
||||
?>
|
||||
@ -21,77 +21,34 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file htdocs/product/stock/liste.php
|
||||
/**
|
||||
\file htdocs/product/stock/liste.php
|
||||
\ingroup stock
|
||||
\brief Page liste des stocks
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
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();
|
||||
|
||||
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;
|
||||
$offset = $limit * $page ;
|
||||
|
||||
if ($sortfield == "") {
|
||||
$sortfield="p.tms"; }
|
||||
|
||||
if ($sortorder == "")
|
||||
{
|
||||
$sortorder="DESC";
|
||||
}
|
||||
if (! $sortfield) $sortfield="e.label";
|
||||
if (! $sortorder) $sortorder="ASC";
|
||||
|
||||
|
||||
$sql = "SELECT p.rowid, p.label, p.price, p.ref FROM llx_product as p";
|
||||
|
||||
if ($_POST["sall"])
|
||||
{
|
||||
$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 = "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";
|
||||
$sql .= " ORDER BY $sortfield $sortorder";
|
||||
$sql .= $db->plimit($limit + 1 ,$offset);
|
||||
$result = $db->query($sql) ;
|
||||
|
||||
@ -101,57 +58,37 @@ if ($result)
|
||||
|
||||
$i = 0;
|
||||
|
||||
if ($num == 1 && (isset($sall) or isset($snom) or isset($sref)))
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
Header("Location: fiche.php?id=$objp->rowid");
|
||||
}
|
||||
|
||||
if ($ref || $snom || $sall)
|
||||
{
|
||||
llxHeader("","","Recherche Produit/Service");
|
||||
llxHeader("","",$langs->trans("ListOfWarehouses"));
|
||||
|
||||
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_barre_liste($langs->trans("ListOfWarehouses"), $page, "liste.php", "", $sortfield, $sortorder,'',$num);
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
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("Label"),"liste.php", "p.label","&envente=$envente&type=$type");
|
||||
print "<td align=\"right\">Prix de vente</td>";
|
||||
print_liste_field_titre($langs->trans("Ref"),"liste.php", "e.ref","");
|
||||
print_liste_field_titre($langs->trans("Label"),"liste.php", "e.label","");
|
||||
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 class="liste_titre">';
|
||||
print '<form action="liste.php?type='.$type.'" method="post">';
|
||||
print '<td><input class="flat" type="text" size="10" name="sref"> <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"> <input class="flat" type="submit" value="go"></td>';
|
||||
print '</form><td> </td></tr>';
|
||||
|
||||
|
||||
$var=True;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print "<TD><a href=\"fiche.php?id=$objp->rowid\">$objp->ref</a></TD>\n";
|
||||
print "<TD>$objp->label</TD>\n";
|
||||
print '<TD align="right">'.price($objp->price).'</TD>';
|
||||
print "</TR>\n";
|
||||
$i++;
|
||||
if ($num) {
|
||||
$entrepot=new Entrepot($db);
|
||||
|
||||
$var=True;
|
||||
while ($i < min($num,$limit))
|
||||
{
|
||||
$objp = $db->fetch_object($result);
|
||||
$var=!$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>'.$objp->label.'</td>';
|
||||
print '<td>'.$entrepot->LibStatut($objp->statut).'</td>';
|
||||
print '<td>'.$entrepot->lieu.'</td>';
|
||||
print "</tr>\n";
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$db->free($result);
|
||||
|
||||
print "</table>";
|
||||
|
||||
@ -41,6 +41,7 @@ function llxHeader($head = "", $urlp = "", $title="")
|
||||
$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/liste.php", $langs->trans("List"));
|
||||
|
||||
$menu->add(DOL_URL_ROOT."/product/stock/mouvement.php", $langs->trans("Movements"));
|
||||
|
||||
|
||||
Loading鈥
Reference in New Issue
Block a user