diff --git a/admin/manage_categories.php b/admin/manage_categories.php index 62498722..b90caebb 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -249,201 +249,46 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) - -
-
- + -
-
- -
-
- - - - - - - - - - - - - - -
-
- -
- - - - - - - - - - - - - - - ' - ', - 1 => '', - 2 => ' ' - ); - - 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 = ' '; - } else { - $remove_code = ' '; - } - - /* Is category private or public? */ - if ($mycat['type']) { - $type_code = ''; - } else { - $type_code = ''; - } - - /* Is auto assign enabled? */ - if ($hesk_settings['autoassign']) { - if ($mycat['autoassign']) { - $autoassign_code = ''; - } else { - $autoassign_code = ''; - } - } else { - $autoassign_code = ''; - } - - echo ' - - - - - - - - - - - '; - - } // End while - - ?> - -
' . $mycat['id'] . '' . $mycat['name'] . '' . $priorities[$mycat['priority']]['formatted'] . '' . $all . ' -
-
-
+ if ($hesk_settings['cust_urgency']) { + hesk_show_notice($hesklang['cat_pri_info'] . ' ' . $hesklang['cpri']); + } + ?> +
+
+ +
+
+ + + + + + + + + + + + + + +
-
' . $usage[$mycat['usage']] . '' . get_manager($mycat['manager'], $users) . ' - - ' . $autoassign_code . ' - ' . $type_code . ' '; - - if ($orderBy != 'name' && $num > 1) { - if ($j == 1) { - echo '  '; - } elseif ($j == $num) { - echo ' '; - } else { - echo ' - -   - '; - } - } - echo ''; - echo $remove_code . '
+
+ +
-
- -
-
- + +
+ +
+ +
+
@@ -560,12 +413,12 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) -
- - @@ -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"> - @@ -634,6 +486,7 @@ $res = hesk_dbQuery("SELECT * FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) + buildCategoryFromJson($data); - $category->id = $id; + $category->id = intval($id); /* @var $categoryHandler CategoryHandler */ $categoryHandler = $applicationContext->get[CategoryHandler::class]; diff --git a/api/index.php b/api/index.php index 25b77ee3..ffaf590d 100644 --- a/api/index.php +++ b/api/index.php @@ -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 diff --git a/internal-api/js/manage-categories.js b/internal-api/js/manage-categories.js index a7716ad7..077eb423 100644 --- a/internal-api/js/manage-categories.js +++ b/internal-api/js/manage-categories.js @@ -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'); } - });*/ + }); }); } \ No newline at end of file