Categories can now be edited via the page
This commit is contained in:
parent
136ca3f206
commit
f7272e8549
@ -249,8 +249,6 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box">
|
||||
<div class="box-body">
|
||||
<?php
|
||||
/* This will handle error, success and notice messages */
|
||||
@ -284,159 +282,6 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="display: none"><?php echo $hesklang['id']; ?></th>
|
||||
<th><?php echo $hesklang['cat_name']; ?></th>
|
||||
<th><?php echo $hesklang['priority']; ?></th>
|
||||
<th><?php echo $hesklang['not']; ?></th>
|
||||
<th><?php echo $hesklang['graph']; ?></th>
|
||||
<th><?php echo $hesklang['usage']; ?></th>
|
||||
<th><?php echo $hesklang['manager']; ?></th>
|
||||
<th><?php echo $hesklang['opt']; ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
/* Get number of tickets per category */
|
||||
$tickets_all = array();
|
||||
$tickets_total = 0;
|
||||
|
||||
$res = hesk_dbQuery('SELECT COUNT(*) AS `cnt`, `category` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'tickets` GROUP BY `category`');
|
||||
while ($tmp = hesk_dbFetchAssoc($res)) {
|
||||
$tickets_all[$tmp['category']] = $tmp['cnt'];
|
||||
$tickets_total += $tmp['cnt'];
|
||||
}
|
||||
|
||||
/* Get list of categories */
|
||||
$res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "categories` ORDER BY `" . $orderBy . "` ASC");
|
||||
$usersRes = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "users` WHERE `isadmin` = '0' ORDER BY `name` ASC");
|
||||
$users = array();
|
||||
while ($userRow = hesk_dbFetchAssoc($usersRes)) {
|
||||
array_push($users, $userRow);
|
||||
}
|
||||
|
||||
$i = 1;
|
||||
$j = 0;
|
||||
$num = hesk_dbNumRows($res);
|
||||
|
||||
$usage = array(
|
||||
0 => '<i class="fa fa-fw fa-ticket icon-link" data-toggle="tooltip" title="' . $hesklang['tickets'] . '"></i>
|
||||
<i class="fa fa-fw fa-calendar icon-link" data-toggle="tooltip" title="' . $hesklang['events'] . '"></i>',
|
||||
1 => '<i class="fa fa-fw fa-ticket icon-link" data-toggle="tooltip" title="' . $hesklang['tickets'] . '"></i><i class="fa fa-fw"></i>',
|
||||
2 => '<i class="fa fa-fw icon-link"> </i> <i class="fa fa-fw fa-calendar icon-link" data-toggle="tooltip" title="' . $hesklang['events'] . '"></i>'
|
||||
);
|
||||
|
||||
while ($mycat = hesk_dbFetchAssoc($res)) {
|
||||
$j++;
|
||||
|
||||
if (isset($_SESSION['selcat2']) && $mycat['id'] == $_SESSION['selcat2']) {
|
||||
$color = 'admin_green';
|
||||
unset($_SESSION['selcat2']);
|
||||
} else {
|
||||
$color = $i ? 'admin_white' : 'admin_gray';
|
||||
}
|
||||
|
||||
$tmp = $i ? 'White' : 'Blue';
|
||||
$style = 'background: ' . $mycat['background_color'];
|
||||
$backgroundVolatile = 'background-volatile';
|
||||
if ($mycat['foreground_color'] != 'AUTO') {
|
||||
$style .= '; color: ' . $mycat['foreground_color'];
|
||||
$backgroundVolatile = '';
|
||||
|
||||
if ($mycat['display_border_outline']) {
|
||||
$style .= '; border: solid 1px ' . $mycat['foreground_color'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($mycat['foreground_color'] == 'AUTO') {
|
||||
$mycat['foreground_color'] = '';
|
||||
}
|
||||
|
||||
$i = $i ? 0 : 1;
|
||||
|
||||
/* Number of tickets and graph width */
|
||||
$all = isset($tickets_all[$mycat['id']]) ? $tickets_all[$mycat['id']] : 0;
|
||||
$width_all = 0;
|
||||
if ($tickets_total && $all) {
|
||||
$width_all = round(($all / $tickets_total) * 100);
|
||||
}
|
||||
|
||||
/* Deleting category with ID 1 (default category) is not allowed */
|
||||
if ($mycat['id'] == 1) {
|
||||
$remove_code = ' <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />';
|
||||
} else {
|
||||
$remove_code = ' <a href="manage_categories.php?a=remove&catid=' . $mycat['id'] . '&token=' . hesk_token_echo(0) . '" onclick="return confirm_delete();"><i class="fa fa-times icon-link red" data-toggle="tooltip" data-placement="top" title="' . $hesklang['delete'] . '"></i></a>';
|
||||
}
|
||||
|
||||
/* Is category private or public? */
|
||||
if ($mycat['type']) {
|
||||
$type_code = '<a href="manage_categories.php?a=type&s=0&catid=' . $mycat['id'] . '&token=' . hesk_token_echo(0) . '"><span class="glyphicon glyphicon-user gray" data-toggle="tooltip" data-placement="top" title="' . $hesklang['cat_private'] . '"></span></a>';
|
||||
} else {
|
||||
$type_code = '<a href="manage_categories.php?a=type&s=1&catid=' . $mycat['id'] . '&token=' . hesk_token_echo(0) . '"><span class="glyphicon glyphicon-user blue" data-toggle="tooltip" data-placement="top" title="' . $hesklang['cat_public'] . '"></span></a>';
|
||||
}
|
||||
|
||||
/* Is auto assign enabled? */
|
||||
if ($hesk_settings['autoassign']) {
|
||||
if ($mycat['autoassign']) {
|
||||
$autoassign_code = '<a href="manage_categories.php?a=autoassign&s=0&catid=' . $mycat['id'] . '&token=' . hesk_token_echo(0) . '"><i class="fa fa-bolt icon-link orange" data-toggle="tooltip" data-placement="top" title="' . $hesklang['aaon'] . '"></i></a>';
|
||||
} else {
|
||||
$autoassign_code = '<a href="manage_categories.php?a=autoassign&s=1&catid=' . $mycat['id'] . '&token=' . hesk_token_echo(0) . '"><i class="fa fa-bolt icon-link gray" data-toggle="tooltip" data-placement="top" title="' . $hesklang['aaoff'] . '"></i></a>';
|
||||
}
|
||||
} else {
|
||||
$autoassign_code = '';
|
||||
}
|
||||
|
||||
echo '
|
||||
<tr data-category-id="' . $mycat['id'] . '" data-name="' . htmlspecialchars($mycat['name']) . '"
|
||||
data-foreground-color="' . htmlspecialchars($mycat['foreground_color']) . '"
|
||||
data-border="' . $mycat['display_border_outline'] . '"
|
||||
data-background-color="'. htmlspecialchars($mycat['background_color']) . '"
|
||||
data-priority="' . $mycat['priority'] . '"
|
||||
data-manager="' . $mycat['manager'] . '" data-usage="'. $mycat['usage'] .'">
|
||||
<td style="display: none">' . $mycat['id'] . '</td>
|
||||
<td><span class="label ' . $backgroundVolatile . ' category-label" style="'.$style.'">' . $mycat['name'] . '</span></td>
|
||||
<td width="1" style="white-space: nowrap;">' . $priorities[$mycat['priority']]['formatted'] . '</td>
|
||||
<td><a href="show_tickets.php?category=' . $mycat['id'] . '&s_all=1&s_my=1&s_ot=1&s_un=1" alt="' . $hesklang['list_tickets_cat'] . '" title="' . $hesklang['list_tickets_cat'] . '">' . $all . '</a></td>
|
||||
<td>
|
||||
<div class="progress" style="width: 160px; margin-bottom: 0" title="' . sprintf($hesklang['perat'], $width_all . '%') . '" data-toggle="tooltip">
|
||||
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width: ' . $width_all . '%">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>' . $usage[$mycat['usage']] . '</td>
|
||||
<td>' . get_manager($mycat['manager'], $users) . '</td>
|
||||
<td>
|
||||
<a href="Javascript:void(0)" onclick="Javascript:hesk_window(\'manage_categories.php?a=linkcode&catid=' . $mycat['id'] . '&p=' . $mycat['type'] . '\',\'200\',\'500\')" id="tooltip"><i class="fa fa-code icon-link" style="color: ' . ($mycat['type'] ? 'gray' : 'green') . '" data-toggle="tooltip" data-placement="top" title="' . $hesklang['geco'] . '"></i></a>
|
||||
' . $autoassign_code . '
|
||||
' . $type_code . ' ';
|
||||
|
||||
if ($orderBy != 'name' && $num > 1) {
|
||||
if ($j == 1) {
|
||||
echo '<img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" /> <a href="manage_categories.php?a=order&catid=' . $mycat['id'] . '&move=15&token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-down icon-link green" data-toggle="tooltip" data-placement="top" title="' . $hesklang['move_dn'] . '"></i></a> ';
|
||||
} elseif ($j == $num) {
|
||||
echo '<a href="manage_categories.php?a=order&catid=' . $mycat['id'] . '&move=-15&token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-up icon-link green" data-toggle="tooltip" data-placement="top" title="' . $hesklang['move_up'] . '"></i></a> <img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;" />';
|
||||
} else {
|
||||
echo '
|
||||
<a href="manage_categories.php?a=order&catid=' . $mycat['id'] . '&move=-15&token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-up icon-link green" data-toggle="tooltip" data-placement="top" title="' . $hesklang['move_up'] . '"></i></a>
|
||||
<a href="manage_categories.php?a=order&catid=' . $mycat['id'] . '&move=15&token=' . hesk_token_echo(0) . '"><i class="fa fa-arrow-down icon-link green" data-toggle="tooltip" data-placement="top" title="' . $hesklang['move_dn'] . '"></i></a>
|
||||
';
|
||||
}
|
||||
}
|
||||
echo '<a href="javascript:;" class="category-modal-trigger" data-category-id="' . $mycat['id'] . '"><i class="fa fa-pencil icon-link orange" data-toggle="tooltip" title="' . $hesklang['edit'] . '"></i></a>';
|
||||
echo $remove_code . '</td>
|
||||
</tr>
|
||||
';
|
||||
|
||||
} // End while
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="overlay" id="overlay">
|
||||
@ -550,6 +395,14 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description" class="col-sm-3 control-label">
|
||||
<?php echo $hesklang['description']; ?>
|
||||
</label>
|
||||
<div class="col-sm-9">
|
||||
<textarea class="form-control" name="description"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -560,12 +413,12 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
<input type="hidden" name="cat-order">
|
||||
<input type="hidden" name="type">
|
||||
<input type="hidden" name="autoassign">
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-default cancel-callback" data-dismiss="modal">
|
||||
<div id="action-buttons" class="btn-group">
|
||||
<button type="button" class="btn btn-default cancel-button cancel-callback" data-dismiss="modal">
|
||||
<i class="fa fa-times-circle"></i>
|
||||
<span><?php echo $hesklang['cancel']; ?></span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-success callback-btn">
|
||||
<button type="submit" class="btn btn-success save-button">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
<span><?php echo $hesklang['save']; ?></span>
|
||||
</button>
|
||||
@ -608,7 +461,6 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
data-toggle="tooltip" data-placement="top" title="Category autoassign tooltip"></i>
|
||||
</a>
|
||||
<a data-property="type-link" href="#">
|
||||
<?php // fa-lock or fa-unlock-alt ?>
|
||||
<i class="fa fa-fw fa-lock gray" data-toggle="tooltip" data-placement="top" title="Category type tooltip"></i>
|
||||
</a>
|
||||
<span class="sort-arrows">
|
||||
@ -634,6 +486,7 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix'])
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
<input type="hidden" name="show-tickets-path" value="show_tickets.php?category={0}&s_all=1&s_my=1&s_ot=1&s_un=1">
|
||||
<?php
|
||||
echo mfh_get_hidden_fields_for_language(array(
|
||||
'critical',
|
||||
|
@ -13,7 +13,7 @@ class CategoryRetriever {
|
||||
private $categoryGateway;
|
||||
|
||||
/**
|
||||
* @param $modsForHeskSettingsGateway ModsForHeskSettingsGateway
|
||||
* @var ModsForHeskSettingsGateway
|
||||
*/
|
||||
private $modsForHeskSettingsGateway;
|
||||
|
||||
|
@ -78,7 +78,7 @@ class CategoryController {
|
||||
$data = JsonRetriever::getJsonData();
|
||||
|
||||
$category = $this->buildCategoryFromJson($data);
|
||||
$category->id = $id;
|
||||
$category->id = intval($id);
|
||||
|
||||
/* @var $categoryHandler CategoryHandler */
|
||||
$categoryHandler = $applicationContext->get[CategoryHandler::class];
|
||||
|
@ -188,8 +188,8 @@ Link::before('globalBefore');
|
||||
Link::all(array(
|
||||
// Categories
|
||||
'/v1/categories/all' => action(\Controllers\Categories\CategoryController::class . '::printAllCategories', [RequestMethod::GET], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||
'/v1/categories' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::POST]),
|
||||
'/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE]),
|
||||
'/v1/categories' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::POST], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||
'/v1/categories/{i}' => action(\Controllers\Categories\CategoryController::class, [RequestMethod::GET, RequestMethod::PUT, RequestMethod::DELETE], SecurityHandler::INTERNAL_OR_AUTH_TOKEN),
|
||||
// Tickets
|
||||
'/v1/tickets' => action(\Controllers\Tickets\CustomerTicketController::class),
|
||||
// Tickets - Staff
|
||||
|
@ -62,9 +62,10 @@ function loadTable() {
|
||||
// Low
|
||||
$priority.text(mfhLang.text('low')).addClass('normal');
|
||||
}
|
||||
var linkPattern = $('input[name="show-tickets-path"]').val();
|
||||
$template.find('a[data-property="number-of-tickets"]')
|
||||
.text(this.numberOfTickets)
|
||||
.attr('href', '#' + this.numberOfTickets);
|
||||
.attr('href', linkPattern.replace('{0}', this.id));
|
||||
var percentText = mfhLang.text('perat');
|
||||
var percentage = Math.round(this.numberOfTickets / totalNumberOfTickets * 100);
|
||||
$template.find('div.progress').attr('title', percentText.replace('%s', percentage + '%'));
|
||||
@ -165,6 +166,9 @@ function bindEditModal() {
|
||||
$modal.find('input[name="foreground-color"]')
|
||||
.colorpicker(colorpickerOptions).end().modal('show');
|
||||
$modal.find('input[name="cat-order"]').val(element.catOrder);
|
||||
$modal.find('input[name="autoassign"]').val(element.autoAssign);
|
||||
$modal.find('input[name="type"]').val(element.type);
|
||||
$modal.find('textarea[name="description"]').val(element.description === null ? '' : element.description);
|
||||
|
||||
$modal.modal('show');
|
||||
});
|
||||
@ -189,16 +193,16 @@ function bindFormSubmit() {
|
||||
var $modal = $('#category-modal');
|
||||
|
||||
var data = {
|
||||
autoassign: $modal.find('input[name="autoassign"]').val(),
|
||||
autoassign: $modal.find('input[name="autoassign"]').val() === 'true',
|
||||
backgroundColor: $modal.find('input[name="background-color"]').val(),
|
||||
description: $modal.find('textarea[name="description"]').val(),
|
||||
displayBorder: $modal.find('input[name="display-border"]:checked').val(),
|
||||
foregroundColor: $modal.find('input[name="foreground-color"]').val() === '' ? 'AUTO' : $modal.find('input[name="foreground-color"]'),
|
||||
displayBorder: $modal.find('input[name="display-border"]:checked').val() === '1',
|
||||
foregroundColor: $modal.find('input[name="foreground-color"]').val() === '' ? 'AUTO' : $modal.find('input[name="foreground-color"]').val(),
|
||||
name: $modal.find('input[name="name"]').val(),
|
||||
priority: $modal.find('select[name="priority"]').val(),
|
||||
type: $modal.find('input[name="type"]').val(),
|
||||
usage: $modal.find('select[name="usage"]').val(),
|
||||
catOrder: $modal.find('input[name="cat-order"]').val()
|
||||
priority: parseInt($modal.find('select[name="priority"]').val()),
|
||||
type: parseInt($modal.find('input[name="type"]').val()),
|
||||
usage: parseInt($modal.find('select[name="usage"]').val()),
|
||||
catOrder: parseInt($modal.find('input[name="cat-order"]').val())
|
||||
};
|
||||
|
||||
var url = heskUrl + 'api/index.php/v1/categories/';
|
||||
@ -206,16 +210,14 @@ function bindFormSubmit() {
|
||||
|
||||
var categoryId = $modal.find('input[name="id"]').val();
|
||||
if (categoryId !== -1) {
|
||||
url += id;
|
||||
url += categoryId;
|
||||
method = 'PUT';
|
||||
}
|
||||
|
||||
$modal.find('#action-buttons').find('.cancel-button').attr('disabled', 'disabled');
|
||||
$modal.find('#action-buttons').find('.save-button').attr('disabled', 'disabled');
|
||||
|
||||
console.log('')
|
||||
|
||||
/*$.ajax({
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: url,
|
||||
headers: {
|
||||
@ -224,7 +226,7 @@ function bindFormSubmit() {
|
||||
},
|
||||
data: JSON.stringify(data),
|
||||
success: function(data) {
|
||||
if (id === -1) {
|
||||
if (categoryId === -1) {
|
||||
mfhAlert.success('CREATED');
|
||||
} else {
|
||||
mfhAlert.success('SAVED');
|
||||
@ -240,6 +242,6 @@ function bindFormSubmit() {
|
||||
$modal.find('#action-buttons').find('.cancel-button').removeAttr('disabled');
|
||||
$modal.find('#action-buttons').find('.save-button').removeAttr('disabled');
|
||||
}
|
||||
});*/
|
||||
});
|
||||
});
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user