RequisiteActionsMenu::items()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 0
cts 37
cp 0
rs 9.312
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
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\menus;
12
13
use hipanel\widgets\AjaxModalWithTemplatedButton;
14
use hiqdev\yii2\menus\Menu;
15
use yii\bootstrap\Modal;
16
use yii\helpers\Html;
17
18
use Yii;
19
20
class RequisiteActionsMenu extends Menu
21
{
22
    public $model;
23
24
    public function items()
25
    {
26
        return [
27
            'view' => [
28
                'label' => Yii::t('hipanel', 'View'),
29
                'icon' => 'fa-info',
30
                'url' => ['@requisite/view', 'id' => $this->model->id],
31
                'encode' => false,
32
            ],
33
            'edit' => [
34
                'label' => Yii::t('hipanel', 'Edit'),
35
                'icon' => 'fa-pencil',
36
                'url' => ['@contact/update', 'id' => $this->model->id],
37
                'encode' => false,
38
            ],
39
            [
40
                'label' => AjaxModalWithTemplatedButton::widget([
41
                    'ajaxModalOptions' => [
42
                        'id' => 'reserve-number-modal-' . $this->model->id,
43
                        'bulkPage' => false,
44
                        'header' => Html::tag('h4', $item['label'], ['class' => 'modal-title']),
0 ignored issues
show
Bug introduced by
The variable $item does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
45
                        'scenario' => 'default',
46
                        'actionUrl' => ['reserve-number', 'id' => $this->model->id],
47
                        'size' => Modal::SIZE_LARGE,
48
                        'handleSubmit' => ['reserve-number', 'id' => $this->model->id],
49
                        'toggleButton' => [
50
                            'tag' => 'a',
51
                            'label' => Html::tag('i', null, ['class' => 'fa fa-ticket']) . " " . Yii::t('hipanel:finance', 'Reserve number'),
52
                            'style' => 'cursor: pointer;',
53
                        ],
54
                    ],
55
                    'toggleButtonTemplate' => '{toggleButton}',
56
                ]),
57
                'encode' => false,
58
                'visible' => Yii::$app->user->can('requisites.update') && $this->model->isRequisite(),
59
            ],
60
        ];
61
    }
62
}
63