#298 Don't allow user to delete statuses that are a default action or have tickets set to that status
This commit is contained in:
parent
7e5390936f
commit
32efca8f5c
@ -147,9 +147,27 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
|
|||||||
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
|
data-toggle="tooltip" title="<?php echo $hesklang['edit']; ?>"></i>
|
||||||
</span>
|
</span>
|
||||||
<?php echoArrows($j, $numberOfStatuses, $row['ID']); ?>
|
<?php echoArrows($j, $numberOfStatuses, $row['ID']); ?>
|
||||||
<span data-toggle="modal" data-target="#modal-status-delete-<?php echo $row['ID']; ?>" style="cursor: pointer;">
|
<?php
|
||||||
<i class="fa fa-times icon-link" style="color: red"
|
// Only show the delete button if (1) it's not a default action and (2) no tickets are set to that status
|
||||||
data-toggle="tooltip" title="<?php echo $hesklang['delete']; ?>"></i>
|
$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>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -585,6 +603,25 @@ function buildEditModal($statusId) {
|
|||||||
<?php
|
<?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() {
|
function echoWarningForStatus() {
|
||||||
global $hesklang;
|
global $hesklang;
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ $hesklang['confirm_delete_status'] = 'Are you sure you want to delete this statu
|
|||||||
$hesklang['status_sort_updated'] = 'Ticket status sort updated!';
|
$hesklang['status_sort_updated'] = 'Ticket status sort updated!';
|
||||||
$hesklang['status_sort'] = 'Status Sorting';
|
$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['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.';
|
||||||
|
|
||||||
// ADDED OR MODIFIED IN Mods for HESK 2.3.0
|
// ADDED OR MODIFIED IN Mods for HESK 2.3.0
|
||||||
$hesklang['sm_icon'] = 'Icon';
|
$hesklang['sm_icon'] = 'Icon';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user