Completed
Push — master ( 386999...127bd3 )
by Dmitry
10:56 queued 03:08
created

src/grid/CreditColumn.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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) {
0 ignored issues
show
The parameter $options is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
                    return Yii::$app->formatter->format(array_shift($column->pluginOptions['value']), ['currency', 'USD']);
39
                },
40
                'ajaxDataOptions' => [
41
                    'currency' => 'currency',
42
                ],
43
            ],
44
        ] : [
45
            'class'          => CurrencyColumn::class,
46
            'contentOptions' => ['class' => 'text-right'],
47
        ];
48
    }
49
}
50