forked from Wavyzz/dolibarr
Merge pull request #5115 from fappels/develop-new-warehouse-only-internal-status
NEW prepare for additional warehouse statuses
This commit is contained in:
@@ -139,3 +139,7 @@ WarehouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn=Source warehouse must
|
|||||||
InventoryCodeShort=Inv./Mov. code
|
InventoryCodeShort=Inv./Mov. code
|
||||||
NoPendingReceptionOnSupplierOrder=No pending reception due to open supplier order
|
NoPendingReceptionOnSupplierOrder=No pending reception due to open supplier order
|
||||||
ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (<strong>%s</strong>) already exists but with different eatby or sellby date (found <strong>%s</strong> but you enter <strong>%s</strong>).
|
ThisSerialAlreadyExistWithDifferentDate=This lot/serial number (<strong>%s</strong>) already exists but with different eatby or sellby date (found <strong>%s</strong> but you enter <strong>%s</strong>).
|
||||||
|
OpenAll=Open for all actions
|
||||||
|
OpenInternal=Open for internal actions
|
||||||
|
OpenShipping=Open for shippings
|
||||||
|
OpenDispatch=Open for dispatch
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2016 Francis Appels <francis.appels@yahoo.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -53,20 +54,20 @@ class FormProduct
|
|||||||
*
|
*
|
||||||
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
||||||
* @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''.
|
* @param string $batch Add quantity of batch stock in label for product with batch name batch, batch name precedes batch_id. Nothing if ''.
|
||||||
* @param int $fk_product_batch Add quantity of batch stock in label for product with batch id fk_product_batch. Nothing if 0.
|
* @param int $status additional filter on status other then 1
|
||||||
* @param boolean $sumStock sum total stock of a warehouse, default true
|
* @param boolean $sumStock sum total stock of a warehouse, default true
|
||||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||||
*/
|
*/
|
||||||
function loadWarehouses($fk_product=0, $batch = '', $fk_product_batch=0, $sumStock = true)
|
function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product
|
if (empty($fk_product) && count($this->cache_warehouses)) return 0; // Cache already loaded and we do not want a list with information specific to a product
|
||||||
|
|
||||||
$sql = "SELECT e.rowid, e.label";
|
$sql = "SELECT e.rowid, e.label, e.description";
|
||||||
if (!empty($fk_product))
|
if (!empty($fk_product))
|
||||||
{
|
{
|
||||||
if (!empty($fk_product_batch) || !empty($batch))
|
if (!empty($batch))
|
||||||
{
|
{
|
||||||
$sql.= ", pb.qty as stock";
|
$sql.= ", pb.qty as stock";
|
||||||
}
|
}
|
||||||
@@ -87,13 +88,18 @@ class FormProduct
|
|||||||
if (!empty($batch))
|
if (!empty($batch))
|
||||||
{
|
{
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'";
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.batch = '".$batch."'";
|
||||||
} else if (!empty($fk_product_batch))
|
}
|
||||||
{
|
|
||||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_batch as pb on pb.fk_product_stock = ps.rowid AND pb.rowid = '".$fk_product_batch."'";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")";
|
$sql.= " WHERE e.entity IN (".getEntity('stock', 1).")";
|
||||||
$sql.= " AND e.statut = 1";
|
if (!empty($status))
|
||||||
|
{
|
||||||
|
$sql.= " AND e.statut IN (1, ".$status.")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sql.= " AND e.statut = 1";
|
||||||
|
}
|
||||||
|
|
||||||
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description";
|
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description";
|
||||||
$sql.= " ORDER BY e.label";
|
$sql.= " ORDER BY e.label";
|
||||||
|
|
||||||
@@ -127,7 +133,7 @@ class FormProduct
|
|||||||
*
|
*
|
||||||
* @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
|
* @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
|
||||||
* @param string $htmlname Name of html select html
|
* @param string $htmlname Name of html select html
|
||||||
* @param string $filtertype For filter
|
* @param string $filtertype For filter, additional filter on status other then 1
|
||||||
* @param int $empty 1=Can be empty, 0 if not
|
* @param int $empty 1=Can be empty, 0 if not
|
||||||
* @param int $disabled 1=Select is disabled
|
* @param int $disabled 1=Select is disabled
|
||||||
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
* @param int $fk_product Add quantity of stock in label for product with id fk_product. Nothing if 0.
|
||||||
@@ -142,11 +148,11 @@ class FormProduct
|
|||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product",LOG_DEBUG);
|
dol_syslog(get_class($this)."::selectWarehouses $selected, $htmlname, $filtertype, $empty, $disabled, $fk_product, $empty_label, $showstock, $forcecombo, $morecss",LOG_DEBUG);
|
||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
|
|
||||||
$this->loadWarehouses($fk_product);
|
$this->loadWarehouses($fk_product, '', + $filtertype); // filter on numeric status
|
||||||
$nbofwarehouses=count($this->cache_warehouses);
|
$nbofwarehouses=count($this->cache_warehouses);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
|
* Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
|
||||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2016 Francis Appels <francis.appels@yahoo.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -53,6 +54,7 @@ $result=restrictedArea($user,'stock');
|
|||||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||||
$hookmanager->initHooks(array('warehousecard','globalcard'));
|
$hookmanager->initHooks(array('warehousecard','globalcard'));
|
||||||
|
|
||||||
|
$object = new Entrepot($db);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
@@ -61,8 +63,6 @@ $hookmanager->initHooks(array('warehousecard','globalcard'));
|
|||||||
// Ajout entrepot
|
// Ajout entrepot
|
||||||
if ($action == 'add' && $user->rights->stock->creer)
|
if ($action == 'add' && $user->rights->stock->creer)
|
||||||
{
|
{
|
||||||
$object = new Entrepot($db);
|
|
||||||
|
|
||||||
$object->ref = GETPOST("ref");
|
$object->ref = GETPOST("ref");
|
||||||
$object->libelle = GETPOST("libelle");
|
$object->libelle = GETPOST("libelle");
|
||||||
$object->description = GETPOST("desc");
|
$object->description = GETPOST("desc");
|
||||||
@@ -107,7 +107,6 @@ if ($action == 'add' && $user->rights->stock->creer)
|
|||||||
// Delete warehouse
|
// Delete warehouse
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer)
|
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->supprimer)
|
||||||
{
|
{
|
||||||
$object = new Entrepot($db);
|
|
||||||
$object->fetch($_REQUEST["id"]);
|
$object->fetch($_REQUEST["id"]);
|
||||||
$result=$object->delete($user);
|
$result=$object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
@@ -125,7 +124,6 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su
|
|||||||
// Modification entrepot
|
// Modification entrepot
|
||||||
if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
||||||
{
|
{
|
||||||
$object = new Entrepot($db);
|
|
||||||
if ($object->fetch($id))
|
if ($object->fetch($id))
|
||||||
{
|
{
|
||||||
$object->libelle = GETPOST("libelle");
|
$object->libelle = GETPOST("libelle");
|
||||||
@@ -215,11 +213,20 @@ if ($action == 'create')
|
|||||||
print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id');
|
print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id');
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
// Status
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||||
print '<select name="statut" class="flat">';
|
print '<select name="statut" class="flat">';
|
||||||
print '<option value="0">'.$langs->trans("WarehouseClosed").'</option>';
|
foreach ($object->statuts as $key => $value)
|
||||||
print '<option value="1" selected>'.$langs->trans("WarehouseOpened").'</option>';
|
{
|
||||||
|
if ($key == 1)
|
||||||
|
{
|
||||||
|
print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
@@ -558,8 +565,17 @@ else
|
|||||||
|
|
||||||
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">';
|
||||||
print '<select name="statut" class="flat">';
|
print '<select name="statut" class="flat">';
|
||||||
print '<option value="0" '.($object->statut == 0?'selected':'').'>'.$langs->trans("WarehouseClosed").'</option>';
|
foreach ($object->statuts as $key => $value)
|
||||||
print '<option value="1" '.($object->statut == 0?'':'selected').'>'.$langs->trans("WarehouseOpened").'</option>';
|
{
|
||||||
|
if ($key == $object->statut)
|
||||||
|
{
|
||||||
|
print '<option value="'.$key.'" selected>'.$langs->trans($value).'</option>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<option value="'.$key.'">'.$langs->trans($value).'</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2008 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2008 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2016 Francis Appels <francis.appels@yahoo.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -34,18 +35,45 @@ class Entrepot extends CommonObject
|
|||||||
{
|
{
|
||||||
public $element='stock';
|
public $element='stock';
|
||||||
public $table_element='entrepot';
|
public $table_element='entrepot';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warehouse closed, inactive
|
||||||
|
*/
|
||||||
|
const STATUS_CLOSED = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warehouse open and operations for customer shipping, supplier dispatch, internal stock transfers/corrections allowed.
|
||||||
|
*/
|
||||||
|
const STATUS_OPEN_ALL = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warehouse open and operations for stock transfers/corrections allowed (not for customer shipping and supplier dispatch).
|
||||||
|
*/
|
||||||
|
const STATUS_OPEN_INTERNAL = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warehouse open and operations for customer shipping and internal stock transfers/corrections allowed (not for supplier dispatch).
|
||||||
|
*/
|
||||||
|
const STATUS_OPEN_SHIPPING = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Warehouse open and operations for supplier dispatch internal stock transfers/corrections allowed (not for customer shipping).
|
||||||
|
*/
|
||||||
|
const STATUS_OPEN_DISPATCH = 4;
|
||||||
|
|
||||||
|
|
||||||
var $libelle;
|
var $libelle;
|
||||||
var $description;
|
var $description;
|
||||||
//! Statut 1 pour ouvert, 0 pour ferme
|
|
||||||
var $statut;
|
var $statut;
|
||||||
var $lieu;
|
var $lieu;
|
||||||
var $address;
|
var $address;
|
||||||
//! Code Postal
|
//! Code Postal
|
||||||
var $zip;
|
var $zip;
|
||||||
var $town;
|
var $town;
|
||||||
|
|
||||||
|
// List of short language codes for status
|
||||||
|
var $statuts = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@@ -53,11 +81,22 @@ class Entrepot extends CommonObject
|
|||||||
*/
|
*/
|
||||||
function __construct($db)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
// List of short language codes for status
|
$this->statuts[self::STATUS_CLOSED] = 'Closed2';
|
||||||
$this->statuts[0] = 'Closed2';
|
if ($conf->global->ENTREPOT_EXTRA_STATUS)
|
||||||
$this->statuts[1] = 'Opened';
|
{
|
||||||
|
$this->statuts[self::STATUS_OPEN_ALL] = 'OpenAll';
|
||||||
|
$this->statuts[self::STATUS_OPEN_INTERNAL] = 'OpenInternal';
|
||||||
|
$this->statuts[self::STATUS_OPEN_SHIPPING] = 'OpenShipping';
|
||||||
|
$this->statuts[self::STATUS_OPEN_DISPATCH] = 'OpenDispatch';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->statuts[self::STATUS_OPEN_ALL] = 'Opened';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -455,42 +494,40 @@ class Entrepot extends CommonObject
|
|||||||
function LibStatut($statut,$mode=0)
|
function LibStatut($statut,$mode=0)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$langs->load('stocks');
|
$langs->load('stocks');
|
||||||
|
|
||||||
|
$picto = 'statut5';
|
||||||
|
$label = $langs->trans($this->statuts[$statut]);
|
||||||
|
|
||||||
|
|
||||||
if ($mode == 0)
|
if ($mode == 0)
|
||||||
{
|
{
|
||||||
$prefix='';
|
return $label;
|
||||||
if ($statut == 0) return $langs->trans($this->statuts[$statut]);
|
|
||||||
if ($statut == 1) return $langs->trans($this->statuts[$statut]);
|
|
||||||
}
|
}
|
||||||
if ($mode == 1)
|
if ($mode == 1)
|
||||||
{
|
{
|
||||||
$prefix='Short';
|
return $label;
|
||||||
if ($statut == 0) return $langs->trans($this->statuts[$statut]);
|
|
||||||
if ($statut == 1) return $langs->trans($this->statuts[$statut]);
|
|
||||||
}
|
}
|
||||||
if ($mode == 2)
|
if ($mode == 2)
|
||||||
{
|
{
|
||||||
$prefix='Short';
|
if ($statut > 0) $picto = 'statut4';
|
||||||
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]);
|
return img_picto($label, $picto).' '.$label;
|
||||||
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
|
|
||||||
}
|
}
|
||||||
if ($mode == 3)
|
if ($mode == 3)
|
||||||
{
|
{
|
||||||
$prefix='Short';
|
if ($statut > 0) $picto = 'statut4';
|
||||||
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
return img_picto($label, $picto).' '.$label;
|
||||||
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4');
|
|
||||||
}
|
}
|
||||||
if ($mode == 4)
|
if ($mode == 4)
|
||||||
{
|
{
|
||||||
if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]),'statut5').' '.$langs->trans($this->statuts[$statut]);
|
if ($statut > 0) $picto = 'statut4';
|
||||||
if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
|
return img_picto($label, $picto).' '.$label;
|
||||||
}
|
}
|
||||||
if ($mode == 5)
|
if ($mode == 5)
|
||||||
{
|
{
|
||||||
$prefix='Short';
|
if ($statut > 0) $picto = 'statut4';
|
||||||
if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut5');
|
return $label.' '.img_picto($label, $picto);
|
||||||
if ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]),'statut4');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user