From 61f6e0eb985a764fc2448e83f1a5ca479c0b8c23 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 8 Nov 2016 12:53:19 -0500 Subject: [PATCH] Fixed custom fields on new ticket --- admin/new_ticket.php | 99 +++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 57 deletions(-) diff --git a/admin/new_ticket.php b/admin/new_ticket.php index 1f8057f1..0f74cb87 100644 --- a/admin/new_ticket.php +++ b/admin/new_ticket.php @@ -350,49 +350,42 @@ $show_quick_help = $show['show']; if ($v['use'] && $v['place'] == 0 && hesk_is_custom_field_in_category($k, $category)) { $v['req'] = $v['req']==2 ? '*' : ''; - if ($v['type'] == 'checkbox' && !isset($_GET["c_$k"])) { + if ($v['type'] == 'checkbox') { $k_value = array(); - if (isset($_SESSION["c_$k"]) && is_array($_SESSION["c_$k"])) { - foreach ($_SESSION["c_$k"] as $myCB) { + if (isset($_SESSION["as_$k"]) && is_array($_SESSION["as_$k"])) { + foreach ($_SESSION["as_$k"] as $myCB) { $k_value[] = stripslashes(hesk_input($myCB)); } } } elseif (isset($_SESSION["as_$k"])) { - $k_value = stripslashes(hesk_input($_SESSION["as_$k"])); - } elseif (isset($_GET["as_$k"])) { - if ($v['type'] == 'checkbox') { - $k_value = explode('-CHECKBOX-', $_GET["as_$k"]); - } else { - $k_value = stripslashes(hesk_GET("as_$k")); - } + $k_value = stripslashes(hesk_input($_SESSION["as_$k"])); } else { - $k_value = ''; + $k_value = ''; } switch ($v['type']) { /* Radio box */ case 'radio': - echo '
'; - - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; + echo '
'; foreach ($v['value']['radio_options'] as $option) { if (strlen($k_value) == 0) { $k_value = $option; - $checked = empty($v['value']['no_default']) ? 'checked="checked"' : ''; + $checked = empty($v['value']['no_default']) ? 'checked' : ''; } elseif ($k_value == $option) { $k_value = $option; - $checked = 'checked="checked"'; + $checked = 'checked'; } else { $checked = ''; } //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - echo '
'; + echo '
'; } echo '
'; @@ -403,12 +396,12 @@ $show_quick_help = $show['show']; //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - echo '
-
'; // Show "Click to select"? if (!empty($v['value']['show_select'])) { @@ -418,7 +411,7 @@ $show_quick_help = $show['show']; foreach ($v['value']['select_options'] as $option) { if ($k_value == $option) { $k_value = $option; - $selected = 'selected="selected"'; + $selected = 'selected'; } else { $selected = ''; } @@ -433,19 +426,19 @@ $show_quick_help = $show['show']; case 'checkbox': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - echo '
'; - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; + echo '
'; foreach ($v['value']['checkbox_options'] as $option) { if (in_array($option, $k_value)) { - $checked = 'checked="checked"'; + $checked = 'checked'; } else { $checked = ''; } - echo '
'; + echo '
'; } echo '
'; break; @@ -454,33 +447,29 @@ $show_quick_help = $show['show']; case 'textarea': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - echo '
+ echo '
-
+
'; break; case 'date': //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); - if (strlen($k_value) != 0) { - $v['value'] = $k_value; - } - - $cls = in_array($k, $_SESSION['iserror']) ? ' isError ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; echo ' -
- +
+
- +
'; break; @@ -491,20 +480,11 @@ $show_quick_help = $show['show']; $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; - } - - if ($v['value'] == 'cc' || $v['value'] == 'bcc') { - // (b)cc isn't a valid email but is the "value" used by settings. Just remove it. - $v['value'] = ''; - } + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; - - echo '
+ echo '
-
+
'; break; @@ -515,15 +495,20 @@ $show_quick_help = $show['show']; default: //Clean up multiple dashes or whitespaces $formattedId = preg_replace("/[\s-]+/", " ", $v['name']); - $formattedId = preg_replace("/[\s_]/", "-", $v['name']); + $formattedId = preg_replace("/[\s_]/", "-", $formattedId); if (strlen($k_value) != 0 || isset($_SESSION["as_$k"])) { $v['value']['default_value'] = $k_value; } - $cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : ''; + $cls = in_array($k, $_SESSION['iserror']) ? ' isError' : ''; - echo '
+ if ($v['type'] == 'readonly') { + $v['value']['max_length'] = 0; + $v['value']['default_value'] = $v['value']['value']; + } + + echo '
';