Added ability to assign a category of product to a customer
This commit is contained in:
parent
6554fde40d
commit
deb94493dd
@ -124,11 +124,9 @@ class Categorie
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
global $langs;
|
||||
global $conf,$langs;
|
||||
$langs->load('categories');
|
||||
|
||||
if ($this->socid == -1) $this->socid = 0;
|
||||
|
||||
if ($this->already_exists ())
|
||||
{
|
||||
$this->error=$langs->trans("ImpossibleAddCat");
|
||||
@ -136,9 +134,17 @@ class Categorie
|
||||
return -1;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, fk_soc, visible, type) ";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description,";
|
||||
if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
$sql.= "fk_soc,";
|
||||
}
|
||||
$sql.= "visible, type) ";
|
||||
$sql.= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."',";
|
||||
$sql.= ($this->socid?$this->socid:"null").",";
|
||||
if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
$sql.= ($this->socid != -1 ? $this->socid : 'null').",";
|
||||
}
|
||||
$sql.= "'".$this->visible."',".$this->type.")";
|
||||
|
||||
|
||||
@ -186,7 +192,6 @@ class Categorie
|
||||
// Clean parameters
|
||||
$this->label=trim($this->label);
|
||||
$this->description=trim($this->description);
|
||||
if ($this->socid == -1) $this->socid = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@ -223,7 +228,7 @@ class Categorie
|
||||
}
|
||||
if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
{
|
||||
$sql .= ", fk_soc = ".$this->socid;
|
||||
$sql .= ", fk_soc = ".($this->socid != -1 ? $this->socid : 'null');
|
||||
}
|
||||
$sql .= ", visible = '".$this->visible."'";
|
||||
$sql .= " WHERE rowid = ".$this->id;
|
||||
|
||||
@ -33,6 +33,8 @@ require "./pre.inc.php";
|
||||
if (!$user->rights->categorie->lire)
|
||||
accessforbidden();
|
||||
|
||||
$type=$_REQUEST['type'];
|
||||
|
||||
// If socid provided by ajax company selector
|
||||
if (! empty($_POST['socid_id']))
|
||||
{
|
||||
@ -71,7 +73,7 @@ if ($_POST["action"] == 'update' && $user->rights->categorie->creer)
|
||||
{
|
||||
if ($categorie->update($user) > 0)
|
||||
{
|
||||
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id);
|
||||
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@ -114,6 +116,7 @@ print "\n";
|
||||
print '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$categorie->id.'">';
|
||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>';
|
||||
|
||||
@ -34,7 +34,7 @@ if ($_REQUEST['id'] == "")
|
||||
exit();
|
||||
}
|
||||
|
||||
$type=$_GET['type'];
|
||||
$type=$_REQUEST['type'];
|
||||
|
||||
// Securite
|
||||
if (! $user->rights->categorie->lire)
|
||||
@ -136,7 +136,7 @@ if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
|
||||
else
|
||||
{
|
||||
print '<tr><td width="20%" class="notopnoleft">';
|
||||
print $langs->trans("InernalCategory").'</td><td>';
|
||||
print $langs->trans("InternalCategory").'</td><td>';
|
||||
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
|
||||
print '</td></tr>';
|
||||
}
|
||||
@ -161,7 +161,7 @@ print "<div class='tabsAction'>\n";
|
||||
|
||||
if ($user->rights->categorie->creer)
|
||||
{
|
||||
print "<a class='butAction' href='edit.php?id=".$c->id."'>".$langs->trans("Modify")."</a>";
|
||||
print "<a class='butAction' href='edit.php?id=".$c->id."&type=".$type."'>".$langs->trans("Modify")."</a>";
|
||||
}
|
||||
|
||||
if ($user->rights->categorie->supprimer)
|
||||
|
||||
@ -34,7 +34,7 @@ alter table llx_rights_def modify column type varchar(1);
|
||||
|
||||
ALTER TABLE `llx_commandedet` ADD column `date_start` DATETIME DEFAULT NULL, ADD `date_end` DATETIME DEFAULT NULL ;
|
||||
|
||||
alter table llx_categorie add column fk_soc integer DEFAULT 0 after description;
|
||||
alter table llx_categorie add column fk_soc integer DEFAULT NULL after description;
|
||||
|
||||
alter table llx_product drop column nbvente;
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ create table llx_categorie
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
label VARCHAR(255), -- category name
|
||||
description text, -- description of the category
|
||||
fk_soc integer DEFAULT 0, -- attribution of the category has a company (for product only)
|
||||
fk_soc integer DEFAULT NULL, -- attribution of the category has a company (for product only)
|
||||
visible tinyint DEFAULT 1 NOT NULL, -- determine if the products are visible or not
|
||||
type tinyint DEFAULT 1 NOT NULL -- category type (product, supplier, customer)
|
||||
)type=innodb;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user