1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace hipanel\modules\finance\menus; |
4
|
|
|
|
5
|
|
|
use hipanel\helpers\Url; |
6
|
|
|
use hipanel\modules\finance\models\Plan; |
7
|
|
|
use hipanel\widgets\SettingsModal; |
8
|
|
|
use Yii; |
9
|
|
|
|
10
|
|
|
class PlanDetailMenu extends \hipanel\menus\AbstractDetailMenu |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var Plan |
14
|
|
|
*/ |
15
|
|
|
public $model; |
16
|
|
|
|
17
|
|
|
public function items() |
18
|
|
|
{ |
19
|
|
|
$actions = PlanActionsMenu::create(['model' => $this->model])->items(); |
20
|
|
|
$items = array_merge($actions, [ |
21
|
|
|
'copy' => [ |
22
|
|
|
'label' => SettingsModal::widget([ |
23
|
|
|
'model' => $this->model, |
24
|
|
|
'title' => Yii::t('hipanel', 'Copy'), |
25
|
|
|
'icon' => 'fa-copy fa-fw', |
26
|
|
|
'scenario' => 'copy', |
27
|
|
|
'handleSubmit' => false, |
28
|
|
|
]), |
29
|
|
|
'encode' => false, |
30
|
|
|
// 'visible' => !$this->model->isDeleted() && Yii::$app->user->can('plan.create'), |
31
|
|
|
'visible' => false, |
32
|
|
|
], |
33
|
|
|
'delete' => [ |
34
|
|
|
'label' => Yii::t('hipanel', 'Delete'), |
35
|
|
|
'icon' => 'fa-trash', |
36
|
|
|
'url' => ['@plan/delete', 'id' => $this->model->id], |
37
|
|
|
'encode' => false, |
38
|
|
|
'linkOptions' => [ |
39
|
|
|
'data' => [ |
40
|
|
|
'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'), |
41
|
|
|
'method' => 'POST', |
42
|
|
|
'pjax' => '0', |
43
|
|
|
], |
44
|
|
|
], |
45
|
|
|
'visible' => \count($this->model->sales) === 0 && !$this->model->isDeleted() && Yii::$app->user->can('plan.delete'), |
46
|
|
|
], |
47
|
|
|
'restore' => [ |
48
|
|
|
'label' => Yii::t('hipanel.finance.plan', 'Restore'), |
49
|
|
|
'icon' => 'fa-refresh', |
50
|
|
|
'url' => ['@plan/restore'], |
51
|
|
|
'linkOptions' => [ |
52
|
|
|
'data' => [ |
53
|
|
|
'method' => 'POST', |
54
|
|
|
'pjax' => '0', |
55
|
|
|
'params' => ['selection[]' => $this->model->id] |
56
|
|
|
], |
57
|
|
|
], |
58
|
|
|
'visible' => $this->model->isDeleted() && Yii::$app->user->can('plan.update'), |
59
|
|
|
], |
60
|
|
|
'bills' => [ |
61
|
|
|
'label' => Yii::t('hipanel:finance', 'Bills'), |
62
|
|
|
'icon' => 'fa-money', |
63
|
|
|
'url' => Url::toSearch('bill', ['tariff_id' => $this->model->id]), |
64
|
|
|
], |
65
|
|
|
]); |
66
|
|
|
unset($items['view']); |
67
|
|
|
|
68
|
|
|
return $items; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|