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

Added ability to assign a category of product to a customer

parent 977bacbd
No related branches found
No related tags found
No related merge requests found
...@@ -217,7 +217,10 @@ class Categorie ...@@ -217,7 +217,10 @@ class Categorie
{ {
$sql .= ", description = '".addslashes($this->description)."'"; $sql .= ", description = '".addslashes($this->description)."'";
} }
if ($this->socid)
{
$sql .= ", fk_soc = ".$this->socid; $sql .= ", fk_soc = ".$this->socid;
}
$sql .= ", visible = '".$this->visible."'"; $sql .= ", visible = '".$this->visible."'";
$sql .= " WHERE rowid = ".$this->id; $sql .= " WHERE rowid = ".$this->id;
......
...@@ -140,7 +140,7 @@ else ...@@ -140,7 +140,7 @@ else
print '</td></tr>'; print '</td></tr>';
if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER && !$categorie->id_mere)
{ {
print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>'; print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>';
print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1); print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1);
......
...@@ -45,7 +45,11 @@ if ($_REQUEST['origin']) ...@@ -45,7 +45,11 @@ if ($_REQUEST['origin'])
if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin']; if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin'];
if ($_GET['type'] == 1) $idSupplierOrigin = $_REQUEST['origin']; if ($_GET['type'] == 1) $idSupplierOrigin = $_REQUEST['origin'];
if ($_GET['type'] == 2) $idCompanyOrigin = $_REQUEST['origin']; if ($_GET['type'] == 2) $idCompanyOrigin = $_REQUEST['origin'];
}
if ($_REQUEST['catorigin'])
{
if ($_GET['type'] == 0) $idCatOrigin = $_REQUEST['catorigin'];
} }
// If socid provided by ajax company selector // If socid provided by ajax company selector
...@@ -80,6 +84,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) ...@@ -80,6 +84,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&type='.$_GET["type"]);
exit; exit;
} }
else if ($idCatOrigin)
{
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&type='.$_GET["type"]);
exit;
}
else else
{ {
header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$_GET["type"]); header("Location: ".DOL_URL_ROOT.'/categories/index.php?leftmenu=cat&type='.$_GET["type"]);
...@@ -140,6 +149,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) ...@@ -140,6 +149,11 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer)
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated"))); header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit; exit;
} }
if ($idCatOrigin)
{
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
exit;
}
header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]); header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$result.'&type='.$_POST["type"]);
exit; exit;
...@@ -174,6 +188,10 @@ if ($user->rights->categorie->creer) ...@@ -174,6 +188,10 @@ if ($user->rights->categorie->creer)
{ {
print '<input type="hidden" name="origin" value="'.$_REQUEST['origin'].'">'; print '<input type="hidden" name="origin" value="'.$_REQUEST['origin'].'">';
} }
if ($_REQUEST['catorigin'])
{
print '<input type="hidden" name="catorigin" value="'.$_REQUEST['catorigin'].'">';
}
print '<input type="hidden" name="nom" value="'.$nom.'">'; print '<input type="hidden" name="nom" value="'.$nom.'">';
print_fiche_titre($langs->trans("CreateCat")); print_fiche_titre($langs->trans("CreateCat"));
...@@ -199,6 +217,18 @@ if ($user->rights->categorie->creer) ...@@ -199,6 +217,18 @@ if ($user->rights->categorie->creer)
print '</td></tr>'; print '</td></tr>';
if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
if ($_REQUEST['catorigin'])
{
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
print $html->select_all_categories($_GET['type'],$_REQUEST['catorigin']);
print '</td></tr>';
print '<tr><td>'.$langs->trans ("ContentsVisibleByAll").'</td><td>';
print $html->selectyesno("visible", 1,1);
print '</td></tr>';
print '<input type="hidden" name="socid" value="'.$_GET['socid'].'">';
}
else
{ {
print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>'; print '<tr><td>'.$langs->trans ("AssignedToCustomer").'</td><td>';
print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1); print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1);
...@@ -206,6 +236,7 @@ if ($user->rights->categorie->creer) ...@@ -206,6 +236,7 @@ if ($user->rights->categorie->creer)
print '<input type="hidden" name="catMere" value="-1">'; print '<input type="hidden" name="catMere" value="-1">';
print '<input type="hidden" name="visible" value="1">'; print '<input type="hidden" name="visible" value="1">';
} }
}
else else
{ {
print '<tr><td>'.$langs->trans ("AddIn").'</td><td>'; print '<tr><td>'.$langs->trans ("AddIn").'</td><td>';
......
...@@ -122,6 +122,8 @@ print nl2br($c->description); ...@@ -122,6 +122,8 @@ print nl2br($c->description);
print '</td></tr>'; print '</td></tr>';
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
if ($c->socid)
{ {
$soc = new Societe($db); $soc = new Societe($db);
$soc->fetch($c->socid); $soc->fetch($c->socid);
...@@ -132,6 +134,14 @@ if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) ...@@ -132,6 +134,14 @@ if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
print '</td></tr>'; print '</td></tr>';
} }
else else
{
print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("InternalCategory").'</td><td>';
print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
print '</td></tr>';
}
}
else
{ {
print '<tr><td width="20%" class="notopnoleft">'; print '<tr><td width="20%" class="notopnoleft">';
print $langs->trans("Status").'</td><td>'; print $langs->trans("Status").'</td><td>';
...@@ -203,6 +213,21 @@ else ...@@ -203,6 +213,21 @@ else
print "<tr><td>".$langs->trans("NoSubCat")."</td></tr>"; print "<tr><td>".$langs->trans("NoSubCat")."</td></tr>";
} }
print "</table>\n"; print "</table>\n";
/*
* Boutons actions
*/
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
print "<div class='tabsAction'>\n";
if ($user->rights->categorie->creer)
{
print "<a class='butAction' href='fiche.php?action=create&amp;catorigin=".$c->id."&amp;socid=".$c->socid."&amp;type=".$type."'>".$langs->trans("Create")."</a>";
}
print "</div>";
}
} }
......
...@@ -73,3 +73,4 @@ ThisCategoryHasNoSupplier=This category does not contain any supplier. ...@@ -73,3 +73,4 @@ ThisCategoryHasNoSupplier=This category does not contain any supplier.
ThisCategoryHasNoCustomer=This category does not contain any customer. ThisCategoryHasNoCustomer=This category does not contain any customer.
AssignedToCustomer=Assigned to a customer AssignedToCustomer=Assigned to a customer
AssignedToTheCustomer=Assigned to the customer AssignedToTheCustomer=Assigned to the customer
InternalCategory=Inernal category
\ No newline at end of file
...@@ -73,3 +73,4 @@ ThisCategoryHasNoSupplier=Cette cat ...@@ -73,3 +73,4 @@ ThisCategoryHasNoSupplier=Cette cat
ThisCategoryHasNoCustomer=Cette catgorie ne contient aucun client. ThisCategoryHasNoCustomer=Cette catgorie ne contient aucun client.
AssignedToCustomer=Attribuer un client AssignedToCustomer=Attribuer un client
AssignedToTheCustomer=Attribu au client AssignedToTheCustomer=Attribu au client
InternalCategory=Catgorie interne
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment