NEW : function to display full path to current warehouse

This commit is contained in:
gauthier 2016-09-16 10:18:36 +02:00
parent 416311a7b9
commit fe1bcb7e0a
2 changed files with 30 additions and 1 deletions

View File

@ -118,7 +118,7 @@ class FormProduct
$obj = $this->db->fetch_object($resql);
if ($sumStock) $obj->stock = price2num($obj->stock,5);
$this->cache_warehouses[$obj->rowid]['id'] =$obj->rowid;
$this->cache_warehouses[$obj->rowid]['label']=$obj->label;
$this->cache_warehouses[$obj->rowid]['label']=$o->get_full_arbo();
$this->cache_warehouses[$obj->rowid]['description'] = $obj->description;
$this->cache_warehouses[$obj->rowid]['stock'] = $obj->stock;
$i++;

View File

@ -606,4 +606,33 @@ class Entrepot extends CommonObject
$this->country_id=1;
$this->country_code='FR';
}
function get_full_arbo() {
global $user,$langs,$conf;
$TArbo = array($this->libelle);
$id = $this->id;
while(true) {
$sql = 'SELECT fk_parent
FROM '.MAIN_DB_PREFIX.'entrepot
WHERE rowid = '.$id;
$resql = $this->db->query($sql);
if($resql) {
$res = $this->db->fetch_object($resql);
if(empty($res->fk_parent)) break;
$id = $res->fk_parent;
$o = new Entrepot($this->db);
$o->fetch($id);
$TArbo[] = $o->libelle;
} else break;
}
return implode(' >> ', array_reverse($TArbo));
}
}