NEW : allow to save a parent warehouse
# Conflicts: # htdocs/product/stock/card.php
This commit is contained in:
parent
d78f204fb6
commit
416311a7b9
@ -135,3 +135,5 @@ ALTER TABLE llx_accounting_bookkeeping ADD COLUMN tms timestamp;
|
||||
ALTER TABLE llx_accounting_account ADD INDEX uk_accounting_account (account_number, entity);
|
||||
|
||||
ALTER TABLE llx_c_payment_term change fdm type_cdr tinyint
|
||||
|
||||
ALTER TABLE llx_entrepot ADD COLUMN fk_parent integer DEFAULT NULL
|
||||
|
||||
@ -34,5 +34,6 @@ create table llx_entrepot
|
||||
fk_pays integer DEFAULT 0,
|
||||
statut tinyint DEFAULT 1, -- 1 open, 0 close
|
||||
fk_user_author integer,
|
||||
import_key varchar(14)
|
||||
import_key varchar(14),
|
||||
fk_parent integer DEFAULT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
WarehouseCard=Warehouse card
|
||||
Warehouse=Warehouse
|
||||
Warehouses=Warehouses
|
||||
ParentWarehouse=Parent warehouse
|
||||
NewWarehouse=New warehouse / Stock area
|
||||
WarehouseEdit=Modify warehouse
|
||||
MenuNewWarehouse=New warehouse
|
||||
|
||||
@ -58,12 +58,14 @@ class FormProduct
|
||||
* @param boolean $sumStock sum total stock of a warehouse, default true
|
||||
* @return int Nb of loaded lines, 0 if already loaded, <0 if KO
|
||||
*/
|
||||
function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true)
|
||||
function loadWarehouses($fk_product=0, $batch = '', $status=null, $sumStock = true, $exclude='')
|
||||
{
|
||||
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 (is_array($exclude)) $excludeGroups = implode("','",$exclude);
|
||||
|
||||
$sql = "SELECT e.rowid, e.label, e.description";
|
||||
if (!empty($fk_product))
|
||||
{
|
||||
@ -100,6 +102,8 @@ class FormProduct
|
||||
$sql.= " AND e.statut = 1";
|
||||
}
|
||||
|
||||
if(!empty($exclude)) $sql.= ' AND e.rowid NOT IN('.implode(',', $exclude).')';
|
||||
|
||||
if ($sumStock && empty($fk_product)) $sql.= " GROUP BY e.rowid, e.label, e.description";
|
||||
$sql.= " ORDER BY e.label";
|
||||
|
||||
@ -144,7 +148,7 @@ class FormProduct
|
||||
* @param string $morecss Add more css classes
|
||||
* @return string HTML select
|
||||
*/
|
||||
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200')
|
||||
function selectWarehouses($selected='',$htmlname='idwarehouse',$filtertype='',$empty=0,$disabled=0,$fk_product=0,$empty_label='', $showstock=0, $forcecombo=0, $events=array(), $morecss='minwidth200', $exclude='')
|
||||
{
|
||||
global $conf,$langs,$user;
|
||||
|
||||
@ -152,7 +156,7 @@ class FormProduct
|
||||
|
||||
$out='';
|
||||
|
||||
$this->loadWarehouses($fk_product, '', + $filtertype); // filter on numeric status
|
||||
$this->loadWarehouses($fk_product, '', + $filtertype, true, $exclude); // filter on numeric status
|
||||
$nbofwarehouses=count($this->cache_warehouses);
|
||||
|
||||
if ($conf->use_javascript_ajax && ! $forcecombo)
|
||||
|
||||
@ -31,10 +31,12 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
|
||||
|
||||
$langs->load("products");
|
||||
$langs->load("stocks");
|
||||
$langs->load("companies");
|
||||
$langs->load("categories");
|
||||
|
||||
$action=GETPOST('action');
|
||||
$cancel=GETPOST('cancel');
|
||||
@ -64,6 +66,7 @@ $object = new Entrepot($db);
|
||||
if ($action == 'add' && $user->rights->stock->creer)
|
||||
{
|
||||
$object->ref = GETPOST("ref");
|
||||
$object->fk_parent = GETPOST("fk_parent");
|
||||
$object->libelle = GETPOST("libelle");
|
||||
$object->description = GETPOST("desc");
|
||||
$object->statut = GETPOST("statut");
|
||||
@ -128,6 +131,7 @@ if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
|
||||
if ($object->fetch($id))
|
||||
{
|
||||
$object->libelle = GETPOST("libelle");
|
||||
$object->fk_parent = GETPOST("fk_parent");
|
||||
$object->description = GETPOST("desc");
|
||||
$object->statut = GETPOST("statut");
|
||||
$object->lieu = GETPOST("lieu");
|
||||
@ -166,6 +170,7 @@ if ($cancel == $langs->trans("Cancel"))
|
||||
|
||||
$productstatic=new Product($db);
|
||||
$form=new Form($db);
|
||||
$formproduct=new FormProduct($db);
|
||||
$formcompany=new FormCompany($db);
|
||||
|
||||
$help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
|
||||
@ -189,6 +194,11 @@ if ($action == 'create')
|
||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value=""></td></tr>';
|
||||
|
||||
print '<tr><td >'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.(!empty($object->lieu)?$object->lieu:'').'"></td></tr>';
|
||||
|
||||
// Parent entrepot
|
||||
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
|
||||
print $formproduct->selectWarehouses('', 'fk_parent', '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Description
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
|
||||
@ -346,6 +356,16 @@ else
|
||||
|
||||
//print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$object->lieu.'</td></tr>';
|
||||
|
||||
// Parent entrepot
|
||||
$e = new Entrepot($db);
|
||||
if(!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
|
||||
|
||||
print '<tr><td>'.$langs->trans("ParentWarehouse").'</td><td>';
|
||||
print $e->getNomUrl(3);
|
||||
print '</td></tr>';
|
||||
|
||||
}
|
||||
|
||||
// Description
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>'.nl2br($object->description).'</td></tr>';
|
||||
|
||||
@ -623,6 +643,11 @@ else
|
||||
print '<tr><td width="20%" class="fieldrequired">'.$langs->trans("Ref").'</td><td colspan="3"><input name="libelle" size="20" value="'.$object->libelle.'"></td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3"><input name="lieu" size="40" value="'.$object->lieu.'"></td></tr>';
|
||||
|
||||
// Parent entrepot
|
||||
print '<tr><td>'.$langs->trans("AddIn").'</td><td>';
|
||||
print $formproduct->selectWarehouses('', 'fk_parent', '', 1, 0, 0, '', 0, 0, array(), 'minwidth200', array($object->id));
|
||||
print '</td></tr>';
|
||||
|
||||
// Description
|
||||
print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">';
|
||||
|
||||
@ -123,8 +123,8 @@ class Entrepot extends CommonObject
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label)";
|
||||
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."')";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (entity, datec, fk_user_author, label, fk_parent)";
|
||||
$sql .= " VALUES (".$conf->entity.",'".$this->db->idate($now)."',".$user->id.",'".$this->db->escape($this->libelle)."', ".($this->fk_parent > 0 ? $this->fk_parent : 'NULL').")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$result=$this->db->query($sql);
|
||||
@ -184,6 +184,7 @@ class Entrepot extends CommonObject
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
|
||||
$sql .= " SET label = '" . $this->db->escape($this->libelle) ."'";
|
||||
$sql .= ", fk_parent = '" . (($this->fk_parent > 0) ? $this->fk_parent : 'NULL') ."'";
|
||||
$sql .= ", description = '" . $this->db->escape($this->description) ."'";
|
||||
$sql .= ", statut = " . $this->statut;
|
||||
$sql .= ", lieu = '" . $this->db->escape($this->lieu) ."'";
|
||||
@ -294,7 +295,7 @@ class Entrepot extends CommonObject
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT rowid, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
|
||||
$sql = "SELECT rowid, fk_parent, label, description, statut, lieu, address, zip, town, fk_pays as country_id";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
|
||||
|
||||
if ($id)
|
||||
@ -317,6 +318,7 @@ class Entrepot extends CommonObject
|
||||
$obj=$this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->fk_parent = $obj->fk_parent;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user