2014-03-23 16:03:30 -04:00
< ? php
2016-11-16 21:16:25 -05:00
/**
*
* This file is part of HESK - PHP Help Desk Software .
*
* ( c ) Copyright Klemen Stirn . All rights reserved .
2016-11-18 12:57:17 -05:00
* https :// www . hesk . com
2016-11-16 21:16:25 -05:00
*
* For the full copyright and license agreement information visit
2016-11-18 12:57:17 -05:00
* https :// www . hesk . com / eula . php
2016-11-16 21:16:25 -05:00
*
*/
2015-09-12 00:46:46 -04:00
define ( 'IN_SCRIPT' , 1 );
define ( 'HESK_PATH' , '../' );
define ( 'WYSIWYG' , 1 );
2015-09-25 22:28:56 -04:00
define ( 'VALIDATOR' , 1 );
2014-03-23 16:03:30 -04:00
// Auto-focus first empty or error field
define ( 'AUTOFOCUS' , true );
/* Get all the required files and functions */
require ( HESK_PATH . 'hesk_settings.inc.php' );
require ( HESK_PATH . 'inc/common.inc.php' );
require ( HESK_PATH . 'inc/admin_functions.inc.php' );
2015-12-27 22:20:25 -05:00
require ( HESK_PATH . 'inc/view_attachment_functions.inc.php' );
2016-09-20 07:59:05 -04:00
require ( HESK_PATH . 'inc/mail_functions.inc.php' );
2014-03-23 16:03:30 -04:00
hesk_load_database_functions ();
hesk_session_start ();
hesk_dbConnect ();
hesk_isLoggedIn ();
2016-10-17 22:09:51 -04:00
// Load custom fields
require_once ( HESK_PATH . 'inc/custom_fields.inc.php' );
2015-01-11 23:36:19 -05:00
// Pre-populate fields
// Customer name
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'name' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_name' ] = $_REQUEST [ 'name' ];
}
// Customer email address
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'email' ])) {
$_SESSION [ 'as_email' ] = $_REQUEST [ 'email' ];
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_email2' ] = $_REQUEST [ 'email' ];
}
// Category ID
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'catid' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_category' ] = intval ( $_REQUEST [ 'catid' ]);
}
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'category' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_category' ] = intval ( $_REQUEST [ 'category' ]);
}
// Priority
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'priority' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_priority' ] = intval ( $_REQUEST [ 'priority' ]);
}
// Subject
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'subject' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_subject' ] = $_REQUEST [ 'subject' ];
}
// Message
2015-09-12 00:46:46 -04:00
if ( isset ( $_REQUEST [ 'message' ])) {
2015-01-11 23:36:19 -05:00
$_SESSION [ 'as_message' ] = $_REQUEST [ 'message' ];
}
// Custom fields
2015-09-12 00:46:46 -04:00
foreach ( $hesk_settings [ 'custom_fields' ] as $k => $v ) {
if ( $v [ 'use' ] && isset ( $_REQUEST [ $k ])) {
$_SESSION [ 'as_' . $k ] = $_REQUEST [ $k ];
2015-01-11 23:36:19 -05:00
}
}
2014-03-23 16:03:30 -04:00
/* Varibles for coloring the fields in case of errors */
2015-09-12 00:46:46 -04:00
if ( ! isset ( $_SESSION [ 'iserror' ])) {
$_SESSION [ 'iserror' ] = array ();
2014-03-23 16:03:30 -04:00
}
2015-09-12 00:46:46 -04:00
if ( ! isset ( $_SESSION [ 'isnotice' ])) {
$_SESSION [ 'isnotice' ] = array ();
2014-03-23 16:03:30 -04:00
}
/* List of users */
$admins = array ();
2015-09-12 00:46:46 -04:00
$result = hesk_dbQuery ( " SELECT `id`,`name`,`isadmin`,`categories`,`heskprivileges` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " users` WHERE `active` = '1' ORDER BY `name` ASC " );
while ( $row = hesk_dbFetchAssoc ( $result )) {
/* Is this an administrator? */
if ( $row [ 'isadmin' ]) {
$admins [ $row [ 'id' ]] = $row [ 'name' ];
continue ;
2014-03-23 16:03:30 -04:00
}
2015-09-12 00:46:46 -04:00
/* Not admin, is user allowed to view tickets? */
if ( strpos ( $row [ 'heskprivileges' ], 'can_view_tickets' ) !== false ) {
$admins [ $row [ 'id' ]] = $row [ 'name' ];
continue ;
}
2014-03-23 16:03:30 -04:00
}
/* Print header */
require_once ( HESK_PATH . 'inc/headerAdmin.inc.php' );
/* Print admin navigation */
require_once ( HESK_PATH . 'inc/show_admin_nav.inc.php' );
2016-10-17 22:09:51 -04:00
// 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 );
}
}
2015-09-12 00:46:46 -04:00
$showRs = hesk_dbQuery ( " SELECT `show` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " quick_help_sections` WHERE `id` = 5 " );
2015-08-15 15:26:55 -04:00
$show = hesk_dbFetchAssoc ( $showRs );
2016-09-27 13:08:31 -04:00
$show_quick_help = $show [ 'show' ];
2014-03-23 16:03:30 -04:00
?>
< ol class = " breadcrumb " >
2015-09-12 00:46:46 -04:00
< li >< a href = " admin_main.php " >< ? php echo $hesk_settings [ 'hesk_title' ]; ?> </a></li>
2016-10-17 22:09:51 -04:00
< ? php if ( $number_of_categories > 1 ) : ?>
< li >< a href = " new_ticket.php " >< ? php echo $hesklang [ 'nti2' ]; ?> </a></li>
2016-11-15 12:31:01 -05:00
< li class = " active " >< ? php echo $hesk_settings [ 'categories' ][ $category ]; ?> </li>
2016-10-17 22:09:51 -04:00
< ? php else : ?>
< li class = " active " >< ? php echo $hesklang [ 'nti2' ]; ?> </li>
< ? php endif ; ?>
2014-03-23 16:03:30 -04:00
</ ol >
2016-09-27 13:08:31 -04:00
< section class = " content " >
< ? php
/* This will handle error, success and notice messages */
hesk_handle_messages ();
if ( $show_quick_help ) : ?>
< div class = " box " >
< div class = " box-header with-border " >
< h1 class = " box-title " >
< ? php echo $hesklang [ 'quick_help' ]; ?>
</ h1 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-minus " ></ i >
</ button >
2014-09-07 11:43:37 -04:00
</ div >
2014-03-23 16:03:30 -04:00
</ div >
2016-09-27 13:08:31 -04:00
< div class = " box-body " >
< p >< ? php echo $hesklang [ 'nti3' ]; ?> </p>
< br >
< p >< ? php echo $hesklang [ 'req_marked_with' ]; ?> <span class="important">*</span></p>
</ div >
</ div >
2015-09-12 00:46:46 -04:00
< ? php endif ; ?>
2016-09-27 13:08:31 -04:00
< div class = " box " >
< div class = " box-header with-border " >
< h1 class = " box-title " >
< ? php echo $hesklang [ 'nti2' ]; ?>
</ h1 >
< div class = " box-tools pull-right " >
< button type = " button " class = " btn btn-box-tool " data - widget = " collapse " >
< i class = " fa fa-minus " ></ i >
</ button >
</ div >
</ div >
< div class = " box-body " >
<!-- START FORM -->
< ? php if ( $modsForHesk_settings [ 'rich_text_for_tickets' ]) : ?>
< script type = " text/javascript " >
/* <![CDATA[ */
tinyMCE . init ({
mode : " textareas " ,
editor_selector : " htmlEditor " ,
elements : " content " ,
theme : " advanced " ,
convert_urls : false ,
theme_advanced_buttons1 : " cut,copy,paste,|,undo,redo,|,formatselect,fontselect,fontsizeselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull " ,
theme_advanced_buttons2 : " sub,sup,|,charmap,|,bullist,numlist,|,outdent,indent,insertdate,inserttime,preview,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,link,unlink,anchor,image,cleanup,code " ,
theme_advanced_buttons3 : " " ,
theme_advanced_toolbar_location : " top " ,
theme_advanced_toolbar_align : " left " ,
theme_advanced_statusbar_location : " bottom " ,
theme_advanced_resizing : true
});
/* ]]> */
</ script >
< ? php endif ;
$onsubmit = '' ;
if ( $modsForHesk_settings [ 'rich_text_for_tickets' ]) {
$onsubmit = 'onsubmit="return validateRichText(\'message-help-block\', \'message-group\', \'message\', \'' . htmlspecialchars ( $hesklang [ 'this_field_is_required' ]) . '\')"' ;
}
?>
< form role = " form " class = " form-horizontal " method = " post " action = " admin_submit_ticket.php " name = " form1 "
enctype = " multipart/form-data " < ? php echo $onsubmit ; ?> >
< ? php if ( $hesk_settings [ 'can_sel_lang' ]) { ?>
< div class = " form-group " >
< label for = " customerLanguage " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'chol' ]; ?> : <span
class = " important " >*</ span ></ label >
< div class = " col-sm-9 " >
< select name = " customerLanguage " id = " customerLanguage " class = " form-control " >
< ? php hesk_listLanguages (); ?>
</ select >
</ div >
</ div >
< ? php } ?>
<!-- Contact info -->
< ? php
$has_error = '' ;
if ( in_array ( 'name' , $_SESSION [ 'iserror' ])) {
$has_error = 'has-error' ;
} ?>
< div class = " form-group <?php echo $has_error ; ?> " >
< label for = " name " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'name' ]; ?> <span
2015-09-12 00:46:46 -04:00
class = " important " >*</ span ></ label >
2014-03-23 16:03:30 -04:00
< div class = " col-sm-9 " >
2016-09-27 13:08:31 -04:00
< input type = " text " class = " form-control " name = " name " size = " 40 " maxlength = " 30 "
value = " <?php if (isset( $_SESSION['as_name'] )) {
echo stripslashes ( hesk_input ( $_SESSION [ 'as_name' ]));
} else if ( isset ( $_GET [ 'name' ])) {
echo hesk_GET ( 'name' );
} ?> "
data - error = " <?php echo htmlspecialchars( $hesklang['enter_your_name'] ); ?> "
placeholder = " <?php echo htmlspecialchars( $hesklang['name'] ); ?> " required >
< div class = " help-block with-errors " ></ div >
</ div >
</ div >
2016-10-02 11:22:49 -04:00
< div class = " form-group " >
2016-10-17 22:09:51 -04:00
< label for = " email " class = " col-sm-3 control-label " >
< ? php
echo $hesklang [ 'email' ];
if ( $hesk_settings [ 'require_email' ]) {
echo '<span class="important">*</span>' ;
}
?>
</ label >
2015-09-12 00:46:46 -04:00
2016-10-02 11:22:49 -04:00
< div class = " col-sm-9 " >
2016-10-17 22:09:51 -04:00
< input type = " text " class = " form-control " name = " email " size = " 40 " maxlength = " 1000 " id = " email "
2016-10-02 11:22:49 -04:00
value = " <?php if (isset( $_SESSION['as_email'] )) {
echo stripslashes ( hesk_input ( $_SESSION [ 'as_email' ]));
} else if ( isset ( $_GET [ 'email' ])) {
echo hesk_GET ( 'email' );
} ?> " <?php if ($hesk_settings['detect_typos']) {
2016-10-26 13:10:23 -04:00
echo ' onblur="Javascript:Javascript:hesk_suggestEmail(\'email\', \'email_suggestions\', 1, 1)"' ;
2016-10-02 11:22:49 -04:00
} ?>
placeholder = " <?php echo htmlspecialchars( $hesklang['email'] ); ?> "
2016-11-01 13:04:16 -04:00
onkeyup = " disableIfEmpty('email','notify-email') "
< ? php if ( $hesk_settings [ 'require_email' ]) { echo 'data-error="' . htmlspecialchars ( $hesklang [ 'enter_valid_email' ]) . '" required' ;} ?> >
< div class = " help-block with-errors " ></ div >
2016-10-02 11:22:49 -04:00
</ div >
2015-09-12 00:46:46 -04:00
2016-10-02 11:22:49 -04:00
</ div >
< div id = " email_suggestions " ></ div >
2016-10-17 22:09:51 -04:00
<!-- Priority -->
2016-09-27 13:08:31 -04:00
< ? php
$has_error = '' ;
if ( in_array ( 'priority' , $_SESSION [ 'iserror' ])) {
$has_error = 'has-error' ;
} ?>
< div class = " form-group <?php echo $has_error ; ?> " >
< label for = " priority " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'priority' ]; ?> <span
class = " important " >*</ span ></ label >
< div class = " col-sm-9 " >
< select name = " priority " class = " form-control "
pattern = " [0-9]+ "
data - error = " <?php echo htmlspecialchars( $hesklang['sel_app_priority'] ); ?> "
required >
< ? php
// Show the "Click to select"?
if ( $hesk_settings [ 'select_pri' ]) {
echo '<option value="">' . $hesklang [ 'select' ] . '</option>' ;
}
?>
< option value = " 3 " < ? php
if (( isset ( $_SESSION [ 'as_priority' ]) && $_SESSION [ 'as_priority' ] == 3 )
|| ( isset ( $_GET [ 'priority' ]) && $_GET [ 'priority' ] == 3 )
) {
echo 'selected="selected"' ;
} ?> ><?php echo $hesklang['low']; ?></option>
< option value = " 2 " < ? php
if (( isset ( $_SESSION [ 'as_priority' ]) && $_SESSION [ 'as_priority' ] == 2 )
|| ( isset ( $_GET [ 'priority' ]) && $_GET [ 'priority' ] == 2 )
) {
echo 'selected="selected"' ;
} ?> ><?php echo $hesklang['medium']; ?></option>
< option value = " 1 " < ? php
if (( isset ( $_SESSION [ 'as_priority' ]) && $_SESSION [ 'as_priority' ] == 1 )
|| ( isset ( $_GET [ 'priority' ]) && $_GET [ 'priority' ] == 1 )
) {
echo 'selected="selected"' ;
} ?> ><?php echo $hesklang['high']; ?></option>
< option value = " 0 " < ? php
if (( isset ( $_SESSION [ 'as_priority' ]) && $_SESSION [ 'as_priority' ] == 0 )
|| ( isset ( $_GET [ 'priority' ]) && $_GET [ 'priority' ] == 0 )
) {
echo 'selected="selected"' ;
} ?> ><?php echo $hesklang['critical']; ?></option>
2014-03-23 16:03:30 -04:00
</ select >
2016-09-27 13:08:31 -04:00
< div class = " help-block with-errors " ></ div >
2014-03-23 16:03:30 -04:00
</ div >
</ div >
2016-09-27 13:08:31 -04:00
< ? php
/* custom fields BEFORE comments */
foreach ( $hesk_settings [ 'custom_fields' ] as $k => $v ) {
2016-10-17 22:09:51 -04:00
if ( $v [ 'use' ] && $v [ 'place' ] == 0 && hesk_is_custom_field_in_category ( $k , $category )) {
2016-11-14 15:52:39 -05:00
if ( $v [ 'req' ] == 2 ) {
$v [ 'req' ] = '<span class="important">*</span>' ;
$required_attribute = 'data-error="' . $hesklang [ 'this_field_is_required' ] . '" required' ;
} else {
$v [ 'req' ] = '' ;
$required_attribute = '' ;
}
2016-09-27 13:08:31 -04:00
2016-11-08 12:53:19 -05:00
if ( $v [ 'type' ] == 'checkbox' ) {
2016-09-27 13:08:31 -04:00
$k_value = array ();
2016-11-08 12:53:19 -05:00
if ( isset ( $_SESSION [ " as_ $k " ]) && is_array ( $_SESSION [ " as_ $k " ])) {
foreach ( $_SESSION [ " as_ $k " ] as $myCB ) {
2016-09-27 13:08:31 -04:00
$k_value [] = stripslashes ( hesk_input ( $myCB ));
}
}
} elseif ( isset ( $_SESSION [ " as_ $k " ])) {
2016-11-08 12:53:19 -05:00
$k_value = stripslashes ( hesk_input ( $_SESSION [ " as_ $k " ]));
2016-09-27 13:08:31 -04:00
} else {
2016-11-08 12:53:19 -05:00
$k_value = '' ;
2016-09-27 13:08:31 -04:00
}
switch ( $v [ 'type' ]) {
/* Radio box */
case 'radio' :
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . '</label><div align="left" class="col-sm-9">' ;
2016-09-27 13:08:31 -04:00
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'radio_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
2016-10-26 13:42:42 -04:00
if ( strlen ( $k_value ) == 0 ) {
$k_value = $option ;
2016-11-08 12:53:19 -05:00
$checked = empty ( $v [ 'value' ][ 'no_default' ]) ? 'checked' : '' ;
2016-10-26 13:42:42 -04:00
} elseif ( $k_value == $option ) {
2016-09-27 13:08:31 -04:00
$k_value = $option ;
2016-11-08 12:53:19 -05:00
$checked = 'checked' ;
2016-09-27 13:08:31 -04:00
} else {
$checked = '' ;
}
2016-11-14 15:52:39 -05:00
echo ' < div class = " radio " >
< label >
2016-11-23 22:15:02 -05:00
< input type = " radio " name = " ' . $k . ' " value = " ' . $option . ' " ' . $checked . $required_attribute . ' >
2016-11-14 15:52:39 -05:00
' . $option . '
</ label >
</ div > ' ;
2016-09-27 13:08:31 -04:00
}
2016-11-14 15:52:39 -05:00
echo '
< div class = " help-block with-errors " ></ div >
</ div >
</ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
/* Select drop-down box */
case 'select' :
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-09-27 13:08:31 -04:00
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label for="' . $v [ 'name' ] . '" class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . ' </ label >
2016-11-23 22:15:02 -05:00
< div class = " col-sm-9 " >< select class = " form-control " name = " ' . $k . ' " ' . $required_attribute . ' > ' ;
2016-09-27 13:08:31 -04:00
// Show "Click to select"?
2016-10-17 22:09:51 -04:00
if ( ! empty ( $v [ 'value' ][ 'show_select' ])) {
2016-09-27 13:08:31 -04:00
echo '<option value="">' . $hesklang [ 'select' ] . '</option>' ;
}
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'select_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
if ( $k_value == $option ) {
$k_value = $option ;
2016-11-08 12:53:19 -05:00
$selected = 'selected' ;
2016-09-27 13:08:31 -04:00
} else {
$selected = '' ;
}
echo '<option ' . $selected . '>' . $option . '</option>' ;
}
2016-11-14 15:52:39 -05:00
echo ' </ select >
< div class = " help-block with-errors " ></ div ></ div ></ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
/* Checkbox */
case 'checkbox' :
2015-09-12 00:46:46 -04:00
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . '</label><div align="left" class="col-sm-9">' ;
2015-09-12 00:46:46 -04:00
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'checkbox_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
if ( in_array ( $option , $k_value )) {
2016-11-08 12:53:19 -05:00
$checked = 'checked' ;
2016-09-27 13:08:31 -04:00
} else {
$checked = '' ;
}
2015-09-12 00:46:46 -04:00
2016-11-23 22:15:02 -05:00
echo '<div class="checkbox"><label><input type="checkbox" name="' . $k . '[]" value="' . $option . '" ' . $checked . $required_attribute . '> ' . $option . '</label></div>' ;
2016-09-27 13:08:31 -04:00
}
2016-11-14 15:52:39 -05:00
echo '
< div class = " help-block with-errors " ></ div ></ div ></ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
/* Large text box */
case 'textarea' :
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2015-09-12 00:46:46 -04:00
2016-11-08 12:53:19 -05:00
echo '<div class="form-group' . $cls . ' " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '] . ' ' . $v[' req '] . ' </ label >
2016-11-23 22:15:02 -05:00
< div class = " col-sm-9 " >< textarea class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " rows = " ' . intval( $v['value'] ['rows']) . ' " cols = " ' . intval( $v['value'] ['cols']) . ' " ' . $required_attribute . ' > ' . $k_value . ' </ textarea >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div ></ div ></ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
case 'date' :
2016-11-14 15:52:39 -05:00
if ( $required_attribute != '' ) {
$required_attribute .= ' pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"' ;
}
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
echo '
2016-11-08 12:53:19 -05:00
< div class = " form-group' . $cls . ' " >
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " datepicker form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 "
2016-11-14 15:52:39 -05:00
value = " ' . $k_value . ' " ' . $required_attribute . ' >
< div class = " help-block with-errors " ></ div >
2016-09-27 13:08:31 -04:00
</ div >
</ div > ' ;
break ;
case 'email' :
2016-10-17 22:09:51 -04:00
$suggest = $hesk_settings [ 'detect_typos' ] ? 'onblur="Javascript:hesk_suggestEmail(\'' . $k . '\', \'' . $k . '_suggestions\', 0, 1' . ( $v [ 'value' ][ 'multiple' ] ? ',1' : '' ) . ')"' : '' ;
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-09-27 13:08:31 -04:00
2016-11-08 12:53:19 -05:00
echo '<div class="form-group' . $cls . ' " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 " value = " ' . $k_value . ' " '.$suggest.$required_attribute.' >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div >
</ div >
2016-10-17 22:09:51 -04:00
</ div >< div id = " '. $k .'_suggestions " ></ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
2016-10-26 13:42:42 -04:00
// Hidden and read-only should work the same as text
2016-09-27 13:08:31 -04:00
case 'hidden' :
case 'readonly' :
default :
2016-10-17 22:09:51 -04:00
if ( strlen ( $k_value ) != 0 || isset ( $_SESSION [ " as_ $k " ])) {
$v [ 'value' ][ 'default_value' ] = $k_value ;
2016-09-27 13:08:31 -04:00
}
2015-09-12 00:46:46 -04:00
2016-11-08 12:53:19 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
echo '<div class="form-group' . $cls . ' " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 " maxlength = " ' . intval( $v['value'] ['max_length']) . ' " value = " ' . $v['value'] ['default_value'] . ' " ' . $cls . $required_attribute . ' >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div >
</ div >
2016-09-27 13:08:31 -04:00
</ div > ' ;
}
2015-09-12 00:46:46 -04:00
}
}
2016-09-27 13:08:31 -04:00
// Lets handle ticket templates
$can_options = '' ;
// Get ticket templates from the database
$res = hesk_dbQuery ( " SELECT * FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " ticket_templates` ORDER BY `tpl_order` ASC " );
// If we have any templates print them out
if ( hesk_dbNumRows ( $res )) {
?>
< script language = " javascript " type = " text/javascript " ><!--
// -->
var myMsgTxt = new Array ();
var mySubjectTxt = new Array ();
myMsgTxt [ 0 ] = '' ;
mySubjectTxt [ 0 ] = '' ;
< ? php
while ( $mysaved = hesk_dbFetchRow ( $res ))
{
$can_options .= '<option value="' . $mysaved [ 0 ] . '">' . $mysaved [ 1 ] . " </option> \n " ;
if ( $modsForHesk_settings [ 'rich_text_for_tickets' ]) {
$theMessage = hesk_html_entity_decode ( $mysaved [ 2 ]);
$theMessage = addslashes ( $theMessage );
echo 'myMsgTxt[' . $mysaved [ 0 ] . ']=\'' . str_replace ( " \r \n " , " \\ r \\ n' + \r \n ' " , $theMessage ) . " '; \n " ;
} else {
echo 'myMsgTxt[' . $mysaved [ 0 ] . ']=\'' . str_replace ( " \r \n " , " \\ r \\ n' + \r \n ' " , addslashes ( $mysaved [ 2 ])) . " '; \n " ;
}
echo 'mySubjectTxt[' . $mysaved [ 0 ] . ']=\'' . str_replace ( " \r \n " , " \\ r \\ n' + \r \n ' " , addslashes ( $mysaved [ 1 ])) . " '; \n " ;
}
?>
function setMessage ( msgid ) {
var useHtmlEditor = < ? php echo $modsForHesk_settings [ 'rich_text_for_tickets' ]; ?> ;
var myMsg = myMsgTxt [ msgid ];
var mySubject = mySubjectTxt [ msgid ];
if ( myMsg == '' ) {
if ( document . form1 . mode [ 1 ] . checked ) {
if ( useHtmlEditor ) {
tinymce . get ( " message " ) . setContent ( '' );
tinymce . get ( " message " ) . execCommand ( 'mceInsertRawHTML' , false , '' );
}
else {
$ ( '#message' ) . val ( '' );
}
$ ( '#subject' ) . val ( '' );
}
return true ;
}
if ( document . getElementById ) {
if ( document . getElementById ( 'moderep' ) . checked ) {
if ( useHtmlEditor ) {
tinymce . get ( " message " ) . setContent ( '' );
tinymce . get ( " message " ) . execCommand ( 'mceInsertRawHTML' , false , myMsg );
} else {
myMsg = $ ( '<textarea />' ) . html ( myMsg ) . text ();
$ ( '#message' ) . val ( myMsg ) . trigger ( 'input' );
}
mySubject = $ ( '<textarea />' ) . html ( mySubject ) . text ();
$ ( '#subject' ) . val ( mySubject ) . trigger ( 'input' );
}
else {
if ( useHtmlEditor ) {
var oldMsg = tinymce . get ( " message " ) . getContent ();
tinymce . get ( " message " ) . setContent ( '' );
tinymce . get ( " message " ) . execCommand ( 'mceInsertRawHTML' , false , oldMsg + myMsg );
} else {
var oldMsg = document . getElementById ( 'message' ) . value ;
var theMsg = $ ( '<textarea />' ) . html ( oldMsg + myMsg ) . text ();
$ ( '#message' ) . val ( theMsg ) . trigger ( 'input' );
}
if ( document . getElementById ( 'subject' ) . value == '' ) {
mySubject = $ ( '<textarea />' ) . html ( mySubject ) . text ();
$ ( '#subject' ) . val ( mySubject ) . trigger ( 'input' );
}
}
}
else {
if ( document . form1 . mode [ 0 ] . checked ) {
document . form1 . message . value = myMsg ;
document . form1 . subject . value = mySubject ;
}
else {
var oldMsg = document . form1 . message . value ;
document . form1 . message . value = oldMsg + myMsg ;
if ( document . form1 . subject . value == '' ) {
document . form1 . subject . value = mySubject ;
}
}
}
}
//-->
</ script >
< ? php
} // END fetchrows
// Print templates
if ( strlen ( $can_options )) {
?>
< div class = " form-group " >
< label for = " modeadd " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'ticket_tpl' ]; ?> </label>
< div class = " col-sm-9 " >
< div class = " radio " >
< label >< input type = " radio " name = " mode " id = " modeadd " value = " 1 "
checked = " checked " > < ? php echo $hesklang [ 'madd' ]; ?> </label>
</ div >
< div class = " radio " >
< label >< input type = " radio " name = " mode " id = " moderep " value = " 0 " /> < ? php echo $hesklang [ 'mrep' ]; ?> </label>
</ div >
< ? php echo hesk_checkPermission ( 'can_man_ticket_tpl' , 0 ) ? '(<a href="manage_ticket_templates.php">' . $hesklang [ 'ticket_tpl_man' ] . '</a>)' : '' ; ?>
</ div >
</ div >
< div class = " form-group " >
< label for = " saved_replies " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'select_ticket_tpl' ]; ?> </label>
< div class = " col-sm-9 " >
< select class = " form-control " name = " saved_replies " onchange = " setMessage(this.value) " >
< option value = " 0 " > - < ? php echo $hesklang [ 'select_empty' ]; ?> -</option>
< ? php echo $can_options ; ?>
</ select >
</ div >
</ div >
< ? php
} // END printing templates
elseif ( hesk_checkPermission ( 'can_man_ticket_tpl' , 0 )) {
?>
< div class = " form-group " >
< div class = " col-sm-9 col-sm-offset-3 " >
< a href = " manage_ticket_templates.php " >< ? php echo $hesklang [ 'ticket_tpl_man' ]; ?> </a>
</ div >
</ div >
< ? php
2015-09-12 00:46:46 -04:00
}
2016-09-27 13:08:31 -04:00
?>
< div class = " form-group " >
< label for = " due-date " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'due_date' ]; ?> </label>
< div class = " col-sm-9 " >
< input class = " form-control datepicker " name = " due-date " placeholder = " <?php echo htmlspecialchars( $hesklang['due_date'] ); ?> "
value = " <?php if (isset( $_GET['due_date'] )) { echo $_GET['due_date'] ; } ?> " >
< span class = " help-block " >< ? php echo $hesklang [ 'date_format' ]; ?> </span>
</ div >
</ div >
< ? php
$has_error = '' ;
if ( in_array ( 'subject' , $_SESSION [ 'iserror' ])) {
$has_error = 'has-error' ;
2016-10-17 22:09:51 -04:00
}
$red_star = '' ;
$validator = '' ;
if ( $hesk_settings [ 'require_subject' ] == 1 ) {
$red_star = '<span class="important">*</span>' ;
$validator = 'data-error="' . htmlspecialchars ( $hesklang [ 'enter_subject' ]) . '"" required' ;
}
?>
2016-09-27 13:08:31 -04:00
< div class = " form-group <?php echo $has_error ; ?> " >
2016-10-17 22:09:51 -04:00
< label for = " subject " class = " col-sm-3 control-label " >
< ? php
echo $hesklang [ 'subject' ];
echo $red_star ;
?>
</ label >
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
< span id = " HeskSub " >< input class = " form-control " type = " text " name = " subject " id = " subject " size = " 40 " maxlength = " 40 "
value = " <?php if (isset( $_SESSION['as_subject'] ) || isset( $_GET['subject'] )) {
echo stripslashes ( hesk_input ( $_SESSION [ 'as_subject' ]));
} ?> " placeholder="<?php echo htmlspecialchars($hesklang['subject']); ?>"
2016-10-17 22:09:51 -04:00
< ? php echo $validator ; ?> ></span>
2016-09-27 13:08:31 -04:00
< div class = " help-block with-errors " ></ div >
</ div >
</ div >
< ? php
$has_error = '' ;
if ( in_array ( 'message' , $_SESSION [ 'iserror' ])) {
$has_error = 'has-error' ;
2016-10-17 22:09:51 -04:00
}
$red_star = '' ;
$validator = '' ;
if ( $hesk_settings [ 'require_message' ] == 1 ) {
$red_star = '<span class="important">*</span>' ;
$validator = 'data-error="' . htmlspecialchars ( $hesklang [ 'enter_message' ]) . '"" required' ;
}
?>
2016-09-27 13:08:31 -04:00
< div class = " form-group <?php echo $has_error ; ?> " id = " message-group " >
2016-10-17 22:09:51 -04:00
< label for = " subject " class = " col-sm-3 control-label " >
< ? php
echo $hesklang [ 'message' ];
echo $red_star ;
?>
</ label >
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
< span id = " HeskMsg " >
< textarea class = " form-control htmlEditor " name = " message " id = " message " rows = " 12 " cols = " 60 "
placeholder = " <?php echo htmlspecialchars( $hesklang['message'] ); ?> "
2016-10-17 22:09:51 -04:00
< ? php echo $validator ; ?> ><?php if (isset($_SESSION['as_message'])) {
2016-09-27 13:08:31 -04:00
echo stripslashes ( hesk_input ( $_SESSION [ 'as_message' ]));
} ?> </textarea>
</ span >
< div class = " help-block with-errors " id = " message-help-block " ></ div >
</ div >
</ div >
< ? php
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
/* custom fields AFTER comments */
foreach ( $hesk_settings [ 'custom_fields' ] as $k => $v ) {
2016-10-17 22:09:51 -04:00
if ( $v [ 'use' ] && $v [ 'place' ] == 1 && hesk_is_custom_field_in_category ( $k , $category )) {
2016-11-14 15:52:39 -05:00
if ( $v [ 'req' ] == 2 ) {
$v [ 'req' ] = '<span class="important">*</span>' ;
$required_attribute = 'data-error="' . $hesklang [ 'this_field_is_required' ] . '" required' ;
} else {
$v [ 'req' ] = '' ;
$required_attribute = '' ;
}
2016-09-27 13:08:31 -04:00
if ( $v [ 'type' ] == 'checkbox' ) {
$k_value = array ();
2016-11-08 13:09:54 -05:00
if ( isset ( $_SESSION [ " as_ $k " ]) && is_array ( $_SESSION [ " as_ $k " ])) {
foreach ( $_SESSION [ " as_ $k " ] as $myCB ) {
2016-09-27 13:08:31 -04:00
$k_value [] = stripslashes ( hesk_input ( $myCB ));
}
}
2016-11-08 13:09:54 -05:00
} elseif ( isset ( $_SESSION [ " as_ $k " ])) {
$k_value = stripslashes ( hesk_input ( $_SESSION [ " as_ $k " ]));
2016-09-27 13:08:31 -04:00
} else {
2016-11-08 13:09:54 -05:00
$k_value = '' ;
2016-09-27 13:08:31 -04:00
}
switch ( $v [ 'type' ]) {
/* Radio box */
case 'radio' :
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . '</label><div align="left" class="col-sm-9">' ;
2016-09-27 13:08:31 -04:00
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'radio_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
2016-11-14 15:52:39 -05:00
if ( strlen ( $k_value ) == 0 ) {
$k_value = $option ;
$checked = empty ( $v [ 'value' ][ 'no_default' ]) ? 'checked' : '' ;
} elseif ( $k_value == $option ) {
2016-09-27 13:08:31 -04:00
$k_value = $option ;
2016-11-08 13:09:54 -05:00
$checked = 'checked' ;
2016-09-27 13:08:31 -04:00
} else {
$checked = '' ;
}
2016-11-23 22:15:02 -05:00
echo '<div class="radio"><label><input type="radio" name="' . $k . '" value="' . $option . '" ' . $checked . ' ' . $required_attribute . '> ' . $option . '</label></div>' ;
2016-09-27 13:08:31 -04:00
}
2016-11-14 15:52:39 -05:00
echo '<div class="help-block with-errors"></div></div></div>' ;
2016-09-27 13:08:31 -04:00
break ;
/* Select drop-down box */
case 'select' :
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-09-27 13:08:31 -04:00
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label for="' . $v [ 'name' ] . '" class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . ' </ label >
2016-11-23 22:15:02 -05:00
< div class = " col-sm-9 " >< select class = " form-control " name = " ' . $k . ' " ' . $required_attribute . ' > ' ;
2016-09-27 13:08:31 -04:00
// Show "Click to select"?
2016-10-17 22:09:51 -04:00
if ( ! empty ( $v [ 'value' ][ 'show_select' ])) {
2016-09-27 13:08:31 -04:00
echo '<option value="">' . $hesklang [ 'select' ] . '</option>' ;
}
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'select_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
if ( $k_value == $option ) {
$k_value = $option ;
2016-11-08 13:09:54 -05:00
$selected = 'selected' ;
2016-09-27 13:08:31 -04:00
} else {
$selected = '' ;
}
echo '<option ' . $selected . '>' . $option . '</option>' ;
}
2016-11-14 15:52:39 -05:00
echo '</select><div class="help-block with-errors"></div></div></div>' ;
2016-09-27 13:08:31 -04:00
break ;
/* Checkbox */
case 'checkbox' :
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2016-11-14 15:52:39 -05:00
echo '<div class="form-group' . $cls . '"><label class="col-sm-3 control-label">' . $v [ 'name' ] . ' ' . $v [ 'req' ] . '</label><div align="left" class="col-sm-9">' ;
2016-09-27 13:08:31 -04:00
2016-10-17 22:09:51 -04:00
foreach ( $v [ 'value' ][ 'checkbox_options' ] as $option ) {
2016-09-27 13:08:31 -04:00
if ( in_array ( $option , $k_value )) {
2016-11-08 13:09:54 -05:00
$checked = 'checked' ;
2016-09-27 13:08:31 -04:00
} else {
$checked = '' ;
}
2016-11-23 22:15:02 -05:00
echo '<div class="checkbox"><label><input type="checkbox" name="' . $k . '[]" value="' . $option . '" ' . $checked . ' ' . $required_attribute . '> ' . $option . '</label></div>' ;
2016-09-27 13:08:31 -04:00
}
2016-11-14 15:52:39 -05:00
echo '<div class="help-block with-errors"></div></div></div>' ;
2016-09-27 13:08:31 -04:00
break ;
/* Large text box */
case 'textarea' :
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2014-12-22 00:30:21 -05:00
2016-11-08 13:09:54 -05:00
echo '<div class="form-group' . $cls . ' " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
2016-11-23 22:15:02 -05:00
< div class = " col-sm-9 " >< textarea class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " rows = " ' . intval( $v['value'] ['rows']) . ' " cols = " ' . intval( $v['value'] ['cols']) . ' " ' . $required_attribute . ' > ' . $k_value . ' </ textarea >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div ></ div >
2016-09-27 13:08:31 -04:00
</ div > ' ;
break ;
2015-01-22 19:36:19 -05:00
2016-09-27 13:08:31 -04:00
case 'date' :
2016-11-14 15:52:39 -05:00
if ( $required_attribute != '' ) {
$required_attribute .= ' pattern="[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])"' ;
}
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2015-01-22 19:36:19 -05:00
2016-09-27 13:08:31 -04:00
echo '
2016-11-08 13:09:54 -05:00
< div class = " form-group' . $cls . ' " >
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " datepicker form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 "
2016-11-14 15:52:39 -05:00
value = " ' . $k_value . ' " ' . $required_attribute . ' >
< div class = " help-block with-errors " ></ div >
2016-09-27 13:08:31 -04:00
</ div >
</ div > ' ;
break ;
case 'email' :
2016-10-17 22:09:51 -04:00
$suggest = $hesk_settings [ 'detect_typos' ] ? 'onblur="Javascript:hesk_suggestEmail(\'' . $k . '\', \'' . $k . '_suggestions\', 0, 1' . ( $v [ 'value' ][ 'multiple' ] ? ',1' : '' ) . ')"' : '' ;
2016-11-08 13:09:54 -05:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' isError' : '' ;
2015-09-08 22:14:00 -04:00
2016-09-27 13:08:31 -04:00
echo ' < div class = " form-group " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 " value = " ' . $k_value . ' " '.$suggest.' ' . $required_attribute . ' >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div >
</ div >
2016-10-17 22:09:51 -04:00
</ div >< div id = " '. $k .'_suggestions " ></ div > ' ;
2016-09-27 13:08:31 -04:00
break ;
2015-01-22 20:29:14 -05:00
2016-09-27 13:08:31 -04:00
case 'hidden' :
case 'readonly' :
default :
2016-10-17 22:09:51 -04:00
if ( strlen ( $k_value ) != 0 || isset ( $_SESSION [ " as_ $k " ])) {
$v [ 'value' ][ 'default_value' ] = $k_value ;
2016-09-27 13:08:31 -04:00
}
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
$cls = in_array ( $k , $_SESSION [ 'iserror' ]) ? ' class="isError" ' : '' ;
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
echo ' < div class = " form-group " >
2016-11-14 15:52:39 -05:00
< label for = " ' . $v['name'] . ' " class = " col-sm-3 control-label " > ' . $v[' name '].' '.$v[' req '] . ' </ label >
< div class = " col-sm-9 " >
2016-11-23 22:15:02 -05:00
< input type = " text " class = " form-control " placeholder = " ' . $v['name'] . ' " name = " ' . $k . ' " size = " 40 " maxlength = " ' . intval( $v['value'] ['max_length']) . ' " value = " ' . $v['value'] ['default_value'] . ' " ' . $required_attribute . ' >
2016-11-14 15:52:39 -05:00
< div class = " help-block with-errors " ></ div >
</ div >
2016-09-27 13:08:31 -04:00
</ div > ' ;
}
2015-09-12 00:46:46 -04:00
}
}
2016-09-27 13:08:31 -04:00
/* end custom after */
/* attachments */
if ( $hesk_settings [ 'attachments' ][ 'use' ]) {
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
?>
< div class = " form-group " >
< label for = " attachments " class = " control-label col-sm-3 " >< ? php echo $hesklang [ 'attachments' ]; ?> :</label>
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
< ? php build_dropzone_markup ( true ); ?>
</ div >
</ div >
< ? php
display_dropzone_field ( $hesk_settings [ 'hesk_url' ] . '/internal-api/ticket/upload-attachment.php' );
2015-09-12 00:46:46 -04:00
}
2015-01-22 20:29:14 -05:00
2016-09-27 13:08:31 -04:00
if ( ! isset ( $_SESSION [ 'as_notify' ])) {
$_SESSION [ 'as_notify' ] = $_SESSION [ 'notify_customer_new' ] ? 1 : 0 ;
2015-09-12 00:46:46 -04:00
}
2016-09-27 13:08:31 -04:00
?>
< div class = " form-group " >
< label class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'addop' ]; ?> :</label>
2015-09-08 22:14:00 -04:00
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
< label >< input type = " checkbox " id = " notify-email " name = " notify "
value = " 1 " < ? php echo empty ( $_SESSION [ 'as_notify' ]) ? '' : 'checked="checked"' ; ?> /> <?php echo $hesklang['seno']; ?>
</ label >< br >
< label >< input type = " checkbox " name = " show "
value = " 1 " < ? php echo ( ! isset ( $_SESSION [ 'as_show' ]) || ! empty ( $_SESSION [ 'as_show' ])) ? 'checked="checked"' : '' ; ?> /> <?php echo $hesklang['otas']; ?>
</ label >
</ div >
</ div >
< ? php
if ( hesk_checkPermission ( 'can_assign_others' , 0 ))
{
$has_error = '' ;
if ( in_array ( 'owner' , $_SESSION [ 'iserror' ])) {
$has_error = 'has-error' ;
}
?>
< div class = " form-group <?php echo $has_error ; ?> " >
< label for = " owner " class = " col-sm-3 control-label " >< ? php echo $hesklang [ 'asst2' ]; ?> :</label>
< div class = " col-sm-9 " >
< select class = " form-control " name = " owner " >
< option value = " -1 " > & gt ; < ? php echo $hesklang [ 'unas' ]; ?> < </option>
< ? php
if ( $hesk_settings [ 'autoassign' ])
{
echo '<option value="-2"> > ' . $hesklang [ 'aass' ] . ' < </option>' ;
}
$owner = isset ( $_SESSION [ 'as_owner' ]) ? intval ( $_SESSION [ 'as_owner' ]) : 0 ;
foreach ( $admins as $k => $v )
{
if ( $k == $owner )
{
echo '<option value="' . $k . '" selected="selected">' . $v . '</option>' ;
}
else
{
echo '<option value="' . $k . '">' . $v . '</option>' ;
}
}
?>
</ select >
</ div >
</ div >
< ? php
2015-09-12 00:46:46 -04:00
}
2016-09-27 13:08:31 -04:00
elseif ( hesk_checkPermission ( 'can_assign_self' , 0 ))
{
$checked = ( ! isset ( $_SESSION [ 'as_owner' ]) || ! empty ( $_SESSION [ 'as_owner' ])) ? 'checked="checked"' : '' ;
?>
< div class = " form-group " >
< div class = " col-sm-9 col-sm-offset-3 " >
< label >< input type = " checkbox " name = " assing_to_self " value = " 1 " < ? php echo $checked ; ?> /> <?php echo $hesklang['asss2']; ?></label>
</ div >
</ div >
< ? php
2015-09-12 00:46:46 -04:00
}
2014-03-23 16:03:30 -04:00
2016-09-27 13:08:31 -04:00
if ( $modsForHesk_settings [ 'request_location' ]) :
?>
< div class = " form-group " >
< label for = " location " class = " col-md-3 control-label " >< ? php echo $hesklang [ 'location_colon' ]; ?> </label>
2014-03-23 16:03:30 -04:00
2016-09-27 13:08:31 -04:00
< div class = " col-sm-9 " >
< p id = " console " >< ? php echo $hesklang [ 'requesting_location_ellipsis' ]; ?> </p>
2015-09-12 00:46:46 -04:00
2016-09-27 13:08:31 -04:00
< div id = " map " style = " height: 300px; display:none " >
</ div >
</ div >
</ div >
< ? php endif ; ?>
<!-- Submit -->
< div class = " form-group " >
< div class = " col-sm-9 col-sm-offset-3 " >
< input type = " hidden " id = " latitude " name = " latitude " value = " E-0 " >
< input type = " hidden " id = " longitude " name = " longitude " value = " E-0 " >
< input type = " hidden " name = " token " value = " <?php hesk_token_echo(); ?> " >
2016-10-17 22:09:51 -04:00
< input type = " hidden " name = " category " value = " <?php echo $category ; ?> " >
2016-09-27 13:08:31 -04:00
< input type = " submit " value = " <?php echo $hesklang['sub_ticket'] ; ?> " class = " btn btn-default " >
</ div >
</ div >
</ form >
2015-05-11 18:53:11 -04:00
</ div >
2015-08-15 15:26:55 -04:00
</ div >
2016-09-27 13:08:31 -04:00
</ section >
2015-09-12 00:46:46 -04:00
2015-09-25 22:28:56 -04:00
< script >
buildValidatorForTicketSubmission ( " form1 " ,
" <?php echo addslashes( $hesklang['select_at_least_one_value'] ); ?> " );
</ script >
2015-09-12 00:46:46 -04:00
</ div >
</ div >
2014-03-23 16:03:30 -04:00
< ? php
2015-05-26 22:04:05 -04:00
// Request for the users location if enabled
2015-09-12 00:46:46 -04:00
if ( $modsForHesk_settings [ 'request_location' ]) {
2015-05-26 22:04:05 -04:00
echo '
< script >
2015-09-12 00:46:46 -04:00
requestUserLocation ( " ' . $hesklang['your_current_location'] . ' " , " ' . $hesklang['unable_to_determine_location'] . ' " );
2015-05-26 22:04:05 -04:00
</ script >
' ;
}
2016-04-30 00:27:24 -04:00
// Set the message in the actual text box if rich text is enabled
if ( $modsForHesk_settings [ 'rich_text_for_tickets' ]) {
2016-07-17 16:17:46 -04:00
$message = hesk_SESSION ( 'as_message' , '' );
2016-04-30 00:27:24 -04:00
echo "
< script >
tinymce . get ( 'message' ) . setContent ( '' );
2016-07-17 16:17:46 -04:00
tinymce . get ( 'message' ) . execCommand ( 'mceInsertRawHTML' , false , '".$message."' );
2016-04-30 00:27:24 -04:00
</ script >
" ;
}
2014-03-23 16:03:30 -04:00
hesk_cleanSessionVars ( 'iserror' );
hesk_cleanSessionVars ( 'isnotice' );
require_once ( HESK_PATH . 'inc/footer.inc.php' );
exit ();
2016-10-18 21:35:04 -04:00
/*** START FUNCTIONS ***/
function print_select_category ( $number_of_categories ) {
global $hesk_settings , $hesklang ;
// A category needs to be selected
if ( isset ( $_GET [ 'category' ]) && empty ( $_GET [ 'category' ])) {
hesk_process_messages ( $hesklang [ 'sel_app_cat' ], 'NOREDIRECT' , 'NOTICE' );
}
/* This will handle error, success and notice messages */
hesk_handle_messages ();
?>
2016-11-08 20:56:19 -05:00
< section class = " content " >
< div class = " box " >
< div class = " box-header with-border " >
< h1 class = " box-title " >
< ? php echo $hesklang [ 'select_category_staff' ]; ?>
</ h1 >
</ div >
< div class = " box-body " >
< div class = " select_category " >
< ? php
// Print a select box if number of categories is large
if ( $number_of_categories > $hesk_settings [ 'cat_show_select' ])
{
2016-10-18 21:35:04 -04:00
?>
2016-11-08 20:56:19 -05:00
< form action = " new_ticket.php " method = " get " >
< select name = " category " id = " select_category " class = " form-control " >
< ? php
if ( $hesk_settings [ 'select_cat' ])
{
echo '<option value="">' . $hesklang [ 'select' ] . '</option>' ;
}
foreach ( $hesk_settings [ 'categories' ] as $k => $v )
{
echo '<option value="' . $k . '">' . $v . '</option>' ;
}
?>
</ select >
2016-10-18 21:35:04 -04:00
2016-11-08 20:56:19 -05:00
& nbsp ; < br />
2016-10-18 21:35:04 -04:00
2016-11-08 20:56:19 -05:00
< div style = " text-align:center " >
< input type = " submit " value = " <?php echo $hesklang['c2c'] ; ?> " class = " btn btn-default " >
</ div >
</ form >
< ? php
}
// Otherwise print quick links
else
2016-10-18 21:35:04 -04:00
{
2016-11-08 20:56:19 -05:00
// echo '<li><a href="new_ticket.php?a=add&category='.$k.'">» '.$v.'</a></li>';
$new_row = 1 ;
foreach ( $hesk_settings [ 'categories' ] as $k => $v ) :
if ( $new_row == 1 ) {
echo '<div class="row">' ;
$new_row = - 1 ;
}
?>
< div class = " col-md-5 col-sm-12 <?php if ( $new_row == -1) { echo 'col-md-offset-1';} ?> " >
< a href = " new_ticket.php?a=add&category=<?php echo $k ; ?> " class = " button-link " >
< div class = " panel panel-default " >
< div class = " panel-body " >
< div class = " row " >
< div class = " col-xs-12 " >
< ? php echo $v ; ?>
</ div >
</ div >
</ div >
</ div >
</ a >
</ div >
< ? php
$new_row ++ ;
if ( $new_row == 1 ) {
echo '</div>' ;
}
endforeach ;
2016-10-18 21:35:04 -04:00
}
?>
2016-11-08 20:56:19 -05:00
</ div >
</ div >
2016-10-18 21:35:04 -04:00
</ div >
2016-11-08 20:56:19 -05:00
</ section >
2016-10-18 21:35:04 -04:00
< ? php
hesk_cleanSessionVars ( 'iserror' );
hesk_cleanSessionVars ( 'isnotice' );
require_once ( HESK_PATH . 'inc/footer.inc.php' );
exit ();
} // END print_select_category()