diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index 39c4c525696..60690cedeeb 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -105,6 +105,7 @@ if (empty($reshook)) {
if ($action == 'add' && $user->rights->stock->creer) {
$object->ref = (string) GETPOST("ref", "alpha");
$object->fk_parent = (int) GETPOST("fk_parent", "int");
+ $object->fk_project = GETPOST('projectid', 'int');
$object->label = (string) GETPOST("libelle", "alpha");
$object->description = (string) GETPOST("desc", "alpha");
$object->statut = GETPOST("statut");
@@ -168,6 +169,7 @@ if (empty($reshook)) {
if ($object->fetch($id)) {
$object->label = GETPOST("libelle");
$object->fk_parent = GETPOST("fk_parent");
+ $object->fk_project = GETPOST('projectid');
$object->description = GETPOST("desc");
$object->statut = GETPOST("statut");
$object->lieu = GETPOST("lieu");
@@ -221,6 +223,9 @@ if (empty($reshook)) {
if ($error) {
$action = 'edit_extras';
}
+ } elseif ($action == 'classin' && $usercancreate) {
+ // Link to a project
+ $object->setProject(GETPOST('projectid', 'int'));
}
if ($cancel == $langs->trans("Cancel")) {
@@ -399,12 +404,39 @@ if ($action == 'create') {
$morehtmlref = '
';
$morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
- $morehtmlref .= '
';
- if ($object->project) {
- $morehtmlref .= '';
- $morehtmlref .= $langs->trans("LocationSummary").' : '.$object->lieu;
- $morehtmlref .= '
';
+
+ // Project
+ if (!empty($conf->projet->enabled)) {
+ $langs->load("projects");
+ $morehtmlref .= '| '.$langs->trans('Project').' | ';
print img_picto('', 'project').$formproject->select_projects(($socid > 0 ? $socid : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500');
diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php
index 214a12ead14..2f3131feba9 100644
--- a/htdocs/product/stock/class/entrepot.class.php
+++ b/htdocs/product/stock/class/entrepot.class.php
@@ -108,6 +108,11 @@ class Entrepot extends CommonObject
*/
public $fk_parent;
+ /**
+ * @var int ID of project
+ */
+ public $fk_project;
+
/**
* @var array List of short language codes for status
*/
@@ -124,6 +129,7 @@ class Entrepot extends CommonObject
'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-2, 'position'=>35, 'searchall'=>1),
'lieu' =>array('type'=>'varchar(64)', 'label'=>'LocationSummary', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'showoncombobox'=>1, 'searchall'=>1),
'fk_parent' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php:1:statut=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ParentWarehouse', 'enabled'=>1, 'visible'=>-2, 'position'=>41),
+ 'fk_project' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Project', 'enabled'=>1, 'visible'=>-1, 'position'=>25),
'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-2, 'position'=>45, 'searchall'=>1),
'zip' =>array('type'=>'varchar(10)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-2, 'position'=>50, 'searchall'=>1),
'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-2, 'position'=>55, 'searchall'=>1),
@@ -198,8 +204,8 @@ class Entrepot extends CommonObject
$this->db->begin();
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (ref, entity, datec, fk_user_author, fk_parent)";
- $sql .= " VALUES ('".$this->db->escape($this->label)."', ".$conf->entity.", '".$this->db->idate($now)."', ".$user->id.", ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").")";
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."entrepot (ref, entity, datec, fk_user_author, fk_parent, fk_project)";
+ $sql .= " VALUES ('".$this->db->escape($this->label)."', ".$conf->entity.", '".$this->db->idate($now)."', ".$user->id.", ".($this->fk_parent > 0 ? $this->fk_parent : "NULL").", ".($this->fk_project > 0 ? $this->fk_project : "NULL").")";
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
@@ -290,6 +296,7 @@ class Entrepot extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."entrepot ";
$sql .= " SET ref = '".$this->db->escape($this->label)."'";
$sql .= ", fk_parent = ".(($this->fk_parent > 0) ? $this->fk_parent : "NULL");
+ $sql .= ", fk_project = ".(($this->fk_project > 0) ? $this->fk_project : "NULL");
$sql .= ", description = '".$this->db->escape($this->description)."'";
$sql .= ", statut = ".$this->statut;
$sql .= ", lieu = '".$this->db->escape($this->lieu)."'";
@@ -432,7 +439,7 @@ class Entrepot extends CommonObject
return -1;
}
- $sql = "SELECT rowid, entity, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,";
+ $sql = "SELECT rowid, entity, fk_parent, fk_project, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,";
$sql .= " model_pdf, import_key";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id) {
@@ -452,6 +459,7 @@ class Entrepot extends CommonObject
$this->id = $obj->rowid;
$this->entity = $obj->entity;
$this->fk_parent = $obj->fk_parent;
+ $this->fk_project = $obj->fk_project;
$this->ref = $obj->label;
$this->label = $obj->label;
$this->libelle = $obj->label; // deprecated
|