Skip to content

Commit

Permalink
Ticket time tracking
Browse files Browse the repository at this point in the history
Bugfix for ticket time tracking as this was broken since the open ticket timer was removed
  • Loading branch information
wrongecho committed May 26, 2024
1 parent f103797 commit 059a551
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 169 deletions.
147 changes: 0 additions & 147 deletions js/header_timers.js

This file was deleted.

27 changes: 5 additions & 22 deletions js/ticket_time_tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
var ticketID = getCurrentTicketID();
var elapsedSecs = getElapsedSeconds();

updateRunningTicketsCount();

function getCurrentTicketID() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get('ticket_id');
Expand Down Expand Up @@ -55,7 +53,6 @@
timerInterval = setInterval(countTime, 1000);
isPaused = false;
document.getElementById("startStopTimer").innerText = "Pause";
updateRunningTicketsCount();
localStorage.setItem("ticket-timer-running-" + ticketID, "true");

}
Expand All @@ -70,7 +67,6 @@
localStorage.removeItem(getLocalStorageKey("startTime"));
isPaused = true;
document.getElementById("startStopTimer").innerText = "Start";
updateRunningTicketsCount();
localStorage.setItem("ticket-timer-running-" + ticketID, "false");

}
Expand All @@ -91,7 +87,6 @@
document.getElementById("startStopTimer").innerText = "Start";
}
localStorage.setItem("ticket-timer-running-" + ticketID, "false");
updateRunningTicketsCount();
}

function forceResetTimer() {
Expand All @@ -102,7 +97,7 @@
displayTime();
document.getElementById("startStopTimer").innerText = "Start";
}

function handleInputFocus() {
if (!isPaused) {
pauseTimer();
Expand All @@ -114,7 +109,7 @@
const minutes = parseInt(document.getElementById("minutes").value, 10) || 0;
const seconds = parseInt(document.getElementById("seconds").value, 10) || 0;
elapsedSecs = (hours * 3600) + (minutes * 60) + seconds;

// Update local storage so the manually entered time is retained even if the page is reloaded.
if (!timerInterval) {
localStorage.setItem(getLocalStorageKey("pausedTime"), elapsedSecs.toString());
Expand All @@ -125,18 +120,6 @@
}
}

function updateRunningTicketsCount() {
let runningTickets = parseInt(document.getElementById('runningTicketsCount').innerText, 10);

if (!isPaused && timerInterval) {
runningTickets += 1;
} else {
runningTickets = Math.max(0, runningTickets - 1);
}

document.getElementById('runningTicketsCount').innerText = runningTickets.toString();
}

// Function to check status and pause timer
function checkStatusAndPauseTimer() {
var status = document.querySelector('select[name="status"]').value;
Expand All @@ -148,7 +131,7 @@
document.getElementById("hours").addEventListener('change', updateTimeFromInput);
document.getElementById("minutes").addEventListener('change', updateTimeFromInput);
document.getElementById("seconds").addEventListener('change', updateTimeFromInput);

document.getElementById("hours").addEventListener('focus', handleInputFocus);
document.getElementById("minutes").addEventListener('focus', handleInputFocus);
document.getElementById("seconds").addEventListener('focus', handleInputFocus);
Expand Down Expand Up @@ -184,11 +167,11 @@
} else if (localStorage.getItem(getLocalStorageKey("startTime"))) {
startTimer();
}

// Check and pause timer if status is pending
checkStatusAndPauseTimer();
} catch (error) {
console.error("There was an issue initializing the timer:", error);
}
});
})();
})();
2 changes: 2 additions & 0 deletions top_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class="fas fa-bars"></i></a>
<!-- Center navbar links -->
<ul class="navbar-nav ml-auto">



<!-- SEARCH FORM -->
<form class="form-inline" action="global_search.php">
<div class="input-group input-group-sm">
Expand Down

0 comments on commit 059a551

Please sign in to comment.