1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Finance module for HiPanel |
5
|
|
|
* |
6
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
7
|
|
|
* @package hipanel-module-finance |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace hipanel\modules\finance\controllers; |
13
|
|
|
|
14
|
|
|
use hipanel\actions\IndexAction; |
15
|
|
|
use hipanel\actions\OrientationAction; |
16
|
|
|
use hipanel\actions\SmartCreateAction; |
17
|
|
|
use hipanel\actions\SmartPerformAction; |
18
|
|
|
use hipanel\actions\SmartUpdateAction; |
19
|
|
|
use hipanel\actions\ValidateFormAction; |
20
|
|
|
use hipanel\actions\ViewAction; |
21
|
|
|
use Yii; |
22
|
|
|
|
23
|
|
|
class BillController extends \hipanel\base\CrudController |
24
|
|
|
{ |
25
|
1 |
|
public function actions() |
26
|
|
|
{ |
27
|
|
|
return [ |
28
|
|
|
'set-orientation' => [ |
29
|
|
|
'class' => OrientationAction::class, |
30
|
|
|
'allowedRoutes' => [ |
31
|
|
|
'@bill/index' |
32
|
|
|
] |
33
|
1 |
|
], |
34
|
|
|
'index' => [ |
35
|
|
|
'class' => IndexAction::class, |
36
|
|
|
'data' => function ($action) { |
37
|
|
|
return [ |
38
|
|
|
'type' => $action->controller->getPaymentType(), |
39
|
|
|
]; |
40
|
1 |
|
}, |
41
|
|
|
], |
42
|
|
|
'view' => [ |
43
|
|
|
'class' => ViewAction::class, |
44
|
|
|
], |
45
|
|
|
'validate-form' => [ |
46
|
|
|
'class' => ValidateFormAction::class, |
47
|
|
|
], |
48
|
|
|
'create' => [ |
49
|
|
|
'class' => SmartCreateAction::class, |
50
|
1 |
|
'data' => function ($action) { |
|
|
|
|
51
|
|
|
$types = $this->getRefs('type,bill', 'hipanel/finance', ['with_hierarchy' => 1, 'orderby' => 'name_asc']); |
52
|
|
|
$billTypes = []; |
53
|
|
|
$billGroupLabels = []; |
54
|
|
|
|
55
|
|
|
foreach ($types as $key => $title) { |
56
|
|
|
list($type, $name) = explode(',', $key); |
57
|
|
|
|
58
|
|
|
if (!isset($billTypes[$type])) { |
59
|
|
|
$billTypes[$type] = []; |
60
|
|
|
$billGroupLabels[$type] = ['label' => $title]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
if (isset($name)) { |
64
|
|
|
foreach ($types as $k => $t) { |
65
|
|
|
if (strpos($k, $type . ',') === 0) { |
66
|
|
|
$billTypes[$type][$k] = $t; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
return ['billTypes' => $billTypes, 'billGroupLabels' => $billGroupLabels]; |
73
|
1 |
|
}, |
74
|
1 |
|
'success' => Yii::t('hipanel/finance', 'Bill was created successfully'), |
75
|
|
|
], |
76
|
|
|
'update' => [ |
77
|
|
|
'class' => SmartUpdateAction::class, |
78
|
1 |
|
'success' => Yii::t('hipanel/finance', 'Bill was updated successfully'), |
79
|
|
|
], |
80
|
|
|
'delete' => [ |
81
|
|
|
'class' => SmartPerformAction::class, |
82
|
1 |
|
'success' => Yii::t('hipanel/finance', 'Bill was deleted successfully'), |
83
|
|
|
], |
84
|
|
|
]; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return array |
89
|
|
|
*/ |
90
|
|
|
public function getPaymentType() |
91
|
|
|
{ |
92
|
|
|
return $this->getRefs('type,bill', 'hipanel/finance', Yii::$app->user->can('support') ? ['with_hierarchy' => true] : []); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.