#325 Finish validation for view ticket

This commit is contained in:
Mike Koch 2015-09-24 17:00:16 -04:00
parent e2ce9186f0
commit 00feae1b7b
4 changed files with 41 additions and 30 deletions

View File

@ -205,6 +205,12 @@ $modsForHesk_settings = mfh_getSettings();
if (defined('RECAPTCHA')) { if (defined('RECAPTCHA')) {
echo '<script src="https://www.google.com/recaptcha/api.js?hl=' . $hesklang['RECAPTCHA'] . '" async defer></script>'; echo '<script src="https://www.google.com/recaptcha/api.js?hl=' . $hesklang['RECAPTCHA'] . '" async defer></script>';
} }
if (defined('VALIDATOR')) {
?>
<script type="text/javascript" src="<?php echo HESK_PATH; ?>js/validation-scripts.js"></script>
<?php
}
?> ?>
</head> </head>

View File

@ -31,6 +31,7 @@
define('IN_SCRIPT', 1); define('IN_SCRIPT', 1);
define('HESK_PATH', './'); define('HESK_PATH', './');
define('WYSIWYG', 1); define('WYSIWYG', 1);
define('VALIDATOR', 1);
// Get all the required files and functions // Get all the required files and functions
require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'hesk_settings.inc.php');
@ -186,8 +187,14 @@ function print_add_ticket()
<div align="left" class="h3"><?php echo $hesklang['add_ticket_general_information']; ?></div> <div align="left" class="h3"><?php echo $hesklang['add_ticket_general_information']; ?></div>
<div class="footerWithBorder"></div> <div class="footerWithBorder"></div>
<div class="blankSpace"></div> <div class="blankSpace"></div>
<?php
$onsubmit = '';
if ($modsForHesk_settings['rich_text_for_tickets_for_customers']) {
$onsubmit = 'onsubmit="return validateRichText(\'message-help-block\', \'message-group\', \'message\', \''.htmlspecialchars($hesklang['this_field_is_required']).'\')"';
}
?>
<form class="form-horizontal" role="form" method="post" action="submit_ticket.php?submit=1" name="form1" <form class="form-horizontal" role="form" method="post" action="submit_ticket.php?submit=1" name="form1"
enctype="multipart/form-data" onsubmit="return validateRichText();"> enctype="multipart/form-data" <?php echo $onsubmit; ?>>
<!-- Contact info --> <!-- Contact info -->
<div class="form-group"> <div class="form-group">
<label for="name" class="col-sm-3 control-label"><?php echo $hesklang['name']; ?>: <font <label for="name" class="col-sm-3 control-label"><?php echo $hesklang['name']; ?>: <font
@ -1146,31 +1153,7 @@ function print_add_ticket()
<?php <?php
} // End ELSE submit_notice } // End ELSE submit_notice
if ($modsForHesk_settings['rich_text_for_tickets_for_customers']):
?> ?>
<script>
function validateRichText() {
$('#message-help-block').text("");
$('#message-group').removeClass('has-error');
var content = tinyMCE.get("message").getContent();
if (content == '') {
$('#message-help-block').text("<?php echo htmlspecialchars($hesklang['this_field_is_required']); ?>").focus();
$('#message-group').addClass('has-error');
$('#message-group').get(0).scrollIntoView();
return false;
}
return true;
}
</script>
<?php else: ?>
<script>
function validateRichText() {
return true;
}
</script>
<?php endif; ?>
<!-- Do not delete or modify the code below, it is used to detect simple SPAM bots --> <!-- Do not delete or modify the code below, it is used to detect simple SPAM bots -->
<input type="hidden" name="hx" value="3"/><input type="hidden" name="hy" value=""/> <input type="hidden" name="hx" value="3"/><input type="hidden" name="hy" value=""/>

13
js/validation-scripts.js Normal file
View File

@ -0,0 +1,13 @@
function validateRichText(helpBlock, messageGroup, messageContainer, errorText) {
$('#' + helpBlock).text("");
$('#' + messageGroup).removeClass('has-error');
var content = tinyMCE.get(messageContainer).getContent();
if (content == '') {
$('#' + helpBlock).text(errorText).focus();
$('#' + messageGroup).addClass('has-error');
$('#' + messageGroup).get(0).scrollIntoView();
return false;
}
return true;
}

View File

@ -32,6 +32,7 @@ define('IN_SCRIPT', 1);
define('HESK_PATH', './'); define('HESK_PATH', './');
define('HESK_NO_ROBOTS', 1); define('HESK_NO_ROBOTS', 1);
define('WYSIWYG', 1); define('WYSIWYG', 1);
define('VALIDATOR', 1);
/* Get all the required files and functions */ /* Get all the required files and functions */
require(HESK_PATH . 'hesk_settings.inc.php'); require(HESK_PATH . 'hesk_settings.inc.php');
@ -581,16 +582,24 @@ function hesk_printCustomerReplyForm($reopen = 0)
<div class="footerWithBorder"></div> <div class="footerWithBorder"></div>
<div class="blankSpace"></div> <div class="blankSpace"></div>
<form role="form" class="form-horizontal" method="post" action="reply_ticket.php" enctype="multipart/form-data"> <?php
<div class="form-group"> $onsubmit = '';
if ($modsForHesk_settings['rich_text_for_tickets_for_customers']) {
$onsubmit = 'onclick="return validateRichText(\'message-help-block\', \'message-group\', \'message\', \''.htmlspecialchars($hesklang['this_field_is_required']).'\')"';
}
?>
<form data-toggle="validator" role="form" class="form-horizontal" method="post" action="reply_ticket.php"
enctype="multipart/form-data" <?php echo $onsubmit; ?>>
<div class="form-group" id="message-group">
<label for="message" class="col-sm-3 control-label"><?php echo $hesklang['message']; ?>: <span <label for="message" class="col-sm-3 control-label"><?php echo $hesklang['message']; ?>: <span
class="important">*</span></label> class="important">*</span></label>
<div class="col-sm-9"> <div class="col-sm-9">
<textarea name="message" class="form-control htmlEditor" rows="12" <textarea name="message" class="form-control htmlEditor" rows="12"
cols="60"><?php if (isset($_SESSION['ticket_message'])) { cols="60" data-error="<?php echo htmlspecialchars($hesklang['enter_message']); ?>" required><?php if (isset($_SESSION['ticket_message'])) {
echo stripslashes(hesk_input($_SESSION['ticket_message'])); echo stripslashes(hesk_input($_SESSION['ticket_message']));
} ?></textarea> } ?></textarea>
<div class="help-block with-errors" id="message-help-block"></div>
<?php if ($modsForHesk_settings['rich_text_for_tickets_for_customers']): ?> <?php if ($modsForHesk_settings['rich_text_for_tickets_for_customers']): ?>
<script type="text/javascript"> <script type="text/javascript">
/* <![CDATA[ */ /* <![CDATA[ */
@ -646,7 +655,7 @@ function hesk_printCustomerReplyForm($reopen = 0)
?> ?>
<div class="form-group"> <div class="form-group">
<div class="col-sm-9 col-sm-offset-3"> <div class="col-sm-9 col-sm-offset-3">
<input type="submit" value="<?php echo $hesklang['submit_reply']; ?>" class="btn btn-default"/> <input type="submit" value="<?php echo $hesklang['submit_reply']; ?>" class="btn btn-default">
</div> </div>
</div> </div>
</form> </form>