|
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
|
|
|
class Session extends CallableClass |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param SessionService $sessionService |
|
15
|
|
|
*/ |
|
16
|
|
|
public function __construct(protected SessionService $sessionService) |
|
17
|
|
|
{} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @before checkRoundSessions |
|
21
|
|
|
* @after hideMenuOnMobile |
|
22
|
|
|
*/ |
|
23
|
|
|
public function home() |
|
24
|
|
|
{ |
|
25
|
|
|
$this->response->html('section-title', trans('tontine.menus.meeting')); |
|
26
|
|
|
$html = $this->render('pages.meeting.session.list.home'); |
|
27
|
|
|
$this->response->html('content-home', $html); |
|
|
|
|
|
|
28
|
|
|
|
|
29
|
|
|
$this->jq('#btn-sessions-refresh')->click($this->rq()->page()); |
|
30
|
|
|
|
|
31
|
|
|
return $this->page(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function page(int $pageNumber = 0) |
|
35
|
|
|
{ |
|
36
|
|
|
$sessionCount = $this->sessionService->getSessionCount(); |
|
37
|
|
|
[$pageNumber, $perPage] = $this->pageNumber($pageNumber, $sessionCount, 'session', 'page'); |
|
38
|
|
|
$sessions = $this->sessionService->getSessions($pageNumber); |
|
39
|
|
|
$pagination = $this->rq()->page()->paginate($pageNumber, $perPage, $sessionCount); |
|
40
|
|
|
|
|
41
|
|
|
$html = $this->render('pages.meeting.session.list.page', [ |
|
42
|
|
|
'sessions' => $sessions, |
|
43
|
|
|
'statuses' => $this->sessionService->getSessionStatuses(), |
|
44
|
|
|
'pagination' => $pagination |
|
45
|
|
|
]); |
|
46
|
|
|
$this->response->html('content-page', $html); |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
$sessionId = jq()->parent()->attr('data-session-id')->toInt(); |
|
49
|
|
|
$this->jq('.btn-session-show')->click($this->rq(Session\Home::class)->home($sessionId)); |
|
50
|
|
|
$this->jq('.btn-session-resync')->click($this->rq()->resync($sessionId) |
|
51
|
|
|
->confirm(trans('tontine.session.questions.resync'))); |
|
52
|
|
|
|
|
53
|
|
|
return $this->response; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function resync(int $sessionId) |
|
57
|
|
|
{ |
|
58
|
|
|
if(!($session = $this->sessionService->getSession($sessionId)) || !$session->opened) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->notify->error(trans('tontine.session.errors.not_opened'), trans('common.titles.error')); |
|
61
|
|
|
return $this->page(); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
$this->sessionService->resyncSession($session); |
|
65
|
|
|
|
|
66
|
|
|
$this->notify->success(trans('tontine.session.messages.resynced'), trans('common.titles.success')); |
|
67
|
|
|
return $this->page(); |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|