Code Duplication    Length = 31-31 lines in 2 locations

src/grid/PurseGridView.php 2 locations

@@ 65-95 (lines=31) @@
62
            'contact' => [
63
                'format' => 'raw',
64
                'label' => Yii::t('hipanel:finance', 'Contact'),
65
                'value' => function ($model) {
66
                    $organization = $model->contact->organization;
67
                    $result = $organization . ($organization ? ' / ' : '') . $model->contact->name;
68
69
                    if (!Yii::$app->user->can('purse.update')) {
70
                        return $result;
71
                    }
72
73
                    return ComboXEditable::widget([
74
                        'model' => $model,
75
                        'attribute' => 'contact_id',
76
                        'value' => $result,
77
                        'pluginOptions' => [
78
                            'url' => ['@purse/update-contact', 'id' => $model->id],
79
                        ],
80
                        'combo' => [
81
                            'class' => ContactCombo::class,
82
                            'filter' => [
83
                                'client_id' => ['format' => $model->id],
84
                            ],
85
                            'current' => [
86
                                $model->contact_id => $result,
87
                            ],
88
                            'pluginOptions' => [
89
                                'select2Options' => [
90
                                    'width' => '40rem',
91
                                ],
92
                            ],
93
                        ],
94
                    ]);
95
                },
96
            ],
97
            'requisite' => [
98
                'format' => 'raw',
@@ 100-130 (lines=31) @@
97
            'requisite' => [
98
                'format' => 'raw',
99
                'label' => Yii::t('hipanel:finance', 'Payment details'),
100
                'value' => function ($model) {
101
                    $organization = $model->requisite->organization;
102
                    $result = $organization . ($organization ? ' / ' : '') . $model->requisite->name;
103
104
                    if (!Yii::$app->user->can('purse.update')) {
105
                        return $result;
106
                    }
107
108
                    return ComboXEditable::widget([
109
                        'model' => $model,
110
                        'attribute' => 'requisite_id',
111
                        'value' => $result,
112
                        'pluginOptions' => [
113
                            'url' => ['@purse/update-requisite', 'id' => $model->id],
114
                        ],
115
                        'combo' => [
116
                            'class' => RequisitesCombo::class,
117
                            'filter' => [
118
                                'client_id' => ['format' => $model->seller_id],
119
                            ],
120
                            'current' => [
121
                                $model->requisite_id => $result,
122
                            ],
123
                            'pluginOptions' => [
124
                                'select2Options' => [
125
                                    'width' => '40rem',
126
                                ],
127
                            ],
128
                        ],
129
                    ]);
130
                },
131
            ],
132
        ]);
133
    }