NEW add minimum stock filter in load warehoues for product form
This commit is contained in:
parent
66a9fabd06
commit
6a734ea828
@ -1262,7 +1262,13 @@ if ($action == 'create')
|
|||||||
if ($line->fk_product > 0)
|
if ($line->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<!-- Show warehouse selection -->';
|
print '<!-- Show warehouse selection -->';
|
||||||
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1);
|
|
||||||
|
$stockMin = false;
|
||||||
|
if (empty($conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER)) {
|
||||||
|
$stockMin = 0;
|
||||||
|
}
|
||||||
|
print $formproduct->selectWarehouses($tmpentrepot_id, 'entl'.$indiceAsked, '', 1, 0, $line->fk_product, '', 1, 0, array(), 'minwidth200', '', 1, $stockMin, 'stock DESC, e.ref');
|
||||||
|
|
||||||
if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id)
|
if ($tmpentrepot_id > 0 && $tmpentrepot_id == $warehouse_id)
|
||||||
{
|
{
|
||||||
//print $stock.' '.$quantityToBeDelivered;
|
//print $stock.' '.$quantityToBeDelivered;
|
||||||
|
|||||||
@ -66,10 +66,13 @@ class FormProduct
|
|||||||
* 'warehouseclosed' = select products from closed warehouses,
|
* 'warehouseclosed' = select products from closed warehouses,
|
||||||
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only
|
* 'warehouseinternal' = select products from warehouses for internal correct/transfer only
|
||||||
* @param boolean $sumStock sum total stock of a warehouse, default true
|
* @param boolean $sumStock sum total stock of a warehouse, default true
|
||||||
* @param array $exclude warehouses ids to exclude
|
* @param string $exclude warehouses ids to exclude
|
||||||
|
* @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock
|
||||||
|
* @param string $orderBy [='e.ref'] Order by
|
||||||
* @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
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '')
|
public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '', $stockMin = false, $orderBy = 'e.ref')
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
@ -130,8 +133,26 @@ class FormProduct
|
|||||||
|
|
||||||
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')';
|
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.$this->db->escape(implode(',', $exclude)).')';
|
||||||
|
|
||||||
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
|
// minimum stock
|
||||||
$sql.= " ORDER BY e.ref";
|
if ($stockMin !== false) {
|
||||||
|
if (!empty($fk_product)) {
|
||||||
|
if (!empty($batch)) {
|
||||||
|
$sql .= " AND pb.qty > " . $this->db->escape($stockMin);
|
||||||
|
} else {
|
||||||
|
$sql .= " AND ps.reel > " . $this->db->escape($stockMin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sumStock && empty($fk_product)) {
|
||||||
|
$sql.= " GROUP BY e.rowid, e.ref, e.description, e.fk_parent";
|
||||||
|
|
||||||
|
// minimum stock
|
||||||
|
if ($stockMin !== false) {
|
||||||
|
$sql .= " HAVING sum(ps.reel) > " . $this->db->escape($stockMin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sql.= " ORDER BY " . $orderBy;
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
|
dol_syslog(get_class($this).'::loadWarehouses', LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -192,7 +213,7 @@ class FormProduct
|
|||||||
/**
|
/**
|
||||||
* Return list of warehouses
|
* Return list of warehouses
|
||||||
*
|
*
|
||||||
* @param int $selected Id of preselected warehouse ('' for no value, 'ifone'=select value if one value otherwise no value)
|
* @param string|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 $filterstatus warehouse status filter, following comma separated filter options can be used
|
* @param string $filterstatus warehouse status filter, following comma separated filter options can be used
|
||||||
* 'warehouseopen' = select products from open warehouses,
|
* 'warehouseopen' = select products from open warehouses,
|
||||||
@ -206,11 +227,15 @@ class FormProduct
|
|||||||
* @param int $forcecombo 1=Force combo iso ajax select2
|
* @param int $forcecombo 1=Force combo iso ajax select2
|
||||||
* @param array $events Events to add to select2
|
* @param array $events Events to add to select2
|
||||||
* @param string $morecss Add more css classes to HTML select
|
* @param string $morecss Add more css classes to HTML select
|
||||||
* @param array $exclude Warehouses ids to exclude
|
* @param string $exclude Warehouses ids to exclude
|
||||||
* @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
|
* @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse
|
||||||
|
* @param bool|int $stockMin [=false] Value of minimum stock to filter or false not not filter by minimum stock
|
||||||
|
* @param string $orderBy [='e.ref'] Order by
|
||||||
* @return string HTML select
|
* @return string HTML select
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1)
|
public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1, $stockMin = false, $orderBy = 'e.ref')
|
||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
|
|
||||||
@ -218,7 +243,7 @@ class FormProduct
|
|||||||
|
|
||||||
$out='';
|
$out='';
|
||||||
if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = '';
|
if (empty($conf->global->ENTREPOT_EXTRA_STATUS)) $filterstatus = '';
|
||||||
$this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude);
|
$this->loadWarehouses($fk_product, '', $filterstatus, true, $exclude, $stockMin, $orderBy);
|
||||||
$nbofwarehouses=count($this->cache_warehouses);
|
$nbofwarehouses=count($this->cache_warehouses);
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user