|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Ajax\Web\Meeting\Session; |
|
4
|
|
|
|
|
5
|
|
|
use App\Ajax\CallableSessionClass; |
|
6
|
|
|
use App\Ajax\Web\Meeting\Session as Menu; |
|
7
|
|
|
use App\Ajax\Web\Meeting\Cash\Disbursement; |
|
8
|
|
|
use App\Ajax\Web\Meeting\Charge\FixedFee; |
|
9
|
|
|
use App\Ajax\Web\Meeting\Charge\LibreFee; |
|
10
|
|
|
use App\Ajax\Web\Meeting\Credit\Loan; |
|
11
|
|
|
use App\Ajax\Web\Meeting\Credit\PartialRefund; |
|
12
|
|
|
use App\Ajax\Web\Meeting\Credit\Refund; |
|
13
|
|
|
use App\Ajax\Web\Meeting\Pool\Deposit; |
|
14
|
|
|
use App\Ajax\Web\Meeting\Pool\Remitment; |
|
15
|
|
|
use App\Ajax\Web\Meeting\Saving\Closing; |
|
16
|
|
|
use App\Ajax\Web\Meeting\Saving\Saving; |
|
17
|
|
|
use App\Ajax\Web\Tontine\Options; |
|
18
|
|
|
use Siak\Tontine\Model\Session as SessionModel; |
|
19
|
|
|
use Siak\Tontine\Service\Report\ReportService; |
|
20
|
|
|
|
|
21
|
|
|
use function Jaxon\jq; |
|
22
|
|
|
use function count; |
|
23
|
|
|
use function trans; |
|
24
|
|
|
|
|
25
|
|
|
class Home extends CallableSessionClass |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* The constructor |
|
29
|
|
|
* |
|
30
|
|
|
* @param ReportService $reportService |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct(protected ReportService $reportService) |
|
33
|
|
|
{} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return void |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function getSession() |
|
39
|
|
|
{ |
|
40
|
|
|
$sessionId = $this->target()->args()[0]; |
|
41
|
|
|
$this->session = $this->sessionService->getSession($sessionId); |
|
42
|
|
|
$this->bag('meeting')->set('session.id', $sessionId); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @exclude |
|
47
|
|
|
*/ |
|
48
|
|
|
public function show(SessionModel $session) |
|
49
|
|
|
{ |
|
50
|
|
|
$this->session = $session; |
|
51
|
|
|
|
|
52
|
|
|
return $this->home($session->id); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function home(int $sessionId) |
|
56
|
|
|
{ |
|
57
|
|
|
$closings = $this->reportService->getClosings($this->session); |
|
|
|
|
|
|
58
|
|
|
$html = $this->render('pages.meeting.session.home', [ |
|
59
|
|
|
'session' => $this->session, |
|
60
|
|
|
'hasClosing' => count($closings) > 0, |
|
61
|
|
|
]); |
|
62
|
|
|
$this->response->html('content-home', $html); |
|
|
|
|
|
|
63
|
|
|
$this->jq('a', '#session-tabs')->click(jq()->tab('show')); |
|
64
|
|
|
$tontineId = jq()->parent()->attr('data-tontine-id')->toInt(); |
|
65
|
|
|
$this->jq('.btn-tontine-edit')->click($this->rq()->edit($tontineId)); |
|
66
|
|
|
|
|
67
|
|
|
$this->jq('#btn-session-back')->click($this->cl(Menu::class)->rq()->home()); |
|
68
|
|
|
$this->jq('#btn-tontine-options')->click($this->cl(Options::class)->rq()->editOptions()); |
|
69
|
|
|
$this->jq('#btn-session-refresh')->click($this->rq()->home($sessionId)); |
|
70
|
|
|
$this->jq('#btn-session-open')->click($this->cl(Session::class)->rq()->open() |
|
71
|
|
|
->confirm(trans('tontine.session.questions.open') . '<br/>' . |
|
72
|
|
|
trans('tontine.session.questions.warning'))); |
|
73
|
|
|
$this->jq('#btn-session-close')->click($this->cl(Session::class)->rq()->close() |
|
74
|
|
|
->confirm(trans('tontine.session.questions.close'))); |
|
75
|
|
|
|
|
76
|
|
|
$this->reports(); |
|
77
|
|
|
$this->pools(); |
|
78
|
|
|
$this->charges(); |
|
79
|
|
|
$this->savings(); |
|
80
|
|
|
$this->credits(); |
|
81
|
|
|
$this->cash(); |
|
82
|
|
|
|
|
83
|
|
|
$this->response->call('showBalanceAmountsWithDelay'); |
|
84
|
|
|
|
|
85
|
|
|
return $this->response; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @return void |
|
90
|
|
|
*/ |
|
91
|
|
|
private function pools() |
|
92
|
|
|
{ |
|
93
|
|
|
$this->cl(Deposit::class)->show($this->session); |
|
94
|
|
|
$this->cl(Remitment::class)->show($this->session); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @return void |
|
99
|
|
|
*/ |
|
100
|
|
|
private function savings() |
|
101
|
|
|
{ |
|
102
|
|
|
$this->cl(Saving::class)->show($this->session); |
|
103
|
|
|
$this->cl(Closing::class)->show($this->session); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return void |
|
108
|
|
|
*/ |
|
109
|
|
|
private function credits() |
|
110
|
|
|
{ |
|
111
|
|
|
$this->cl(Loan::class)->show($this->session); |
|
112
|
|
|
$this->cl(PartialRefund::class)->show($this->session); |
|
113
|
|
|
$this->cl(Refund::class)->show($this->session); |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @return void |
|
118
|
|
|
*/ |
|
119
|
|
|
private function cash() |
|
120
|
|
|
{ |
|
121
|
|
|
$this->cl(Disbursement::class)->show($this->session); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* @return void |
|
126
|
|
|
*/ |
|
127
|
|
|
private function charges() |
|
128
|
|
|
{ |
|
129
|
|
|
$this->cl(FixedFee::class)->show($this->session); |
|
130
|
|
|
$this->cl(LibreFee::class)->show($this->session); |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @return void |
|
135
|
|
|
*/ |
|
136
|
|
|
private function reports() |
|
137
|
|
|
{ |
|
138
|
|
|
// Summernote options |
|
139
|
|
|
$options = [ |
|
140
|
|
|
'height' => 300, |
|
141
|
|
|
'toolbar' => [ |
|
142
|
|
|
// [groupName, [list of button]], |
|
143
|
|
|
['style', ['bold', 'italic', 'underline', 'clear']], |
|
144
|
|
|
['font', ['strikethrough', 'superscript', 'subscript']], |
|
145
|
|
|
['fontsize', ['fontsize']], |
|
146
|
|
|
['color', ['color']], |
|
147
|
|
|
['para', ['ul', 'ol', 'paragraph']], |
|
148
|
|
|
// ['height', ['height']], |
|
149
|
|
|
], |
|
150
|
|
|
]; |
|
151
|
|
|
$this->jq('#session-agenda')->summernote($options); |
|
152
|
|
|
$this->jq('#session-report')->summernote($options); |
|
153
|
|
|
$agendaText = jq('#session-agenda')->summernote('code'); |
|
154
|
|
|
$reportText = jq('#session-report')->summernote('code'); |
|
155
|
|
|
$this->jq('#btn-save-agenda')->click($this->cl(Session::class)->rq()->saveAgenda($agendaText)); |
|
156
|
|
|
$this->jq('#btn-save-report')->click($this->cl(Session::class)->rq()->saveReport($reportText)); |
|
157
|
|
|
} |
|
158
|
|
|
} |
|
159
|
|
|
|