Add navigation next/previous in warehous cards
This commit is contained in:
parent
211be07fb1
commit
6ab140f169
@ -19,52 +19,56 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\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 $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\class Entrepot
|
* \class Entrepot
|
||||||
\brief Classe permettant la gestion des entrepots
|
* \brief Classe permettant la gestion des entrepots
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class Entrepot
|
class Entrepot extends CommonObject
|
||||||
{
|
{
|
||||||
var $db;
|
var $db;
|
||||||
var $error;
|
var $error;
|
||||||
|
var $element='label';
|
||||||
|
var $table_element='entrepot';
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $libelle;
|
var $libelle;
|
||||||
var $description;
|
var $description;
|
||||||
//! Statut 1 pour ouvert, 0 pour ferme
|
//! Statut 1 pour ouvert, 0 pour ferme
|
||||||
var $statut;
|
var $statut;
|
||||||
var $lieu;
|
var $lieu;
|
||||||
var $address;
|
var $address;
|
||||||
//! Code Postal
|
//! Code Postal
|
||||||
var $cp;
|
var $cp;
|
||||||
var $ville;
|
var $ville;
|
||||||
var $pays_id;
|
var $pays_id;
|
||||||
|
|
||||||
/*
|
|
||||||
* \brief Constructeur de l'objet entrepot
|
|
||||||
* \param DB Handler d'accès à la base de donnée
|
|
||||||
*/
|
|
||||||
function Entrepot($DB)
|
|
||||||
{
|
|
||||||
global $langs;
|
|
||||||
$this->db = $DB;
|
|
||||||
|
|
||||||
$this->statuts[0] = $langs->trans("Closed2");
|
|
||||||
$this->statuts[1] = $langs->trans("Opened");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Creation d'un entrepot en base
|
* \brief Constructeur de l'objet entrepot
|
||||||
* \param Objet user qui crée l'entrepot
|
* \param DB Handler d'accès à la base de donnée
|
||||||
*/
|
*/
|
||||||
|
function Entrepot($DB)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
$this->db = $DB;
|
||||||
|
|
||||||
|
$this->statuts[0] = $langs->trans("Closed2");
|
||||||
|
$this->statuts[1] = $langs->trans("Opened");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Creation d'un entrepot en base
|
||||||
|
* \param Objet user qui crée l'entrepot
|
||||||
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
// Si libelle non defini, erreur
|
// Si libelle non defini, erreur
|
||||||
@ -116,60 +120,60 @@ class Entrepot
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Mise a jour des information d'un entrepot
|
* \brief Mise a jour des information d'un entrepot
|
||||||
* \param id id de l'entrepot à modifier
|
* \param id id de l'entrepot à modifier
|
||||||
* \param user
|
* \param user
|
||||||
*/
|
*/
|
||||||
function update($id, $user)
|
function update($id, $user)
|
||||||
{
|
|
||||||
$this->libelle=addslashes(trim($this->libelle));
|
|
||||||
$this->description=addslashes(trim($this->description));
|
|
||||||
|
|
||||||
$this->lieu=addslashes(trim($this->lieu));
|
|
||||||
$this->address=addslashes(trim($this->address));
|
|
||||||
$this->cp=trim($this->cp);
|
|
||||||
$this->ville=addslashes(trim($this->ville));
|
|
||||||
$this->pays_id=trim($this->pays_id?$this->pays_id:0);
|
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
|
|
||||||
$sql .= " SET label = '" . $this->libelle ."'";
|
|
||||||
$sql .= ",description = '" . $this->description ."'";
|
|
||||||
$sql .= ",statut = " . $this->statut ;
|
|
||||||
$sql .= ",lieu = '" . $this->lieu ."'";
|
|
||||||
$sql .= ",address = '" . $this->address ."'";
|
|
||||||
$sql .= ",cp = '" . $this->cp ."'";
|
|
||||||
$sql .= ",ville = '" . $this->ville ."'";
|
|
||||||
$sql .= ",fk_pays = " . $this->pays_id;
|
|
||||||
$sql .= " WHERE rowid = " . $id;
|
|
||||||
|
|
||||||
if ( $this->db->query($sql) )
|
|
||||||
{
|
{
|
||||||
|
$this->libelle=addslashes(trim($this->libelle));
|
||||||
|
$this->description=addslashes(trim($this->description));
|
||||||
|
|
||||||
|
$this->lieu=addslashes(trim($this->lieu));
|
||||||
|
$this->address=addslashes(trim($this->address));
|
||||||
|
$this->cp=trim($this->cp);
|
||||||
|
$this->ville=addslashes(trim($this->ville));
|
||||||
|
$this->pays_id=trim($this->pays_id?$this->pays_id:0);
|
||||||
|
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
|
||||||
|
$sql .= " SET label = '" . $this->libelle ."'";
|
||||||
|
$sql .= ",description = '" . $this->description ."'";
|
||||||
|
$sql .= ",statut = " . $this->statut ;
|
||||||
|
$sql .= ",lieu = '" . $this->lieu ."'";
|
||||||
|
$sql .= ",address = '" . $this->address ."'";
|
||||||
|
$sql .= ",cp = '" . $this->cp ."'";
|
||||||
|
$sql .= ",ville = '" . $this->ville ."'";
|
||||||
|
$sql .= ",fk_pays = " . $this->pays_id;
|
||||||
|
$sql .= " WHERE rowid = " . $id;
|
||||||
|
|
||||||
|
if ( $this->db->query($sql) )
|
||||||
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error()." sql=$sql";;
|
$this->error=$this->db->error()." sql=$sql";;
|
||||||
dolibarr_syslog("Entrepot::Update return -1");
|
dolibarr_syslog("Entrepot::Update return -1");
|
||||||
dolibarr_syslog("Entrepot::Update ".$this->error);
|
dolibarr_syslog("Entrepot::Update ".$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Recupéeration de la base d'un entrepot
|
* \brief Recupéeration de la base d'un entrepot
|
||||||
* \param id id de l'entrepot a récupérer
|
* \param id id de l'entrepot a récupérer
|
||||||
*/
|
*/
|
||||||
function fetch ($id)
|
function fetch ($id)
|
||||||
{
|
{
|
||||||
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
$sql = "SELECT rowid, label, description, statut, lieu, address, cp, ville, fk_pays";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||||
$sql .= " WHERE rowid = $id";
|
$sql .= " WHERE rowid = $id";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$obj=$this->db->fetch_object($result);
|
$obj=$this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
@ -184,141 +188,141 @@ class Entrepot
|
|||||||
$this->pays_id = $obj->fk_pays;
|
$this->pays_id = $obj->fk_pays;
|
||||||
|
|
||||||
if ($this->pays_id)
|
if ($this->pays_id)
|
||||||
{
|
{
|
||||||
$sqlp = "SELECT libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$this->pays_id;
|
$sqlp = "SELECT libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$this->pays_id;
|
||||||
$resql=$this->db->query($sqlp);
|
$resql=$this->db->query($sqlp);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$objp = $this->db->fetch_object($resql);
|
$objp = $this->db->fetch_object($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($db);
|
dolibarr_print_error($db);
|
||||||
}
|
}
|
||||||
$this->pays=$objp->libelle;
|
$this->pays=$objp->libelle;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Charge les informations d'ordre info dans l'objet entrepot
|
* \brief Charge les informations d'ordre info dans l'objet entrepot
|
||||||
* \param id id de l'entrepot a charger
|
* \param id id de l'entrepot a charger
|
||||||
*/
|
*/
|
||||||
function info($id)
|
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)
|
|
||||||
{
|
{
|
||||||
|
$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)
|
||||||
|
{
|
||||||
if ($this->db->num_rows($result))
|
if ($this->db->num_rows($result))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
|
|
||||||
if ($obj->fk_user_author) {
|
if ($obj->fk_user_author) {
|
||||||
$cuser = new User($this->db, $obj->fk_user_author);
|
$cuser = new User($this->db, $obj->fk_user_author);
|
||||||
$cuser->fetch();
|
$cuser->fetch();
|
||||||
$this->user_creation = $cuser;
|
$this->user_creation = $cuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($obj->fk_user_valid) {
|
if ($obj->fk_user_valid) {
|
||||||
$vuser = new User($this->db, $obj->fk_user_valid);
|
$vuser = new User($this->db, $obj->fk_user_valid);
|
||||||
$vuser->fetch();
|
$vuser->fetch();
|
||||||
$this->user_validation = $vuser;
|
$this->user_validation = $vuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->date_creation = $obj->datec;
|
$this->date_creation = $obj->datec;
|
||||||
$this->date_modification = $obj->datem;
|
$this->date_modification = $obj->datem;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie la liste des entrepôts ouverts
|
* \brief Renvoie la liste des entrepôts ouverts
|
||||||
*/
|
*/
|
||||||
function list_array()
|
function list_array()
|
||||||
{
|
{
|
||||||
$liste = array();
|
$liste = array();
|
||||||
|
|
||||||
$sql = "SELECT rowid, label";
|
$sql = "SELECT rowid, label";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
|
$sql.= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||||
$sql.= " WHERE statut = 1";
|
$sql.= " WHERE statut = 1";
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
|
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row($i);
|
$row = $this->db->fetch_row($i);
|
||||||
$liste[$row[0]] = $row[1];
|
$liste[$row[0]] = $row[1];
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
}
|
}
|
||||||
return $liste;
|
return $liste;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Renvoie le stock (nombre de produits) de l'entrepot
|
* \brief Renvoie le stock (nombre de produits) de l'entrepot
|
||||||
*/
|
*/
|
||||||
function nb_products()
|
function nb_products()
|
||||||
{
|
{
|
||||||
global $conf,$user;
|
global $conf,$user;
|
||||||
|
|
||||||
$sql = "SELECT sum(ps.reel)";
|
$sql = "SELECT sum(ps.reel)";
|
||||||
$sql .= " FROM llx_product_stock as ps";
|
$sql .= " FROM llx_product_stock as ps";
|
||||||
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
||||||
{
|
{
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON cp.fk_product = p.rowid";
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
||||||
}
|
}
|
||||||
$sql .= " WHERE ps.fk_entrepot = ".$this->id;
|
$sql .= " WHERE ps.fk_entrepot = ".$this->id;
|
||||||
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
if ($conf->categorie->enabled && !$user->rights->categorie->voir)
|
||||||
{
|
{
|
||||||
$sql.= ' AND IFNULL(c.visible,1)=1';
|
$sql.= ' AND IFNULL(c.visible,1)=1';
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->db->query($sql) ;
|
$result = $this->db->query($sql) ;
|
||||||
|
|
||||||
if ( $result )
|
if ( $result )
|
||||||
{
|
{
|
||||||
$row = $this->db->fetch_row(0);
|
$row = $this->db->fetch_row(0);
|
||||||
return $row[0];
|
return $row[0];
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme)
|
* \brief Retourne le libellé du statut d'un entrepot (ouvert, ferme)
|
||||||
|
|||||||
@ -37,6 +37,8 @@ $mesg = '';
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader("","",$langs->trans("WarehouseCard"));
|
llxHeader("","",$langs->trans("WarehouseCard"));
|
||||||
|
|
||||||
if ($_GET["id"])
|
if ($_GET["id"])
|
||||||
@ -82,12 +84,14 @@ if ($_GET["id"])
|
|||||||
$head[$h][1] = $langs->trans("Info");
|
$head[$h][1] = $langs->trans("Info");
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse"));
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
|
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($entrepot,'id','',1,'rowid','libelle');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -20,10 +20,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/product/stock/fiche.php
|
* \file htdocs/product/stock/fiche.php
|
||||||
\ingroup stock
|
* \ingroup stock
|
||||||
\brief Page fiche entrepot
|
* \brief Page fiche entrepot
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
@ -123,9 +123,10 @@ if ($_POST["cancel"] == $langs->trans("Cancel"))
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader("","",$langs->trans("WarehouseCard"));
|
llxHeader("","",$langs->trans("WarehouseCard"));
|
||||||
|
|
||||||
$form=new Form($db);
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'create')
|
if ($_GET["action"] == 'create')
|
||||||
{
|
{
|
||||||
@ -235,12 +236,14 @@ else
|
|||||||
$head[$h][1] = $langs->trans("Info");
|
$head[$h][1] = $langs->trans("Info");
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse"));
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
|
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($entrepot,'id','',1,'rowid','libelle');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,11 @@ if (! $sortfield) $sortfield="m.datem";
|
|||||||
if (! $sortorder) $sortorder="DESC";
|
if (! $sortorder) $sortorder="DESC";
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
|
|
||||||
$sql = "SELECT p.rowid, p.label as produit,";
|
$sql = "SELECT p.rowid, p.label as produit,";
|
||||||
$sql.= " s.label as stock, s.rowid as entrepot_id,";
|
$sql.= " s.label as stock, s.rowid as entrepot_id,";
|
||||||
@ -116,12 +121,14 @@ if ($resql)
|
|||||||
$head[$h][1] = $langs->trans("Info");
|
$head[$h][1] = $langs->trans("Info");
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse").': '.$entrepot->libelle);
|
dolibarr_fiche_head($head, $hselected, $langs->trans("Warehouse"));
|
||||||
|
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
// Ref
|
// Ref
|
||||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">'.$entrepot->libelle.'</td>';
|
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
||||||
|
print $form->showrefnav($entrepot,'id','',1,'rowid','libelle');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user