|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Ajax\Web\Meeting\Session; |
|
4
|
|
|
|
|
5
|
|
|
use App\Ajax\CallableSessionClass; |
|
6
|
|
|
use Siak\Tontine\Service\BalanceCalculator; |
|
7
|
|
|
use Siak\Tontine\Service\LocaleService; |
|
8
|
|
|
|
|
9
|
|
|
use function trans; |
|
10
|
|
|
|
|
11
|
|
|
class Session extends CallableSessionClass |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @var LocaleService |
|
15
|
|
|
*/ |
|
16
|
|
|
protected LocaleService $localeService; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param BalanceCalculator $balanceCalculator |
|
20
|
|
|
*/ |
|
21
|
|
|
public function __construct(private BalanceCalculator $balanceCalculator) |
|
22
|
|
|
{} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @di $localeService |
|
26
|
|
|
*/ |
|
27
|
|
|
public function showBalanceAmounts() |
|
28
|
|
|
{ |
|
29
|
|
|
$amount = $this->balanceCalculator->getBalanceForLoan($this->session); |
|
|
|
|
|
|
30
|
|
|
$html = trans('meeting.loan.labels.amount_available', [ |
|
31
|
|
|
'amount' => $this->localeService->formatMoney($amount), |
|
32
|
|
|
]); |
|
33
|
|
|
$this->response->html('loan_amount_available', $html); |
|
34
|
|
|
|
|
35
|
|
|
$amount = $this->balanceCalculator->getTotalBalance($this->session); |
|
|
|
|
|
|
36
|
|
|
$html = trans('meeting.disbursement.labels.amount_available', [ |
|
37
|
|
|
'amount' => $this->localeService->formatMoney($amount), |
|
38
|
|
|
]); |
|
39
|
|
|
$this->response->html('total_amount_available', $html); |
|
40
|
|
|
|
|
41
|
|
|
return $this->response; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function showBalanceDetails(bool $lendable) |
|
45
|
|
|
{ |
|
46
|
|
|
$balances = $this->balanceCalculator->getBalances($this->session, $lendable); |
|
|
|
|
|
|
47
|
|
|
$title = trans('meeting.titles.amounts'); |
|
48
|
|
|
$content = $this->render('pages.meeting.session.balances', [ |
|
49
|
|
|
'session' => $this->session, |
|
50
|
|
|
'balances' => $balances, |
|
51
|
|
|
]); |
|
52
|
|
|
$buttons = [[ |
|
53
|
|
|
'title' => trans('common.actions.close'), |
|
54
|
|
|
'class' => 'btn btn-tertiary', |
|
55
|
|
|
'click' => 'close', |
|
56
|
|
|
]]; |
|
57
|
|
|
$this->dialog->show($title, $content, $buttons); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
return $this->response; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function open() |
|
63
|
|
|
{ |
|
64
|
|
|
$this->sessionService->openSession($this->session); |
|
|
|
|
|
|
65
|
|
|
$this->cl(Home::class)->show($this->session); |
|
66
|
|
|
|
|
67
|
|
|
return $this->response; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
public function close() |
|
71
|
|
|
{ |
|
72
|
|
|
$this->sessionService->closeSession($this->session); |
|
|
|
|
|
|
73
|
|
|
$this->cl(Home::class)->show($this->session); |
|
74
|
|
|
|
|
75
|
|
|
return $this->response; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function saveAgenda(string $text) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->sessionService->saveAgenda($this->session, $text); |
|
|
|
|
|
|
81
|
|
|
$this->notify->success(trans('meeting.messages.agenda.updated'), trans('common.titles.success')); |
|
82
|
|
|
|
|
83
|
|
|
return $this->response; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function saveReport(string $text) |
|
87
|
|
|
{ |
|
88
|
|
|
$this->sessionService->saveReport($this->session, $text); |
|
|
|
|
|
|
89
|
|
|
$this->notify->success(trans('meeting.messages.report.updated'), trans('common.titles.success')); |
|
90
|
|
|
|
|
91
|
|
|
return $this->response; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|