Merge branch 'master' into attachment-improvements
This commit is contained in:
commit
c136e7cd45
@ -21,10 +21,11 @@ define('WYSIWYG',1);
|
||||
|
||||
// Are we performing an action?
|
||||
if (isset($_REQUEST['a'])) {
|
||||
if ($_POST['a'] == 'create') { createStatus(); }
|
||||
elseif ($_POST['a'] == 'update') { updateStatus(); }
|
||||
elseif ($_GET['a'] == 'delete') { deleteStatus(); }
|
||||
elseif ($_GET['a'] == 'sort') { moveStatus(); }
|
||||
if ($_REQUEST['a'] == 'create') { createStatus(); }
|
||||
elseif ($_REQUEST['a'] == 'update') { updateStatus(); }
|
||||
elseif ($_REQUEST['a'] == 'delete') { deleteStatus(); }
|
||||
elseif ($_REQUEST['a'] == 'sort') { moveStatus(); }
|
||||
elseif ($_REQUEST['a'] == 'save') { save(); }
|
||||
}
|
||||
|
||||
|
||||
@ -147,9 +148,27 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
|
||||
</span>
|
||||
<?php echoArrows($j, $numberOfStatuses, $row['ID']); ?>
|
||||
<span data-toggle="modal" data-target="#modal-status-delete-<?php echo $row['ID']; ?>" style="cursor: pointer;">
|
||||
<i class="fa fa-times icon-link" style="color: red"
|
||||
data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i>
|
||||
<?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';
|
||||
$dataTarget = 'data-target="#modal-status-delete-'.$row['ID'];
|
||||
$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>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
@ -307,7 +326,7 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-sm-offset-6">
|
||||
<input type="hidden" name="action" value="save">
|
||||
<input type="hidden" name="a" value="save">
|
||||
<input type="submit" class="btn btn-default" value="<?php echo $hesklang['save_changes']; ?>">
|
||||
</div>
|
||||
</form>
|
||||
@ -585,6 +604,25 @@ function buildEditModal($statusId) {
|
||||
<?php
|
||||
}
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
function echoWarningForStatus() {
|
||||
global $hesklang;
|
||||
|
||||
@ -600,8 +638,14 @@ function createStatus() {
|
||||
$isClosed = hesk_POST('closed');
|
||||
$closable = hesk_POST('closable');
|
||||
$textColor = hesk_POST('text-color');
|
||||
$insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`Key`, `TextColor`, `IsClosed`, `Closable`)
|
||||
VALUES ('STORED IN XREF TABLE', '".hesk_dbEscape($textColor)."', ".intval($isClosed).", '".hesk_dbEscape($closable)."')";
|
||||
|
||||
/* 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;
|
||||
|
||||
$insert = "INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` (`Key`, `TextColor`, `IsClosed`, `Closable`, `sort`)
|
||||
VALUES ('STORED IN XREF TABLE', '".hesk_dbEscape($textColor)."', ".intval($isClosed).", '".hesk_dbEscape($closable)."', ".intval($my_order).")";
|
||||
hesk_dbQuery($insert);
|
||||
|
||||
$newStatusId = hesk_dbInsertID();
|
||||
@ -646,6 +690,7 @@ function deleteStatus() {
|
||||
|
||||
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));
|
||||
resortStatuses();
|
||||
|
||||
hesk_process_messages($hesklang['ticket_status_deleted'],'manage_statuses.php','SUCCESS');
|
||||
}
|
||||
@ -659,9 +704,16 @@ function moveStatus() {
|
||||
hesk_dbQuery("UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` SET `sort` = `sort`+".intval($statusMove)."
|
||||
WHERE `ID` = '".intval($statusId)."' LIMIT 1");
|
||||
|
||||
resortStatuses();
|
||||
|
||||
hesk_process_messages($hesklang['status_sort_updated'],'manage_statuses.php','SUCCESS');
|
||||
}
|
||||
|
||||
function resortStatuses() {
|
||||
global $hesk_settings;
|
||||
|
||||
/* 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))
|
||||
{
|
||||
@ -669,8 +721,6 @@ function moveStatus() {
|
||||
WHERE `ID`='".intval($myStatus['ID'])."' LIMIT 1");
|
||||
$i += 10;
|
||||
}
|
||||
|
||||
hesk_process_messages($hesklang['status_sort_updated'],'manage_statuses.php','SUCCESS');
|
||||
}
|
||||
|
||||
function save() {
|
||||
@ -711,5 +761,5 @@ function save() {
|
||||
$updateQuery = $defaultQuery . "`IsAutocloseOption` = 1 WHERE `ID` = ".intval($_POST['autocloseTicketOption']);
|
||||
hesk_dbQuery($updateQuery);
|
||||
|
||||
hesk_process_messages($hesklang['statuses_saved'],'manage_statuses.php','SUCCESS');
|
||||
hesk_process_messages($hesklang['default_statuses_updated'],'manage_statuses.php','SUCCESS');
|
||||
}
|
@ -51,6 +51,8 @@ $hesklang['confirm_delete_status'] = 'Are you sure you want to delete this statu
|
||||
$hesklang['status_sort_updated'] = 'Ticket status sort updated!';
|
||||
$hesklang['status_sort'] = 'Status Sorting';
|
||||
$hesklang['status_sort_help'] = 'Determines if statuses shown on the manage statuses page and all dropdowns are sorted by the user-defined order (default), or sorted alphabetically.';
|
||||
$hesklang['cannot_delete_status_tickets'] = 'This status cannot be deleted because there are tickets set to this status.';
|
||||
$hesklang['default_statuses_updated'] = 'Default statuses have been updated!';
|
||||
|
||||
// ADDED OR MODIFIED IN Mods for HESK 2.3.0
|
||||
$hesklang['sm_icon'] = 'Icon';
|
||||
|
Loading…
x
Reference in New Issue
Block a user