Qual: Factorize some code.

Look: Add picto for warehouse on stock tabs.
This commit is contained in:
Laurent Destailleur 2009-07-29 19:02:04 +00:00
parent f63e31cbf5
commit 1ce9e4b884
7 changed files with 115 additions and 167 deletions

75
htdocs/lib/stock.lib.php Normal file
View File

@ -0,0 +1,75 @@
<?php
/* Copyright (C) 2009 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.
* 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;
}
?>

View File

@ -25,6 +25,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php");
$langs->load("products"); $langs->load("products");
$langs->load("stocks"); $langs->load("stocks");
@ -52,39 +53,11 @@ if ($_GET["id"])
dol_print_error($db); dol_print_error($db);
} }
/*
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; $head = stock_prepare_head($entrepot);
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id; dol_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
$head[$h][1] = $langs->trans("StockMovements");
$h++;
$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 '<table class="border" width="100%">'; print '<table class="border" width="100%">';
@ -137,7 +110,7 @@ if ($_GET["id"])
print "<div class=\"graph\">\n"; print "<div class=\"graph\">\n";
$year = strftime("%Y",time()); $year = strftime("%Y",time());
$file=DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year).'.png'; $file=$conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
// TODO Build graph in $file from a table called llx_stock_log // TODO Build graph in $file from a table called llx_stock_log

View File

@ -27,6 +27,7 @@
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php");
@ -208,40 +209,10 @@ else
*/ */
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{ {
$head = stock_prepare_head($entrepot);
/* dol_fiche_head($head, 'card', $langs->trans("Warehouse"), 0, 'stock');
* 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/mouvement.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("StockMovements");
$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 '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -25,6 +25,7 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php");
$langs->load("stocks"); $langs->load("stocks");
@ -38,36 +39,9 @@ $entrepot = new Entrepot($db);
$entrepot->fetch($_GET["id"]); $entrepot->fetch($_GET["id"]);
$entrepot->info($_GET["id"]); $entrepot->info($_GET["id"]);
$h = 0; $head = stock_prepare_head($entrepot);
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; dol_fiche_head($head, 'info', $langs->trans("Warehouse"), 0, 'stock');
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("StockMovements");
$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");
$hselected=$h;
$h++;
dol_fiche_head($head, $hselected, $langs->trans("Warehouse"));
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';

View File

@ -27,10 +27,12 @@
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/product.class.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."/lib/product.lib.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php"); require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$langs->load("products"); $langs->load("products");
$langs->load("stocks");
if (!$user->rights->produit->lire) accessforbidden(); if (!$user->rights->produit->lire) accessforbidden();
@ -126,36 +128,10 @@ if ($resql)
*/ */
if ($_GET["id"]) if ($_GET["id"])
{ {
$h = 0; $head = stock_prepare_head($entrepot);
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; dol_fiche_head($head, 'movements', $langs->trans("Warehouse"), 0, 'stock');
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$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 '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -20,13 +20,15 @@
*/ */
/** /**
\file htdocs/product/stock/user.php * \file htdocs/product/stock/user.php
\ingroup stock * \ingroup stock
\brief Page to link dolibarr users with warehouses * \brief Page to link dolibarr users with warehouses
\version $Id$ * \version $Id$
*/ */
require("./pre.inc.php"); require("./pre.inc.php");
require_once(DOL_DOCUMENT_ROOT."/lib/stock.lib.php");
$langs->load("products"); $langs->load("products");
$langs->load("stocks"); $langs->load("stocks");
@ -74,33 +76,10 @@ if ($_GET["id"])
if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit') if ($_GET["action"] <> 'edit' && $_GET["action"] <> 're-edit')
{ {
/* $head = stock_prepare_head($entrepot);
* Affichage onglets
*/
$h = 0;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche.php?id='.$entrepot->id; dol_fiche_head($head, 'user', $langs->trans("Warehouse"), 0, 'stock');
$head[$h][1] = $langs->trans("WarehouseCard");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/mouvement.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("StockMovements");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/fiche-valo.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("EnhancedValue");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/product/stock/user.php?id='.$entrepot->id;
$head[$h][1] = $langs->trans("Users");
$hselected=$h;
$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").': '.$entrepot->libelle);
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';