More custom field fixes

merge-requests/28/head
Mike Koch 8 years ago
parent 61f6e0eb98
commit 59cc8498cf

@ -214,13 +214,22 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
<div id="readonly" style="display:<?php echo ($type == 'readonly') ? 'block' : 'none' ?>">
<div class="form-group">
<label class="col-sm-3 control-label" for="max_length">
<?php echo $hesklang['custom_l']; ?>
</label>
<div class="col-sm-3">
<input type="text" class="form-control" name="max_length"
value="<?php echo isset($value['max_length']) ? intval($value['max_length']) : '255'; ?>" size="5">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="value">
<?php echo $hesklang['value']; ?>
<?php echo $hesklang['defw']; ?>
</label>
<div class="col-sm-3">
<input type="text" class="form-control" name="value"
value="<?php echo isset($value['value']) ? $value['value'] : ''; ?>" size="30">
<input type="text" class="form-control" name="default_value"
value="<?php echo isset($value['default_value']) ? $value['default_value'] : ''; ?>" size="30">
</div>
</div>
</div>
@ -1188,8 +1197,9 @@ function cf_validate()
break;
case 'readonly':
$value = hesk_POST('value');
$cf['value'] = array('value' => $value);
$max_length = hesk_POST('max_length');
$value = hesk_POST('default_value');
$cf['value'] = array('default_value' => $value, 'max_length' => $max_length);
break;
default:

