1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Finance module for HiPanel |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-finance |
6
|
|
|
* @package hipanel-module-finance |
7
|
|
|
* @license BSD-3-Clause |
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace hipanel\modules\finance\controllers; |
12
|
|
|
|
13
|
|
|
use hipanel\actions\ComboSearchAction; |
14
|
|
|
use hipanel\actions\IndexAction; |
15
|
|
|
use hipanel\actions\SmartCreateAction; |
16
|
|
|
use hipanel\actions\SmartDeleteAction; |
17
|
|
|
use hipanel\actions\SmartUpdateAction; |
18
|
|
|
use hipanel\actions\ValidateFormAction; |
19
|
|
|
use hipanel\actions\ViewAction; |
20
|
|
|
use hipanel\filters\EasyAccessControl; |
21
|
|
|
use Yii; |
22
|
|
|
|
23
|
|
|
class TariffProfileController extends \hipanel\base\CrudController |
24
|
|
|
{ |
25
|
|
View Code Duplication |
public function behaviors() |
26
|
|
|
{ |
27
|
|
|
return array_merge(parent::behaviors(), [ |
28
|
|
|
'access-control' => [ |
29
|
|
|
'class' => EasyAccessControl::class, |
30
|
|
|
'actions' => [ |
31
|
|
|
'create' => 'plan.create', |
32
|
|
|
'update' => 'plan.update', |
33
|
|
|
'delete' => 'plan.delete', |
34
|
|
|
'*' => 'plan.read', |
35
|
|
|
], |
36
|
|
|
], |
37
|
|
|
]); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function actions() |
41
|
|
|
{ |
42
|
|
|
return array_merge(parent::actions(), [ |
43
|
|
|
'index' => [ |
44
|
|
|
'class' => IndexAction::class, |
45
|
|
|
], |
46
|
|
|
'create' => [ |
47
|
|
|
'class' => SmartCreateAction::class, |
48
|
|
|
'data' => function(\hipanel\actions\RenderAction $action) : array { |
|
|
|
|
49
|
|
|
$user = Yii::$app->user->identity; |
50
|
|
|
if ($user->type === 'reseller') { |
51
|
|
|
return [ |
52
|
|
|
'client' => $user->username, |
53
|
|
|
'client_id' => $user->id, |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
return [ |
57
|
|
|
'client' => $user->seller, |
58
|
|
|
'client_id' => $user->seller_id, |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
], |
62
|
|
|
'update' => [ |
63
|
|
|
'class' => SmartUpdateAction::class, |
64
|
|
|
'data' => function(\hipanel\actions\RenderAction $action, array $data) : array { |
65
|
|
|
$model = $data['model']; |
66
|
|
|
return [ |
67
|
|
|
'client' => $model->client, |
68
|
|
|
'client_id' => $model->client_id, |
69
|
|
|
]; |
70
|
|
|
}, |
71
|
|
|
], |
72
|
|
|
'search' => [ |
73
|
|
|
'class' => ComboSearchAction::class, |
74
|
|
|
], |
75
|
|
|
'validate-form' => [ |
76
|
|
|
'class' => ValidateFormAction::class, |
77
|
|
|
], |
78
|
|
|
'view' => [ |
79
|
|
|
'class' => ViewAction::class, |
80
|
|
|
], |
81
|
|
|
'delete' => [ |
82
|
|
|
'class' => SmartDeleteAction::class, |
83
|
|
|
'success' => Yii::t('hipanel.finance.tariffprofile', 'Profile deleted'), |
84
|
|
|
], |
85
|
|
|
]); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.