From 7ab4706524afc9a218b5b13b62042790c4fd585b Mon Sep 17 00:00:00 2001 From: Naz Date: Thu, 14 May 2026 14:40:53 +0800 Subject: [PATCH] Update OT --- .gitignore | 3 - .../Views/ApprovalDashboard/Approval.cshtml | 110 ++- .../Views/ApprovalDashboard/OtReview.cshtml | 3 +- .../Views/Overtime/OtRegister.cshtml | 35 +- .../Views/Overtime/OtStatus.cshtml | 276 ++++--- Controllers/API/OvertimeAPI.cs | 775 +++++++++--------- 6 files changed, 694 insertions(+), 508 deletions(-) diff --git a/.gitignore b/.gitignore index 5b013e7..eaa9902 100644 --- a/.gitignore +++ b/.gitignore @@ -361,6 +361,3 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd - -# Ignore local publish test builds -publish-test/ \ No newline at end of file diff --git a/Areas/OTcalculate/Views/ApprovalDashboard/Approval.cshtml b/Areas/OTcalculate/Views/ApprovalDashboard/Approval.cshtml index c0f3a04..8686779 100644 --- a/Areas/OTcalculate/Views/ApprovalDashboard/Approval.cshtml +++ b/Areas/OTcalculate/Views/ApprovalDashboard/Approval.cshtml @@ -150,14 +150,32 @@
-
- + +
+
+ +
+ + +
+ @* {{ selectedItems.length }} Selected *@ + + +
+ + - + + + + - - - +
+ + Staff Name @@ -182,11 +200,19 @@ ActionAction
+ + {{ row.fullName }} {{ formatDate(row.submitDate) }} @@ -194,13 +220,14 @@
HoD: {{ row.hodStatus }}
Manager: {{ row.managerStatus }}
HR: {{ row.hrStatus }}
+
Rejected by a previous approver
+
+ - - -
No {{ activeTab === 'pending' ? 'pending' : 'completed' }} actions found for your current filters.No {{ activeTab === 'pending' ? 'pending' : 'completed' }} actions found for your current filters.
@@ -278,19 +302,32 @@ searchQuery: '', currentPage: 1, itemsPerPage: 10, - overallPendingMonths: [] + overallPendingMonths: [], + selectedItems: JSON.parse(sessionStorage.getItem('approvalSelectedItems')) || [] }; }, watch: { activeTab() { this.currentPage = 1; this.searchQuery = ''; + this.selectedItems = []; }, searchQuery() { this.currentPage = 1; + this.selectedItems = []; }, itemsPerPage() { this.currentPage = 1; + this.selectedItems = []; + }, + currentPage() { + this.selectedItems = []; + }, + selectedItems: { + handler(newVal) { + sessionStorage.setItem('approvalSelectedItems', JSON.stringify(newVal)); + }, + deep: true } }, computed: { @@ -365,6 +402,28 @@ }, completedActionsCount() { return this.otStatusList.filter(row => row.currentUserStatus === 'Approved' || row.currentUserStatus === 'Rejected').length; + }, + selectAll: { + get() { + const approvableItems = this.paginatedData.filter(row => row.canApprove); + if (approvableItems.length === 0) return false; + return approvableItems.every(row => this.selectedItems.includes(row.statusId)); + }, + set(isChecked) { + const approvableItems = this.paginatedData.filter(row => row.canApprove); + if (isChecked) { + + approvableItems.forEach(row => { + if (!this.selectedItems.includes(row.statusId)) { + this.selectedItems.push(row.statusId); + } + }); + } else { + + const approvableIds = approvableItems.map(row => row.statusId); + this.selectedItems = this.selectedItems.filter(id => !approvableIds.includes(id)); + } + } } }, methods: { @@ -443,6 +502,37 @@ this.sortDirection = 'asc'; } this.currentPage = 1; + }, + bulkUpdateStatus(decision) { + if (this.selectedItems.length === 0) return; + + const actionText = decision === 'Approved' ? 'approve' : 'reject'; + const confirmed = confirm(`Are you sure you want to ${actionText} ${this.selectedItems.length} selected requests?`); + + if (!confirmed) return; + + const apiCalls = this.selectedItems.map(statusId => { + return fetch('/OvertimeAPI/UpdateApprovalStatus', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ statusId: statusId, decision: decision }) + }).then(res => { + if (!res.ok) throw new Error("Failed to update status"); + return res.json(); + }); + }); + + Promise.all(apiCalls) + .then(() => { + alert(`Successfully ${actionText}d ${this.selectedItems.length} requests.`); + this.selectedItems = []; + this.loadData(); + }) + .catch(err => { + console.error("Error updating bulk status:", err); + alert("An error occurred during bulk update. Some requests may not have saved properly. Refreshing data."); + this.loadData(); + }); } }, mounted() { diff --git a/Areas/OTcalculate/Views/ApprovalDashboard/OtReview.cshtml b/Areas/OTcalculate/Views/ApprovalDashboard/OtReview.cshtml index 44bfaf2..0736111 100644 --- a/Areas/OTcalculate/Views/ApprovalDashboard/OtReview.cshtml +++ b/Areas/OTcalculate/Views/ApprovalDashboard/OtReview.cshtml @@ -239,7 +239,8 @@
-
+ +
diff --git a/Areas/OTcalculate/Views/Overtime/OtRegister.cshtml b/Areas/OTcalculate/Views/Overtime/OtRegister.cshtml index 24eb502..0d3fd2d 100644 --- a/Areas/OTcalculate/Views/Overtime/OtRegister.cshtml +++ b/Areas/OTcalculate/Views/Overtime/OtRegister.cshtml @@ -75,25 +75,32 @@
- + +
+ +
*Only for PSTW AIR
- + +
+ +
*Only for PSTW MARINE
+