RequisiteDetailMenu   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 44
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A items() 0 39 2
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\helpers\Url;
14
use hipanel\widgets\AjaxModal;
15
use yii\bootstrap\Modal;
16
use yii\helpers\Html;
17
use Yii;
18
19
class RequisiteDetailMenu extends \hipanel\menus\AbstractDetailMenu
20
{
21
    public $model;
22
23
    public function items()
24
    {
25
        $user = Yii::$app->user;
26
        $items = RequisiteActionsMenu::create([
27
            'model' => $this->model,
28
        ])->items();
29
30
        $items = array_merge($items, [
31
            [
32
                'label' => AjaxModal::widget([
33
                    'id' => 'set-templates-modal',
34
                    'header' => Html::tag('h4', Yii::t('hipanel:finance', 'Set templates') . ': ' . Html::tag('b', "{$this->model->name} / {$this->model->organization}"), ['class' => 'modal-title']),
35
                    'scenario' => 'set-templates',
36
                    'actionUrl' => ['set-templates-modal', 'id' => $this->model->id],
37
                    'size' => Modal::SIZE_LARGE,
38
                    'toggleButton' => [
39
                         'label' => '<i class="fa fa-fw fa-exchange"></i>' . Yii::t('hipanel:finance', 'Set templates'),
40
                         'class' => 'clickable',
41
                         'data-pjax' => 0,
42
                         'tag' => 'a',
43
                    ],
44
                ]),
45
                'encode' => false,
46
                'visible' => $user->can('requisites.update'),
47
            ],
48
        ]);
49
50
        if (Yii::getAlias('@document', false)) {
51
            $items[] = [
52
                'label' => Yii::t('hipanel:client', 'Documents'),
53
                'icon' => 'fa-paperclip',
54
                'url' => ['@contact/attach-documents', 'id' => $this->model->id],
55
            ];
56
        }
57
58
        unset($items['view']);
59
60
        return $items;
61
    }
62
}
63