Commit 713ccea42a2a0618753db6f55cf5d6b3fa95fc15
1 parent
8f1a5501
test
Showing
8 changed files
with
170 additions
and
12 deletions
Show diff stats
common/models/FeedbackCompany.php
@@ -20,6 +20,9 @@ use yii\behaviors\TimestampBehavior; | @@ -20,6 +20,9 @@ use yii\behaviors\TimestampBehavior; | ||
20 | */ | 20 | */ |
21 | class FeedbackCompany extends \yii\db\ActiveRecord | 21 | class FeedbackCompany extends \yii\db\ActiveRecord |
22 | { | 22 | { |
23 | + | ||
24 | + const STATUS_NEW = 1; | ||
25 | + const STATUS_READ = 2; | ||
23 | /** | 26 | /** |
24 | * @inheritdoc | 27 | * @inheritdoc |
25 | */ | 28 | */ |
common/models/FeedbackCompanySearch.php
@@ -12,6 +12,10 @@ | @@ -12,6 +12,10 @@ | ||
12 | class FeedbackCompanySearch extends FeedbackCompany | 12 | class FeedbackCompanySearch extends FeedbackCompany |
13 | { | 13 | { |
14 | 14 | ||
15 | + public $date_add_from; | ||
16 | + | ||
17 | + public $date_add_to; | ||
18 | + | ||
15 | /** | 19 | /** |
16 | * @inheritdoc | 20 | * @inheritdoc |
17 | */ | 21 | */ |
@@ -23,10 +27,21 @@ | @@ -23,10 +27,21 @@ | ||
23 | 'name', | 27 | 'name', |
24 | 'date_add', | 28 | 'date_add', |
25 | 'phone', | 29 | 'phone', |
26 | - 'status', | 30 | + 'date_add_from', |
31 | + 'date_add_to', | ||
27 | ], | 32 | ], |
28 | 'safe', | 33 | 'safe', |
29 | ], | 34 | ], |
35 | + [ | ||
36 | + [ 'status' ], | ||
37 | + 'integer', | ||
38 | + ], | ||
39 | + [ | ||
40 | + 'date_add_to', | ||
41 | + 'compare', | ||
42 | + 'compareAttribute' => 'date_add_from', | ||
43 | + 'operator' => '>=', | ||
44 | + ], | ||
30 | ]; | 45 | ]; |
31 | } | 46 | } |
32 | 47 | ||
@@ -55,7 +70,37 @@ | @@ -55,7 +70,37 @@ | ||
55 | 'like', | 70 | 'like', |
56 | 'LOWER(phone)', | 71 | 'LOWER(phone)', |
57 | mb_strtolower($this->phone), | 72 | mb_strtolower($this->phone), |
58 | - ]); | 73 | + ]) |
74 | + ->andFilterWhere([ 'status' => $this->status ]); | ||
75 | + | ||
76 | + $date_add_from = $this->date_add_from; | ||
77 | + $date_add_to = $this->date_add_to; | ||
78 | + if(!empty( $date_add_from )) { | ||
79 | + $date_add_from = strtotime($date_add_from); | ||
80 | + } | ||
81 | + if(!empty( $date_add_to )) { | ||
82 | + $date_add_to = strtotime($date_add_to) + 86400; | ||
83 | + } | ||
84 | + if(!empty( $date_add_from ) && !empty( $date_add_to )) { | ||
85 | + $query->andWhere([ | ||
86 | + 'between', | ||
87 | + 'date_add', | ||
88 | + $date_add_from, | ||
89 | + $date_add_to, | ||
90 | + ]); | ||
91 | + } elseif(!empty( $date_add_from )) { | ||
92 | + $query->andWhere([ | ||
93 | + '>=', | ||
94 | + 'date_add', | ||
95 | + $date_add_from, | ||
96 | + ]); | ||
97 | + } elseif(!empty( $date_add_to )) { | ||
98 | + $query->andWhere([ | ||
99 | + '<=', | ||
100 | + 'date_add', | ||
101 | + $date_add_to, | ||
102 | + ]); | ||
103 | + } | ||
59 | 104 | ||
60 | return $dataProvider; | 105 | return $dataProvider; |
61 | 106 |
common/modules/fileloader/models/Fileloader.php
@@ -46,6 +46,7 @@ class Fileloader extends \yii\db\ActiveRecord | @@ -46,6 +46,7 @@ class Fileloader extends \yii\db\ActiveRecord | ||
46 | public function rules() | 46 | public function rules() |
47 | { | 47 | { |
48 | return [ | 48 | return [ |
49 | + [['files'], 'file', 'maxSize' => 5242880], | ||
49 | [['status'], 'integer'], | 50 | [['status'], 'integer'], |
50 | [['name'], 'string', 'max' => 50], | 51 | [['name'], 'string', 'max' => 50], |
51 | [['dir'], 'string', 'max' => 255], | 52 | [['dir'], 'string', 'max' => 255], |
common/modules/fileloader/resources/handler.js
@@ -37,7 +37,6 @@ $(function() { | @@ -37,7 +37,6 @@ $(function() { | ||
37 | } | 37 | } |
38 | }); | 38 | }); |
39 | } | 39 | } |
40 | - | ||
41 | $(document).on('click', '.fileloader-item-remove', function(e) { | 40 | $(document).on('click', '.fileloader-item-remove', function(e) { |
42 | var wrapper = $(this).parents('.fileloader-item-wrapper').first(); | 41 | var wrapper = $(this).parents('.fileloader-item-wrapper').first(); |
43 | var id = $(wrapper).data('id'); | 42 | var id = $(wrapper).data('id'); |
frontend/controllers/AccountsController.php
@@ -42,6 +42,7 @@ | @@ -42,6 +42,7 @@ | ||
42 | use yii\filters\VerbFilter; | 42 | use yii\filters\VerbFilter; |
43 | use yii\web\Controller; | 43 | use yii\web\Controller; |
44 | use yii\web\NotFoundHttpException; | 44 | use yii\web\NotFoundHttpException; |
45 | + use yii\web\Response; | ||
45 | use yii\web\UploadedFile; | 46 | use yii\web\UploadedFile; |
46 | 47 | ||
47 | /** | 48 | /** |
@@ -76,6 +77,7 @@ | @@ -76,6 +77,7 @@ | ||
76 | 'blog-delete' => [ 'POST' ], | 77 | 'blog-delete' => [ 'POST' ], |
77 | 'gallery-cover' => [ 'POST' ], | 78 | 'gallery-cover' => [ 'POST' ], |
78 | 'feedback-delete' => [ 'POST' ], | 79 | 'feedback-delete' => [ 'POST' ], |
80 | + 'feedback-read' => [ 'POST' ], | ||
79 | ], | 81 | ], |
80 | ], | 82 | ], |
81 | ]; | 83 | ]; |
@@ -89,7 +91,14 @@ | @@ -89,7 +91,14 @@ | ||
89 | 'status' => 2, | 91 | 'status' => 2, |
90 | ]) | 92 | ]) |
91 | ->count(); | 93 | ->count(); |
94 | + $feedback_company_count = FeedbackCompany::find() | ||
95 | + ->where([ | ||
96 | + 'user_id' => \Yii::$app->user->id, | ||
97 | + 'status' => FeedbackCompany::STATUS_NEW, | ||
98 | + ]) | ||
99 | + ->count(); | ||
92 | $this->view->params[ 'portfolio_user_count' ] = $portfolio_user_count; | 100 | $this->view->params[ 'portfolio_user_count' ] = $portfolio_user_count; |
101 | + $this->view->params[ 'feedback_company_count' ] = $feedback_company_count; | ||
93 | return parent::beforeAction($action); // TODO: Change the autogenerated stub | 102 | return parent::beforeAction($action); // TODO: Change the autogenerated stub |
94 | } | 103 | } |
95 | 104 | ||
@@ -297,6 +306,15 @@ | @@ -297,6 +306,15 @@ | ||
297 | { | 306 | { |
298 | $searchModel = new FeedbackCompanySearch(); | 307 | $searchModel = new FeedbackCompanySearch(); |
299 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | 308 | $dataProvider = $searchModel->search(Yii::$app->request->queryParams); |
309 | + $dataProvider->pagination = [ | ||
310 | + 'pageSize' => 20, | ||
311 | + ]; | ||
312 | + $dataProvider->sort = new Sort([ | ||
313 | + 'defaultOrder' => [ | ||
314 | + 'status' => SORT_ASC, | ||
315 | + 'date_add' => SORT_DESC, | ||
316 | + ], | ||
317 | + ]); | ||
300 | 318 | ||
301 | return $this->render('feedback-company', [ | 319 | return $this->render('feedback-company', [ |
302 | 'searchModel' => $searchModel, | 320 | 'searchModel' => $searchModel, |
@@ -306,7 +324,12 @@ | @@ -306,7 +324,12 @@ | ||
306 | 324 | ||
307 | /** | 325 | /** |
308 | * Delete company feedback | 326 | * Delete company feedback |
309 | - * @return string | 327 | + * |
328 | + * @param int $id | ||
329 | + * | ||
330 | + * @return Response | ||
331 | + * @throws NotFoundHttpException | ||
332 | + * @throws \Exception | ||
310 | */ | 333 | */ |
311 | public function actionFeedbackDelete($id) | 334 | public function actionFeedbackDelete($id) |
312 | { | 335 | { |
@@ -317,11 +340,41 @@ | @@ -317,11 +340,41 @@ | ||
317 | ]) | 340 | ]) |
318 | ->one(); | 341 | ->one(); |
319 | 342 | ||
320 | - if(empty($model)) { | 343 | + if(empty( $model )) { |
321 | throw new NotFoundHttpException('Заявка не найдена'); | 344 | throw new NotFoundHttpException('Заявка не найдена'); |
322 | } else { | 345 | } else { |
323 | $model->delete(); | 346 | $model->delete(); |
324 | - return $this->redirect(['accounts/feedback-company']); | 347 | + return $this->redirect([ 'accounts/feedback-company' ]); |
348 | + } | ||
349 | + } | ||
350 | + | ||
351 | + /** | ||
352 | + * Mark feedback as read | ||
353 | + * | ||
354 | + * @param int $id | ||
355 | + * | ||
356 | + * @return Response | ||
357 | + * @throws NotFoundHttpException | ||
358 | + */ | ||
359 | + public function actionFeedbackRead($id) | ||
360 | + { | ||
361 | + $model = FeedbackCompany::find() | ||
362 | + ->where([ | ||
363 | + 'feedback_company_id' => $id, | ||
364 | + 'user_id' => \Yii::$app->user->id, | ||
365 | + ]) | ||
366 | + ->andWhere([ | ||
367 | + 'not', | ||
368 | + [ 'status' => FeedbackCompany::STATUS_READ ], | ||
369 | + ]) | ||
370 | + ->one(); | ||
371 | + | ||
372 | + if(empty( $model )) { | ||
373 | + throw new NotFoundHttpException('Заявка не найдена'); | ||
374 | + } else { | ||
375 | + $model->status = FeedbackCompany::STATUS_READ; | ||
376 | + $model->save(false); | ||
377 | + return $this->redirect([ 'accounts/feedback-company' ]); | ||
325 | } | 378 | } |
326 | } | 379 | } |
327 | 380 |
frontend/views/accounts/feedback-company.php
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | use yii\grid\GridView; | 5 | use yii\grid\GridView; |
6 | use yii\grid\SerialColumn; | 6 | use yii\grid\SerialColumn; |
7 | use yii\helpers\Html; | 7 | use yii\helpers\Html; |
8 | + use yii\jui\DatePicker; | ||
8 | use yii\web\View; | 9 | use yii\web\View; |
9 | 10 | ||
10 | /** | 11 | /** |
@@ -25,17 +26,52 @@ | @@ -25,17 +26,52 @@ | ||
25 | [ 'class' => SerialColumn::className() ], | 26 | [ 'class' => SerialColumn::className() ], |
26 | [ | 27 | [ |
27 | 'attribute' => 'date_add', | 28 | 'attribute' => 'date_add', |
28 | - 'value' => function($model, $key) { | 29 | + 'filter' => "<div class=\"input-group input-group-xs input-daterange\"> |
30 | +<span class='field-teamsearch-experience_from_from'>" . DatePicker::widget([ | ||
31 | + 'model' => $searchModel, | ||
32 | + 'attribute' => 'date_add_from', | ||
33 | + 'language' => 'ru', | ||
34 | + 'dateFormat' => 'yyyy-MM-dd', | ||
35 | + 'clientOptions' => [ | ||
36 | + 'changeYear' => true, | ||
37 | + 'changeMonth' => true, | ||
38 | + 'maxDate' => ($searchModel->date_add_to?:date('Y-m-d')), | ||
39 | + ], | ||
40 | + ]) . "</span> | ||
41 | +<span class=\"input-group-addon kv-field-separator\"> | ||
42 | +<i class=\"glyphicon glyphicon-resize-horizontal\"></i> | ||
43 | +</span> | ||
44 | +<span class='field-teamsearch-experience_from_to'>" . DatePicker::widget([ | ||
45 | + 'model' => $searchModel, | ||
46 | + 'attribute' => 'date_add_to', | ||
47 | + 'language' => 'ru', | ||
48 | + 'dateFormat' => 'yyyy-MM-dd', | ||
49 | + 'clientOptions' => [ | ||
50 | + 'changeYear' => true, | ||
51 | + 'changeMonth' => true, | ||
52 | + 'minDate' => $searchModel->date_add_from, | ||
53 | + 'maxDate' => date('Y-m-d'), | ||
54 | + ], | ||
55 | + ]) . "</span> | ||
56 | +</div>", | ||
57 | + 'value' => function($model, $key) { | ||
29 | return date('Y-m-d H:i:s', $model->date_add); | 58 | return date('Y-m-d H:i:s', $model->date_add); |
30 | - } | 59 | + }, |
31 | ], | 60 | ], |
32 | [ | 61 | [ |
33 | 'attribute' => 'name', | 62 | 'attribute' => 'name', |
34 | - 'label' => 'Имя и фамилия', | 63 | + 'label' => 'Имя и фамилия', |
35 | ], | 64 | ], |
36 | 'phone', | 65 | 'phone', |
37 | [ | 66 | [ |
38 | 'attribute' => 'status', | 67 | 'attribute' => 'status', |
68 | + 'filter' => [ | ||
69 | + 1 => 'Только непрочитанные', | ||
70 | + ], | ||
71 | + 'filterInputOptions' => [ | ||
72 | + 'prompt' => 'Все записи', | ||
73 | + 'class' => 'form-control', | ||
74 | + ], | ||
39 | ], | 75 | ], |
40 | [ | 76 | [ |
41 | 'class' => ActionColumn::className(), | 77 | 'class' => ActionColumn::className(), |
@@ -54,8 +90,26 @@ | @@ -54,8 +90,26 @@ | ||
54 | 'data-pjax' => 0, | 90 | 'data-pjax' => 0, |
55 | ]); | 91 | ]); |
56 | }, | 92 | }, |
93 | + 'read' => function($url, $model, $key) { | ||
94 | + if($model->status == $model::STATUS_NEW) { | ||
95 | + return Html::a(Html::tag('span', '', [ | ||
96 | + 'class' => 'glyphicon glyphicon-ok', | ||
97 | + ]), [ | ||
98 | + 'accounts/feedback-read', | ||
99 | + 'id' => $model->feedback_company_id, | ||
100 | + ], [ | ||
101 | + 'title' => 'Прочесть', | ||
102 | + 'aria-label' => 'Прочесть', | ||
103 | + 'data-confirm' => 'Вы уверены, что хотите отметить заявку прочтенной?', | ||
104 | + 'data-method' => 'post', | ||
105 | + 'data-pjax' => 0, | ||
106 | + ]); | ||
107 | + } else { | ||
108 | + return false; | ||
109 | + } | ||
110 | + }, | ||
57 | ], | 111 | ], |
58 | - 'template' => '{delete}', | 112 | + 'template' => '{read}{delete}', |
59 | ], | 113 | ], |
60 | ], | 114 | ], |
61 | ]); ?> | 115 | ]); ?> |
frontend/views/company/portfolio-view.php
@@ -121,7 +121,9 @@ | @@ -121,7 +121,9 @@ | ||
121 | <?php | 121 | <?php |
122 | foreach($portfolio->ShowGallery($portfolio->gallery->photo) as $one_photo) { | 122 | foreach($portfolio->ShowGallery($portfolio->gallery->photo) as $one_photo) { |
123 | ?> | 123 | ?> |
124 | - <li><img src="<?= $one_photo ?>" alt=""/></li> | 124 | + <li> |
125 | + <img src="<?= $portfolio->minImg($one_photo, 210, 150) ?>" alt=""/> | ||
126 | + </li> | ||
125 | <?php | 127 | <?php |
126 | } | 128 | } |
127 | ?> | 129 | ?> |
frontend/views/layouts/admin.php
@@ -111,8 +111,9 @@ | @@ -111,8 +111,9 @@ | ||
111 | 'url' => [ 'accounts/vacancy' ], | 111 | 'url' => [ 'accounts/vacancy' ], |
112 | 'active' => preg_match('/^vacancy.*$/', $this->context->action->id) ? true : false, | 112 | 'active' => preg_match('/^vacancy.*$/', $this->context->action->id) ? true : false, |
113 | ], [ | 113 | ], [ |
114 | - 'label' => 'Заявки', | 114 | + 'label' => "Заявки <span class='ico_num'>{$this->params['feedback_company_count']}</span>", |
115 | 'url' => [ 'accounts/feedback-company' ], | 115 | 'url' => [ 'accounts/feedback-company' ], |
116 | + 'encode' => false, | ||
116 | ]); | 117 | ]); |
117 | 118 | ||
118 | } | 119 | } |