Add edit/delete action icons on categories list pages
+ classes for icons + format color as in latest commits
This commit is contained in:
parent
9d31780155
commit
574f1f0336
@ -39,6 +39,7 @@ $type = GETPOST('type', 'aZ09'); // Can be int or string
|
|||||||
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
|
$action = (GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'edit');
|
||||||
$confirm = GETPOST('confirm');
|
$confirm = GETPOST('confirm');
|
||||||
$cancel = GETPOST('cancel', 'alpha');
|
$cancel = GETPOST('cancel', 'alpha');
|
||||||
|
$backtopage = GETPOST('backtopage', 'alpha');
|
||||||
|
|
||||||
$socid = (int) GETPOST('socid', 'int');
|
$socid = (int) GETPOST('socid', 'int');
|
||||||
$label = (string) GETPOST('label', 'alphanohtml');
|
$label = (string) GETPOST('label', 'alphanohtml');
|
||||||
@ -74,8 +75,13 @@ $error = 0;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ($cancel) {
|
if ($cancel) {
|
||||||
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$object->id.'&type='.$type);
|
if ($backtopage) {
|
||||||
exit;
|
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
|
// Action mise a jour d'une categorie
|
||||||
@ -98,9 +104,15 @@ if ($action == 'update' && $user->rights->categorie->creer) {
|
|||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) $error++;
|
||||||
|
|
||||||
if (!$error && $object->update($user) > 0) {
|
if (!$error && $object->update($user) > 0)
|
||||||
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;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
@ -131,6 +143,7 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
|
|||||||
print '<input type="hidden" name="action" value="update">';
|
print '<input type="hidden" name="action" value="update">';
|
||||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||||
print '<input type="hidden" name="type" value="'.$type.'">';
|
print '<input type="hidden" name="type" value="'.$type.'">';
|
||||||
|
print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
|
||||||
|
|
||||||
print dol_get_fiche_head('');
|
print dol_get_fiche_head('');
|
||||||
|
|
||||||
|
|||||||
@ -109,7 +109,7 @@ if (empty($nosearch)) {
|
|||||||
|
|
||||||
foreach ($cats as $cat)
|
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".'<tr class="oddeven">'."\n";
|
print "\t".'<tr class="oddeven">'."\n";
|
||||||
print "\t\t<td>";
|
print "\t\t<td>";
|
||||||
@ -160,26 +160,45 @@ foreach ($fulltree as $key => $val)
|
|||||||
$categstatic->ref = $val['label'];
|
$categstatic->ref = $val['label'];
|
||||||
$categstatic->color = $val['color'];
|
$categstatic->color = $val['color'];
|
||||||
$categstatic->type = $type;
|
$categstatic->type = $type;
|
||||||
$li = $categstatic->getNomUrl(1, '', 60, $moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam));
|
|
||||||
$desc = dol_htmlcleanlastbr($val['description']);
|
$desc = dol_htmlcleanlastbr($val['description']);
|
||||||
|
|
||||||
$counter = '';
|
$counter = '';
|
||||||
|
|
||||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
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
|
// 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 = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
|
$counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$color = $categstatic->color ? ' style="background: #'.sprintf("%06s", $categstatic->color).';"' : ' style="background: #bbb"';
|
$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(
|
$entry = '<table class="nobordernopadding centpercent">';
|
||||||
'rowid'=>$val['rowid'],
|
$entry .= '<tr>';
|
||||||
'fk_menu'=>$val['fk_parent'],
|
|
||||||
'entry'=>'<table class="nobordernopadding centpercent"><tr><td><span class="noborderoncategories"'.$color.'>'.$li.'</span></td>'.$counter.
|
$entry .= '<td>';
|
||||||
'<td class="right" width="20px;"><a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'">'.img_view().'</a></td></tr></table>'
|
$entry .= '<span class="noborderoncategories" '.$color.'>'.$li.'</span>';
|
||||||
);
|
$entry .= '</td>';
|
||||||
|
|
||||||
|
$entry .= $counter;
|
||||||
|
|
||||||
|
$entry .= '<td class="right" width="20px;">';
|
||||||
|
$entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type).'">'.img_view().'</a>';
|
||||||
|
$entry .= '</td>';
|
||||||
|
$entry .= '<td class="right" width="20px;">';
|
||||||
|
$entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.$moreparam.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type).'">'.img_edit().'</a>';
|
||||||
|
$entry .= '</td>';
|
||||||
|
$entry .= '<td class="right" width="20px;">';
|
||||||
|
$entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.$moreparam.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?type='.$type.$moreparam).'">'.img_delete().'</a>';
|
||||||
|
$entry .= '</td>';
|
||||||
|
|
||||||
|
$entry .= '</tr>';
|
||||||
|
$entry .= '</table>';
|
||||||
|
|
||||||
|
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -194,7 +213,6 @@ if (!empty($conf->use_javascript_ajax))
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
$nbofentries = (count($data) - 1);
|
$nbofentries = (count($data) - 1);
|
||||||
|
|
||||||
if ($nbofentries > 0)
|
if ($nbofentries > 0)
|
||||||
{
|
{
|
||||||
print '<tr class="pair"><td colspan="3">';
|
print '<tr class="pair"><td colspan="3">';
|
||||||
|
|||||||
@ -104,6 +104,14 @@ if ($objecttype != $type) {
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if ($confirm == 'no')
|
||||||
|
{
|
||||||
|
if ($backtopage) {
|
||||||
|
header("Location: ".$backtopage);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||||
// Remove element from category
|
// Remove element from category
|
||||||
@ -164,8 +172,13 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
|
|||||||
{
|
{
|
||||||
if ($object->delete($user) >= 0)
|
if ($object->delete($user) >= 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
|
if ($backtopage) {
|
||||||
exit;
|
header("Location: ".$backtopage);
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/categories/index.php?type='.$type);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
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')
|
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 '<br>';
|
print '<br>';
|
||||||
@ -294,7 +311,7 @@ if ($user->rights->categorie->creer)
|
|||||||
|
|
||||||
if ($user->rights->categorie->supprimer)
|
if ($user->rights->categorie->supprimer)
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'">'.$langs->trans("Delete").'</a>';
|
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&token='.newToken().'&id='.$object->id.'&type='.$type.'&backtolist='.urlencode($backtolist).'">'.$langs->trans("Delete").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -376,8 +393,7 @@ if ($cats < 0)
|
|||||||
$categstatic->type = $type;
|
$categstatic->type = $type;
|
||||||
$desc = dol_htmlcleanlastbr($val['description']);
|
$desc = dol_htmlcleanlastbr($val['description']);
|
||||||
|
|
||||||
$counter = 0;
|
$counter = '';
|
||||||
|
|
||||||
if ($conf->global->CATEGORY_SHOW_COUNTS)
|
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
|
// 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("account", 1) // Categorie::TYPE_ACCOUNT is "bank_account" instead of "account"
|
||||||
: $categstatic->getObjectsInCateg($type, 1);
|
: $categstatic->getObjectsInCateg($type, 1);
|
||||||
|
|
||||||
$counter = is_countable($elements) ? count($elements) : 0;
|
$counter = "<td class='left' width='40px;'>".(is_countable($elements) ? count($elements) : '0')."</td>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$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 = '<table class="nobordernopadding centpercent">';
|
$entry = '<table class="nobordernopadding centpercent">';
|
||||||
$entry .= '<tr>';
|
$entry .= '<tr>';
|
||||||
|
|
||||||
$entry .= '<td>';
|
$entry .= '<td>';
|
||||||
$entry .= '<span class="noborderoncategories" '.$color.'>'.$categstatic->getNomUrl(1, '', 60).'</span>';
|
$entry .= '<span class="noborderoncategories" '.$color.'>'.$li.'</span>';
|
||||||
$entry .= '</td>';
|
$entry .= '</td>';
|
||||||
|
|
||||||
$entry .= '<td class="left" width="40px;">'.$counter.'</td>';
|
$entry .= $counter;
|
||||||
|
|
||||||
$entry .= '<td class="right" width="20px;">';
|
$entry .= '<td class="right" width="20px;">';
|
||||||
$entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'">'.img_view().'</a>';
|
$entry .= '<a href="'.DOL_URL_ROOT.'/categories/viewcat.php?id='.$val['id'].'&type='.$type.'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_view().'</a>';
|
||||||
|
$entry .= '</td>';
|
||||||
|
$entry .= '<td class="right" width="20px;">';
|
||||||
|
$entry .= '<a class="editfielda" href="'.DOL_URL_ROOT.'/categories/edit.php?id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_edit().'</a>';
|
||||||
|
$entry .= '</td>';
|
||||||
|
$entry .= '<td class="right" width="20px;">';
|
||||||
|
$entry .= '<a class="deletefilelink" href="'.DOL_URL_ROOT.'/categories/viewcat.php?action=delete&token='.newToken().'&id='.$val['id'].'&type='.$type.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'&backtolist='.urlencode($_SERVER["PHP_SELF"].'?id='.$id.'&type='.$type).'">'.img_delete().'</a>';
|
||||||
$entry .= '</td>';
|
$entry .= '</td>';
|
||||||
|
|
||||||
$entry .= '</tr>';
|
$entry .= '</tr>';
|
||||||
@ -409,7 +432,8 @@ if ($cats < 0)
|
|||||||
$data[] = array('rowid' => $val['rowid'], 'fk_menu' => $val['fk_parent'], 'entry' => $entry);
|
$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';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/treeview.lib.php';
|
||||||
print '<tr class="pair">';
|
print '<tr class="pair">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user