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
This commit is contained in:
mahdahar 2026-03-04 13:49:46 +07:00
parent c2d66d0082
commit c2c70505e5
3 changed files with 66 additions and 52 deletions

View File

@ -11,7 +11,6 @@ $roleConfig = $config['cs'];
<?= $this->include('shared/dialog_unval'); ?> <?= $this->include('shared/dialog_unval'); ?>
<?= $this->include('shared/dialog_audit'); ?> <?= $this->include('shared/dialog_audit'); ?>
<?= $this->include('shared/dialog_results_generate'); ?> <?= $this->include('shared/dialog_results_generate'); ?>
<?= $this->include('shared/dialog_eng_result'); ?>
</main> </main>
<?= $this->endSection(); ?> <?= $this->endSection(); ?>

View File

@ -214,6 +214,9 @@ $configKey = $roleMap[$userRole] ?? '';
$previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false; $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
?> ?>
<td> <td>
<?php if (session('userroleid') == 3): ?>
<span class="text-xs font-bold" :class="req.VAL1USER && req.VAL2USER ? 'text-success' : 'text-warning'" x-text="req.VAL1USER && req.VAL2USER ? 'Ready' : 'Pending'"></span>
<?php else: ?>
<?php if ($previewEnabled): ?> <?php if ($previewEnabled): ?>
<template x-if="['Pend', 'PartColl', 'Coll'].includes(req.STATS)"> <template x-if="['Pend', 'PartColl', 'Coll'].includes(req.STATS)">
<button disabled class="btn btn-xs w-full btn-warning opacity-70 cursor-not-allowed"> <button disabled class="btn btn-xs w-full btn-warning opacity-70 cursor-not-allowed">
@ -278,12 +281,14 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if (!in_array(session('userroleid'), [3, 4])): ?>
<li x-show="!req.REPORT_LANG || req.REPORT_LANG != 1"> <li x-show="!req.REPORT_LANG || req.REPORT_LANG != 1">
<a @click="openEngResultDialog(req)"> <a @click="openEngResultDialog(req)">
<i class="fa fa-language mr-2"></i> <i class="fa fa-language mr-2"></i>
<span>Create Eng Result</span> <span>Create Eng Result</span>
</a> </a>
</li> </li>
<?php endif; ?>
</div> </div>
</template> </template>
<?php if (!$previewEnabled): ?> <?php if (!$previewEnabled): ?>
@ -303,8 +308,12 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
<?php else: ?> <?php else: ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?>
</td> </td>
<td> <td>
<?php if (session('userroleid') == 3): ?>
<span class="text-xs text-base-content/40">-</span>
<?php else: ?>
<div class="dropdown dropdown-top dropdown-end dropdown-hover"> <div class="dropdown dropdown-top dropdown-end dropdown-hover">
<div tabindex="0" role="button" class="btn btn-xs btn-primary w-full"> <div tabindex="0" role="button" class="btn btn-xs btn-primary w-full">
<i class="fa fa-cog mr-1"></i> Actions <i class="fa fa-cog mr-1"></i> Actions
@ -330,6 +339,7 @@ $previewEnabled = $configFile[$configKey]['previewEnabled'] ?? false;
</li> </li>
</ul> </ul>
</div> </div>
<?php endif; ?>
</td> </td>
</tr> </tr>
</template> </template>

View File

@ -47,6 +47,9 @@ document.addEventListener('alpine:init', () => {
Fin: ['Fin'], 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 // Sorting & Pagination
sortCol: 'REQDATE', sortCol: 'REQDATE',
sortAsc: false, sortAsc: false,
@ -126,6 +129,14 @@ document.addEventListener('alpine:init', () => {
computeSorted() { computeSorted() {
this.sorted = this.filtered.slice().sort((a, b) => { 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; 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;
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() { fetchList() {
this.isLoading = true; this.isLoading = true;
this.list = []; 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(); let param = new URLSearchParams(this.filter).toString();
for (let k in this.counters) { this.counters[k] = 0; } for (let k in this.counters) { this.counters[k] = 0; }
fetch(`${BASEURL}/api/requests?${param}`, { fetch(`${BASEURL}/api/requests?${param}`, {
@ -174,11 +184,6 @@ document.addEventListener('alpine:init', () => {
this.counters.Total++; 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 // Compute derived data after list is loaded
this.computeFiltered(); this.computeFiltered();
this.computeValidatedCount(); this.computeValidatedCount();