Skip to content

Commit

Permalink
refactor: allow rejection of requisitions
Browse files Browse the repository at this point in the history
  • Loading branch information
im-machakata committed Apr 7, 2024
1 parent 42d5d34 commit 20807a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
9 changes: 3 additions & 6 deletions app/Controllers/Requisition.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function viewUserReportsIndex()

public function authorizeRequisitionsIndex()
{
$isSupervisor = $this->account->Department == 'Supervisor';
$isSupervisor = $this->account->department == 'Supervisor';
$allowedStatus = $isSupervisor ? 'Submitted' : 'Supervisor_Approved';
self::$VIEW_PARAMS['statuses'] = [
'Approve' => $isSupervisor ? 'Supervisor_Approved' : 'Finance_Disbursed',
Expand All @@ -203,7 +203,7 @@ public function authorizeRequisitionsIndex()

public function authorizeRequisitions()
{
$isSupervisor = $this->account->Department == 'Supervisor';
$isSupervisor = $this->account->department == 'Supervisor';
$allowedStatus = $isSupervisor ? 'Submitted' : 'Supervisor_Approved';
self::$VIEW_PARAMS['statuses'] = [
'CanReject' => $isSupervisor
Expand All @@ -212,10 +212,7 @@ public function authorizeRequisitions()
// this prevents the user from rejecting requisitions without the required rights
if ($isSupervisor) {
$allowedApprovals = 'Supervisor_Approved,Reject';
self::$VIEW_PARAMS['statuses'] = [
'Approve' => 'Supervisor_Approved',
'CanReject' => $this->account->Department == 'Supervisor'
];
self::$VIEW_PARAMS['statuses']['Approve'] = 'Supervisor_Approved';
} else {
$allowedApprovals = 'Finance_Disbursed';
}
Expand Down
8 changes: 4 additions & 4 deletions app/Views/forms/authorize-requisitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@
<label class="btn btn-outline-primary" for="StatusSubmitted">Submitted</label>
<input type="radio" class="btn-check" name="Status" value="<?= $statuses['Approve'] ?>" id="StatusApprove" autocomplete="off">
<label class="btn btn-outline-primary" for="StatusApprove">Approve Requisition</label>
<?php if($statuses['CanReject']):?>
<input type="radio" class="btn-check" name="Status" id="StatusDismiss" value="<?= $statuses['Reject'] ?>" autocomplete="off">
<label class="btn btn-outline-primary" for="StatusDismiss">Cancel Requisition</label>
<?php endif;?>
<?php if ($statuses['CanReject']) : ?>
<input type="radio" class="btn-check" name="Status" id="StatusDismiss" value="Rejected" autocomplete="off">
<label class="btn btn-outline-primary" for="StatusDismiss">Reject Requisition</label>
<?php endif; ?>
</div>
</div>
<div class="mb-2 col-12">
Expand Down

0 comments on commit 20807a7

Please sign in to comment.