Skip to content

Commit bb65334

Browse files
committed
Add previous/next navigation buttons to Deposit Slip Editor
Fixes #5043: Users can now navigate between deposits without returning to the deposit list. Adds Previous/Next buttons and a Back to Deposits link for improved workflow during deposit review and reconciliation.
1 parent 0471005 commit bb65334

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/ChurchCRM/model/ChurchCRM/Deposit.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use ChurchCRM\dto\SystemConfig;
66
use ChurchCRM\model\ChurchCRM\Base\Deposit as BaseDeposit;
7+
use ChurchCRM\model\ChurchCRM\DepositQuery;
78
use ChurchCRM\model\ChurchCRM\Map\DonationFundTableMap;
89
use ChurchCRM\model\ChurchCRM\Map\PledgeTableMap;
910
use ChurchCRM\model\ChurchCRM\PledgeQuery as ChildPledgeQuery;
@@ -484,4 +485,26 @@ public function getPledgesJoinAll(Criteria $criteria = null, ConnectionInterface
484485

485486
return $this->getPledges($query, $con);
486487
}
488+
489+
/**
490+
* Get the previous deposit (by ID).
491+
*/
492+
public static function getPreviousDeposit(int $currentId): ?Deposit
493+
{
494+
return DepositQuery::create()
495+
->filterById($currentId, Criteria::LESS_THAN)
496+
->orderById(Criteria::DESC)
497+
->findOne();
498+
}
499+
500+
/**
501+
* Get the next deposit (by ID).
502+
*/
503+
public static function getNextDeposit(int $currentId): ?Deposit
504+
{
505+
return DepositQuery::create()
506+
->filterById($currentId, Criteria::GREATER_THAN)
507+
->orderById(Criteria::ASC)
508+
->findOne();
509+
}
487510
}

src/DepositSlipEditor.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
use ChurchCRM\Authentication\AuthenticationManager;
77
use ChurchCRM\dto\SystemURLs;
8+
use ChurchCRM\model\ChurchCRM\Deposit;
89
use ChurchCRM\model\ChurchCRM\DepositQuery;
910
use ChurchCRM\Utils\InputUtils;
1011
use ChurchCRM\Utils\RedirectUtils;
@@ -45,6 +46,10 @@
4546

4647
$sPageTitle = $thisDeposit->getType() . ' ' . gettext('Deposit Slip Number: ') . $iDepositSlipID;
4748

49+
// Get previous and next deposits for navigation
50+
$prevDeposit = Deposit::getPreviousDeposit($iDepositSlipID);
51+
$nextDeposit = Deposit::getNextDeposit($iDepositSlipID);
52+
4853
//Is this the second pass?
4954
if (isset($_POST['DepositSlipLoadAuthorized'])) {
5055
$thisDeposit->loadAuthorized();
@@ -61,6 +66,29 @@
6166

6267
require_once 'Include/Header.php';
6368
?>
69+
<!-- Deposit Navigation -->
70+
<div class="row mb-3">
71+
<div class="col-12">
72+
<div class="d-flex justify-content-between align-items-center">
73+
<a href="FindDepositSlip.php" class="btn btn-outline-secondary">
74+
<i class="fa-solid fa-arrow-left"></i> <?= gettext('Back to Deposits'); ?>
75+
</a>
76+
<div class="btn-group" role="group" aria-label="<?= gettext('Deposit Navigation'); ?>">
77+
<a href="<?= $prevDeposit ? 'DepositSlipEditor.php?DepositSlipID=' . $prevDeposit->getId() : '#'; ?>"
78+
class="btn btn-outline-primary <?= $prevDeposit ? '' : 'disabled'; ?>"
79+
<?= $prevDeposit ? '' : 'aria-disabled="true"'; ?>>
80+
<i class="fa-solid fa-chevron-left"></i> <?= gettext('Previous'); ?>
81+
</a>
82+
<a href="<?= $nextDeposit ? 'DepositSlipEditor.php?DepositSlipID=' . $nextDeposit->getId() : '#'; ?>"
83+
class="btn btn-outline-primary <?= $nextDeposit ? '' : 'disabled'; ?>"
84+
<?= $nextDeposit ? '' : 'aria-disabled="true"'; ?>>
85+
<?= gettext('Next'); ?> <i class="fa-solid fa-chevron-right"></i>
86+
</a>
87+
</div>
88+
</div>
89+
</div>
90+
</div>
91+
6492
<!-- Deposit Slip Editor Main Container -->
6593
<div id="depositSlipEditorContainer">
6694
<div class="row">

0 commit comments

Comments
 (0)