From 75a9725994a69550c392b9eda55478ba811e17a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20K=C5=82opotek=20-=20INTERDUO?= Date: Mon, 4 Aug 2025 15:30:37 +0200 Subject: [PATCH 1/2] bugfix: display events ordered by date in ticket assigned event tab --- lib/LMSManagers/LMSHelpdeskManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/LMSManagers/LMSHelpdeskManager.php b/lib/LMSManagers/LMSHelpdeskManager.php index 9fe1d0952d..a84a526095 100644 --- a/lib/LMSManagers/LMSHelpdeskManager.php +++ b/lib/LMSManagers/LMSHelpdeskManager.php @@ -783,7 +783,7 @@ public function GetEventsByTicketId($id) . 'LEFT JOIN vaddresses va ON va.id = events.address_id ' . 'LEFT JOIN vnodes as vn ON (nodeid = vn.id) ' . 'LEFT JOIN customerview c ON (events.customerid = c.id) ' - . 'WHERE ticketid = ? ORDER BY events.id ASC', array($id)); + . 'WHERE ticketid = ? ORDER BY events.date ASC', array($id)); if (is_array($events)) { foreach ($events as $idx => $row) { From 2eb1a1eeae5d07dc718e11d724abc0306c2457a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20K=C5=82opotek=20-=20INTERDUO?= Date: Thu, 4 Sep 2025 22:44:57 +0200 Subject: [PATCH 2/2] enhancement: allow to set ticket as periodic and create new events by crontab script --- bin/lms-timetable-scheduler.php | 107 ++++++++++++++++++++ doc/ChangeLog | 1 + doc/lms.mysql | 1 + doc/lms.pgsql | 3 +- lib/LMSManagers/LMSHelpdeskManager.php | 41 ++++++-- lib/SYSLOG.class.php | 3 + lib/definitions.php | 62 +++++++++++- lib/locale/pl_PL/strings.php | 15 +++ lib/upgradedb/mysql.2025073000.php | 30 ++++++ lib/upgradedb/postgres.2025073000.php | 30 ++++++ modules/rtqueueview.php | 26 ++++- modules/rtticketadd.php | 6 ++ modules/rtticketedit.php | 6 ++ templates/default/rt/rtfilter.html | 9 ++ templates/default/rt/rtticketinfobox.html | 10 ++ templates/default/rt/rtticketinfoshort.html | 13 +++ templates/default/rt/rtticketmodify.html | 10 ++ 17 files changed, 362 insertions(+), 11 deletions(-) create mode 100755 bin/lms-timetable-scheduler.php create mode 100644 lib/upgradedb/mysql.2025073000.php create mode 100644 lib/upgradedb/postgres.2025073000.php diff --git a/bin/lms-timetable-scheduler.php b/bin/lms-timetable-scheduler.php new file mode 100755 index 0000000000..df20897d1f --- /dev/null +++ b/bin/lms-timetable-scheduler.php @@ -0,0 +1,107 @@ +#!/usr/bin/env php + 'c', + 'debug' => 'd', +); + +$script_help = <<setPluginManager($plugin_manager); + +$rt_schedule_planing_forward_events = ConfigHelper::getConfig('rt.schedule_planing_forward_events', 3); +$tickets_to_plan = $LMS->GetQueueContents( + [ + 'periodicity' => -1, + 'deleted' => 0, + 'closed' => 0, + 'short' => true, + ] +); + +function CalculateNextOccurrenceInFuture($start, $periodicity) +{ + global $EVENT_PERIODICITY; + $timestamp = (new DateTime())->setTimestamp($start); + $interval = $EVENT_PERIODICITY[$periodicity]['map']; + $now = time(); + + do { + $timestamp->modify($interval); + } while ($timestamp->getTimestamp() <= $now); + + return $timestamp->getTimestamp(); +} + +if (empty($tickets_to_plan)) { + die(); +} + +foreach ($tickets_to_plan as $idx => $t) { + $t = $LMS->GetTicketContents($t['id']); + + for ($a = $t['openeventcount'] ?? 0; $a < $rt_schedule_planing_forward_events; $a++) { + $ticket_events = $LMS->GetEventsByTicketId($t['ticketid']); + $last_ticket_event = (is_array($ticket_events) && !empty($ticket_events)) ? end($ticket_events) : null; + $timestamp = $last_ticket_event['date'] ?? $t['createtime']; + $next_occurrence = CalculateNextOccurrenceInFuture($timestamp, $t['periodicity']); + $params = [ + 'date' => $next_occurrence, + 'begintime' => $last_ticket_event['begintime'] ?? 0, + 'endtime' => $last_ticket_event['endtime'] ?? 0, + 'enddate' => $last_ticket_event['enddate'] ?? 0, + 'title' => $t['messages'][0]['subject'] ?? null, + 'description' => $t['messages'][0]['body'] ?? null, + 'userlist' => array($t['owner']) ?? null, + 'custid' => $t['customerid'] ?? null, + 'address_id' => $t['address_id'] ?? null, + 'ticketid' => $t['ticketid'], + 'nodeid' => $t['nodeid'] ?? null, + 'private' => 0, + 'type' => EVENT_OTHER, + ]; + if ($debug) { + print_r($params) . PHP_EOL; + } + $LMS->EventAdd($params); + } +} diff --git a/doc/ChangeLog b/doc/ChangeLog index 99240a17f3..ca572af8ad 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1069,6 +1069,7 @@ version 28-git (????-??-??): - improvement: 'rt.from_header_email_is_customer_contact_check' configuration variable with default 'true' value allows to disable checking if 'from' header e-mail address is customer contact during ticket message reply form startup [chilan] + - enhancement: allow to set ticket as periodic and create new events by crontab script [interduo] version 27.0 (2021-08-20): diff --git a/doc/lms.mysql b/doc/lms.mysql index abdef978b3..8c1536ab3c 100644 --- a/doc/lms.mysql +++ b/doc/lms.mysql @@ -2244,6 +2244,7 @@ CREATE TABLE rttickets ( modtime int(16) NOT NULL DEFAULT 0, source tinyint(4) NOT NULL DEFAULT '0', priority tinyint(4) DEFAULT NULL, + periodicity smallint DEFAULT 0, deleted tinyint(1) NOT NULL DEFAULT '0', deltime int(16) NOT NULL DEFAULT 0, deluserid int(11) DEFAULT NULL, diff --git a/doc/lms.pgsql b/doc/lms.pgsql index 85fb05a500..f5701cb6f2 100644 --- a/doc/lms.pgsql +++ b/doc/lms.pgsql @@ -2157,6 +2157,7 @@ CREATE TABLE rttickets ( modtime bigint NOT NULL DEFAULT 0, source smallint DEFAULT 0 NOT NULL, priority smallint DEFAULT NULL, + periodicity smallint DEFAULT 0, deleted smallint DEFAULT 0 NOT NULL, deltime bigint DEFAULT 0 NOT NULL, deluserid integer DEFAULT NULL @@ -4525,6 +4526,6 @@ INSERT INTO netdevicemodels (name, alternative_name, netdeviceproducerid) VALUES ('XR7', 'XR7 MINI PCI PCBA', 2), ('XR9', 'MINI PCI 600MW 900MHZ', 2); -INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2025081300'); +INSERT INTO dbinfo (keytype, keyvalue) VALUES ('dbversion', '2025073000'); COMMIT; diff --git a/lib/LMSManagers/LMSHelpdeskManager.php b/lib/LMSManagers/LMSHelpdeskManager.php index a84a526095..b2c96476bb 100644 --- a/lib/LMSManagers/LMSHelpdeskManager.php +++ b/lib/LMSManagers/LMSHelpdeskManager.php @@ -138,7 +138,7 @@ public function GetQueueContents(array $params) { $userid = Auth::GetCurrentUser(); extract($params); - foreach (array('ids', 'state', 'priority', 'source', 'owner', 'catids', 'removed', 'netdevids', 'netnodeids', 'deadline', + foreach (array('ids', 'state', 'priority', 'periodicity', 'source', 'owner', 'catids', 'removed', 'netdevids', 'netnodeids', 'deadline', 'serviceids', 'typeids', 'unread', 'parentids', 'verifierids', 'rights', 'projectids', 'cid', 'subject', 'fromdate', 'todate', 'short', 'watching') as $var) { if (!isset(${$var})) { ${$var} = null; @@ -185,6 +185,9 @@ public function GetQueueContents(array $params) case 'priority': $sqlord = ' ORDER BY t.priority'; break; + case 'periodicity': + $sqlord = ' ORDER BY t.periodicity'; + break; case 'deadline': $sqlord = ' ORDER BY t.deadline'; break; @@ -223,6 +226,16 @@ public function GetQueueContents(array $params) $priorityfilter = ' AND t.priority = '.$priority; } + if (empty($periodicity)) { + $periodicityfilter = ''; + } elseif (is_array($periodicity)) { + $periodicityfilter = ' AND t.periodicity IN (' . implode(',', $periodicity) . ')'; + } elseif ($periodicity == -1) { + $periodicityfilter = ' AND t.periodicity IS NOT NULL'; + } else { + $periodicityfilter = ' AND t.periodicity = ' . $periodicity; + } + if (empty($source) || intval($source) == -1) { $sourcefilter = ''; } else { @@ -485,6 +498,7 @@ public function GetQueueContents(array $params) . $parentfilter . $statefilter . $priorityfilter + . $periodicityfilter . $sourcefilter . $ownerfilter . $removedfilter @@ -504,7 +518,7 @@ public function GetQueueContents(array $params) if ($result = $this->db->GetAll( 'SELECT DISTINCT t.id, t.customerid, t.address_id, va.name AS vaname, va.city AS vacity, va.street, va.house, va.flat, c.address, c.city, vusers.name AS ownername, - t.subject, t.state, owner AS ownerid, t.requestor AS req, t.source, t.priority, rtqueues.name,' + t.subject, t.state, owner AS ownerid, t.requestor AS req, t.source, t.priority, t.periodicity, rtqueues.name,' . $this->db->Concat('c.lastname', "' '", 'c.name') . ' AS customername, t.requestor_phone, t.requestor_mail, t.deadline, t.requestor_userid, rq.name AS requestor_name, t.createtime AS createtime, u.name AS creatorname, t.deleted, t.deltime, t.deluserid, @@ -594,6 +608,7 @@ public function GetQueueContents(array $params) . $parentfilter . $statefilter . $priorityfilter + . $periodicityfilter . $sourcefilter . $ownerfilter . $removedfilter @@ -651,6 +666,7 @@ public function GetQueueContents(array $params) $result['owner'] = $owner; $result['removed'] = $removed; $result['priority'] = $priority; + $result['periodicity'] = $periodicity; $result['source'] = $source; $result['deadline'] = $deadline; $result['service'] = $serviceids; @@ -1150,9 +1166,9 @@ public function TicketAdd($ticket, $files = null) $this->db->Execute( 'INSERT INTO rttickets (queueid, customerid, requestor, requestor_mail, requestor_phone, - requestor_userid, subject, state, owner, createtime, modtime, cause, creatorid, source, priority, address_id, nodeid, + requestor_userid, subject, state, owner, createtime, modtime, cause, creatorid, source, priority, periodicity, address_id, nodeid, netnodeid, netdevid, verifierid, deadline, service, type, invprojectid, parentid, customcreatetime, customresolvetime) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array( $ticket['queue'], empty($ticket['customerid']) ? null : $ticket['customerid'], @@ -1169,6 +1185,7 @@ public function TicketAdd($ticket, $files = null) $ticket['userid'] ?? Auth::GetCurrentUser(), $ticket['source'] ?? 0, isset($ticket['priority']) && strlen($ticket['priority']) ? $ticket['priority'] : null, + empty($ticket['periodicity']) ? null : $ticket['periodicity'], !empty($ticket['address_id']) ? $ticket['address_id'] : null, !empty($ticket['nodeid']) ? $ticket['nodeid'] : null, !empty($ticket['netnodeid']) ? $ticket['netnodeid'] : null, @@ -1296,7 +1313,7 @@ public function GetTicketContents($id, $short = false) $ticket = $this->db->GetRow('SELECT t.id AS ticketid, t.queueid, rtqueues.name AS queuename, t.requestor, t.requestor_phone, t.requestor_mail, t.requestor_userid, d.name AS requestor_username, t.state, t.owner, t.customerid, t.cause, t.creatorid, c.name AS creator, - t.source, t.priority, i.id AS invprojectid, i.name AS invproject_name, t.verifier_rtime, ' + t.source, t.priority, t.periodicity, i.id AS invprojectid, i.name AS invproject_name, t.verifier_rtime, ' . $this->db->Concat('customers.lastname', "' '", 'customers.name') . ' AS customername, o.name AS ownername, t.createtime, t.resolvetime, t.customcreatetime, @@ -1554,7 +1571,7 @@ protected function updateTicketParentID($ticketid, $parentid = null) public function TicketChange($ticketid, array $props) { - global $LMS, $RT_STATES, $RT_CAUSE, $RT_SOURCES, $RT_PRIORITIES, $SERVICETYPES, $RT_TYPES; + global $LMS, $RT_STATES, $RT_CAUSE, $RT_SOURCES, $RT_PRIORITIES, $SERVICETYPES, $RT_TYPES, $EVENT_PERIODICITY; $allow_empty_categories = ConfigHelper::checkConfig('rt.allow_empty_categories', ConfigHelper::checkConfig('phpui.helpdesk_allow_empty_categories')); @@ -1612,6 +1629,15 @@ public function TicketChange($ticketid, array $props) $props['priority'] = $ticket['priority']; } + if (array_key_exists('periodicity', $props) && $ticket['periodicity'] != $props['periodicity']) { + $a = isset($ticket['periodicity']) ? $EVENT_PERIODICITY[$ticket['periodicity']]['label'] : trans('none'); + $b = isset($props['periodicity']) ? $EVENT_PERIODICITY[$props['periodicity']]['label'] : trans('none'); + $notes[] = trans('Ticket\'s scheduling periodicity has been changed from $a to $b.', $a, $b); + $type = $type | RTMESSAGE_PERIODICITY_CHANGE; + } else { + $props['periodicity'] = $ticket['periodicity']; + } + if (isset($props['state']) && $ticket['state'] != $props['state']) { $notes[] = trans('Ticket\'s state has been changed from $a to $b.', $RT_STATES[$ticket['state']]['label'], $RT_STATES[$props['state']]['label']); $type = $type | RTMESSAGE_STATE_CHANGE; @@ -1992,7 +2018,7 @@ public function TicketChange($ticketid, array $props) $userid : $props['owner']; $this->db->Execute( 'UPDATE rttickets SET queueid = ?, owner = ?, cause = ?, state = ?, modtime = ?, resolvetime=?, subject = ?, - customerid = ?, source = ?, priority = ?, address_id = ?, nodeid = ?, netnodeid = ?, netdevid = ?, + customerid = ?, source = ?, priority = ?, periodicity = ?, address_id = ?, nodeid = ?, netnodeid = ?, netdevid = ?, verifierid = ?, verifier_rtime = ?, deadline = ?, service = ?, type = ?, invprojectid = ?, requestor_userid = ?, requestor = ?, requestor_mail = ?, requestor_phone = ?, parentid = ?, customcreatetime = ?, customresolvetime = ? @@ -2008,6 +2034,7 @@ public function TicketChange($ticketid, array $props) $props['customerid'], $props['source'], $props['priority'], + $props['periodicity'], $props['address_id'], $props['nodeid'], $props['netnodeid'], diff --git a/lib/SYSLOG.class.php b/lib/SYSLOG.class.php index 4b668e770e..8b3cda1544 100644 --- a/lib/SYSLOG.class.php +++ b/lib/SYSLOG.class.php @@ -96,6 +96,7 @@ class SYSLOG public const RES_TARIFF_PRICE_VARIANT = 68; public const RES_TICKET_MESSAGE = 69; public const RES_QUEUE = 70; + public const RES_PERIODICITY = 71; public const OPER_ADD = 1; public const OPER_DELETE = 2; @@ -167,6 +168,7 @@ class SYSLOG self::RES_TARIFFASSIGN => 'tariff assignment', self::RES_EVENT => 'event', self::RES_EVENTASSIGN => 'event assignment', + self::RES_PERIODICITY => 'scheduling periodicity', self::RES_ADDRESS => 'address', self::RES_TICKET => 'ticket', self::RES_DOCATTACH => 'document attachment', @@ -239,6 +241,7 @@ class SYSLOG self::RES_TARIFFASSIGN => 'tariffassignmentid', self::RES_EVENT => 'eventid', self::RES_EVENTASSIGN => 'eventassignmentid', + self::RES_PERIODICITY => 'periodid', self::RES_ADDRESS => 'address_id', self::RES_TICKET => 'ticketid', self::RES_DOCATTACH => 'documentattachmentid', diff --git a/lib/definitions.php b/lib/definitions.php index 5cba7b7e42..598b1e5aec 100644 --- a/lib/definitions.php +++ b/lib/definitions.php @@ -642,7 +642,8 @@ RTMESSAGE_PARENT_CHANGE = 1048576, RTMESSAGE_ASSIGNED_EVENT_ADD = 2097152, RTMESSAGE_ASSIGNED_EVENT_CHANGE = 4194304, - RTMESSAGE_ASSIGNED_EVENT_DELETE = 8388608; + RTMESSAGE_ASSIGNED_EVENT_DELETE = 8388608, + RTMESSAGE_PERIODICITY_CHANGE = 16777216; const NETWORK_NODE_FLAG_BSA = 1, NETWORK_NODE_FLAG_INTERFACE_COUNT_INCREASE_POSSIBILITY = 2, @@ -1069,7 +1070,10 @@ QUARTERLY = 4, YEARLY = 5, CONTINUOUS = 6, - HALFYEARLY = 7; + HALFYEARLY = 7, + EVERY_OTHER_DAY = 8, + EVERY_OTHER_WEEK = 9, + EVERY_OTHER_MONTH = 10; // Accounting periods $PERIODS = array( @@ -1092,6 +1096,59 @@ YEARLY => ConfigHelper::getConfig('assignments.billing_period_yearly', trans('yearly')), ); +$EVENT_PERIODICITY = array( + DISPOSABLE => array( + 'label' => trans('disposable'), + 'map' => 0, + 'name' => 'EVENT_PERIODICITY_DISPOSABLE', + ), + DAILY => array( + 'label' => trans('daily'), + 'map' => '+1 day', + 'name' => 'EVENT_PERIODICITY_DAILY', + ), + EVERY_OTHER_DAY => array( + 'label' => trans('every other day'), + 'map' => '+2 days', + 'name' => 'EVENT_PERIODICITY_EVERY_OTHER_DAY', + ), + WEEKLY => array( + 'label' => trans('weekly'), + 'map' => '+1 week', + 'name' => 'EVENT_PERIODICITY_WEEKLY', + ), + EVERY_OTHER_WEEK => array( + 'label' => trans('every other week'), + 'map' => '+2 week', + 'name' => 'EVENT_PERIODICITY_EVERY_OTHER_WEEK', + ), + MONTHLY => array( + 'label' => trans('monthly'), + 'map' => '+1 month', + 'name' => 'EVENT_PERIODICITY_MONTHLY', + ), + EVERY_OTHER_MONTH => array( + 'label' => trans('every other month'), + 'map' => '+2 months', + 'name' => 'EVENT_PERIODICITY_EVERY_OTHER_MONTH', + ), + QUARTERLY => array( + 'label' => trans('quarterly'), + 'map' => '+3 months', + 'name' => 'EVENT_PERIODICITY_QUARTERLY', + ), + HALFYEARLY => array( + 'label' => trans('halfyearly'), + 'map' => '+6 months', + 'name' => 'EVENT_PERIODICITY_HALFYEARLY', + ), + YEARLY => array( + 'label' => trans('yearly'), + 'map' => '+1 year', + 'name' => 'EVENT_PERIODICITY_YEARLY', + ), +); + // Numbering periods $NUM_PERIODS = array( CONTINUOUS => trans('continuously'), @@ -2069,6 +2126,7 @@ function ($link_technology) { '_RT_PRIORITIES' => $RT_PRIORITIES, '_RT_PRIORITY_STYLES' => $RT_PRIORITY_STYLES, '_RT_TYPES' => $RT_TYPES, + '_EVENT_PERIODICITY' => $EVENT_PERIODICITY, '_CONFIG_TYPES' => $CONFIG_TYPES, '_TARIFF_FLAGS' => $TARIFF_FLAGS, '_SERVICETYPES' => $SERVICETYPES, diff --git a/lib/locale/pl_PL/strings.php b/lib/locale/pl_PL/strings.php index a955c10ba7..ef73d5f0cf 100644 --- a/lib/locale/pl_PL/strings.php +++ b/lib/locale/pl_PL/strings.php @@ -43,6 +43,19 @@ $_LANG['IDs in external systems'] = 'Identyfikatory w systemach zewnętrznych'; $_LANG['ID in external system'] = 'Identyfikator w systemie zewnętrznym'; $_LANG['Service provider'] = 'Dostawca usług'; +$_LANG['Scheduling periodicity'] = 'Cykliczność planowania'; +$_LANG['scheduling periodicity'] = 'cykliczność planowania'; +$_LANG['disposable'] = 'brak'; +$_LANG['daily'] = 'dzienna'; +$_LANG['weekly'] = 'tygodniowa'; +$_LANG['monthly'] = 'miesięczna'; +$_LANG['quarterly'] = 'kwartalna'; +$_LANG['halfyearly'] = 'półroczna'; +$_LANG['yearly'] = 'roczna'; +$_LANG['continuous'] = 'ciągła'; +$_LANG['every other day'] = 'co drugi dzień'; +$_LANG['every other week'] = 'co drugi tydzień'; +$_LANG['every other month'] = 'co drugi miesiąc'; $_LANG['No external system!'] = 'Brak systemu zewnętrznego'; $_LANG['Selected service provider has assigned External ID already!'] = 'Wybrany system zewnętrzny ma już przypisany zewnętrzny identyfikator!'; @@ -1322,6 +1335,7 @@ $_LANG['Price:'] = 'Cena:'; $_LANG['Price'] = 'Cena'; $_LANG['price'] = 'cena'; +$_LANG['Fatal error: cannot connect to database!'] = 'Błąd krytyczny: Brak połączenia z bazą danych!'; $_LANG['Gross Price:'] = 'Cena brutto:'; $_LANG['Gross value'] = 'Wartość brutto'; $_LANG['Gross Value'] = 'Wartość brutto'; @@ -4223,6 +4237,7 @@ $_LANG['Ticket\'s node has been changed to $a ($b).'] = 'Komputer powiązany ze zgłoszeniem został zmieniony na $a ($b).'; $_LANG['Ticket\'s node $a ($b) has been removed.'] = 'Komputer powiązany ze zgłoszeniem $a ($b) został usunięty.'; $_LANG['Ticket\'s priority has been changed from $a to $b.'] = 'Priorytet zgłoszenia został zmieniony z $a na $b.'; +$_LANG['Ticket\'s scheduling periodicity has been changed from $a to $b.'] = 'Cykliczność planowania zdarzenia została zmieniona z $a na $b.'; $_LANG['Show tickets'] = 'Pokaż zgłoszenia'; $_LANG['any sms'] = 'dowolny SMS'; diff --git a/lib/upgradedb/mysql.2025073000.php b/lib/upgradedb/mysql.2025073000.php new file mode 100644 index 0000000000..7e39c00ac3 --- /dev/null +++ b/lib/upgradedb/mysql.2025073000.php @@ -0,0 +1,30 @@ +BeginTrans(); + +$this->Execute("ALTER TABLE rttickets ADD COLUMN periodicity smallint DEFAULT 0"); + +$this->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2025073000', 'dbversion')); + +$this->CommitTrans(); diff --git a/lib/upgradedb/postgres.2025073000.php b/lib/upgradedb/postgres.2025073000.php new file mode 100644 index 0000000000..7e39c00ac3 --- /dev/null +++ b/lib/upgradedb/postgres.2025073000.php @@ -0,0 +1,30 @@ +BeginTrans(); + +$this->Execute("ALTER TABLE rttickets ADD COLUMN periodicity smallint DEFAULT 0"); + +$this->Execute("UPDATE dbinfo SET keyvalue = ? WHERE keytype = ?", array('2025073000', 'dbversion')); + +$this->CommitTrans(); diff --git a/modules/rtqueueview.php b/modules/rtqueueview.php index f1d627e996..48f0079865 100644 --- a/modules/rtqueueview.php +++ b/modules/rtqueueview.php @@ -368,7 +368,31 @@ $filter['direction'] = $queue['direction']; $filter['order'] = $queue['order']; -unset($queue['total'], $queue['state'], $queue['priority'], $queue['source'], $queue['order'], $queue['direction'], $queue['owner'], $queue['removed'], $queue['deadline'], $queue['service'], $queue['type'], $queue['unread'], $queue['parentids'], $queue['rights'], $queue['verifier'], $queue['netnode'], $queue['projectids'], $queue['cid'], $queue['subject'], $queue['fromdate'], $queue['todate'], $queue['watching']); +unset( + $queue['total'], + $queue['state'], + $queue['priority'], + $queue['periodicity'], + $queue['source'], + $queue['order'], + $queue['direction'], + $queue['owner'], + $queue['removed'], + $queue['deadline'], + $queue['service'], + $queue['type'], + $queue['unread'], + $queue['parentids'], + $queue['rights'], + $queue['verifier'], + $queue['netnode'], + $queue['projectids'], + $queue['cid'], + $queue['subject'], + $queue['fromdate'], + $queue['todate'], + $queue['watching'], +); $queues = $LMS->GetQueueList(array('stats' => false)); $categories = $LMS->GetUserCategories($currentuser); diff --git a/modules/rtticketadd.php b/modules/rtticketadd.php index bf56b6c3e6..f02b1f1e95 100644 --- a/modules/rtticketadd.php +++ b/modules/rtticketadd.php @@ -234,6 +234,10 @@ unset($ticket['priority']); } + if ($ticket['periodicity'] == '') { + unset($ticket['periodicity']); + } + $ticket['customcreatetime'] = $customcreatetime; $ticket['customresolvetime'] = $customresolvetime; @@ -377,6 +381,7 @@ function ($contact) { 'subject' => $ticket['subject'], 'body' => $ticket['body'], 'priority' => isset($ticketdata['priority']) && is_numeric($ticketdata['priority']) ? $RT_PRIORITIES[$ticketdata['priority']] : trans('undefined'), + 'periodicity' => $ticketdata['periodicity'], 'deadline' => $ticketdata['deadline'], 'service' => $ticketdata['service'], 'type' => $ticketdata['type'], @@ -608,6 +613,7 @@ function ($m) use ($id) { $ticket['cause'] = $oldticket['cause']; $ticket['source'] = $oldticket['source']; $ticket['priority'] = $oldticket['priority']; + $ticket['periodicity'] = $oldticket['periodicity']; $ticket['address_id'] = $oldticket['address_id']; $ticket['nodeid'] = $oldticket['nodeid']; $ticket['netnodeid'] = $oldticket['netnodeid']; diff --git a/modules/rtticketedit.php b/modules/rtticketedit.php index ab8e3b7361..2129a2507f 100644 --- a/modules/rtticketedit.php +++ b/modules/rtticketedit.php @@ -167,6 +167,7 @@ function ($contact) { 'status' => $ticket['status'], 'categories' => $ticket['categorynames'], 'priority' => isset($ticket['priority']) && is_numeric($ticket['priority']) ? $RT_PRIORITIES[$ticket['priority']] : trans('undefined'), + 'periodicity' => $ticket['periodicity'] ?? null, 'deadline' => $ticket['deadline'], 'service' => $ticket['service'], 'type' => $ticket['type'], @@ -506,6 +507,7 @@ function ($m) use ($ticketid) { 'status' => $ticket['status'], 'categories' => $ticket['categorynames'], 'priority' => isset($ticket['priority']) && is_numeric($ticket['priority']) ? $RT_PRIORITIES[$ticket['priority']] : trans('undefined'), + 'periodicity' => $ticket['periodicity'] ?? null, 'deadline' => $ticket['deadline'], 'service' => $ticket['service'], 'type' => $ticket['type'], @@ -777,6 +779,7 @@ function ($m) use ($ticketid) { 'categories' => isset($ticketedit['categories']) ? array_keys($ticketedit['categories']) : array(), 'source' => $ticketedit['source'], 'priority' => $ticketedit['priority'] ?? null, + 'periodicity' => $ticketedit['periodicity'] ?? null, 'address_id' => $ticketedit['address_id'] == -1 ? null : $ticketedit['address_id'], 'nodeid' => empty($ticketedit['nodeid']) ? null : $ticketedit['nodeid'], 'netnodeid' => empty($ticketedit['netnodeid']) ? null : $ticketedit['netnodeid'], @@ -827,6 +830,7 @@ function ($m) use ($ticketid) { || $ticket['owner'] != $ticketedit['owner'] || $ticket['deadline'] != $ticketedit['deadline'] || $ticket['priority'] != $ticketedit['priority'] + || $ticket['periodicity'] != $ticketedit['periodicity'] || $ticket['parentid'] != $ticketedit['parentid'])) || ($ticket['queueid'] != $ticketedit['queue'] && !empty($newticket_notify)) || ($ticket['verifierid'] != $ticketedit['verifierid'] && !empty($ticketedit['verifierid'])))) { @@ -913,6 +917,7 @@ function ($contact) { 'subject' => $LMS->cleanupTicketSubject($ticket['subject']), 'body' => $message['body'], 'priority' => isset($ticketdata['priority']) && is_numeric($ticketdata['priority']) ? $RT_PRIORITIES[$ticketdata['priority']] : trans('undefined'), + 'periodicity' => $ticketdata['periodicity'] ?? null, 'deadline' => $ticketdata['deadline'], 'service' => $ticketdata['service'], 'type' => $ticketdata['type'], @@ -980,6 +985,7 @@ function ($contact) { $ticket['netdevid'] = $ticketedit['netdevid']; $ticket['invprojectid'] = empty($ticketedit['invprojectid']) ? null : $ticketedit['invprojectid']; $ticket['priority'] = $ticketedit['priority']; + $ticket['periodicity'] = $ticketedit['periodicity']; $ticket['requestor_userid'] = $ticketedit['requestor_userid']; $ticket['requestor_name'] = $ticketedit['requestor_name'] ?? null; $ticket['requestor_mail'] = $ticketedit['requestor_mail'] ?? null; diff --git a/templates/default/rt/rtfilter.html b/templates/default/rt/rtfilter.html index a246b17f1b..1c98191e29 100644 --- a/templates/default/rt/rtfilter.html +++ b/templates/default/rt/rtfilter.html @@ -67,6 +67,15 @@ +