diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index f9ce1c0516e..3cabe51b737 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Davoleau Brice * Copyright (C) 2005 Rodolphe Quiedeville - * Copyright (C) 2006-2007 Regis Houssin + * Copyright (C) 2006-2008 Regis Houssin * Copyright (C) 2006-2008 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * @@ -72,7 +72,7 @@ class Categorie */ function fetch($id) { - $sql = "SELECT rowid, label, description, visible, type"; + $sql = "SELECT rowid, label, description, fk_soc, visible, type"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; $sql.= " WHERE rowid = ".$id; @@ -82,9 +82,10 @@ class Categorie { $res = $this->db->fetch_array($resql); - $this->id = $res['rowid']; - $this->label = $res['label']; + $this->id = $res['rowid']; + $this->label = $res['label']; $this->description = $res['description']; + $this->socid = $res['fk_soc']; $this->visible = $res['visible']; $this->type = $res['type']; @@ -136,7 +137,7 @@ class Categorie } $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.")"; + $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."',".$this->socid.",'".$this->visible."',".$this->type.")"; $res = $this->db->query ($sql); @@ -216,6 +217,7 @@ class Categorie { $sql .= ", description = '".addslashes($this->description)."'"; } + $sql .= ", fk_soc = ".$this->socid; $sql .= ", visible = '".$this->visible."'"; $sql .= " WHERE rowid = ".$this->id; diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 154a084db91..e37f36a1926 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2007 Laurent Destailleur - * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2005-2008 Regis Houssin * Copyright (C) 2007 Patrick Raguin * * This program is free software; you can redistribute it and/or modify @@ -32,6 +32,13 @@ require "./pre.inc.php"; if (!$user->rights->categorie->lire) accessforbidden(); + +// If socid provided by ajax company selector +if (! empty($_POST['socid_id'])) +{ + $_POST['socid'] = $_POST['socid_id']; + $_REQUEST['socid'] = $_REQUEST['socid_id']; +} // Action mise à jour d'une catégorie if ($_POST["action"] == 'update' && $user->rights->categorie->creer) @@ -41,6 +48,7 @@ if ($_POST["action"] == 'update' && $user->rights->categorie->creer) $categorie->label = $_POST["nom"]; $categorie->description = $_POST["description"]; + $categorie->socid = $_POST["socid"]; $categorie->visible = $_POST["visible"]; if($_POST['catMere'] != "-1") @@ -132,13 +140,24 @@ else print ''; -print ''.$langs->trans("AddIn").''; -print $html->select_all_categories($categorie->type,$categorie->id_mere); -print ''; - -print ''.$langs->trans("ContentsVisibleByAll").''; -print $html->selectyesno("visible",$categorie->visible,1); -print ''; +if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) +{ + print ''.$langs->trans ("AssignedToCustomer").''; + print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1); + print ''; + print ''; + print ''; +} +else +{ + print ''.$langs->trans("AddIn").''; + print $html->select_all_categories($categorie->type,$categorie->id_mere); + print ''; + + print ''.$langs->trans("ContentsVisibleByAll").''; + print $html->selectyesno("visible",$categorie->visible,1); + print ''; +} print ''; print '';