diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index f9ce1c0516e730eaf9903e64383ee165567b279c..3cabe51b73739ef7a29ddb9ce05a9223e937dee4 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> * Copyright (C) 2005 Davoleau Brice <brice.davoleau@gmail.com> * Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> - * Copyright (C) 2006-2007 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2006-2008 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * @@ -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 154a084db913b7a227df7d3109ab2edb067cf7ea..e37f36a19265d2bcc8864191011f558624581235 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> * Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> - * Copyright (C) 2005-2006 Regis Houssin <regis@dolibarr.fr> + * Copyright (C) 2005-2008 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * * 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 '</td></tr>'; -print '<tr><td>'.$langs->trans("AddIn").'</td><td>'; -print $html->select_all_categories($categorie->type,$categorie->id_mere); -print '</td></tr>'; - -print '<tr><td>'.$langs->trans("ContentsVisibleByAll").'</td><td>'; -print $html->selectyesno("visible",$categorie->visible,1); -print '</td></tr>'; +if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) +{ + print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>'; + print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1); + print '</td></tr>'; + print '<input type="hidden" name="catMere" value="-1">'; + print '<input type="hidden" name="visible" value="1">'; +} +else +{ + print '<tr><td>'.$langs->trans("AddIn").'</td><td>'; + print $html->select_all_categories($categorie->type,$categorie->id_mere); + print '</td></tr>'; + + print '<tr><td>'.$langs->trans("ContentsVisibleByAll").'</td><td>'; + print $html->selectyesno("visible",$categorie->visible,1); + print '</td></tr>'; +} print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '</td></tr>';