diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 35420759ded..4eac3ec9a08 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -109,6 +109,8 @@ if (empty($nosearch)) {
foreach ($cats as $cat)
{
+ $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"';
+
print "\t".'
'."\n";
print "\t\t| ";
$categstatic->id = $cat->id;
@@ -116,7 +118,7 @@ if (empty($nosearch)) {
$categstatic->label = $cat->label;
$categstatic->type = $cat->type;
$categstatic->color = $cat->color;
- print 'color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>';
+ print '';
print $categstatic->getNomUrl(1, '');
print '';
print " | \n";
@@ -170,10 +172,12 @@ foreach ($fulltree as $key => $val)
$counter = "".(is_countable($elements) ? count($elements) : '0')." | ";
}
+ $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"';
+
$data[] = array(
'rowid'=>$val['rowid'],
'fk_menu'=>$val['fk_parent'],
- 'entry'=>'| color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"').'>'.$li.' | '.$counter.
+ 'entry'=>''
);
}
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 8c1eccfa846..7f673a1ecff 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -82,6 +82,10 @@ if ($result <= 0) {
dol_print_error($db, $object->error); exit;
}
+$objecttype = $object->type;
+if (is_numeric($objecttype)) $objecttype = Categorie::$MAP_ID_TO_CODE[$objecttype];
+if ($type === '') $type = $objecttype;
+
if (is_numeric($type)) $type = Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility
$extrafields = new ExtraFields($db);
@@ -90,10 +94,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array
$hookmanager->initHooks(array('categorycard', 'globalcard'));
+// Protection when type provided is not similare to type of category
+if ($objecttype != $type) {
+ print 'Error: Value for type parameter does not match value of the type of the category with id='.$id;
+ exit;
+}
/*
* Actions
*/
+
$parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
// Remove element from category
@@ -522,6 +532,84 @@ if ($type == Categorie::TYPE_PRODUCT)
}
}
+if ($type == Categorie::TYPE_CUSTOMER)
+{
+ $permission = $user->rights->societe->creer;
+
+ $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
+ if ($socs < 0)
+ {
+ dol_print_error($db, $object->error, $object->errors);
+ } else {
+ // Form to add record into a category
+ $showclassifyform = 1;
+ if ($showclassifyform)
+ {
+ print '
';
+ print '';
+ }
+
+ print ''."\n";
+ }
+}
+
+
if ($type == Categorie::TYPE_SUPPLIER)
{
$permission = $user->rights->societe->creer;
@@ -600,83 +688,6 @@ if ($type == Categorie::TYPE_SUPPLIER)
}
}
-if ($type == Categorie::TYPE_CUSTOMER)
-{
- $permission = $user->rights->societe->creer;
-
- $socs = $object->getObjectsInCateg($type, 0, $limit, $offset);
- if ($socs < 0)
- {
- dol_print_error($db, $object->error, $object->errors);
- } else {
- // Form to add record into a category
- $showclassifyform = 1;
- if ($showclassifyform)
- {
- print '
';
- print '';
- }
-
- print ''."\n";
- }
-}
-
// List of members
if ($type == Categorie::TYPE_MEMBER)
{
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 32a79d5c667..ac0900f0c29 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6598,7 +6598,7 @@ abstract class CommonObject
{
$toprint = array();
foreach ($value_arr as $keyval=>$valueval) {
- $toprint[] = ''.$param['options'][$valueval].'';
+ $toprint[] = ''.$param['options'][$valueval].'';
}
$value = ''.implode(' ', $toprint).'
';
}
@@ -6646,9 +6646,9 @@ abstract class CommonObject
$translabel = $langs->trans($obj->$field_toshow);
}
if ($translabel != $field_toshow) {
- $toprint[] = ''.dol_trunc($translabel, 18).'';
+ $toprint[] = ''.dol_trunc($translabel, 18).'';
} else {
- $toprint[] = ''.$obj->$field_toshow.'';
+ $toprint[] = ''.$obj->$field_toshow.'';
}
}
} else {
@@ -6657,9 +6657,9 @@ abstract class CommonObject
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
- $toprint[] = ''.dol_trunc($translabel, 18).'';
+ $toprint[] = ''.dol_trunc($translabel, 18).'';
} else {
- $toprint[] = ''.$obj->{$InfoFieldList[1]}.'';
+ $toprint[] = ''.$obj->{$InfoFieldList[1]}.'';
}
}
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index c01a1dd6ed0..87cee951170 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1702,7 +1702,7 @@ class ExtraFields
$c->fetch($obj->rowid);
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
foreach ($ways as $way) {
- $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'';
+ $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #bbb"').'>'.img_object('', 'category').' '.$way.'';
}
$value = ''.implode(' ', $toprint).'
';
}
@@ -1718,7 +1718,7 @@ class ExtraFields
if (is_array($value_arr))
{
foreach ($value_arr as $keyval=>$valueval) {
- $toprint[] = ''.$param['options'][$valueval].'';
+ $toprint[] = ''.$param['options'][$valueval].'';
}
}
$value = ''.implode(' ', $toprint).'
';
@@ -1775,9 +1775,9 @@ class ExtraFields
$translabel = $langs->trans($obj->$field_toshow);
}
if ($translabel != $field_toshow) {
- $toprint[] = ''.dol_trunc($translabel, 18).'';
+ $toprint[] = ''.dol_trunc($translabel, 18).'';
} else {
- $toprint[] = ''.$obj->$field_toshow.'';
+ $toprint[] = ''.$obj->$field_toshow.'';
}
}
} else {
@@ -1786,9 +1786,9 @@ class ExtraFields
$translabel = $langs->trans($obj->{$InfoFieldList[1]});
}
if ($translabel != $obj->{$InfoFieldList[1]}) {
- $toprint[] = ''.dol_trunc($translabel, 18).'';
+ $toprint[] = ''.dol_trunc($translabel, 18).'';
} else {
- $toprint[] = ''.$obj->{$InfoFieldList[1]}.'';
+ $toprint[] = ''.$obj->{$InfoFieldList[1]}.'';
}
}
}
@@ -1803,7 +1803,7 @@ class ExtraFields
$c->fetch($obj->rowid);
$ways = $c->print_all_ways(); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formatted text
foreach ($ways as $way) {
- $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.img_object('', 'category').' '.$way.'';
+ $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #bbb"').'>'.img_object('', 'category').' '.$way.'';
}
}
}
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 15cfa9e5771..1cd1463fd67 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -6840,7 +6840,7 @@ class Form
$ways = $c->print_all_ways(' >> ', ($nolink ? 'none' : ''), 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text
foreach ($ways as $way)
{
- $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #aaa"').'>'.$way.'';
+ $toprint[] = 'color ? ' style="background: #'.$c->color.';"' : ' style="background: #bbb"').'>'.$way.'';
}
}
return ''.implode(' ', $toprint).'
';
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index ee9e8564933..0b4c4e499e3 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -798,7 +798,7 @@ class FormCompany extends Form
if ($rendermode === 'view') {
$toprint = array();
foreach ($contact->roles as $key => $val) {
- $toprint[] = ''.$val['label'].'';
+ $toprint[] = ''.$val['label'].'';
}
return ''.implode(' ', $toprint).'
';
}
diff --git a/htdocs/langs/en_US/categories.lang b/htdocs/langs/en_US/categories.lang
index c813f6d694f..ba37a43b4ec 100644
--- a/htdocs/langs/en_US/categories.lang
+++ b/htdocs/langs/en_US/categories.lang
@@ -81,6 +81,8 @@ CategoriesSetup=Tags/categories setup
CategorieRecursiv=Link with parent tag/category automatically
CategorieRecursivHelp=If option is on, when you add a product into a subcategory, product will also be added into the parent category.
AddProductServiceIntoCategory=Add the following product/service
+AddCustomerIntoCategory=Assign category to customer
+AddSupplierIntoCategory=Assign category to supplier
ShowCategory=Show tag/category
ByDefaultInList=By default in list
ChooseCategory=Choose category