@ -503,11 +503,6 @@ $show_quick_help = $show['show'];
$cls = in_array($k, $_SESSION['iserror']) ? ' isError' : '';
if ($v['type'] == 'readonly') {
$v['value']['max_length'] = 0;
$v['value']['default_value'] = $v['value']['value'];
}
echo '<div class="form-group' . $cls . '">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><input type="text" class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40" maxlength="' . intval($v['value']['max_length']) . '" value="' . $v['value']['default_value'] . '" ' . $cls . ' /></div>
@ -727,46 +722,43 @@ $show_quick_help = $show['show'];
foreach ($hesk_settings['custom_fields'] as $k => $v) {
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'] == 2 ? '<span class="important">*</span>' : '';
$v['req'] = $v['req']==2 ? '<span class="important">*</span>' : '';
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["c_$k"])) {
$k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
} elseif (isset($_SESSION["as_$k"])) {
$k_value = stripslashes(hesk_input($_SESSION["as_$k"]));
} else {
$k_value = '';
$k_value = '';
}
switch ($v['type']) {
/* Radio box */
case 'radio':
echo '<div class="form-group"><label class="col-sm-3 control-label">' . $v['name'] . '</label><div align="left" class="col-sm-9">';
$cls = in_array($k, $_SESSION['iserror']) ? ' isError' : '';
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v['name'] . '</label><div align="left" class="col-sm-9">';
$cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : '';
foreach ($v['value']['radio_options'] as $option) {
if (strlen($k_value) == 0 || $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 '<label style="font-weight: normal;"><input type="radio" id="' . $formattedId . '" name="' . $k . '" value="' . $option . '" ' . $checked . ' ' . $cls . ' /> ' . $option . '</label><br>';
echo '<div class="radio"><label><input type="radio" id="' . $formattedId . '" name="' . $k . '" value="' . $option . '" ' . $checked . '> ' . $option . '</label></div>';
}
echo '</div></div>';
@ -777,12 +769,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 '<div class="form-group"><label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><select class="form-control" id="' . $formattedId . '" name="' . $k . '" ' . $cls . '>';
echo '<div class="form-group' . $cls . '"><label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><select class="form-control" id="' . $formattedId . '" name="' . $k . '">';
// Show "Click to select"?
if (!empty($v['value']['show_select'])) {
@ -792,7 +784,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 = '';
}
@ -807,19 +799,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 '<div class="form-group"><label class="col-sm-3 control-label">' . $v['name'] . '</label><div align="left" class="col-sm-9">';
$cls = in_array($k, $_SESSION['iserror']) ? ' class="isError" ' : '';
$cls = in_array($k, $_SESSION['iserror']) ? ' isError' : '';
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v['name'] . '</label><div align="left" class="col-sm-9">';
foreach ($v['value']['checkbox_options'] as $option) {
if (in_array($option, $k_value)) {
$checked = 'checked="checked"';
$checked = 'checked';
} else {
$checked = '';
}
echo '<label style="font-weight: normal;"><input id="' . $formattedId . '" type="checkbox" name="' . $k . '[]" value="' . $option . '" ' . $checked . ' ' . $cls . ' /> ' . $option . '</label><br>';
echo '<div class="checkbox"><label><input id="' . $formattedId . '" type="checkbox" name="' . $k . '[]" value="' . $option . '" ' . $checked . ' ' . $cls . ' /> ' . $option . '</label></div>';
}
echo '</div></div>';
break;
@ -828,11 +820,11 @@ $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 '<div class="form-group">
echo '<div class="form-group' . $cls . '">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><textarea class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" rows="' . intval($v['value']['rows']) . '" cols="' . intval($v['value']['cols']) . '" ' . $cls . '>' . $k_value . '</textarea></div>
</div>';
@ -841,44 +833,31 @@ $show_quick_help = $show['show'];
case 'date':
//Clean up multiple dashes or whitespaces
$formattedId = preg_replace("/[\s-]+/", " ", $v['name']);
$formattedId = preg_replace("/[\s_]/", "-", $v['name']);
if (strlen($k_value) != 0) {
$v['value'] = $k_value;
}
$formattedId = preg_replace("/[\s_]/", "-", $formattedId);
$cls = in_array($k, $_SESSION['iserror']) ? ' isError ' : '';
$cls = in_array($k, $_SESSION['iserror']) ? ' isError' : '';
echo '
<div class="form-group">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name:'].' '.$v['req'] . '</label>
<div class="form-group' . $cls . '">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'].' '.$v['req'] . '</label>
<div class="col-sm-9">
<input type="text" class="datepicker form-control white-readonly ' . $cls . '" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40"
maxlength="' . $v['maxlen'] . '" value="' . $v['value'] . '" readonly>
<input type="text" class="datepicker form-control white-readonly" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40"
value="' . $k_value . '" readonly>
</div>
</div>';
break;
case 'email':
//Clean up multiple dashes or whitespaces
$formattedId = preg_replace("/[\s-]+/", " ", $v['name']);
$formattedId = preg_replace("/[\s_]/", "-", $v['name']);
$formattedId = preg_replace("/[\s_]/", "-", $formattedId);
$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']) ? ' class="isError" ' : '';
$cls = in_array($k, $_SESSION['iserror']) ? ' isError' : '';
echo '<div class="form-group">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><input type="text" class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40" maxlength="' . $v['maxlen'] . '" value="' . $v['value'] . '" ' . $cls . ' '.$suggest.'></div>
<div class="col-sm-9"><input type="text" class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40" value="' . $k_value . '" '.$suggest.'></div>
</div><div id="'.$k.'_suggestions"></div>';
break;
@ -888,7 +867,7 @@ $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;
@ -898,7 +877,7 @@ $show_quick_help = $show['show'];
echo '<div class="form-group">
<label for="' . $v['name'] . '" class="col-sm-3 control-label">' . $v['name'] . '</label>
<div class="col-sm-9"><input type="text" class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40" maxlength="' . intval($v['value']['max_length']) . '" value="' . $v['value']['default_value'] . '" ' . $cls . ' /></div>
<div class="col-sm-9"><input type="text" class="form-control" placeholder="' . htmlspecialchars($v['name']) . '" id="' . $formattedId . '" name="' . $k . '" size="40" maxlength="' . intval($v['value']['max_length']) . '" value="' . $v['value']['default_value'] . '"></div>
</div>';
}
}

@ -619,7 +619,7 @@ function print_add_ticket()
<div class="form-group '.$cls.'">
<label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="'.$k.'" size="40" value="'.$v['value']['value'].'" readonly>
<input type="text" class="form-control" name="'.$k.'" size="40" value="'.$v['value']['default_value'].'" readonly>
</div>
</div>';
break;
@ -927,7 +927,7 @@ function print_add_ticket()
<div class="form-group '.$cls.'">
<label for="'.$k.'" class="col-sm-3 control-label">'.$v['name'].' '.$v['req'].'</label>
<div class="col-sm-9">
<input type="text" class="form-control" name="'.$k.'" size="40" value="'.$v['value']['value'].'" readonly>
<input type="text" class="form-control" name="'.$k.'" size="40" value="'.$v['value']['default_value'].'" readonly>
</div>
</div>';
break;

Loading…
Cancel
Save