Projects: Keep project tickets apart under Admin Settings Projects leaves a project's tickets off the tickets list's usual views with a Projects view of their own, out of the dashboard and menu counts and the Dispatch queue, with no SLA, while Mine, Workload and the calendar keep them in the project's color with the agent's color as a dot; a ticket taken out of its project, or every one when it is switched off, gets its SLA back counted from then; off by default; database 3.8.9 adds config_project_tickets_apart, config_project_ticket_color and tickets.ticket_sla_from; 26.11.9 changelog entries

This commit is contained in:
johnnyq
2026-11-17 21:26:50 -05:00
parent 475f27fc7f
commit 55e7f6cc5d
19 changed files with 318 additions and 14 deletions

View File

@@ -0,0 +1,35 @@
<?php
/*
* ITFlow - Database update to version 3.8.9 (from 3.8.8)
* Included by admin/database_updates.php - do not access directly
*
* Project tickets kept apart from the service desk (functions/project_tickets.php):
* settings.config_project_tickets_apart - 1 keeps a project's tickets off the
* Tickets list's usual views, the dashboard's counts and the Dispatch queue,
* with no SLA; 0 (the default) as before.
* settings.config_project_ticket_color - their bookings' colour on the calendar;
* NULL is purple.
* tickets.ticket_sla_from - when the ticket's SLA targets count from, when it
* isn't when it was made: the moment it left a project. NULL from creation.
*
* Re-runnable: each column is added only where it isn't there yet.
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
$itflow_column = function ($table, $column) use ($mysqli) {
$result = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '$table' AND COLUMN_NAME = '$column' LIMIT 1");
return $result && mysqli_num_rows($result) > 0;
};
if (!$itflow_column('settings', 'config_project_tickets_apart')) {
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_project_tickets_apart` tinyint(1) NOT NULL DEFAULT 0 AFTER `config_project_next_number`");
}
if (!$itflow_column('settings', 'config_project_ticket_color')) {
mysqli_query($mysqli, "ALTER TABLE `settings` ADD `config_project_ticket_color` varchar(20) DEFAULT NULL AFTER `config_project_tickets_apart`");
}
if (!$itflow_column('tickets', 'ticket_sla_from')) {
mysqli_query($mysqli, "ALTER TABLE `tickets` ADD `ticket_sla_from` datetime DEFAULT NULL AFTER `ticket_sla_id`");
}

View File

@@ -3,7 +3,9 @@
/*
* Admin > Settings > Projects (admin/settings_project.php):
* edit_project_settings saves the numbering - a next number already in use
* comes back to the page saying so.
* comes back to the page saying so - and whether project tickets are kept
* apart, with their calendar colour; switching that works out the open
* project tickets' SLAs again.
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
@@ -12,14 +14,28 @@ if (isset($_POST['edit_project_settings'])) {
validateCSRFToken();
$before = settingsCurrent(['config_project_prefix', 'config_project_next_number']);
$ticket_columns = projectTicketsReady() ? ['config_project_tickets_apart', 'config_project_ticket_color'] : [];
$before = settingsCurrent(array_merge(['config_project_prefix', 'config_project_next_number'], $ticket_columns));
[$prefix, $number, $errors] = settingsNumberingCheck('project', $_POST + array_map('strval', $before), $before);
if ($errors) {
settingsRefuse('project', $errors);
}
settingsSave('project', $before, ['config_project_prefix' => $prefix, 'config_project_next_number' => $number]);
$after = ['config_project_prefix' => $prefix, 'config_project_next_number' => $number];
// Project tickets kept apart, and their colour (functions/project_tickets.php) - a switch sends nothing when off
if ($ticket_columns) {
$after['config_project_tickets_apart'] = empty($_POST['config_project_tickets_apart']) ? '0' : '1';
$color = calendarColor((string) ($_POST['config_project_ticket_color'] ?? ''), '');
$after['config_project_ticket_color'] = $color === '' || strtolower($color) === PROJECT_TICKET_COLOR ? null : $color;
}
settingsSave('project', $before, $after);
// Switched on, the open project tickets lose their SLA; off, they get it back counted from now
if ($ticket_columns && $after['config_project_tickets_apart'] !== (string) intval($before['config_project_tickets_apart'])) {
projectTicketsSwitched($after['config_project_tickets_apart'] === '1');
}
redirect();

View File

@@ -1,8 +1,9 @@
<?php
/*
* Admin > Settings > Projects - how projects are numbered. Saved by
* edit_project_settings (admin/post/settings_project.php).
* Admin > Settings > Projects - how projects are numbered, and whether their
* tickets are kept apart from the service desk (functions/project_tickets.php).
* Saved by edit_project_settings (admin/post/settings_project.php).
*/
require_once "includes/inc_all_admin.php";
@@ -21,6 +22,16 @@ echo settingsPageStart('project');
<?= settingsNumberingFields('project', $config_project_prefix, $config_project_next_number) ?>
<?= settingsSectionEnd() ?>
<?php if (projectTicketsReady()) {
$project_tickets = projectTicketsSettings(); ?>
<?= settingsSectionStart('tickets', 'Project tickets', 'A project\'s tickets can be kept apart from the service desk - its dates count, not an SLA.') ?>
<?= settingsSwitch('config_project_tickets_apart', $project_tickets['apart'] ? 1 : 0, ['label' => 'Keep project tickets apart',
'help' => 'A ticket in a project is left off the Tickets list\'s usual views - it has a Projects view of its own - the dashboard\'s unassigned count and the Dispatch queue, and has no SLA. Agents still see their own under Mine, in Dispatch\'s Workload and on the calendar. A ticket taken out of its project gets its SLA back, counted from then - and so do they all if this is switched off.']) ?>
<?= settingsInput('config_project_ticket_color', $project_tickets['color'], ['type' => 'color', 'icon' => 'fa-palette', 'class' => 'form-control-color',
'label' => 'Calendar color', 'help' => 'Their bookings on the calendar and Dispatch while they are kept apart - on the calendar, with a dot in the agent\'s own color beside their name.']) ?>
<?= settingsSectionEnd() ?>
<?php } ?>
<?= settingsSaveBar('edit_project_settings') ?>
</div>
</div>