CreditColumn   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 31
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveConfig() 0 28 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\grid;
12
13
use hipanel\grid\CurrencyColumn;
14
use hipanel\grid\XEditableColumn;
15
use hipanel\helpers\Url;
16
use hiqdev\xeditable\widgets\RemoteFormatXEditable;
17
use Yii;
18
19
class CreditColumn
20
{
21
    public static function resolveConfig()
22
    {
23
        return Yii::$app->user->can('manage') ? [
24
            'class'          => XEditableColumn::class,
25
            'filter'         => false,
26
            'contentOptions' => ['class' => 'text-right'],
27
            'widgetOptions'  => [
28
                'class' => RemoteFormatXEditable::class,
29
                'linkOptions' => [
30
                    'data-currency' => 'usd',
31
                ],
32
            ],
33
            'pluginOptions'  => [
34
                'url'                => '@client/set-credit',
35
                'title'              => Yii::t('hipanel:finance', 'Set credit'),
36
                'ajaxUrl'            => Url::to('/format/currency'),
37
                'data-display-value' => function ($column, $options) {
38
                    return Yii::$app->formatter->format(array_shift($column->pluginOptions['value']), ['currency', $options['model']->currency]);
39
                },
40
                'ajaxDataOptions' => [
41
                    'currency' => 'currency',
42
                ],
43
            ],
44
        ] : [
45
            'class'          => CurrencyColumn::class,
46
            'contentOptions' => ['class' => 'text-right'],
47
        ];
48
    }
49
}
50