diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 4ed340c86c1..fba8ddcf7b0 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -45,6 +45,7 @@ class Categorie var $id_mere; var $label; var $description; + var $socid; var $statut; var $type; // 0=Produit, 1=Fournisseur, 2=Tiers @@ -124,6 +125,7 @@ class Categorie { global $langs; $langs->load('categories'); + if ($this->already_exists ()) { $this->error=$langs->trans("ImpossibleAddCat"); @@ -131,8 +133,8 @@ class Categorie return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, visible,type) "; - $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."', '".$this->visible."',".$this->type.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, fk_soc, visible, type) "; + $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."','".$this->socid."','".$this->visible."',".$this->type.")"; $res = $this->db->query ($sql); diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index 4c3e41c1b79..c67856d3a3b 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -48,6 +48,13 @@ if ($_REQUEST['origin']) } +// If socid provided by ajax company selector +if (! empty($_POST['socid_id'])) +{ + $_POST['socid'] = $_POST['socid_id']; + $_REQUEST['socid'] = $_REQUEST['socid_id']; +} + /* * Actions @@ -87,6 +94,7 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) $categorie->socid = $_POST["socid"]; $categorie->visible = $_POST["visible"]; $categorie->type = $_POST["type"]; + if($_POST['catMere'] != "-1") $categorie->id_mere = $_POST['catMere']; @@ -193,10 +201,10 @@ if ($user->rights->categorie->creer) if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) { print '