1 | <?php |
||
27 | class TicketGridView extends BoxedGridView |
||
28 | { |
||
29 | public $enableListChecker = false; |
||
30 | |||
31 | public function columns() |
||
32 | { |
||
33 | return array_merge(parent::columns(), [ |
||
34 | 'subject' => [ |
||
35 | 'attribute' => 'subject', |
||
36 | 'format' => 'raw', |
||
37 | 'filterInputOptions' => ['style' => 'width:100%', 'class' => 'form-control'], |
||
38 | 'value' => function ($model) { |
||
39 | $decorator = new ThreadDecorator($model); |
||
40 | |||
41 | $ava = Html::tag('div', Gravatar::widget([ |
||
42 | 'emailHash' => $model->author_email, |
||
43 | 'defaultImage' => 'identicon', |
||
44 | 'options' => [ |
||
45 | 'alt' => Yii::t('hipanel:ticket', 'Avatar for {login}', ['login' => $model->author]), |
||
46 | 'class' => 'img-circle', |
||
47 | ], |
||
48 | 'size' => 40, |
||
49 | ]), ['class' => 'pull-right']); |
||
50 | |||
51 | $titleLink = [ |
||
52 | Html::a($decorator->subject, $model->threadUrl, [ |
||
53 | 'class' => 'text-bold', |
||
54 | 'style' => $model->state === Thread::STATE_CLOSE ? 'color: black !important;' : '', |
||
55 | ]), |
||
56 | Topic::widget(['topics' => $model->topics]), |
||
57 | Html::tag( |
||
58 | 'div', |
||
59 | sprintf('#%s %s %s', |
||
60 | $model->id, |
||
61 | Html::tag('span', Yii::t('hipanel:ticket', $model->state_label), ['class' => 'text-bold']), |
||
62 | Yii::$app->formatter->asDatetime($model->create_time) |
||
63 | ), |
||
64 | ['class' => 'text-muted'] |
||
65 | ), |
||
66 | ]; |
||
67 | |||
68 | return $ava . Html::tag('div', implode('', $titleLink)); |
||
69 | }, |
||
70 | ], |
||
71 | 'author_id' => [ |
||
72 | 'class' => ClientColumn::class, |
||
73 | 'label' => Yii::t('hipanel:ticket', 'Author'), |
||
74 | 'idAttribute' => 'author_id', |
||
75 | 'sortAttribute' => 'author', |
||
76 | 'attribute' => 'author_id', |
||
77 | 'value' => function ($model) { |
||
78 | return ClientSellerLink::widget(compact('model')); |
||
79 | }, |
||
80 | ], |
||
81 | 'responsible_id' => [ |
||
82 | 'class' => ClientColumn::class, |
||
83 | 'idAttribute' => 'responsible_id', |
||
84 | 'sortAttribute' => 'responsible', |
||
85 | 'attribute' => 'responsible_id', |
||
86 | 'clientType' => ['admin', 'seller', 'manager'], |
||
87 | 'value' => function ($model) { |
||
88 | return Html::a($model['responsible'], ['/client/client/view', 'id' => $model->responsible_id]); |
||
89 | }, |
||
90 | 'visible' => Yii::$app->user->can('support'), |
||
91 | ], |
||
92 | 'recipient_id' => [ |
||
93 | 'class' => ClientColumn::class, |
||
94 | 'idAttribute' => 'recipient_id', |
||
95 | 'label' => Yii::t('hipanel:ticket', 'Recipient'), |
||
96 | 'sortAttribute' => 'recipient', |
||
97 | 'attribute' => 'recipient_id', |
||
98 | 'value' => function ($model) { |
||
99 | return Html::a($model->recipient, ['/client/client/view', 'id' => $model->recipient_id]); |
||
100 | }, |
||
101 | 'visible' => Yii::$app->user->can('support'), |
||
102 | ], |
||
103 | 'answer_count' => [ |
||
104 | 'attribute' => 'answer_count', |
||
105 | 'label' => Yii::t('hipanel:ticket', 'Answers'), |
||
106 | 'format' => 'raw', |
||
107 | 'filter' => false, |
||
108 | 'enableSorting' => false, |
||
109 | 'value' => function ($model) { |
||
110 | $lastAnswer = [ |
||
111 | ClientSellerLink::widget([ |
||
112 | 'model' => $model, |
||
113 | 'clientAttribute' => 'replier', |
||
114 | 'clientIdAttribute' => 'replier_id', |
||
115 | 'sellerAttribute' => false, |
||
116 | ]), '<br>', |
||
117 | |||
118 | Html::tag('span', Yii::$app->formatter->asRelativeTime($model->reply_time), [ |
||
119 | 'style' => 'font-size: smaller;white-space: nowrap;', |
||
120 | 'class' => 'text-muted', |
||
121 | ]), ' ', |
||
122 | |||
123 | Html::tag('span', $model->answer_count, [ |
||
124 | 'class' => 'label label-default', |
||
125 | 'title' => Yii::t('hipanel:ticket', |
||
126 | 'Ticket contains {n, plural, one{# answer} other{# answers}}', |
||
127 | ['n' => $model->answer_count] |
||
128 | ), |
||
129 | ]), |
||
130 | ]; |
||
131 | |||
132 | return implode('', $lastAnswer); |
||
133 | }, |
||
134 | 'contentOptions' => [ |
||
135 | 'class' => 'answer', |
||
136 | ], |
||
137 | ], |
||
138 | 'actions' => [ |
||
139 | 'class' => MenuColumn::class, |
||
140 | 'menuClass' => TicketActionsMenu::class, |
||
141 | ], |
||
142 | ]); |
||
143 | } |
||
144 | |||
145 | public function run() |
||
155 | } |
||
156 |