Completed
Push — master ( 0272da...851765 )
by Andrii
08:55
created

DocumentsColumn   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 5
dl 0
loc 26
ccs 0
cts 21
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDataCellValue() 0 21 1
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-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\grid;
12
13
use hipanel\widgets\ArraySpoiler;
14
use hipanel\helpers\FontIcon;
15
use Yii;
16
use yii\helpers\Html;
17
18
class DocumentsColumn extends \hipanel\grid\DataColumn
19
{
20
    public $format = 'raw';
21
22
    public function getDataCellValue($model, $key, $index)
23
    {
24
        return ArraySpoiler::widget([
25
            'mode'              => ArraySpoiler::MODE_SPOILER,
26
            'data'              => parent::getDataCellValue($model, $key, $index),
27
            'delimiter'         => ' ',
28
            'formatter'         => function ($doc) {
29
                return Html::a(
30
                    FontIcon::i('fa-file-pdf-o fa-2x') . date(' M Y', strtotime($doc->validity_start)),
31
                    ["/file/{$doc->file_id}/{$doc->filename}", 'nocache' => 1],
32
                    ['target' => '_blank', 'class' => 'text-info text-nowrap col-xs-6 col-sm-6 col-md-6 col-lg-3']
33
                );
34
            },
35
            'template'          => '{button}{visible}{hidden}',
36
            'visibleCount'      => 2,
37
            'button'            => [
38
                'label' => FontIcon::i('fa-history fa-2x') . ' ' . Yii::t('hipanel', 'History'),
39
                'class' => 'pull-right text-nowrap',
40
            ],
41
        ]);
42
    }
43
}
44