diff --git a/admin/manage_categories.php b/admin/manage_categories.php index 6f106775..2e2e48e0 100644 --- a/admin/manage_categories.php +++ b/admin/manage_categories.php @@ -62,8 +62,6 @@ if ($action = hesk_REQUEST('a')) { hesk_process_messages($hesklang['ddemo'], 'manage_categories.php', 'NOTICE'); } elseif ($action == 'new') { new_cat(); - } elseif ($action == 'rename') { - rename_cat(); } elseif ($action == 'remove') { remove(); } elseif ($action == 'order') { @@ -72,10 +70,8 @@ if ($action = hesk_REQUEST('a')) { toggle_autoassign(); } elseif ($action == 'type') { toggle_type(); - } elseif ($action == 'priority') { - change_priority(); - } elseif ($action == 'manager') { - change_manager(); + } elseif ($action == 'edit') { + update_category(); } } @@ -112,18 +108,12 @@ while ($mycat = hesk_dbFetchAssoc($res)) { ?>
- -
-
- +
+
+ +
+
-

- -

: ()

@@ -137,8 +127,8 @@ while ($mycat = hesk_dbFetchAssoc($res)) { echo ' value="' . hesk_input($_SESSION['catname']) . '" '; } ?> - data-error="" - required> + data-error="" + required>
@@ -174,8 +164,8 @@ while ($mycat = hesk_dbFetchAssoc($res)) {
+ placeholder="" type="text" + name="color" maxlength="7">
@@ -209,230 +199,248 @@ while ($mycat = hesk_dbFetchAssoc($res)) {
-
-
-

- -
-
- - -
- -
-
-
- - -
- - data-error="" - required> -
-
-
-
- - - -
-
-
-
-
-

- -
-
- - -
- -
-
-
- - -
- -
-
-
-
- - - -
-
-
-
- -
- -

- -
- - - - - - - - - - - - - '; - } else { - $remove_code = ' '; - } +
+
+ +
+
+ '; - } else { - $type_code = ''; + if ($hesk_settings['cust_urgency']) { + hesk_show_notice($hesklang['cat_pri_info'] . ' ' . $hesklang['cpri']); } + ?> +
+ + + + + + + + + + + '; - } else { - $autoassign_code = ''; + /* 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); } - } else { - $autoassign_code = ''; - } - echo ' - - - + $i = 1; + $j = 0; + $num = hesk_dbNumRows($res); + + 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 = 'font-weight:normal;font-size:1em'; + if ($mycat['color'] == null) { + $style .= ';color: black'; + } else { + $style .= ';background: ' . $mycat['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 ' + + + - + + } + } + echo ''; + echo $remove_code . ' '; - } // End while + } // End while - ?> -
' . $mycat['id'] . '' . $mycat['name'] . '
' . $mycat['id'] . '' . $mycat['name'] . ' ' . $priorities[$mycat['priority']]['formatted'] . ' ' . $all . ' -
-
- 40% Complete (success) +
+
+ 40% Complete (success) +
-
' . output_user_dropdown($mycat['id'], $mycat['manager'], $users) . '' . get_manager($mycat['manager'], $users) . ' ' . $autoassign_code . ' ' . $type_code . ' '; - if ($orderBy != 'name' && $num > 1) { - if ($j == 1) { - echo ' '; - } elseif ($j == $num) { - echo ' '; - } else { - echo ' + if ($orderBy != 'name' && $num > 1) { + if ($j == 1) { + echo '  '; + } elseif ($j == $num) { + echo ' '; + } else { + echo '   '; - } - } - - echo $remove_code . '
+ ?> + +
+
+ + + ' . stripslashes($catname) . '', $_SERVER['PHP_SELF'], 'SUCCESS'); + hesk_process_messages(sprintf($hesklang['category_updated'], stripslashes($catname)), $_SERVER['PHP_SELF'], 'SUCCESS'); } // End rename_cat() @@ -731,59 +740,42 @@ function toggle_type() } // End toggle_type() -function output_user_dropdown($catId, $selectId, $userArray) +function output_user_dropdown($userArray) { global $hesklang; if (!hesk_checkPermission('can_set_manager', 0)) { foreach ($userArray as $user) { if ($user['id'] == $selectId) { - return '

' . $user['name'] . '

'; + return '

' . $user['name'] . '

'; } } - return '

' . $hesklang['no_manager'] . '

'; + return '

' . $hesklang['no_manager'] . '

'; } else { - $dropdownMarkup = ' '; foreach ($userArray as $user) { - $select = $selectId == $user['id'] ? 'selected' : ''; - $dropdownMarkup .= ''; + $dropdownMarkup .= ''; } $dropdownMarkup .= ''; - return '
- - - ' . $dropdownMarkup . ' -
'; + return $dropdownMarkup; } } -function change_manager() -{ - global $hesklang, $hesk_settings; - - $catid = hesk_POST('catid'); - $newManagerId = hesk_POST('managerid'); +function get_manager($user_id, $user_array) { + global $hesklang; - hesk_dbQuery('UPDATE `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'categories` SET `manager` = ' . intval($newManagerId) . ' WHERE `id` = ' . intval($catid)); - if (hesk_dbAffectedRows() != 1) { - hesk_process_messages($hesklang['int_error'] . ': ' . $hesklang['cat_not_found'], './manage_categories.php'); - } - if ($newManagerId == 0) { - // There is no new manager. - return; - } - // Add the category to the user's categories list, if not already present - $currentCatRs = hesk_dbQuery('SELECT `categories` FROM `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'users` WHERE `id` = ' . intval($newManagerId)); - $currentCategories = hesk_dbFetchAssoc($currentCatRs); - $categories = explode(',', $currentCategories['categories']); - if (!in_array($catid, $categories)) { - hesk_dbQuery('UPDATE `' . hesk_dbEscape($hesk_settings['db_pfix']) . 'users` SET `categories` = \'' . $currentCategories['categories'] . ',' . $catid . '\' WHERE `id` = ' . intval($newManagerId)); + if ($user_id == 0) { + return $hesklang['no_manager']; } - hesk_process_messages($hesklang['manager_updated'], './manage_categories.php', 'SUCCESS'); + foreach ($user_array as $user) { + if ($user['id'] == $user_id) { + return $user['name']; + } + } } ?> diff --git a/js/modsForHesk-javascript.js b/js/modsForHesk-javascript.js index 25269c7e..cab0b88f 100644 --- a/js/modsForHesk-javascript.js +++ b/js/modsForHesk-javascript.js @@ -48,8 +48,33 @@ var loadJquery = function() }); $('.clockpicker').clockpicker(); + + // Set the proper text color for background-volatile elements + $('.background-volatile').each(function() { + $this = $(this); + var background = $this.css('background-color'); + + if (background !== 'rgba(0, 0, 0, 0)') { + var grayCount = calculateGrayCount(background); + + if (grayCount > 186) { + $this.css('color', '#000'); + } else { + $this.css('color', '#fff'); + } + } + }); }; +function calculateGrayCount(background) { + var parts = background.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); + var red = parts[1]; + var green = parts[2]; + var blue = parts[3]; + + return red*0.299 + green*0.587 + blue*0.114; +} + var setIcon = function(icon) { $('[data-toggle="iconpicker"]').iconpicker('setIcon', icon); } diff --git a/language/en/text.php b/language/en/text.php index 84314040..ab143df0 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -42,6 +42,7 @@ $hesklang['attachment_remove'] = 'Remove attachment'; $hesklang['due_date'] = 'Due Date'; $hesklang['category_color'] = 'Color'; $hesklang['category_color_help'] = 'The hex code for the color to be used on the view ticket screen and calendar. Leave blank for no color'; +$hesklang['category_updated'] = 'Changes to %s have been saved'; // ADDED OR MODIFIED IN Mods for HESK 2.5.2 $hesklang['manage_statuses'] = 'Manage Statuses';