Conditions | 5 |
Paths | 1 |
Total Lines | 47 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 0 |
1 | <?php |
||
16 | public function items() |
||
17 | { |
||
18 | $actions = PlanActionsMenu::create(['model' => $this->model])->items(); |
||
19 | $items = array_merge($actions, [ |
||
20 | 'copy' => [ |
||
21 | 'label' => SettingsModal::widget([ |
||
22 | 'model' => $this->model, |
||
23 | 'title' => Yii::t('hipanel', 'Copy'), |
||
24 | 'icon' => 'fa-copy fa-fw', |
||
25 | 'scenario' => 'copy', |
||
26 | 'handleSubmit' => false, |
||
27 | ]), |
||
28 | 'encode' => false, |
||
29 | 'visible' => !$this->model->isDeleted() && Yii::$app->user->can('plan.create'), |
||
30 | ], |
||
31 | 'delete' => [ |
||
32 | 'label' => Yii::t('hipanel', 'Delete'), |
||
33 | 'icon' => 'fa-trash', |
||
34 | 'url' => ['@plan/delete', 'id' => $this->model->id], |
||
35 | 'encode' => false, |
||
36 | 'linkOptions' => [ |
||
37 | 'data' => [ |
||
38 | 'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'), |
||
39 | 'method' => 'POST', |
||
40 | 'pjax' => '0', |
||
41 | ], |
||
42 | ], |
||
43 | 'visible' => \count($this->model->sales) === 0 && !$this->model->isDeleted() && Yii::$app->user->can('plan.delete'), |
||
44 | ], |
||
45 | 'restore' => [ |
||
46 | 'label' => Yii::t('hipanel.finance.plan', 'Restore'), |
||
47 | 'icon' => 'fa-refresh', |
||
48 | 'url' => ['@plan/restore'], |
||
49 | 'linkOptions' => [ |
||
50 | 'data' => [ |
||
51 | 'method' => 'POST', |
||
52 | 'pjax' => '0', |
||
53 | 'params' => ['selection[]' => $this->model->id] |
||
54 | ], |
||
55 | ], |
||
56 | 'visible' => $this->model->isDeleted() && Yii::$app->user->can('plan.update'), |
||
57 | ], |
||
58 | ]); |
||
59 | unset($items['view']); |
||
60 | |||
61 | return $items; |
||
62 | } |
||
63 | } |
||
64 |