2015-05-12 22:08:17 -04:00
< ? php
define ( 'IN_SCRIPT' , 1 );
define ( 'HESK_PATH' , '../' );
/* Get all the required files and functions */
require ( HESK_PATH . 'hesk_settings.inc.php' );
2015-07-29 22:27:00 -04:00
require ( HESK_PATH . 'modsForHesk_settings.inc.php' );
2015-05-12 22:08:17 -04:00
require ( HESK_PATH . 'inc/common.inc.php' );
require ( HESK_PATH . 'inc/admin_functions.inc.php' );
2015-07-30 12:35:30 -04:00
require ( HESK_PATH . 'inc/status_functions.inc.php' );
2015-05-12 22:08:17 -04:00
hesk_load_database_functions ();
hesk_session_start ();
hesk_dbConnect ();
hesk_isLoggedIn ();
2015-05-13 17:56:52 -04:00
hesk_checkPermission ( 'can_man_ticket_statuses' );
2015-05-12 22:08:17 -04:00
define ( 'WYSIWYG' , 1 );
// Are we performing an action?
2015-07-26 21:47:05 -04:00
if ( isset ( $_REQUEST [ 'a' ])) {
2015-08-20 00:34:00 -04:00
if ( defined ( 'HESK_DEMO' ) ) { hesk_process_messages ( $hesklang [ 'cannot_edit_status_demo' ], 'manage_statuses.php' ); }
elseif ( $_REQUEST [ 'a' ] == 'create' ) { createStatus (); }
2015-08-03 21:53:07 -04:00
elseif ( $_REQUEST [ 'a' ] == 'update' ) { updateStatus (); }
elseif ( $_REQUEST [ 'a' ] == 'delete' ) { deleteStatus (); }
elseif ( $_REQUEST [ 'a' ] == 'sort' ) { moveStatus (); }
elseif ( $_REQUEST [ 'a' ] == 'save' ) { save (); }
2015-05-12 22:08:17 -04:00
}
2015-07-26 21:23:04 -04:00
2015-05-12 22:08:17 -04:00
/* Print header */
require_once ( HESK_PATH . 'inc/headerAdmin.inc.php' );
/* Print main manage users page */
require_once ( HESK_PATH . 'inc/show_admin_nav.inc.php' );
?>
< div class = " row " style = " padding: 20px " >
< ul class = " nav nav-tabs " role = " tablist " >
< ? php
// Show a link to banned_emails.php if user has permission
if ( hesk_checkPermission ( 'can_ban_emails' , 0 ) )
{
echo '
< li role = " presentation " >
< a title = " ' . $hesklang['banemail'] . ' " href = " banned_emails.php " > '.$hesklang[' banemail '].' </ a >
</ li >
' ;
}
if ( hesk_checkPermission ( 'can_ban_ips' , 0 ) )
{
echo '
< li role = " presentation " >
< a title = " ' . $hesklang['banip'] . ' " href = " banned_ips.php " > '.$hesklang[' banip '].' </ a >
</ li > ' ;
}
// Show a link to status_message.php if user has permission to do so
if ( hesk_checkPermission ( 'can_service_msg' , 0 ) )
{
echo '
< li role = " presentation " >
< a title = " ' . $hesklang['sm_title'] . ' " href = " service_messages.php " > ' . $hesklang[' sm_title '] . ' </ a >
</ li > ' ;
}
2015-05-13 17:57:08 -04:00
if ( hesk_checkPermission ( 'can_man_email_tpl' , 0 ) )
2015-05-12 22:08:17 -04:00
{
echo '
< li role = " presentation " >
< a title = " '. $hesklang['email_templates'] .' " href = " manage_email_templates.php " > '.$hesklang[' email_templates '].' </ a >
</ li >
' ;
}
?>
< li role = " presentation " class = " active " >
< a href = " # " >< ? php echo $hesklang [ 'statuses' ]; ?> <i class="fa fa-question-circle settingsquestionmark" data-toggle="popover" title="<?php echo $hesklang['statuses']; ?>" data-content="<?php echo $hesklang['statuses_intro']; ?>"></i></a>
</ li >
</ ul >
< div class = " tab-content summaryList tabPadding " >
< div class = " row " >
< div class = " col-md-12 " >
< ? php
/* This will handle error, success and notice messages */
hesk_handle_messages ();
//-- We need to get all of the statuses and dump the information to the page.
2015-07-23 21:25:27 -04:00
$numOfStatusesRS = hesk_dbQuery ( 'SELECT 1 FROM `' . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . 'statuses`' );
$numberOfStatuses = hesk_dbNumRows ( $numOfStatusesRS );
2015-07-30 12:35:30 -04:00
$statuses = mfh_getAllStatuses ();
2015-05-12 22:08:17 -04:00
?>
< form class = " form-horizontal " method = " post " action = " manage_statuses.php " role = " form " >
2015-07-19 22:20:18 -04:00
< div class = " panel panel-default " >
< div class = " panel-heading " >
2015-07-23 22:06:02 -04:00
< h4 >
< ? php echo $hesklang [ 'statuses' ]; ?>
< span class = " nu-floatRight " style = " margin-top: -7px " >
2015-07-25 01:11:08 -04:00
< button class = " btn btn-success " data - toggle = " modal " data - target = " #modal-status-new " >
2015-07-23 22:06:02 -04:00
< i class = " fa fa-plus-circle " ></ i >
< ? php
echo $hesklang [ 'new_status' ];
?>
2015-07-25 01:11:08 -04:00
</ button >
2015-07-23 22:06:02 -04:00
</ span >
</ h4 >
2015-07-19 22:20:18 -04:00
</ div >
2015-05-12 22:08:17 -04:00
< table class = " table table-hover " >
< thead >
< tr >
2015-07-19 22:20:18 -04:00
< th >< ? php echo $hesklang [ 'name' ]; ?> </th>
2015-07-23 21:25:27 -04:00
< th >< ? php echo $hesklang [ 'closable_question' ]; ?> </th>
< th >< ? php echo $hesklang [ 'closedQuestionMark' ]; ?> </th>
2015-07-22 22:04:10 -04:00
< th >< ? php echo $hesklang [ 'actions' ]; ?> </th>
2015-05-12 22:08:17 -04:00
</ tr >
</ thead >
< tbody >
2015-07-23 21:25:27 -04:00
< ? php
$j = 1 ;
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row ) :
2015-07-23 21:25:27 -04:00
?>
2015-07-19 22:20:18 -04:00
< tr id = " s<?php echo $row['ID'] ; ?>_row " >
2015-07-22 22:04:10 -04:00
< td style = " color: <?php echo $row['TextColor'] ; ?>; font-weight: bold " >
2015-07-29 22:27:00 -04:00
< ? php echo $row [ 'text' ]; ?>
2015-07-19 22:20:18 -04:00
</ td >
< td >
2015-07-22 22:04:10 -04:00
< ? php
if ( $row [ 'Closable' ] == 'yes' ) {
echo $hesklang [ 'yes_title_case' ];
} elseif ( $row [ 'Closable' ] == 'conly' ) {
echo $hesklang [ 'customers_only' ];
} elseif ( $row [ 'Closable' ] == 'sonly' ) {
echo $hesklang [ 'staff_only' ];
} elseif ( $row [ 'Closable' ] == 'no' ) {
echo $hesklang [ 'no_title_case' ];
}
?>
2015-07-19 22:20:18 -04:00
</ td >
< td >
2015-07-22 22:04:10 -04:00
< ? php
if ( $row [ 'IsClosed' ]) {
2015-07-26 12:17:41 -04:00
echo '<i class="fa fa-check-circle icon-link" style="color: green;"></i>' ;
2015-07-22 22:04:10 -04:00
}
?>
2015-07-19 22:20:18 -04:00
</ td >
< td >
2015-07-26 21:23:04 -04:00
< span data - toggle = " modal " data - target = " #modal-status-<?php echo $row['ID'] ; ?> " style = " cursor: pointer; " >
2015-07-23 22:06:02 -04:00
< i class = " fa fa-pencil icon-link " style = " color: orange "
2015-07-26 21:23:04 -04:00
data - toggle = " tooltip " title = " <?php echo $hesklang['edit'] ; ?> " ></ i >
</ span >
2015-07-26 22:17:30 -04:00
< ? php echoArrows ( $j , $numberOfStatuses , $row [ 'ID' ]); ?>
2015-08-02 22:21:05 -04:00
< ? php
// Only show the delete button if (1) it's not a default action and (2) no tickets are set to that status
$delete = canStatusBeDeleted ( $row [ 'ID' ]);
$cursor = 'cursor: pointer' ;
$iconStyle = 'color: red' ;
2015-08-15 15:46:38 -04:00
$dataTarget = 'data-target="#modal-status-delete-' . $row [ 'ID' ] . '"' ;
2015-08-02 22:21:05 -04:00
$tooltip = $hesklang [ 'delete' ];
if ( $delete == 'no-default' || $delete == 'no-tickets' ) {
$cursor = '' ;
$dataTarget = '' ;
$iconStyle = 'color: grey' ;
}
if ( $delete == 'no-default' ) {
$tooltip = $hesklang [ 'whyCantIDeleteThisStatusReason' ];
} elseif ( $delete == 'no-tickets' ) {
$tooltip = $hesklang [ 'cannot_delete_status_tickets' ];
}
?>
< span data - toggle = " modal " < ? php echo $dataTarget ; ?> style="<?php echo $cursor; ?>;">
< i class = " fa fa-times icon-link " style = " <?php echo $iconStyle ; ?> "
data - toggle = " tooltip " title = " <?php echo $tooltip ; ?> " ></ i >
2015-07-26 21:47:05 -04:00
</ span >
2015-07-19 22:20:18 -04:00
</ td >
</ tr >
2015-07-26 21:47:05 -04:00
< ? php
$j ++ ;
2015-07-26 23:45:50 -04:00
endforeach ; ?>
2015-05-12 22:08:17 -04:00
</ tbody >
</ table >
</ div >
2015-07-19 22:20:18 -04:00
< div class = " panel panel-default " >
< div class = " panel-heading " >
< h4 >< ? php echo $hesklang [ 'defaultStatusForAction' ]; ?> </h4>
2015-05-12 22:08:17 -04:00
</ div >
2015-07-19 22:20:18 -04:00
< div class = " panel-body " >
< div class = " form-group " >
< label for = " newTicket " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isNewTicketMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " newTicket " class = " form-control " id = " newTicket " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 1 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsNewTicketStatus' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " closedByClient " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isClosedByClientMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " closedByClient " class = " form-control " id = " closedByClient " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 0 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsClosedByClient' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " replyFromClient " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isRepliedByClientMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " replyFromClient " class = " form-control " id = " replyFromClient " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 1 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsCustomerReplyStatus' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " staffClosedOption " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isStaffClosedOptionMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " staffClosedOption " class = " form-control " id = " staffClosedOption " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 0 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsStaffClosedOption' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " staffReopenedStatus " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isStaffReopenedStatusMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " staffReopenedStatus " class = " form-control " id = " staffReopenedStatus " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 1 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsStaffReopenedStatus' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " defaultStaffReplyStatus " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'isDefaultStaffReplyStatusMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " defaultStaffReplyStatus " class = " form-control " id = " defaultStaffReplyStatus " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 1 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsDefaultStaffReplyStatus' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " lockedTicketStatus " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'lockedTicketStatusMsg' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " lockedTicketStatus " class = " form-control " id = " lockedTicketStatus " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
$selectedEcho = ( $row [ 'LockedTicketStatus' ] == 1 ) ? 'selected="selected"' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
< div class = " form-group " >
< label for = " autocloseTicketOption " class = " col-sm-6 col-xs-12 control-label " >< ? php echo $hesklang [ 'autoclose_ticket_status' ]; ?> </label>
< div class = " col-sm-6 col-xs-12 " >
< select name = " autocloseTicketOption " class = " form-control " id = " autocloseTicketOption " >
< ? php
2015-07-29 22:27:00 -04:00
foreach ( $statuses as $key => $row )
2015-07-19 22:20:18 -04:00
{
2015-07-29 22:27:00 -04:00
if ( $row [ 'IsClosed' ] == 0 ) {
continue ;
}
2015-07-19 22:20:18 -04:00
$selectedEcho = ( $row [ 'IsAutocloseOption' ] == 1 ) ? 'selected' : '' ;
2015-07-26 12:17:41 -04:00
echo '<option value="' . $row [ 'ID' ] . '" ' . $selectedEcho . '>' . mfh_getDisplayTextForStatusId ( $row [ 'ID' ]) . '</option>' ;
2015-07-19 22:20:18 -04:00
}
?>
</ select >
</ div >
</ div >
2015-05-12 22:08:17 -04:00
</ div >
</ div >
< div class = " col-sm-6 col-sm-offset-6 " >
2015-08-03 21:53:07 -04:00
< input type = " hidden " name = " a " value = " save " >
2015-05-12 22:08:17 -04:00
< input type = " submit " class = " btn btn-default " value = " <?php echo $hesklang['save_changes'] ; ?> " >
</ div >
</ form >
</ div >
</ div >
</ div >
</ div >
< ? php
2015-07-26 23:45:50 -04:00
foreach ( $statuses as $status ) {
buildEditModal ( $status [ 'ID' ]);
buildConfirmDeleteModal ( $status [ 'ID' ]);
}
2015-07-25 01:11:08 -04:00
buildCreateModal ();
2015-05-12 22:08:17 -04:00
require_once ( HESK_PATH . 'inc/footer.inc.php' );
exit ();
2015-07-26 21:47:05 -04:00
function buildConfirmDeleteModal ( $statusId ) {
global $hesklang ;
?>
< div class = " modal fade " id = " modal-status-delete-<?php echo $statusId ; ?> " tabindex = " -1 " role = " dialog " aria - labelledby = " myLargeModalLabel " aria - hidden = " true " >
< div class = " modal-dialog modal-lg " >
< div class = " modal-content " >
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - label = " Close " >< span aria - hidden = " true " >& times ; </ span ></ button >
< h4 class = " modal-title " >< ? php echo $hesklang [ 'confirm_delete_status_question' ]; ?> </h4>
</ div >
< div class = " modal-body " >
< div class = " row " >
< div class = " col-md-12 " >
< p >< ? php echo $hesklang [ 'confirm_delete_status' ]; ?> </p>
</ div >
</ div >
</ div >
< div class = " modal-footer " >
< input type = " hidden " name = " a " value = " create " >
< div class = " btn-group " >
< a href = " manage_statuses.php?a=delete&id=<?php echo $statusId ; ?> " class = " btn btn-danger " >
< ? php echo $hesklang [ 'delete' ]; ?>
</ a >
< button type = " button " class = " btn btn-default " data - dismiss = " modal " >< ? php echo $hesklang [ 'cancel' ]; ?> </button>
</ div >
</ div >
</ div >
</ div >
</ div >
< ? php
}
2015-07-26 22:17:30 -04:00
function echoArrows ( $index , $numberOfStatuses , $statusId ) {
2015-07-29 22:27:00 -04:00
global $hesklang , $modsForHesk_settings ;
if ( $modsForHesk_settings [ 'statuses_order_column' ] == 'name' ) {
return ;
}
2015-07-23 22:06:02 -04:00
2015-07-23 21:25:27 -04:00
if ( $index !== 1 ) {
// Display move up
2015-07-27 00:06:57 -04:00
echo '<a href="manage_statuses.php?a=sort&move=-15&id=' . $statusId . ' " >
2015-07-26 22:17:30 -04:00
< i class = " fa fa-arrow-up icon-link " style = " color: green " data - toggle = " tooltip "
title = " '.htmlspecialchars( $hesklang['move_up'] ).' " ></ i ></ a > ' ;
2015-07-23 21:25:27 -04:00
} else {
echo '<img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;"> ' ;
}
if ( $index !== $numberOfStatuses ) {
// Display move down
2015-07-27 00:06:57 -04:00
echo '<a href="manage_statuses.php?a=sort&move=15&id=' . $statusId . ' " >
< i class = " fa fa-arrow-down icon-link " style = " color: green " data - toggle = " tooltip "
title = " '.htmlspecialchars( $hesklang['move_dn'] ).' " ></ i ></ a > ' ;
2015-07-23 21:25:27 -04:00
} else {
echo '<img src="../img/blank.gif" width="16" height="16" alt="" style="padding:3px;border:none;">' ;
}
}
2015-07-25 01:11:08 -04:00
function buildCreateModal () {
global $hesklang , $hesk_settings ;
$languages = array ();
foreach ( $hesk_settings [ 'languages' ] as $key => $value ) {
$languages [ $key ] = $hesk_settings [ 'languages' ][ $key ][ 'folder' ];
}
?>
< div class = " modal fade " id = " modal-status-new " tabindex = " -1 " role = " dialog " aria - labelledby = " myLargeModalLabel " aria - hidden = " true " >
< div class = " modal-dialog modal-lg " >
< div class = " modal-content " >
2015-07-25 16:33:44 -04:00
< form action = " manage_statuses.php " role = " form " method = " post " class = " form-horizontal " >
2015-07-25 01:11:08 -04:00
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - label = " Close " >< span aria - hidden = " true " >& times ; </ span ></ button >
< h4 class = " modal-title " >< ? php echo $hesklang [ 'create_new_status_title' ]; ?> </h4>
</ div >
< div class = " modal-body " >
< div class = " row " >
< div class = " col-md-6 " >
2015-08-15 15:46:38 -04:00
< h4 >< ? php echo $hesklang [ 'status_name_title' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " popover "
title = " <?php echo $hesklang['status_name_title'] ; ?> "
data - content = " <?php echo $hesklang['status_name_title_help'] ; ?> " ></ i ></ h4 >
2015-07-25 01:11:08 -04:00
< div class = " footerWithBorder blankSpace " ></ div >
< ? php foreach ( $languages as $language => $languageCode ) : ?>
< div class = " form-group " >
2015-07-25 16:33:44 -04:00
< label class = " col-sm-3 control-label " for = " name[<?php echo $language ; ?>] " >
2015-07-25 01:11:08 -04:00
< ? php echo $language ; ?>
</ label >
< div class = " col-sm-9 " >
< input type = " text " placeholder = " <?php echo htmlspecialchars( $language ); ?> "
2015-07-25 16:33:44 -04:00
class = " form-control " name = " name[<?php echo $language ; ?>] " >
2015-07-25 01:11:08 -04:00
</ div >
</ div >
< ? php endforeach ; ?>
</ div >
< div class = " col-md-6 " >
< h4 >< ? php echo $hesklang [ 'properties' ]; ?> </h4>
< div class = " footerWithBorder blankSpace " ></ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " text-color " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'textColor' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " popover "
title = " <?php echo $hesklang['textColor'] ; ?> "
data - content = " <?php echo $hesklang['textColorDescr'] ; ?> " ></ i >
</ label >
2015-07-25 01:11:08 -04:00
< div class = " col-sm-8 " >
< input type = " text " name = " text-color " class = " form-control "
placeholder = " <?php echo htmlspecialchars( $hesklang['textColor'] ); ?> " >
</ div >
</ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " closable " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'closable' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " htmlpopover "
title = " <?php echo $hesklang['closable'] ; ?> "
data - content = " <?php echo $hesklang['closable_description'] ; ?> " ></ i >
</ label >
2015-07-25 01:11:08 -04:00
< div class = " col-sm-8 " >
< select name = " closable " class = " form-control " >
< option value = " yes " >< ? php echo $hesklang [ 'yes_title_case' ]; ?> </option>
< option value = " conly " >< ? php echo $hesklang [ 'customers_only' ]; ?> </option>
< option value = " sonly " >< ? php echo $hesklang [ 'staff_only' ]; ?> </option>
< option value = " no " >< ? php echo $hesklang [ 'no_title_case' ]; ?> </option>
</ select >
</ div >
</ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " closed " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'closed_title' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " htmlpopover "
title = " <?php echo $hesklang['closed_title'] ; ?> "
data - content = " <?php echo $hesklang['closedQuestionMarkDescr'] ; ?> " ></ i >
</ label >
2015-07-25 01:11:08 -04:00
< div class = " col-sm-8 " >
< select name = " closed " class = " form-control " >
< option value = " 1 " >< ? php echo $hesklang [ 'yes_title_case' ]; ?> </option>
< option value = " 0 " >< ? php echo $hesklang [ 'no_title_case' ]; ?> </option>
</ select >
</ div >
</ div >
</ div >
</ div >
</ div >
< div class = " modal-footer " >
< input type = " hidden " name = " a " value = " create " >
< div class = " btn-group " >
< input type = " submit " class = " btn btn-success " value = " <?php echo $hesklang['save_changes'] ; ?> " >
< button type = " button " class = " btn btn-default " data - dismiss = " modal " >< ? php echo $hesklang [ 'close_modal_without_saving' ]; ?> </button>
</ div >
</ div >
</ form >
</ div >
</ div >
</ div >
< ? php
2015-07-23 22:06:02 -04:00
}
2015-07-26 21:23:04 -04:00
function buildEditModal ( $statusId ) {
global $hesklang , $hesk_settings ;
// Get status information for this status
$getStatusRs = hesk_dbQuery ( " SELECT * FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` WHERE `ID` = " . intval ( $statusId ));
$status = hesk_dbFetchAssoc ( $getStatusRs );
$textRs = hesk_dbQuery ( " SELECT `language`, `text` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref`
WHERE `status_id` = " .intval( $statusId ));
$textArray = array ();
while ( $row = hesk_dbFetchAssoc ( $textRs )) {
$textArray [ $row [ 'language' ]] = $row [ 'text' ];
}
$languages = array ();
foreach ( $hesk_settings [ 'languages' ] as $key => $value ) {
$languages [ $key ] = $hesk_settings [ 'languages' ][ $key ][ 'folder' ];
}
?>
< div class = " modal fade " id = " modal-status-<?php echo $statusId ; ?> " tabindex = " -1 " role = " dialog " aria - labelledby = " myLargeModalLabel " aria - hidden = " true " >
< div class = " modal-dialog modal-lg " >
< div class = " modal-content " >
< form action = " manage_statuses.php " role = " form " method = " post " class = " form-horizontal " >
< div class = " modal-header " >
< button type = " button " class = " close " data - dismiss = " modal " aria - label = " Close " >< span aria - hidden = " true " >& times ; </ span ></ button >
< h4 class = " modal-title " >< ? php echo sprintf ( $hesklang [ 'editing_status_x' ], $status [ 'TextColor' ], mfh_getDisplayTextForStatusId ( $statusId )); ?> </h4>
</ div >
< div class = " modal-body " >
< div class = " row " >
< div class = " col-md-6 " >
2015-08-15 15:46:38 -04:00
< h4 >
< ? php echo $hesklang [ 'status_name_title' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " popover "
title = " <?php echo $hesklang['status_name_title'] ; ?> "
data - content = " <?php echo $hesklang['status_name_title_help'] ; ?> " ></ i >
</ h4 >
2015-07-26 21:23:04 -04:00
< div class = " footerWithBorder blankSpace " ></ div >
< ? php foreach ( $languages as $language => $languageCode ) :
$warning = '' ;
if ( isset ( $textArray [ $language ])) {
$text = $textArray [ $language ];
} else {
2015-07-26 23:45:50 -04:00
hesk_setLanguage ( $language );
2015-07-26 21:23:04 -04:00
$text = $hesklang [ $status [ 'Key' ]];
2015-07-26 23:45:50 -04:00
hesk_resetLanguage ();
2015-07-26 21:23:04 -04:00
$warning = 'has-warning' ;
}
?>
< div class = " form-group <?php echo $warning ; ?> " >
< label class = " col-sm-3 control-label " for = " name[<?php echo $language ; ?>] " >
< ? php
if ( $warning != '' ) {
echoWarningForStatus ();
}
echo $language ;
?>
</ label >
< div class = " col-sm-9 " >
< input type = " text " placeholder = " <?php echo htmlspecialchars( $language ); ?> "
class = " form-control " name = " name[<?php echo $language ; ?>] "
value = " <?php echo htmlspecialchars( $text ); ?> " >
</ div >
</ div >
< ? php endforeach ; ?>
</ div >
< div class = " col-md-6 " >
< h4 >< ? php echo $hesklang [ 'properties' ]; ?> </h4>
< div class = " footerWithBorder blankSpace " ></ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " text-color " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'textColor' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " popover "
title = " <?php echo $hesklang['textColor'] ; ?> "
data - content = " <?php echo $hesklang['textColorDescr'] ; ?> " ></ i >
</ label >
2015-07-26 21:23:04 -04:00
< div class = " col-sm-8 " >
< input type = " text " name = " text-color " class = " form-control "
value = " <?php echo $status['TextColor'] ; ?> "
placeholder = " <?php echo htmlspecialchars( $hesklang['textColor'] ); ?> " >
</ div >
</ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " closable " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'closable' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " htmlpopover "
title = " <?php echo $hesklang['closable'] ; ?> "
data - content = " <?php echo $hesklang['closable_description'] ; ?> " ></ i >
</ label >
2015-07-26 21:23:04 -04:00
< div class = " col-sm-8 " >
< ? php
$yesSelected = $status [ 'Closable' ] == 'yes' ? 'selected' : '' ;
$customersOnlySelected = $status [ 'Closable' ] == 'conly' ? 'selected' : '' ;
$staffOnlySelected = $status [ 'Closable' ] == 'sonly' ? 'selected' : '' ;
$noSelected = $status [ 'Closable' ] == 'no' ? 'selected' : '' ;
?>
< select name = " closable " class = " form-control " >
< option value = " yes " < ? php echo $yesSelected ; ?> ><?php echo $hesklang['yes_title_case']; ?></option>
< option value = " conly " < ? php echo $customersOnlySelected ; ?> ><?php echo $hesklang['customers_only']; ?></option>
< option value = " sonly " < ? php echo $staffOnlySelected ; ?> ><?php echo $hesklang['staff_only']; ?></option>
< option value = " no " < ? php echo $noSelected ; ?> ><?php echo $hesklang['no_title_case']; ?></option>
</ select >
</ div >
</ div >
< div class = " form-group " >
2015-08-15 15:46:38 -04:00
< label for = " closed " class = " col-sm-4 control-label " >
< ? php echo $hesklang [ 'closed_title' ]; ?>
< i class = " fa fa-question-circle settingsquestionmark "
data - toggle = " htmlpopover "
title = " <?php echo $hesklang['closed_title'] ; ?> "
data - content = " <?php echo $hesklang['closedQuestionMarkDescr'] ; ?> " ></ i >
</ label >
2015-07-26 21:23:04 -04:00
< div class = " col-sm-8 " >
< ? php
$yes = $status [ 'IsClosed' ] == 1 ? 'selected' : '' ;
$no = $status [ 'IsClosed' ] == 1 ? '' : 'selected' ;
?>
< select name = " closed " class = " form-control " >
< option value = " 1 " < ? php echo $yes ; ?> ><?php echo $hesklang['yes_title_case']; ?></option>
< option value = " 0 " < ? php echo $no ; ?> ><?php echo $hesklang['no_title_case']; ?></option>
</ select >
</ div >
</ div >
</ div >
</ div >
</ div >
< div class = " modal-footer " >
< input type = " hidden " name = " a " value = " update " >
< input type = " hidden " name = " status-id " value = " <?php echo $statusId ; ?> " >
< div class = " btn-group " >
< input type = " submit " class = " btn btn-success " value = " <?php echo $hesklang['save_changes'] ; ?> " >
< button type = " button " class = " btn btn-default " data - dismiss = " modal " >< ? php echo $hesklang [ 'close_modal_without_saving' ]; ?> </button>
</ div >
</ div >
</ form >
</ div >
</ div >
</ div >
< ? php
}
2015-08-02 22:21:05 -04:00
function canStatusBeDeleted ( $id ) {
global $hesk_settings ;
$defaultActionSql = " SELECT 1 FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` WHERE `ID` = " . intval ( $id ) . " AND
( `IsNewTicketStatus` = 1 OR `IsClosedByClient` = 1 OR `IsCustomerReplyStatus` = 1 OR `IsStaffClosedOption` = 1
OR `IsStaffReopenedStatus` = 1 OR `IsDefaultStaffReplyStatus` = 1 OR `LockedTicketStatus` = 1 OR `IsAutocloseOption` = 1 ) " ;
$defaultActionRs = hesk_dbQuery ( $defaultActionSql );
if ( hesk_dbNumRows ( $defaultActionRs ) > 0 ) {
// it's a default action
return 'no-default' ;
}
// check if any tickets have this status
$statusRs = hesk_dbQuery ( " SELECT 1 FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " tickets` WHERE `status` = " . intval ( $id ));
if ( hesk_dbNumRows ( $statusRs ) > 0 ) {
return 'no-tickets' ;
}
return 'yes' ;
}
2015-07-26 21:23:04 -04:00
function echoWarningForStatus () {
global $hesklang ;
echo '<i class="fa fa-exclamation-triangle" data-toggle="tooltip" title="' . htmlspecialchars ( $hesklang [ 'status_not_in_database' ]) . '"></i> ' ;
}
2015-07-25 16:33:44 -04:00
function createStatus () {
global $hesklang , $hesk_settings ;
hesk_dbConnect ();
// Create the new status record
$isClosed = hesk_POST ( 'closed' );
$closable = hesk_POST ( 'closable' );
$textColor = hesk_POST ( 'text-color' );
2015-08-02 21:59:48 -04:00
/* Get the latest cat_order */
$res = hesk_dbQuery ( " SELECT `sort` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ORDER BY `sort` DESC LIMIT 1 " );
$row = hesk_dbFetchRow ( $res );
$my_order = $row [ 0 ] + 10 ;
2015-08-08 14:55:25 -04:00
// Get the next status id
2015-08-09 17:04:11 -04:00
$res = hesk_dbQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ORDER BY `ID` DESC LIMIT 1 " );
2015-08-08 14:55:25 -04:00
$row = hesk_dbFetchAssoc ( $res );
2015-08-08 15:09:35 -04:00
$nextId = $row [ 'ID' ] + 1 ;
2015-08-08 14:55:25 -04:00
2015-08-08 15:09:35 -04:00
$insert = " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` (`ID`, `Key`, `TextColor`, `IsClosed`, `Closable`, `sort`)
2015-08-08 14:55:25 -04:00
VALUES ( " .intval( $nextId ). " , 'STORED IN XREF TABLE' , '".hesk_dbEscape($textColor)."' , " .intval( $isClosed ). " , '".hesk_dbEscape($closable)."' , " .intval( $my_order ). " ) " ;
2015-07-25 16:33:44 -04:00
hesk_dbQuery ( $insert );
// For each language, create a value in the xref table
foreach ( hesk_POST_array ( 'name' ) as $language => $translation ) {
hesk_dbQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (`language`, `text`, `status_id`)
2015-08-15 15:46:38 -04:00
VALUES ( '".hesk_dbEscape($language)."' , '".hesk_dbEscape($translation)."' , " .intval( $nextId ). " ) " );
2015-07-25 16:33:44 -04:00
}
hesk_process_messages ( $hesklang [ 'new_status_created' ], 'manage_statuses.php' , 'SUCCESS' );
}
2015-07-26 21:23:04 -04:00
function updateStatus () {
global $hesklang , $hesk_settings ;
$statusId = hesk_POST ( 'status-id' );
$isClosed = hesk_POST ( 'closed' );
$closable = hesk_POST ( 'closable' );
$textColor = hesk_POST ( 'text-color' );
$update = " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses`
SET `TextColor` = '".hesk_dbEscape($textColor)."' ,
`IsClosed` = " .intval( $isClosed ). " ,
`Closable` = '".hesk_dbEscape($closable)."'
WHERE `ID` = " .intval( $statusId );
hesk_dbQuery ( $update );
// For each language, delete the xref record and insert the new ones
hesk_dbQuery ( " DELETE FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` WHERE `status_id` = " . intval ( $statusId ));
foreach ( hesk_POST_array ( 'name' ) as $language => $translation ) {
hesk_dbQuery ( " INSERT INTO ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` (`language`, `text`, `status_id`)
2015-07-27 00:06:57 -04:00
VALUES ( '".hesk_dbEscape($language)."' , '".hesk_dbEscape($translation)."' , " .intval( $statusId ). " ) " );
2015-07-26 21:23:04 -04:00
}
hesk_process_messages ( $hesklang [ 'ticket_status_updated' ], 'manage_statuses.php' , 'SUCCESS' );
}
2015-07-26 21:47:05 -04:00
function deleteStatus () {
global $hesklang , $hesk_settings ;
$statusId = hesk_GET ( 'id' );
hesk_dbQuery ( " DELETE FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " text_to_status_xref` WHERE `status_id` = " . intval ( $statusId ));
hesk_dbQuery ( " DELETE FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` WHERE `ID` = " . intval ( $statusId ));
2015-08-02 22:01:17 -04:00
resortStatuses ();
2015-07-26 21:47:05 -04:00
hesk_process_messages ( $hesklang [ 'ticket_status_deleted' ], 'manage_statuses.php' , 'SUCCESS' );
}
2015-07-27 00:06:57 -04:00
function moveStatus () {
global $hesk_settings , $hesklang ;
2015-07-26 22:17:30 -04:00
2015-07-27 00:06:57 -04:00
$statusId = intval ( hesk_GET ( 'id' ));
$statusMove = intval ( hesk_GET ( 'move' ));
2015-07-26 22:17:30 -04:00
2015-07-27 00:06:57 -04:00
hesk_dbQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `sort` = `sort`+ " . intval ( $statusMove ) . "
WHERE `ID` = '".intval($statusId)."' LIMIT 1 " );
2015-08-02 22:01:17 -04:00
resortStatuses ();
hesk_process_messages ( $hesklang [ 'status_sort_updated' ], 'manage_statuses.php' , 'SUCCESS' );
}
function resortStatuses () {
global $hesk_settings ;
2015-07-27 00:06:57 -04:00
/* Update all category fields with new order */
$res = hesk_dbQuery ( " SELECT `ID` FROM ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` ORDER BY `sort` ASC " );
$i = 10 ;
while ( $myStatus = hesk_dbFetchAssoc ( $res ))
{
hesk_dbQuery ( " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET `sort`= " . intval ( $i ) . "
WHERE `ID` = '".intval($myStatus[' ID '])."' LIMIT 1 " );
$i += 10 ;
2015-07-26 22:17:30 -04:00
}
}
2015-07-25 16:33:44 -04:00
2015-05-12 22:08:17 -04:00
function save () {
global $hesklang , $hesk_settings ;
//-- Update default status for actions
$defaultQuery = " UPDATE ` " . hesk_dbEscape ( $hesk_settings [ 'db_pfix' ]) . " statuses` SET " ;
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsNewTicketStatus` = 0 " );
$updateQuery = $defaultQuery . " `IsNewTicketStatus` = 1 WHERE `ID` = " . intval ( $_POST [ 'newTicket' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsClosedByClient` = 0 " );
$updateQuery = $defaultQuery . " `IsClosedByClient` = 1 WHERE `ID` = " . intval ( $_POST [ 'closedByClient' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsCustomerReplyStatus` = 0 " );
$updateQuery = $defaultQuery . " `IsCustomerReplyStatus` = 1 WHERE `ID` = " . intval ( $_POST [ 'replyFromClient' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsStaffClosedOption` = 0 " );
$updateQuery = $defaultQuery . " `IsStaffClosedOption` = 1 WHERE `ID` = " . intval ( $_POST [ 'staffClosedOption' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsStaffReopenedStatus` = 0 " );
$updateQuery = $defaultQuery . " `IsStaffReopenedStatus` = 1 WHERE `ID` = " . intval ( $_POST [ 'staffReopenedStatus' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsDefaultStaffReplyStatus` = 0 " );
$updateQuery = $defaultQuery . " `IsDefaultStaffReplyStatus` = 1 WHERE `ID` = " . intval ( $_POST [ 'defaultStaffReplyStatus' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `LockedTicketStatus` = 0 " );
$updateQuery = $defaultQuery . " `LockedTicketStatus` = 1 WHERE `ID` = " . intval ( $_POST [ 'lockedTicketStatus' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-07-23 21:39:34 -04:00
hesk_dbQuery ( $defaultQuery . " `IsAutocloseOption` = 0 " );
$updateQuery = $defaultQuery . " `IsAutocloseOption` = 1 WHERE `ID` = " . intval ( $_POST [ 'autocloseTicketOption' ]);
hesk_dbQuery ( $updateQuery );
2015-05-12 22:08:17 -04:00
2015-08-03 21:53:07 -04:00
hesk_process_messages ( $hesklang [ 'default_statuses_updated' ], 'manage_statuses.php' , 'SUCCESS' );
2015-05-12 22:08:17 -04:00
}