diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 95b6f6208a5..ad5bbdd0867 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -1542,8 +1542,11 @@ if ($action == 'create') } if ($subj == 0) // Line not shown yet, we show it { - print ''; - print ''; + $warehouse_selected_id = GETPOST('entrepot_id', 'int'); + + print ''; + print ''; + if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { $disabled = ''; @@ -1551,6 +1554,9 @@ if ($action == 'create') { $disabled = 'disabled="disabled"'; } + if ($warehouse_selected_id <= 0) { // We did not force a given warehouse, so we won't have no warehouse to change qty. + $disabled = 'disabled="disabled"'; + } print ' '; } else @@ -1562,7 +1568,6 @@ if ($action == 'create') print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { - $warehouse_selected_id = GETPOST('entrepot_id', 'int'); if ($warehouse_selected_id > 0) { $warehouseObject = new Entrepot($db); diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 8193cf78934..ea5feaa170c 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -114,6 +114,7 @@ class Entrepot extends CommonObject */ public $fields = array( 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>15), 'ref' =>array('type'=>'varchar(255)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'showoncombobox'=>1, 'position'=>25), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>30), 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35), @@ -456,6 +457,7 @@ class Entrepot extends CommonObject } $sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax"; + $sql .= ", entity"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; if ($id) { @@ -475,6 +477,7 @@ class Entrepot extends CommonObject $obj = $this->db->fetch_object($result); $this->id = $obj->rowid; + $this->entity = $obj->entity; $this->fk_parent = $obj->fk_parent; $this->ref = $obj->label; $this->label = $obj->label; diff --git a/htdocs/product/stock/list.php b/htdocs/product/stock/list.php index 78418f90db6..47c3ac9d1b5 100644 --- a/htdocs/product/stock/list.php +++ b/htdocs/product/stock/list.php @@ -226,13 +226,13 @@ if (!empty($conf->categorie->enabled)) } foreach ($search as $key => $val) { - if ($key == 'status' && $search[$key] == -1) continue; + if (($key == 'status' && $search[$key] == -1) || $key=='entity') continue; $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { if ($search[$key] == '-1') $search[$key] = ''; $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') $sql .= natural_search((($key == 'ref') ? 't.ref' : $key), $search[$key], (($key == 'status') ? 2 : $mode_search)); } if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields