|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Ajax\Web\Meeting\Charge; |
|
4
|
|
|
|
|
5
|
|
|
use App\Ajax\CallableClass; |
|
6
|
|
|
use Siak\Tontine\Service\LocaleService; |
|
7
|
|
|
use Siak\Tontine\Service\Meeting\Charge\FixedFeeService; |
|
8
|
|
|
use Siak\Tontine\Model\Session as SessionModel; |
|
9
|
|
|
|
|
10
|
|
|
use function Jaxon\jq; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @databag meeting |
|
14
|
|
|
* @before getSession |
|
15
|
|
|
*/ |
|
16
|
|
|
class FixedFee extends CallableClass |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @di |
|
20
|
|
|
* @var LocaleService |
|
21
|
|
|
*/ |
|
22
|
|
|
protected LocaleService $localeService; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var FixedFeeService |
|
26
|
|
|
*/ |
|
27
|
|
|
protected FixedFeeService $feeService; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var SessionModel|null |
|
31
|
|
|
*/ |
|
32
|
|
|
protected ?SessionModel $session; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* The constructor |
|
36
|
|
|
* |
|
37
|
|
|
* @param FixedFeeService $feeService |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(FixedFeeService $feeService) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->feeService = $feeService; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
protected function getSession() |
|
48
|
|
|
{ |
|
49
|
|
|
$sessionId = $this->bag('meeting')->get('session.id'); |
|
50
|
|
|
$this->session = $this->feeService->getSession($sessionId); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @exclude |
|
55
|
|
|
*/ |
|
56
|
|
|
public function show(SessionModel $session) |
|
57
|
|
|
{ |
|
58
|
|
|
$this->session = $session; |
|
59
|
|
|
|
|
60
|
|
|
return $this->home(); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function home() |
|
64
|
|
|
{ |
|
65
|
|
|
$html = $this->view()->render('tontine.pages.meeting.charge.fixed.home') |
|
66
|
|
|
->with('session', $this->session); |
|
67
|
|
|
$this->response->html('meeting-fees-fixed', $html); |
|
|
|
|
|
|
68
|
|
|
$this->jq('#btn-fees-fixed-refresh')->click($this->rq()->home()); |
|
69
|
|
|
|
|
70
|
|
|
return $this->page(1); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function page(int $pageNumber) |
|
74
|
|
|
{ |
|
75
|
|
|
$chargeCount = $this->feeService->getFeeCount(); |
|
76
|
|
|
[$pageNumber, $perPage] = $this->pageNumber($pageNumber, $chargeCount, |
|
77
|
|
|
'meeting', 'fee.fixed.page'); |
|
78
|
|
|
$charges = $this->feeService->getFees($pageNumber); |
|
79
|
|
|
$pagination = $this->rq()->page()->paginate($pageNumber, $perPage, $chargeCount); |
|
80
|
|
|
// Bill and settlement counts and amounts |
|
81
|
|
|
$bills = $this->feeService->getBills($this->session); |
|
|
|
|
|
|
82
|
|
|
$settlements = $this->feeService->getSettlements($this->session); |
|
|
|
|
|
|
83
|
|
|
|
|
84
|
|
|
$html = $this->view()->render('tontine.pages.meeting.charge.fixed.page') |
|
85
|
|
|
->with('session', $this->session) |
|
86
|
|
|
->with('charges', $charges) |
|
87
|
|
|
->with('bills', $bills) |
|
88
|
|
|
->with('settlements', $settlements) |
|
89
|
|
|
->with('pagination', $pagination); |
|
90
|
|
|
$this->response->html('meeting-fees-fixed-page', $html); |
|
|
|
|
|
|
91
|
|
|
|
|
92
|
|
|
$chargeId = jq()->parent()->attr('data-charge-id')->toInt(); |
|
93
|
|
|
$this->jq('.btn-fee-fixed-settlements') |
|
94
|
|
|
->click($this->cl(Fixed\Settlement::class)->rq()->home($chargeId)); |
|
95
|
|
|
|
|
96
|
|
|
return $this->response; |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|