From c2c70505e56c1e4d9fee43c77e7314a7f68efb7b Mon Sep 17 00:00:00 2001
From: mahdahar <89adham@gmail.com>
Date: Wed, 4 Mar 2026 13:49:46 +0700
Subject: [PATCH] Remove unused dialog include and add Phlebo role-specific UI
logic
- Remove dialog_eng_result.php include from CS index view
- Add role-based status display for Phlebo (role 3) showing Ready/Pending badges
- Fix indentation inconsistencies in content_requests.php dropdown menus
- Add role restrictions: hide Generate Result and Create Eng Result buttons for CS (role 4) and Phlebo (role 3)
- Move status sorting logic from fetchList to computeSorted for proper Alpine.js reactivity
- Add statusOrder mapping (Pend -> Coll -> Recv -> Inc -> Fin) for consistent request sorting
- Simplify Actions dropdown for Phlebo role to show only status indicator
---
app/Views/cs/index.php | 1 -
app/Views/shared/content_requests.php | 100 ++++++++++++++------------
app/Views/shared/script_requests.php | 17 +++--
3 files changed, 66 insertions(+), 52 deletions(-)
diff --git a/app/Views/cs/index.php b/app/Views/cs/index.php
index 9043ee6..3cf0cc8 100644
--- a/app/Views/cs/index.php
+++ b/app/Views/cs/index.php
@@ -11,7 +11,6 @@ $roleConfig = $config['cs'];
= $this->include('shared/dialog_unval'); ?>
= $this->include('shared/dialog_audit'); ?>
= $this->include('shared/dialog_results_generate'); ?>
- = $this->include('shared/dialog_eng_result'); ?>
= $this->endSection(); ?>
diff --git a/app/Views/shared/content_requests.php b/app/Views/shared/content_requests.php
index 6bcd763..a9184e6 100644
--- a/app/Views/shared/content_requests.php
+++ b/app/Views/shared/content_requests.php
@@ -214,6 +214,9 @@ $configKey = $roleMap[$userRole] ?? '';
$previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
?>
+
+
+
|
+
+
+
+
+
+
+
-
-
- Actions
-
+
+ -
+
+
+
|
diff --git a/app/Views/shared/script_requests.php b/app/Views/shared/script_requests.php
index 9d76690..f569864 100644
--- a/app/Views/shared/script_requests.php
+++ b/app/Views/shared/script_requests.php
@@ -47,6 +47,9 @@ document.addEventListener('alpine:init', () => {
Fin: ['Fin'],
},
+ // Status order for sorting (Pend -> Coll -> Recv -> Inc -> Fin)
+ statusOrder: { Pend: 1, PartColl: 2, Coll: 3, PartRecv: 4, Recv: 5, Inc: 6, Fin: 7 },
+
// Sorting & Pagination
sortCol: 'REQDATE',
sortAsc: false,
@@ -126,6 +129,14 @@ document.addEventListener('alpine:init', () => {
computeSorted() {
this.sorted = this.filtered.slice().sort((a, b) => {
+ // First sort by status (Pend -> Coll -> Recv -> Inc -> Fin)
+ let statusA = this.statusOrder[a.STATS] ?? 0;
+ let statusB = this.statusOrder[b.STATS] ?? 0;
+ if (statusA !== statusB) {
+ return statusA - statusB;
+ }
+
+ // Then sort by selected column
let modifier = this.sortAsc ? 1 : -1;
if (a[this.sortCol] < b[this.sortCol]) return -1 * modifier;
if (a[this.sortCol] > b[this.sortCol]) return 1 * modifier;
@@ -157,7 +168,6 @@ document.addEventListener('alpine:init', () => {
fetchList() {
this.isLoading = true;
this.list = [];
- let statusOrder = { Pend: 1, PartColl: 2, Coll: 3, PartRecv: 4, Recv: 5, Inc: 6, Fin: 7 };
let param = new URLSearchParams(this.filter).toString();
for (let k in this.counters) { this.counters[k] = 0; }
fetch(`${BASEURL}/api/requests?${param}`, {
@@ -174,11 +184,6 @@ document.addEventListener('alpine:init', () => {
this.counters.Total++;
}
});
- this.list.sort((a, b) => {
- let codeA = statusOrder[a.STATS] ?? 0;
- let codeB = statusOrder[b.STATS] ?? 0;
- return codeA - codeB;
- });
// Compute derived data after list is loaded
this.computeFiltered();
this.computeValidatedCount();