mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 00:59:03 +00:00
Ticket timer (forum #3237): with Start the timer on opening a ticket on, a reply or note stops the timer instead of a new one starting by itself as the ticket comes back, it stays stopped on reloads and other changes on the ticket until play is pressed or the ticket is opened again from elsewhere, saying Stopped with your reply, choosing On Hold, Resolved or Closed for after the reply pauses it by status id, and a ticket opened with autostart off no longer keeps an empty time that stopped autostart later; 26.12.3 changelog
This commit is contained in:
@@ -121,6 +121,8 @@ Update from Maintenance > Update as usual - this release has sixteen database ch
|
||||
- UniFi through Site Manager with many sites (forum #3236): linked sites never got their devices - every sync spent its time asking each of hundreds of sites for its device count before reaching the linked ones, and said "0 devices brought in. Stopped for time" every time. Device counts now come from Site Manager's own list of sites in one or two requests, a console is only asked for its sites when it has one ITFlow doesn't know yet, listing new sites gets at most half a sync's time, and at least one linked site's devices come in each sync.
|
||||
- Linking a network platform's site or an RMM's client, Sync Now, Test and saving a provider no longer freeze your other ITFlow pages while the RMM or UniFi answers, and linking brings in just that one's devices instead of listing every site first.
|
||||
- UniFi asking ITFlow to slow down (HTTP 429) - Site Manager allows 100 requests a minute for each console - is waited out when it's a few seconds and said plainly otherwise, where it was reported as consoles needing newer firmware.
|
||||
- Ticket timer (forum #3237): with Start the timer on opening a ticket on, a new timer started by itself the moment a reply or note was sent, as the ticket came back - so after replying and moving on, it ran in the top bar until someone threw it away. A reply or note now puts the time on it and stops the timer: the ticket comes back with it stopped, saying "Stopped with your reply", and it stays stopped until you press play, or until you next open the ticket from somewhere else, which starts it as before.
|
||||
- Choosing On Hold, Resolved or Closed under Status after this pauses the ticket's timer, as was meant - it checked for a status called Pending, by a name the list doesn't carry, so it never did.
|
||||
|
||||
### Developer Updates
|
||||
|
||||
@@ -184,6 +186,7 @@ Update from Maintenance > Update as usual - this release has sixteen database ch
|
||||
- Text messaging receive only: database 4.3.6 adds sms_providers.sms_provider_send (1, or 0 for Receive only). smsSends() reads it; smsReady() is false when a provider doesn't send, so smsQueue() and everything that texts stops there, and smsNotSendingWhy() says why. smsReceiveOnly() and smsTicketTextedInNumber() drive the notes on Text Messaging, Text Messages, Settings > Notifications and Tickets and the ticket reply box; smsProviderCheck() needs the SID and secret only when sending; setting a provider to Receive only cancels the texts waiting to go (smsCancelWaiting()). Inbound (api/sms/skyetel.php, smsInbound()) is unchanged.
|
||||
- RMM sync (forum #3236): rmmSync() skips the client listing when $only is given, gives it half of $max_seconds through rmmDeadline() (rmmPastDeadline() for a kind to leave out what can wait), always syncs at least one linked client, records each synced client's device count, keeps the stored count when a kind returns devices null, and marks clients gone only from a whole list (a kind returns 'partial' with what it left). rmmUnifiSites() for unifi_cloud takes counts from Site Manager's GET /v1/sites (rmmUnifiSiteManagerSites(), by hostId and meta.name = internalReference), asks a console's connector for sites only when it has sites not in rmm_clients (rmmUnifiKnownSites()), and stops asking at the deadline; unifi_os counts per site only up to UNIFI_COUNT_SITES_MAX (50). rmmHttp() waits out a 429 with Retry-After up to RMM_RETRY_WAIT (10 s) and retries once (rmmHttpOnce() is one request), with a 'rate' hint. rmmWithoutSession() closes the PHP session around the slow calls in admin/post/rmm.php and agent/post/asset.php and reopens it for the message.
|
||||
- Offering autopay: database 4.3.7 adds settings.config_invoice_offer_autopay and recurring_invoices.recurring_invoice_offer_autopay (both 1). functions/billing_pay.php: autopayOfferOn() reads the setting (guarded with settingsColumnExists()); autopayOfferBlocked(billingRow('recurring')) gives why a recurring invoice isn't offered, or '' - autopay on (recurring_payment_id), billingStripeProvider() null, the setting or the recurring invoice's switch off, status not 1 or archived, or billingOnlinePayAllowed() false for its amount; autopayOffer($invoice) is null for no recurring invoice, a Cancelled or Non-Billable invoice, no url key or another client's recurring invoice, else autopayOfferDetails() - number, title, amount, currency, period, fee (billingCardFeeTerms(billingCardFeeFor())), this_invoice (still owed and due after today, which the nightly autopay charges on its due date) and url (autopayOfferUrl(), guest/guest_autopay.php with the invoice's id and url key). autopayConsentText() is what the client agrees to. billingInvoiceEmail() puts billingAutopayOfferEmail() in the invoice kind only - not receipts or reminders - as emailHtml()'s new offer part (title, text, button, small; a box after the button with an outlined button). guest/guest_autopay.php checks the key with hash_equals() and guestLinkExpired(), says when autopay is on (invoiceAutopay()) or blocked, and otherwise posts name, email and agree through js/guest_autopay_stripe.js to guest_ajax.php?guest_autopay_checkout, where autopayCheckoutStart() makes the Stripe customer if the client has none (under GET_LOCK, retried once after billingStripeCustomerGone() with billingStripeCustomerForget()) and a Checkout Session - mode setup, ui_mode embedded_page, payment_method_types card, the customer, metadata itflow_autopay_invoice_id, itflow_recurring_invoice_id, itflow_client_id, itflow_consent_name, itflow_consent_email and itflow_consent - returning its client secret for stripe.initEmbeddedCheckout(). Its return_url is guest_post.php?guest_autopay_done with the invoice's id and key, where autopayCheckoutFinish() (under GET_LOCK per recurring invoice) treats a session already in an Autopay history line as done, then retrieves the session, requires mode setup, status complete, the metadata's invoice and recurring invoice and the client's own customer, retrieves its SetupIntent (succeeded) and PaymentMethod, saves the card once per payment method id in client_saved_payment_methods, replaces the recurring_payments row, writes billingLog('recurring', ..., 'Autopay') with the card, who, the invoice, the consent and the session id, logAudit(), appNotify('Autopay') and billingMailAutopayOn() (functions/billing_email.php, with autopayChangeText()). guest_view_invoice.php and client/invoice.php show [data-autopay-offer]; the portal's posts set_recurring_payment with a saved card that hasn't expired, and set_recurring_payment (client/post.php) now writes Autopay history and appNotify() when turned on. agent/recurring_invoice.php's Autopay card posts set_recurring_offer_autopay (agent/post/recurring_invoice.php, module_sales 2) while there is no autopay and Stripe is set up. guest_autopay_checkout, guest_autopay_done and set_recurring_offer_autopay are refused in demo mode.
|
||||
- Ticket timer (forum #3237): agent/js/ticket_time_tracking.js sets sessionStorage ticket-timer-replied-<ticket id> when the reply form's submit goes through (not defaultPrevented, as with Undo send holding it), beside forceResetTimer(). On load, with no time on the ticket and ticketAutoStart on, cameBackAfterReply() keeps the timer stopped and shows [data-timer-replied] while that flag is set and document.referrer is this same ticket page (its own post's redirect, a reload, another change on the ticket); a referrer from anywhere else forgets the flag and the timer starts as before. startTimer() forgets it. A pausedTime of 0 counts as no time, and the stopped start no longer writes one, so a ticket opened with autostart off doesn't keep an empty key that stopped autostart later. checkStatusAndPauseTimer() matches the reply status select's value - a status id - against its data-timer-pause (TICKET_STATUS_ON_HOLD, RESOLVED and CLOSED), on change only and only while the timer runs; it matched "Pending" and "Close" against the id and ran on load.
|
||||
|
||||
## [26.12.2]
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ echo settingsPageStart('ticket');
|
||||
<?php } ?>
|
||||
|
||||
<?= settingsSectionStart('time', 'Time and billing', 'How time on a ticket starts, and whether it bills.') ?>
|
||||
<?= settingsSwitch('config_ticket_timer_autostart', $config_ticket_timer_autostart, ['help' => 'The timer runs from opening a ticket, rather than from pressing start.']) ?>
|
||||
<?= settingsSwitch('config_ticket_timer_autostart', $config_ticket_timer_autostart, ['help' => 'The timer runs from opening a ticket, rather than from pressing start. A reply or note puts the time on it and stops the timer - press start to time more, and it starts again the next time the ticket is opened.']) ?>
|
||||
<?php if ($config_module_enable_accounting) { ?>
|
||||
<?= settingsSwitch('config_ticket_default_billable', $config_ticket_default_billable, ['help' => 'A new ticket starts billable - each can be changed. How the time is billed is in <a href="settings_invoice.php#billing-time">Invoices and billing</a>.']) ?>
|
||||
<?php } ?>
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* A ticket's timer, on its page (agent/ticket.php), kept in this browser's localStorage so it
|
||||
* runs on while you're elsewhere (the top bar's timers, js/ticket_timers.js, read the same keys).
|
||||
* With Start the timer on opening a ticket on, it starts by itself when you open the ticket.
|
||||
* Sending a reply or note puts the time on it and stops the timer: the page comes back with it
|
||||
* stopped, and stays so - reloading, or anything else done on the ticket - until you press play or
|
||||
* come to the ticket again from elsewhere, which starts a new one. Choosing On Hold, Resolved or
|
||||
* Closed for after the reply pauses it.
|
||||
*/
|
||||
(function() {
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var timerInterval = null;
|
||||
@@ -59,7 +68,47 @@
|
||||
displayTime();
|
||||
}
|
||||
|
||||
// Sent a reply or note here - the timer stays stopped while the page comes back from this ticket
|
||||
function repliedKey() {
|
||||
return "ticket-timer-replied-" + ticketID;
|
||||
}
|
||||
|
||||
function forgetReplied() {
|
||||
try {
|
||||
sessionStorage.removeItem(repliedKey());
|
||||
} catch (e) {}
|
||||
let hint = document.querySelector("[data-timer-replied]");
|
||||
if (hint) hint.hidden = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Whether this page is the ticket coming back after your reply - from its own form, a reload,
|
||||
* or another change made on it. Arriving from anywhere else forgets the reply, so the timer
|
||||
* starts again as it does on opening a ticket.
|
||||
*/
|
||||
function cameBackAfterReply() {
|
||||
let at = 0;
|
||||
try {
|
||||
at = parseInt(sessionStorage.getItem(repliedKey()) || "0", 10);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
if (!at) {
|
||||
return false;
|
||||
}
|
||||
let fromHere = false;
|
||||
try {
|
||||
let from = new URL(document.referrer);
|
||||
fromHere = from.origin === window.location.origin && from.pathname === window.location.pathname && from.searchParams.get("ticket_id") === String(ticketID);
|
||||
} catch (e) {}
|
||||
if (!fromHere) {
|
||||
forgetReplied();
|
||||
}
|
||||
return fromHere;
|
||||
}
|
||||
|
||||
function startTimer() {
|
||||
forgetReplied();
|
||||
if (!localStorage.getItem(getLocalStorageKey("startTime"))) {
|
||||
localStorage.setItem(getLocalStorageKey("startTime"), Date.now().toString());
|
||||
}
|
||||
@@ -116,6 +165,8 @@
|
||||
|
||||
function handleInputFocus() {
|
||||
pauseTimer();
|
||||
let hint = document.querySelector("[data-timer-replied]");
|
||||
if (hint) hint.hidden = true;
|
||||
}
|
||||
|
||||
function updateTimeFromInput() {
|
||||
@@ -133,11 +184,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
// On Hold, Resolved or Closed chosen for after the reply - the work is done, so it stops counting.
|
||||
// The select's values are status ids; data-timer-pause lists those that pause it.
|
||||
function checkStatusAndPauseTimer() {
|
||||
var statusEl = document.querySelector('select[name="status"]');
|
||||
if (statusEl) {
|
||||
var status = statusEl.value;
|
||||
if (status.includes("Pending") || status.includes("Close")) {
|
||||
if (statusEl && timerInterval) {
|
||||
var pausing = (statusEl.getAttribute("data-timer-pause") || "").split(",");
|
||||
if (pausing.indexOf(String(statusEl.value)) !== -1) {
|
||||
pauseTimer();
|
||||
}
|
||||
}
|
||||
@@ -201,6 +254,10 @@
|
||||
setTimeout(function() {
|
||||
if (!e.defaultPrevented) {
|
||||
forceResetTimer();
|
||||
// ... and it stays stopped when the page comes back, rather than starting again
|
||||
try {
|
||||
sessionStorage.setItem(repliedKey(), Date.now().toString());
|
||||
} catch (err) {}
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
@@ -217,18 +274,21 @@
|
||||
try {
|
||||
displayTime();
|
||||
|
||||
if (!localStorage.getItem(getLocalStorageKey("startTime")) && !localStorage.getItem(getLocalStorageKey("pausedTime"))) {
|
||||
if (typeof ticketAutoStart !== "undefined" && ticketAutoStart === 1) {
|
||||
// No time on it - a pausedTime of 0 left by an older version counts as none
|
||||
if (!localStorage.getItem(getLocalStorageKey("startTime")) && !(parseInt(localStorage.getItem(getLocalStorageKey("pausedTime")) || "0", 10) > 0)) {
|
||||
let autoStart = typeof ticketAutoStart !== "undefined" && ticketAutoStart === 1;
|
||||
if (autoStart && cameBackAfterReply()) {
|
||||
// Stopped with the reply just sent - press play to time more
|
||||
let hint = document.querySelector("[data-timer-replied]");
|
||||
if (hint) hint.hidden = false;
|
||||
} else if (autoStart) {
|
||||
startTimer();
|
||||
} else {
|
||||
pauseTimer();
|
||||
}
|
||||
localStorage.removeItem(getLocalStorageKey("pausedTime"));
|
||||
} else if (localStorage.getItem(getLocalStorageKey("startTime"))) {
|
||||
startTimer();
|
||||
}
|
||||
|
||||
checkStatusAndPauseTimer();
|
||||
|
||||
} catch (error) {
|
||||
console.error("There was an issue initializing the timer:", error);
|
||||
}
|
||||
|
||||
@@ -1008,6 +1008,8 @@ if (isset($_GET['ticket_id'])) {
|
||||
<button type="button" class="btn btn-light border" id="startStopTimer" title="Start / pause the timer"><i class="fas fa-play"></i></button>
|
||||
<button type="button" class="btn btn-light border" id="resetTimer" title="Reset the timer"><i class="fas fa-redo-alt"></i></button>
|
||||
</div>
|
||||
<!-- Sending a reply stops the timer - said when the page comes back (agent/js/ticket_time_tracking.js) -->
|
||||
<div class="form-text mt-1" data-timer-replied title="Press play to time more" hidden><i class="fas fa-fw fa-stopwatch me-1"></i>Stopped with your reply</div>
|
||||
<!-- Add a block of time in one click - the timer stops at the new total (agent/js/ticket_reply_extras.js) -->
|
||||
<div class="d-flex flex-wrap gap-1 mt-1" data-time-add>
|
||||
<?php foreach ([15 => '+15m', 30 => '+30m', 60 => '+1h'] as $minutes => $label) { ?>
|
||||
@@ -1036,7 +1038,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
<div class="row g-2 align-items-end">
|
||||
<div class="col-md-5">
|
||||
<label class="form-label small text-secondary mb-1" for="ticket_reply_status">Status after this</label>
|
||||
<select class="form-select select2" name="status" id="ticket_reply_status" required>
|
||||
<select class="form-select select2" name="status" id="ticket_reply_status" required data-timer-pause="<?= implode(',', [TICKET_STATUS_ON_HOLD, TICKET_STATUS_RESOLVED, TICKET_STATUS_CLOSED]) ?>">
|
||||
<!-- Resolved stays on offer here (reply and resolve in one go) unless open tasks block it -->
|
||||
<?php foreach ($ticket_status_options as $status_option) {
|
||||
$ticket_status_id_select = intval($status_option['ticket_status_id']);
|
||||
|
||||
Reference in New Issue
Block a user