diff --git a/htdocs/lib/stock.lib.php b/htdocs/lib/stock.lib.php new file mode 100644 index 00000000000..2b7c76f37ae --- /dev/null +++ b/htdocs/lib/stock.lib.php @@ -0,0 +1,75 @@ + + * + * 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. + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/lib/stock.lib.php + * \brief Library file with function for stock module + * \version $Id$ + */ + +/** + * Enter description here... + * + * @param unknown_type $contrat + * @return unknown + */ +function stock_prepare_head($entrepot) +{ + global $langs, $conf; + + $h = 0; + $head = array(); + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("WarehouseCard"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("StockMovements"); + $head[$h][2] = 'movements'; + $h++; + + /* + $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("EnhancedValue"); + $head[$h][2] = 'value'; + $h++; + */ + + if ($conf->global->STOCK_USE_WAREHOUSE_BY_USER) + { + // Add the constant STOCK_USE_WAREHOUSE_BY_USER in cont table to use this feature. + // Should not be enabled by defaut because does not work yet correctly because + // there is no way to add values in the table llx_user_entrepot + $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("Users"); + $head[$h][2] = 'user'; + $h++; + } + + $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; + $head[$h][1] = $langs->trans("Info"); + $head[$h][2] = 'info'; + $h++; + + return $head; +} + +?> \ No newline at end of file diff --git a/htdocs/product/stock/entrepot.class.php b/htdocs/product/stock/entrepot.class.php index 324bfe7f8e5..c1dc2061fb3 100644 --- a/htdocs/product/stock/entrepot.class.php +++ b/htdocs/product/stock/entrepot.class.php @@ -228,30 +228,30 @@ class Entrepot extends CommonObject $result=$this->db->query($sql); if ($result) { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $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_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; - } + 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->date_creation = $obj->datec; + $this->date_modification = $obj->datem; - } + } - $this->db->free($result); + $this->db->free($result); } else diff --git a/htdocs/product/stock/fiche-valo.php b/htdocs/product/stock/fiche-valo.php index deb59397d33..1817e6a42ed 100644 --- a/htdocs/product/stock/fiche-valo.php +++ b/htdocs/product/stock/fiche-valo.php @@ -25,6 +25,7 @@ */ require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php"); $langs->load("products"); $langs->load("stocks"); @@ -52,39 +53,11 @@ if ($_GET["id"]) dol_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"); - $h++; + $head = stock_prepare_head($entrepot); - $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("StockMovements"); - $h++; + dol_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock'); - $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("EnhancedValue"); - $hselected=$h; - $h++; - - if ($conf->global->STOCK_USE_WAREHOUSE_BY_USER) - { - // Add the constant STOCK_USE_WAREHOUSE_BY_USER in cont table to use this feature. - // Should not be enabled by defaut because does not work yet correctly because - // there is no way to add values in the table llx_user_entrepot - $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("Users"); - $h++; - } - - $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id; - $head[$h][1] = $langs->trans("Info"); - $h++; - - dol_fiche_head($head, $hselected, $langs->trans("Warehouse")); print '
| ';
diff --git a/htdocs/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php
index ce2c29bbbe4..5bc526c7ca8 100644
--- a/htdocs/product/stock/mouvement.php
+++ b/htdocs/product/stock/mouvement.php
@@ -27,10 +27,12 @@
require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
+require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$langs->load("products");
+$langs->load("stocks");
if (!$user->rights->produit->lire) accessforbidden();
@@ -126,36 +128,10 @@ if ($resql)
*/
if ($_GET["id"])
{
- $h = 0;
+ $head = stock_prepare_head($entrepot);
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("WarehouseCard");
- $h++;
+ dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock');
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("StockMovements");
- $hselected=$h;
- $h++;
-
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("EnhancedValue");
- $h++;
-
- if ($conf->global->STOCK_USE_WAREHOUSE_BY_USER)
- {
- // Add the constant STOCK_USE_WAREHOUSE_BY_USER in cont table to use this feature.
- // Should not be enabled by defaut because does not work yet correctly because
- // there is no way to add values in the table llx_user_entrepot
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("Users");
- $h++;
- }
-
- $head[$h][0] = DOL_URL_ROOT.'/product/stock/info.php?id='.$entrepot->id;
- $head[$h][1] = $langs->trans("Info");
- $h++;
-
- dol_fiche_head($head, $hselected, $langs->trans("Warehouse"));
print ' |