|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Ajax\Web\Tontine; |
|
4
|
|
|
|
|
5
|
|
|
use App\Ajax\CallableClass; |
|
6
|
|
|
use Siak\Tontine\Service\Tontine\TontineService; |
|
7
|
|
|
use Siak\Tontine\Validation\Tontine\OptionsValidator; |
|
8
|
|
|
|
|
9
|
|
|
use function Jaxon\pm; |
|
10
|
|
|
use function trans; |
|
11
|
|
|
|
|
12
|
|
|
class Options extends CallableClass |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @var OptionsValidator |
|
16
|
|
|
*/ |
|
17
|
|
|
protected OptionsValidator $validator; |
|
18
|
|
|
|
|
19
|
|
|
public function __construct(private TontineService $tontineService) |
|
20
|
|
|
{} |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @after hideMenuOnMobile |
|
24
|
|
|
*/ |
|
25
|
|
|
public function home() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->response->html('section-title', trans('tontine.menus.tontine')); |
|
28
|
|
|
$this->response->html('content-home', $this->render('pages.tontine.options')); |
|
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
$this->cl(Fund::class)->home(); |
|
31
|
|
|
$this->cl(Category::class)->home(); |
|
32
|
|
|
$this->cl(Charge::class)->home(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function editOptions() |
|
36
|
|
|
{ |
|
37
|
|
|
$options = $this->tontineService->getTontineOptions(); |
|
38
|
|
|
$template = $options['reports']['template'] ?? 'default'; |
|
39
|
|
|
$title = trans('tontine.options.titles.edit'); |
|
40
|
|
|
$content = $this->render('pages.tontine.options.edit', [ |
|
41
|
|
|
'template' => $template, |
|
42
|
|
|
'templates' => [ |
|
43
|
|
|
'default' => trans('tontine.options.labels.default'), |
|
44
|
|
|
'raptor' => 'Raptor', |
|
45
|
|
|
], |
|
46
|
|
|
]); |
|
47
|
|
|
$buttons = [[ |
|
48
|
|
|
'title' => trans('common.actions.cancel'), |
|
49
|
|
|
'class' => 'btn btn-tertiary', |
|
50
|
|
|
'click' => 'close', |
|
51
|
|
|
],[ |
|
52
|
|
|
'title' => trans('common.actions.save'), |
|
53
|
|
|
'class' => 'btn btn-primary', |
|
54
|
|
|
'click' => $this->rq()->saveOptions(pm()->form('options-form')), |
|
55
|
|
|
]]; |
|
56
|
|
|
|
|
57
|
|
|
$this->dialog->show($title, $content, $buttons); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
return $this->response; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @di $validator |
|
64
|
|
|
*/ |
|
65
|
|
|
public function saveOptions(array $formValues) |
|
66
|
|
|
{ |
|
67
|
|
|
// Validation |
|
68
|
|
|
$options = $this->validator->validateItem($formValues); |
|
69
|
|
|
$this->tontineService->saveTontineOptions($options); |
|
70
|
|
|
|
|
71
|
|
|
$this->dialog->hide(); |
|
72
|
|
|
$this->notify->success(trans('tontine.options.messages.saved')); |
|
73
|
|
|
|
|
74
|
|
|
return $this->response; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|