Passed
Push — main ( 6ca2bb...bc39e3 )
by Thierry
05:43
created

Home::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
b 0
f 0
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
20
use function Jaxon\jq;
21
use function trans;
22
23
class Home extends CallableSessionClass
24
{
25
    /**
26
     * @return void
27
     */
28
    protected function getSession()
29
    {
30
        $sessionId = $this->target()->args()[0];
31
        $this->session = $this->sessionService->getSession($sessionId);
32
        $this->bag('meeting')->set('session.id', $sessionId);
33
    }
34
35
    /**
36
     * @return void
37
     */
38
    private function setup()
39
    {
40
        $this->jq('#btn-session-back')->click($this->rq(Menu::class)->home());
41
        $this->jq('#btn-tontine-options')->click($this->rq(Options::class)->editOptions());
42
43
        $this->response->call('showBalanceAmountsWithDelay');
44
    }
45
46
    public function pools(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

46
    public function pools(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
47
    {
48
        $html = $this->renderView('pages.meeting.session.home.pools', [
49
            'session' => $this->session,
50
        ]);
51
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

51
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
52
53
        $this->setup();
54
        $this->jq('#btn-session-refresh')->click($this->rq()->pools($this->session->id));
55
56
        $this->cl(Deposit::class)->show($this->session);
57
        $this->cl(Remitment::class)->show($this->session);
58
59
        $this->response->call('setSmScreenHandler', 'session-pools-sm-screens');
60
61
        return $this->response;
62
    }
63
64
    public function savings(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function savings(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66
        $html = $this->renderView('pages.meeting.session.home.savings', [
67
            'session' => $this->session,
68
        ]);
69
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

69
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
70
71
        $this->setup();
72
        $this->jq('#btn-session-refresh')->click($this->rq()->savings($this->session->id));
73
74
        $this->cl(Saving::class)->show($this->session);
75
        $this->cl(Closing::class)->show($this->session);
76
77
        $this->response->call('setSmScreenHandler', 'session-savings-sm-screens');
78
79
        return $this->response;
80
    }
81
82
    public function credits(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

82
    public function credits(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
83
    {
84
        $html = $this->renderView('pages.meeting.session.home.credits', [
85
            'session' => $this->session,
86
        ]);
87
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

87
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
88
89
        $this->setup();
90
        $this->jq('#btn-session-refresh')->click($this->rq()->credits($this->session->id));
91
92
        $this->cl(Loan::class)->show($this->session);
93
        $this->cl(PartialRefund::class)->show($this->session);
94
        $this->cl(Refund::class)->show($this->session);
95
96
        $this->response->call('setSmScreenHandler', 'session-credits-sm-screens');
97
98
        return $this->response;
99
    }
100
101
    public function cash(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

101
    public function cash(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
102
    {
103
        $html = $this->renderView('pages.meeting.session.home.cash', [
104
            'session' => $this->session,
105
        ]);
106
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

106
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
107
108
        $this->setup();
109
        $this->jq('#btn-session-refresh')->click($this->rq()->cash($this->session->id));
110
111
        $this->cl(Disbursement::class)->show($this->session);
112
113
        return $this->response;
114
    }
115
116
    public function charges(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

116
    public function charges(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
117
    {
118
        $html = $this->renderView('pages.meeting.session.home.charges', [
119
            'session' => $this->session,
120
        ]);
121
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

121
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
122
123
        $this->setup();
124
        $this->jq('#btn-session-refresh')->click($this->rq()->charges($this->session->id));
125
126
        $this->cl(FixedFee::class)->show($this->session);
127
        $this->cl(LibreFee::class)->show($this->session);
128
129
        $this->response->call('setSmScreenHandler', 'session-charges-sm-screens');
130
131
        return $this->response;
132
    }
133
134
    public function reports(int $sessionId)
0 ignored issues
show
Unused Code introduced by
The parameter $sessionId is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

134
    public function reports(/** @scrutinizer ignore-unused */ int $sessionId)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
135
    {
136
        $html = $this->renderView('pages.meeting.session.home.reports', [
137
            'session' => $this->session,
138
        ]);
139
        $this->response->html('content-home', $html);
0 ignored issues
show
Bug introduced by
It seems like $html can also be of type null; however, parameter $sData of Jaxon\Response\Response::html() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

139
        $this->response->html('content-home', /** @scrutinizer ignore-type */ $html);
Loading history...
140
141
        $this->setup();
142
        $this->jq('#btn-session-refresh')->click($this->rq()->reports($this->session->id));
143
144
        // Summernote options
145
        $options = [
146
            'height' => 300,
147
            'toolbar' => [
148
                // [groupName, [list of button]],
149
                ['style', ['bold', 'italic', 'underline', 'clear']],
150
                ['font', ['strikethrough', 'superscript', 'subscript']],
151
                ['fontsize', ['fontsize']],
152
                ['color', ['color']],
153
                ['para', ['ul', 'ol', 'paragraph']],
154
                // ['height', ['height']],
155
            ],
156
        ];
157
        $this->jq('#session-agenda')->summernote($options);
158
        $this->jq('#session-report')->summernote($options);
159
        $agendaText = jq('#session-agenda')->summernote('code');
160
        $reportText = jq('#session-report')->summernote('code');
161
        $this->jq('#btn-save-agenda')->click($this->rq(Session::class)->saveAgenda($agendaText));
162
        $this->jq('#btn-save-report')->click($this->rq(Session::class)->saveReport($reportText));
163
164
        return $this->response;
165
    }
166
}
167