Code Duplication    Length = 31-31 lines in 2 locations

src/grid/PurseGridView.php 2 locations

@@ 37-67 (lines=31) @@
34
            'contact' => [
35
                'format' => 'raw',
36
                'label' => Yii::t('hipanel:finance', 'Contact'),
37
                'value' => function ($model) {
38
                    $organization = $model->contact->organization;
39
                    $result = $organization . ($organization ? ' / ' : '') . $model->contact->name;
40
41
                    if (!Yii::$app->user->can('manage')) {
42
                        return $result;
43
                    }
44
45
                    return ComboXEditable::widget([
46
                        'model' => $model,
47
                        'attribute' => 'contact_id',
48
                        'value' => $result,
49
                        'pluginOptions' => [
50
                            'url' => ['@purse/update-contact', 'id' => $model->id],
51
                        ],
52
                        'combo' => [
53
                            'class' => ContactCombo::class,
54
                            'filter' => [
55
                                'client_id' => ['format' => $model->id],
56
                            ],
57
                            'current' => [
58
                                $model->contact_id => $result,
59
                            ],
60
                            'pluginOptions' => [
61
                                'select2Options' => [
62
                                    'width' => '40rem',
63
                                ],
64
                            ],
65
                        ],
66
                    ]);
67
                },
68
            ],
69
            'requisite' => [
70
                'format' => 'raw',
@@ 72-102 (lines=31) @@
69
            'requisite' => [
70
                'format' => 'raw',
71
                'label' => Yii::t('hipanel:finance', 'Payment details'),
72
                'value' => function ($model) {
73
                    $organization = $model->requisite->organization;
74
                    $result = $organization . ($organization ? ' / ' : '') . $model->requisite->name;
75
76
                    if (!Yii::$app->user->can('manage')) {
77
                        return $result;
78
                    }
79
80
                    return ComboXEditable::widget([
81
                        'model' => $model,
82
                        'attribute' => 'requisite_id',
83
                        'value' => $result,
84
                        'pluginOptions' => [
85
                            'url' => ['@purse/update-requisite', 'id' => $model->id],
86
                        ],
87
                        'combo' => [
88
                            'class' => ContactCombo::class,
89
                            'filter' => [
90
                                'client_id' => ['format' => $model->seller_id],
91
                            ],
92
                            'current' => [
93
                                $model->requisite_id => $result,
94
                            ],
95
                            'pluginOptions' => [
96
                                'select2Options' => [
97
                                    'width' => '40rem',
98
                                ],
99
                            ],
100
                        ],
101
                    ]);
102
                },
103
            ],
104
        ];
105
    }