diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index f4b7e12cc30..acb0aef2793 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -39,6 +39,7 @@ $type = GETPOST('type', 'aZ09'); // Can be int or string
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
$confirm = GETPOST('confirm');
$cancel = GETPOST('cancel', 'alpha');
+$backtopage = GETPOST('backtopage', 'alpha');
$socid = (int) GETPOST('socid', 'int');
$label = (string) GETPOST('label', 'alphanohtml');
@@ -74,8 +75,13 @@ $error = 0;
*/
if ($cancel) {
- header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
- exit;
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
+ exit;
+ }
}
// Action mise a jour d'une categorie
@@ -98,9 +104,15 @@ if ($action == 'update' && $user->rights->categorie->creer) {
$ret = $extrafields->setOptionalsFromPost(null, $object);
if ($ret < 0) $error++;
- if (!$error && $object->update($user) > 0) {
- header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
- exit;
+ if (!$error && $object->update($user) > 0)
+ {
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
+ exit;
+ }
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -131,6 +143,7 @@ print ' ';
print ' ';
print ' ';
print ' ';
+print ' ';
print dol_get_fiche_head('');
diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php
index 5adc7bbb17b..ff897db86a7 100644
--- a/htdocs/categories/index.php
+++ b/htdocs/categories/index.php
@@ -109,7 +109,7 @@ if (empty($nosearch)) {
foreach ($cats as $cat)
{
- $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #bbb"';
+ $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
print "\t".'
'."\n";
print "\t\t";
@@ -160,26 +160,45 @@ foreach ($fulltree as $key => $val)
$categstatic->ref = $val['label'];
$categstatic->color = $val['color'];
$categstatic->type = $type;
- $li = $categstatic->getNomUrl(1, '', 60, $moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
$desc = dol_htmlcleanlastbr($val['description']);
$counter = '';
-
if ($conf->global->CATEGORY_SHOW_COUNTS)
{
// we need only a count of the elements, so it is enough to consume only the id's from the database
- $elements = $categstatic->getObjectsInCateg($type, 1);
+ $elements = $type == Categorie::TYPE_ACCOUNT
+ ? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
+ : $categstatic->getObjectsInCateg($type, 1);
+
$counter = " ".(is_countable($elements) ? count($elements) : '0')." ";
}
$color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
+ $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
- $data[] = array(
- 'rowid'=>$val['rowid'],
- 'fk_menu'=>$val['fk_parent'],
- 'entry'=>''
- );
+ $entry = '';
+ $entry .= '';
+
+ $entry .= '';
+ $entry .= ''.$li.' ';
+ $entry .= ' ';
+
+ $entry .= $counter;
+
+ $entry .= '';
+ $entry .= ''.img_view().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_edit().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_delete().' ';
+ $entry .= ' ';
+
+ $entry .= ' ';
+ $entry .= '
';
+
+ $data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
}
@@ -194,7 +213,6 @@ if (!empty($conf->use_javascript_ajax))
print ' ';
$nbofentries = (count($data) - 1);
-
if ($nbofentries > 0)
{
print '';
diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php
index 864de6e2e98..b376b3d3320 100644
--- a/htdocs/categories/viewcat.php
+++ b/htdocs/categories/viewcat.php
@@ -104,6 +104,14 @@ if ($objecttype != $type) {
* Actions
*/
+if ($confirm == 'no')
+{
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ }
+}
+
$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
@@ -164,8 +172,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
{
if ($object->delete($user) >= 0)
{
- header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
- exit;
+ if ($backtopage) {
+ header("Location: ".$backtopage);
+ exit;
+ } else {
+ header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
+ exit;
+ }
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
@@ -250,7 +263,11 @@ dol_banner_tab($object, 'label', $linkback, ($user->socid ? 0 : 1), 'label', 'la
if ($action == 'delete')
{
- print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
+ if ($backtopage) {
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type.'&backtopage='.urlencode($backtopage), $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 2);
+ } else {
+ print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&type='.$type, $langs->trans('DeleteCategory'), $langs->trans('ConfirmDeleteCategory'), 'confirm_delete', '', '', 1);
+ }
}
print ' ';
@@ -294,7 +311,7 @@ if ($user->rights->categorie->creer)
if ($user->rights->categorie->supprimer)
{
- print 'id.'&type='.$type.'">'.$langs->trans("Delete").' ';
+ print 'id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").' ';
}
print "";
@@ -376,8 +393,7 @@ if ($cats < 0)
$categstatic->type = $type;
$desc = dol_htmlcleanlastbr($val['description']);
- $counter = 0;
-
+ $counter = '';
if ($conf->global->CATEGORY_SHOW_COUNTS)
{
// we need only a count of the elements, so it is enough to consume only the id's from the database
@@ -385,22 +401,29 @@ if ($cats < 0)
? $categstatic->getObjectsInCateg("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
: $categstatic->getObjectsInCateg($type, 1);
- $counter = is_countable($elements) ? count($elements) : 0;
+ $counter = " ".(is_countable($elements) ? count($elements) : '0')." ";
}
- $color = $categstatic->color ? ' style="background: #'.$categstatic->color.';"' : ' style="background: #aaa"';
+ $color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
+ $li = $categstatic->getNomUrl(1, '', 60, '&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type));
$entry = '';
$entry .= '';
$entry .= '';
- $entry .= ''.$categstatic->getNomUrl(1, '', 60).' ';
+ $entry .= ''.$li.' ';
$entry .= ' ';
- $entry .= ''.$counter.' ';
+ $entry .= $counter;
$entry .= '';
- $entry .= ''.img_view().' ';
+ $entry .= ''.img_view().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_edit().' ';
+ $entry .= ' ';
+ $entry .= '';
+ $entry .= ''.img_delete().' ';
$entry .= ' ';
$entry .= ' ';
@@ -409,7 +432,8 @@ if ($cats < 0)
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
}
- if ((count($data) - 1))
+ $nbofentries = (count($data) - 1);
+ if ($nbofentries > 0)
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
print '';