diff --git a/admin/new_ticket.php b/admin/new_ticket.php index cedc18e8..fad34c8f 100644 --- a/admin/new_ticket.php +++ b/admin/new_ticket.php @@ -48,6 +48,9 @@ hesk_session_start(); hesk_dbConnect(); hesk_isLoggedIn(); +// Load custom fields +require_once(HESK_PATH . 'inc/custom_fields.inc.php'); + // Pre-populate fields // Customer name if (isset($_REQUEST['name'])) { @@ -122,6 +125,35 @@ require_once(HESK_PATH . 'inc/headerAdmin.inc.php'); /* Print admin navigation */ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php'); +// Get categories +$hesk_settings['categories'] = array(); + +if (hesk_checkPermission('can_submit_any_cat', 0)) { + $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` ORDER BY `cat_order` ASC"); +} else { + $res = hesk_dbQuery("SELECT `id`, `name` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."categories` WHERE ".hesk_myCategories('id')." ORDER BY `cat_order` ASC"); +} + +while ($row = hesk_dbFetchAssoc($res)) { + $hesk_settings['categories'][$row['id']] = $row['name']; +} + +$number_of_categories = count($hesk_settings['categories']); + +if ($number_of_categories == 0) { + $category = 1; +} elseif ($number_of_categories == 1) { + $category = current(array_keys($hesk_settings['categories'])); +} else { + $category = isset($_GET['catid']) ? hesk_REQUEST('catid'): hesk_REQUEST('category'); + + // Force the customer to select a category? + if (!isset($hesk_settings['categories'][$category])) { + return print_select_category($number_of_categories); + } +} + + $showRs = hesk_dbQuery("SELECT `show` FROM `" . hesk_dbEscape($hesk_settings['db_pfix']) . "quick_help_sections` WHERE `id` = 5"); $show = hesk_dbFetchAssoc($showRs); $show_quick_help = $show['show']; @@ -129,7 +161,11 @@ $show_quick_help = $show['show'];
- +
- placeholder="" - onkeyup="disableIfEmpty('email-input','notify-email')"> + onkeyup="disableIfEmpty('email','notify-email')">
- - -
- - -
- -
-
-
+ $v) { - if ($v['use'] && $v['place'] == 0) { + if ($v['use'] && $v['place'] == 0 && hesk_is_custom_field_in_category($k, $category)) { if ($modsForHesk_settings['custom_field_setting']) { $v['name'] = $hesklang[$v['name']]; } - // $v['req'] = $v['req'] ? '*' : ''; - // Staff doesn't need to fill in required custom fields - $v['req'] = ''; + $v['req'] = $v['req']==2 ? '*' : ''; if ($v['type'] == 'checkbox' && !isset($_GET["c_$k"])) { $k_value = array(); @@ -374,10 +377,9 @@ $show_quick_help = $show['show']; case 'radio': echo '
'; - $options = explode('#HESK#', $v['value']); $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - foreach ($options as $option) { + foreach ($v['value']['radio_options'] as $option) { if (strlen($k_value) == 0 || $k_value == $option) { $k_value = $option; @@ -409,15 +411,11 @@ $show_quick_help = $show['show'];
'; break; - case 'multiselect': - //Clean up multiple dashes or whitespaces - $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - - echo '
-
-
- - -
'; - break; - /* Checkbox */ case 'checkbox': //Clean up multiple dashes or whitespaces @@ -469,11 +436,9 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s_]/", "-", $v['name']); echo '
'; - $options = explode('#HESK#', $v['value']); $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - foreach ($options as $option) { - + foreach ($v['value']['checkbox_options'] as $option) { if (in_array($option, $k_value)) { $checked = 'checked="checked"'; } else { @@ -491,15 +456,11 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - $size = explode('#', $v['value']); - $size[0] = empty($size[0]) ? 5 : intval($size[0]); - $size[1] = empty($size[1]) ? 30 : intval($size[1]); - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; echo '
-
+
'; break; @@ -516,20 +477,20 @@ $show_quick_help = $show['show']; echo '
- +
- ' . $hesklang['date_format'] . ' + maxlength="' . $v['maxlen'] . '" value="' . $v['value'] . '" readonly>
'; break; - case 'email': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 1'.($v['value']['multiple'] ? ',1' : '').')"' : ''; + if (strlen($k_value) != 0) { $v['value'] = $k_value; } @@ -543,8 +504,8 @@ $show_quick_help = $show['show']; echo '
-
-
'; +
+
'; break; @@ -554,13 +515,9 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s_]/", "-", $formattedId); if (strlen($k_value) != 0) { - $v['value'] = $k_value; + $v['value']['hidden_default_value'] = $k_value; } - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - - echo ''; - + $hidden_cf_buffer .= ''; break; case 'readonly': @@ -587,15 +544,15 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - if (strlen($k_value) != 0) { - $v['value'] = $k_value; + if (strlen($k_value) != 0 || isset($_SESSION["as_$k"])) { + $v['value']['default_value'] = $k_value; } $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; echo '
-
+
'; } } @@ -750,17 +707,28 @@ $show_quick_help = $show['show']; $has_error = ''; if (in_array('subject', $_SESSION['iserror'])) { $has_error = 'has-error'; - }?> + } + + $red_star = ''; + $validator = ''; + if ($hesk_settings['require_subject'] == 1) { + $red_star = '*'; + $validator = 'data-error="' . htmlspecialchars($hesklang['enter_subject']) . '"" required'; + } + ?>
- +
+ >
@@ -768,16 +736,27 @@ $show_quick_help = $show['show']; $has_error = ''; if (in_array('message', $_SESSION['iserror'])) { $has_error = 'has-error'; - } ?> + } + + $red_star = ''; + $validator = ''; + if ($hesk_settings['require_message'] == 1) { + $red_star = '*'; + $validator = 'data-error="' . htmlspecialchars($hesklang['enter_message']) . '"" required'; + } + ?>
- +
@@ -789,14 +768,12 @@ $show_quick_help = $show['show']; /* custom fields AFTER comments */ foreach ($hesk_settings['custom_fields'] as $k => $v) { - if ($v['use'] && $v['place']) { + if ($v['use'] && $v['place'] == 1 && hesk_is_custom_field_in_category($k, $category)) { if ($modsForHesk_settings['custom_field_setting']) { $v['name'] = $hesklang[$v['name']]; } - // $v['req'] = $v['req'] ? '*' : ''; - // Staff doesn't need to fill in required custom fields - $v['req'] = ''; + $v['req'] = $v['req'] == 2 ? '*' : ''; if ($v['type'] == 'checkbox') { $k_value = array(); @@ -814,16 +791,11 @@ $show_quick_help = $show['show']; switch ($v['type']) { /* Radio box */ case 'radio': - //Clean up multiple dashes or whitespaces - $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - echo '
'; - $options = explode('#HESK#', $v['value']); $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - foreach ($options as $option) { + foreach ($v['value']['radio_options'] as $option) { if (strlen($k_value) == 0 || $k_value == $option) { $k_value = $option; @@ -832,6 +804,10 @@ $show_quick_help = $show['show']; $checked = ''; } + //Clean up multiple dashes or whitespaces + $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + echo '
'; } @@ -840,25 +816,22 @@ $show_quick_help = $show['show']; /* Select drop-down box */ case 'select': + //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - echo '
+ echo '
+
'; break; @@ -927,51 +893,20 @@ $show_quick_help = $show['show']; echo '
- +
- ' . $hesklang['date_format'] . ' + maxlength="' . $v['maxlen'] . '" value="' . $v['value'] . '" readonly>
'; break; - - case 'multiselect': - //Clean up multiple dashes or whitespaces - $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - - echo '
-
-
- - -
'; - break; - case 'email': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $suggest = $hesk_settings['detect_typos'] ? 'onblur="Javascript:hesk_suggestEmail(\''.$k.'\', \''.$k.'_suggestions\', 0, 1'.($v['value']['multiple'] ? ',1' : '').')"' : ''; + if (strlen($k_value) != 0) { $v['value'] = $k_value; } @@ -985,8 +920,8 @@ $show_quick_help = $show['show']; echo '
-
-
'; +
+
'; break; @@ -996,13 +931,9 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s_]/", "-", $formattedId); if (strlen($k_value) != 0) { - $v['value'] = $k_value; + $v['value']['hidden_default_value'] = $k_value; } - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - - echo ''; - + $hidden_cf_buffer .= ''; break; case 'readonly': @@ -1029,15 +960,15 @@ $show_quick_help = $show['show']; $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); $formattedId = preg_replace("/[\s_]/", "-", $v['name']); - if (strlen($k_value) != 0) { - $v['value'] = $k_value; + if (strlen($k_value) != 0 || isset($_SESSION["as_$k"])) { + $v['value']['default_value'] = $k_value; } $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; echo '
-
+
'; } } @@ -1145,6 +1076,7 @@ $show_quick_help = $show['show']; +