|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Ajax\Web\Meeting; |
|
4
|
|
|
|
|
5
|
|
|
use App\Ajax\CallableClass; |
|
6
|
|
|
use Siak\Tontine\Service\Meeting\SessionService; |
|
7
|
|
|
|
|
8
|
|
|
use function Jaxon\jq; |
|
9
|
|
|
use function trans; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @before checkGuestAccess ["meeting", "sessions"] |
|
13
|
|
|
*/ |
|
14
|
|
|
class Session extends CallableClass |
|
15
|
|
|
{ |
|
16
|
|
|
/** |
|
17
|
|
|
* @param SessionService $sessionService |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct(protected SessionService $sessionService) |
|
20
|
|
|
{} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @before checkRoundSessions |
|
24
|
|
|
* @after hideMenuOnMobile |
|
25
|
|
|
*/ |
|
26
|
|
|
public function home() |
|
27
|
|
|
{ |
|
28
|
|
|
$this->response->html('section-title', trans('tontine.menus.meeting')); |
|
29
|
|
|
$html = $this->renderView('pages.meeting.session.list.home'); |
|
30
|
|
|
$this->response->html('content-home', $html); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
$this->jq('#btn-sessions-refresh')->click($this->rq()->page()); |
|
33
|
|
|
|
|
34
|
|
|
return $this->page(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function page(int $pageNumber = 0) |
|
38
|
|
|
{ |
|
39
|
|
|
$sessionCount = $this->sessionService->getSessionCount(); |
|
40
|
|
|
[$pageNumber, $perPage] = $this->pageNumber($pageNumber, $sessionCount, 'session', 'page'); |
|
41
|
|
|
$sessions = $this->sessionService->getSessions($pageNumber); |
|
42
|
|
|
$pagination = $this->rq()->page()->paginate($pageNumber, $perPage, $sessionCount); |
|
43
|
|
|
|
|
44
|
|
|
$html = $this->renderView('pages.meeting.session.list.page', [ |
|
45
|
|
|
'sessions' => $sessions, |
|
46
|
|
|
'statuses' => $this->sessionService->getSessionStatuses(), |
|
47
|
|
|
'pagination' => $pagination |
|
48
|
|
|
]); |
|
49
|
|
|
$this->response->html('content-page', $html); |
|
|
|
|
|
|
50
|
|
|
$this->response->call('makeTableResponsive', 'content-page'); |
|
51
|
|
|
|
|
52
|
|
|
$rqHome = $this->rq(Session\Home::class); |
|
53
|
|
|
$sessionId = jq()->parent()->attr('data-session-id')->toInt(); |
|
54
|
|
|
$this->jq('.btn-session-resync')->click($this->rq()->resync($sessionId) |
|
55
|
|
|
->confirm(trans('tontine.session.questions.resync'))); |
|
56
|
|
|
$this->jq('.btn-session-open')->click($this->rq()->open($sessionId) |
|
57
|
|
|
->confirm(trans('tontine.session.questions.open') . '<br/>' . |
|
58
|
|
|
trans('tontine.session.questions.warning'))); |
|
59
|
|
|
$this->jq('.btn-session-close')->click($this->rq()->close($sessionId) |
|
60
|
|
|
->confirm(trans('tontine.session.questions.close'))); |
|
61
|
|
|
|
|
62
|
|
|
$this->jq('.btn-session-pools')->click($rqHome->pools($sessionId)); |
|
63
|
|
|
$this->jq('.btn-session-savings')->click($rqHome->savings($sessionId)); |
|
64
|
|
|
$this->jq('.btn-session-credits')->click($rqHome->credits($sessionId)); |
|
65
|
|
|
$this->jq('.btn-session-cash')->click($rqHome->cash($sessionId)); |
|
66
|
|
|
$this->jq('.btn-session-charges')->click($rqHome->charges($sessionId)); |
|
67
|
|
|
$this->jq('.btn-session-reports')->click($rqHome->reports($sessionId)); |
|
68
|
|
|
|
|
69
|
|
|
return $this->response; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function open(int $sessionId) |
|
73
|
|
|
{ |
|
74
|
|
|
if(!($session = $this->sessionService->getSession($sessionId)) || $session->opened) |
|
75
|
|
|
{ |
|
76
|
|
|
$this->notify->error(trans('tontine.session.errors.opened'), trans('common.titles.error')); |
|
77
|
|
|
return $this->page(); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$this->sessionService->openSession($session); |
|
81
|
|
|
|
|
82
|
|
|
return $this->page(); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
public function close(int $sessionId) |
|
86
|
|
|
{ |
|
87
|
|
|
if(!($session = $this->sessionService->getSession($sessionId)) || !$session->opened) |
|
88
|
|
|
{ |
|
89
|
|
|
$this->notify->error(trans('tontine.session.errors.not_opened'), trans('common.titles.error')); |
|
90
|
|
|
return $this->page(); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
$this->sessionService->closeSession($session); |
|
94
|
|
|
|
|
95
|
|
|
return $this->page(); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
public function resync(int $sessionId) |
|
99
|
|
|
{ |
|
100
|
|
|
if(!($session = $this->sessionService->getSession($sessionId)) || !$session->opened) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->notify->error(trans('tontine.session.errors.not_opened'), trans('common.titles.error')); |
|
103
|
|
|
return $this->page(); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
$this->sessionService->resyncSession($session); |
|
107
|
|
|
|
|
108
|
|
|
$this->notify->success(trans('tontine.session.messages.resynced'), trans('common.titles.success')); |
|
109
|
|
|
return $this->page(); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
|