diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php
index aa3bfc2e921..1c6f2893046 100644
--- a/htdocs/categories/categorie.class.php
+++ b/htdocs/categories/categorie.class.php
@@ -217,7 +217,10 @@ class Categorie
{
$sql .= ", description = '".addslashes($this->description)."'";
}
- $sql .= ", fk_soc = ".$this->socid;
+ if ($this->socid)
+ {
+ $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 e37f36a1926..a04558599af 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -140,7 +140,7 @@ else
print '';
-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 '
'.$langs->trans ("AssignedToCustomer").' ';
print $html->select_societes($categorie->socid,'socid','s.client = 1 AND s.fournisseur = 0',1);
diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php
index c67856d3a3b..983c35e3819 100644
--- a/htdocs/categories/fiche.php
+++ b/htdocs/categories/fiche.php
@@ -45,7 +45,11 @@ if ($_REQUEST['origin'])
if ($_GET['type'] == 0) $idProdOrigin = $_REQUEST['origin'];
if ($_GET['type'] == 1) $idSupplierOrigin = $_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
@@ -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"]);
exit;
}
+ else if ($idCatOrigin)
+ {
+ header("Location: ".DOL_URL_ROOT.'/categories/viewcat.php?id='.$idCatOrigin.'&type='.$_GET["type"]);
+ exit;
+ }
else
{
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)
header("Location: ".DOL_URL_ROOT.'/categories/categorie.php?socid='.$idSupplierOrigin.'&mesg='.urlencode($langs->trans("CatCreated")));
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"]);
exit;
@@ -174,6 +188,10 @@ if ($user->rights->categorie->creer)
{
print ' ';
}
+ if ($_REQUEST['catorigin'])
+ {
+ print ' ';
+ }
print ' ';
print_fiche_titre($langs->trans("CreateCat"));
@@ -200,11 +218,24 @@ if ($user->rights->categorie->creer)
print ' ';
if ($_GET['type'] == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
- print ''.$langs->trans ("AssignedToCustomer").' ';
- print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1);
- print ' ';
- print ' ';
- print ' ';
+ if ($_REQUEST['catorigin'])
+ {
+ print ''.$langs->trans ("AddIn").' ';
+ print $html->select_all_categories($_GET['type'],$_REQUEST['catorigin']);
+ print ' ';
+ print ''.$langs->trans ("ContentsVisibleByAll").' ';
+ print $html->selectyesno("visible", 1,1);
+ print ' ';
+ print ' ';
+ }
+ else
+ {
+ print ''.$langs->trans ("AssignedToCustomer").' ';
+ print $html->select_societes($_REQUEST['socid_id'],'socid','s.client = 1 AND s.fournisseur = 0',1);
+ print ' ';
+ print ' ';
+ print ' ';
+ }
}
else
{
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 7c984c685bb..2d0a46b7ccd 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -123,13 +123,23 @@ print '';
if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
{
- $soc = new Societe($db);
- $soc->fetch($c->socid);
-
- print '';
- print $langs->trans("AssignedToTheCustomer").' ';
- print $soc->getNomUrl(1);
- print ' ';
+ if ($c->socid)
+ {
+ $soc = new Societe($db);
+ $soc->fetch($c->socid);
+
+ print '';
+ print $langs->trans("AssignedToTheCustomer").' ';
+ print $soc->getNomUrl(1);
+ print ' ';
+ }
+ else
+ {
+ print '';
+ print $langs->trans("InternalCategory").' ';
+ print ($c->visible ? $langs->trans("Visible") : $langs->trans("Invisible"));
+ print ' ';
+ }
}
else
{
@@ -203,6 +213,21 @@ else
print "".$langs->trans("NoSubCat")." ";
}
print "\n";
+
+ /*
+ * Boutons actions
+ */
+ if ($type == 0 && $conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER)
+ {
+ print "";
+ }
}
@@ -323,4 +348,4 @@ if($c->type == 2)
$db->close();
llxFooter('$Date$ - $Revision$');
-?>
+?>
\ No newline at end of file
diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang
index 52ba35906db..e9fa03c4d04 100644
--- a/htdocs/langs/en_US/categories.lang
+++ b/htdocs/langs/en_US/categories.lang
@@ -72,4 +72,5 @@ ThisCategoryHasNoProduct=This category does not contain any product.
ThisCategoryHasNoSupplier=This category does not contain any supplier.
ThisCategoryHasNoCustomer=This category does not contain any customer.
AssignedToCustomer=Assigned to a customer
-AssignedToTheCustomer=Assigned to the customer
\ No newline at end of file
+AssignedToTheCustomer=Assigned to the customer
+InternalCategory=Inernal category
\ No newline at end of file
diff --git a/htdocs/langs/fr_FR/categories.lang b/htdocs/langs/fr_FR/categories.lang
index 63962e05d0f..be9da5e62e5 100644
--- a/htdocs/langs/fr_FR/categories.lang
+++ b/htdocs/langs/fr_FR/categories.lang
@@ -72,4 +72,5 @@ ThisCategoryHasNoProduct=Cette cat
ThisCategoryHasNoSupplier=Cette catégorie ne contient aucun fournisseur.
ThisCategoryHasNoCustomer=Cette catégorie ne contient aucun client.
AssignedToCustomer=Attribuer à un client
-AssignedToTheCustomer=Attribué au client
\ No newline at end of file
+AssignedToTheCustomer=Attribué au client
+InternalCategory=Catégorie interne
\ No newline at end of file