Skip to content
Snippets Groups Projects
Commit e32d52b6 authored by Regis Houssin's avatar Regis Houssin
Browse files

Added ability to assign a category of product to a customer

parent 38a6d671
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2005 Davoleau Brice <brice.davoleau@gmail.com> * Copyright (C) 2005 Davoleau Brice <brice.davoleau@gmail.com>
* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> * 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) 2006-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
...@@ -72,7 +72,7 @@ class Categorie ...@@ -72,7 +72,7 @@ class Categorie
*/ */
function fetch($id) 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.= " FROM ".MAIN_DB_PREFIX."categorie";
$sql.= " WHERE rowid = ".$id; $sql.= " WHERE rowid = ".$id;
...@@ -85,6 +85,7 @@ class Categorie ...@@ -85,6 +85,7 @@ class Categorie
$this->id = $res['rowid']; $this->id = $res['rowid'];
$this->label = $res['label']; $this->label = $res['label'];
$this->description = $res['description']; $this->description = $res['description'];
$this->socid = $res['fk_soc'];
$this->visible = $res['visible']; $this->visible = $res['visible'];
$this->type = $res['type']; $this->type = $res['type'];
...@@ -136,7 +137,7 @@ class Categorie ...@@ -136,7 +137,7 @@ class Categorie
} }
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, fk_soc, visible, 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.")"; $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."',".$this->socid.",'".$this->visible."',".$this->type.")";
$res = $this->db->query ($sql); $res = $this->db->query ($sql);
...@@ -216,6 +217,7 @@ class Categorie ...@@ -216,6 +217,7 @@ class Categorie
{ {
$sql .= ", description = '".addslashes($this->description)."'"; $sql .= ", description = '".addslashes($this->description)."'";
} }
$sql .= ", fk_soc = ".$this->socid;
$sql .= ", visible = '".$this->visible."'"; $sql .= ", visible = '".$this->visible."'";
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
......
<?php <?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net> * 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> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -33,6 +33,13 @@ require "./pre.inc.php"; ...@@ -33,6 +33,13 @@ require "./pre.inc.php";
if (!$user->rights->categorie->lire) if (!$user->rights->categorie->lire)
accessforbidden(); 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 catgorie // Action mise jour d'une catgorie
if ($_POST["action"] == 'update' && $user->rights->categorie->creer) if ($_POST["action"] == 'update' && $user->rights->categorie->creer)
{ {
...@@ -41,6 +48,7 @@ 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->label = $_POST["nom"];
$categorie->description = $_POST["description"]; $categorie->description = $_POST["description"];
$categorie->socid = $_POST["socid"];
$categorie->visible = $_POST["visible"]; $categorie->visible = $_POST["visible"];
if($_POST['catMere'] != "-1") if($_POST['catMere'] != "-1")
...@@ -132,6 +140,16 @@ else ...@@ -132,6 +140,16 @@ else
print '</td></tr>'; 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 '<tr><td>'.$langs->trans("AddIn").'</td><td>';
print $html->select_all_categories($categorie->type,$categorie->id_mere); print $html->select_all_categories($categorie->type,$categorie->id_mere);
print '</td></tr>'; print '</td></tr>';
...@@ -139,6 +157,7 @@ print '</td></tr>'; ...@@ -139,6 +157,7 @@ print '</td></tr>';
print '<tr><td>'.$langs->trans("ContentsVisibleByAll").'</td><td>'; print '<tr><td>'.$langs->trans("ContentsVisibleByAll").'</td><td>';
print $html->selectyesno("visible",$categorie->visible,1); print $html->selectyesno("visible",$categorie->visible,1);
print '</td></tr>'; print '</td></tr>';
}
print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'">'; print '<tr><td colspan="2" align="center"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</td></tr>'; print '</td></tr>';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment