forked from hiqdev/hipanel-module-stock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPartRepresentations.php
84 lines (81 loc) · 3.31 KB
/
PartRepresentations.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace hipanel\modules\stock\grid;
use hipanel\modules\stock\helpers\ProfitColumns;
use hiqdev\higrid\representations\RepresentationCollection;
use Yii;
class PartRepresentations extends RepresentationCollection
{
protected function fillRepresentations()
{
$user = Yii::$app->user;
$this->representations = array_filter([
'common' => [
'label' => Yii::t('hipanel', 'common'),
'columns' => array_filter([
'checkbox',
'model_type', 'model_brand', 'model', 'partno', 'serial',
'last_move', 'move_type_and_date', 'device_location', 'warranty_till',
$user->can('move.read') ? 'move_descr' : null,
$user->can('order.read') ? 'order_name' : null,
$user->can('order.read') ? 'company_id' : null,
]),
],
'brief' => [
'label' => Yii::t('hipanel', 'brief'),
'columns' => array_filter([
'checkbox',
'model_type', 'model_brand', 'partno', 'serial',
'last_move', 'move_type_and_date',
$user->can('move.read') ? 'move_descr' : null,
]),
],
'report' => [
'label' => Yii::t('hipanel', 'report'),
'columns' => [
'checkbox',
'model_type', 'model_brand', 'partno', 'serial',
'create_date', 'price', 'place',
],
],
'detailed' => $user->can('tmp disabled') ? [
'label' => Yii::t('hipanel', 'detailed'),
'columns' => array_filter([
'checkbox',
'model_type', 'model_brand',
'partno', 'serial',
'last_move', 'move_type_and_date', 'device_location',
$user->can('move.read') ? 'move_descr' :null,
$user->can('order.read') ? 'order_data' : null,
'dc_ticket',
]),
] : '',
'selling' => $user->can('order.create') ? [
'label' => Yii::t('hipanel:stock', 'selling'),
'columns' => [
'checkbox',
'buyer',
'last_move',
'model_type',
'partno',
'serial',
'price',
'selling_price',
'selling_time',
]
] : null,
'profit-report' => $user->can('order.read-profits') ? [
'label' => Yii::t('hipanel', 'profit report'),
'columns' => ProfitColumns::getColumnNames(['checkbox', 'buyer', 'company_id', 'serial', 'partno']),
] : null,
'admin' => $user->can('admin') && $user->can('order.create') ? [
'label' => Yii::t('hipanel:stock', 'Administrative'),
'columns' => [
'checkbox',
'model_type', 'model_brand', 'partno', 'serial', 'place', 'reserve',
$user->can('move.read') ? 'last_move_with_descr' : 'last_move',
'move_time',
],
] : null,
]);
}
}