Commit 37c8e2646398c096d83a24837dd5279a3c3ddf3b
1 parent
4f7ef4a2
test
Showing
13 changed files
with
380 additions
and
48 deletions
Show diff stats
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\behaviors\TimestampBehavior; | |
7 | + | |
8 | +/** | |
9 | + * This is the model class for table "feedback_company". | |
10 | + * | |
11 | + * @property integer $feedback_company_id | |
12 | + * @property integer $date_add | |
13 | + * @property string $name | |
14 | + * @property string $phone | |
15 | + * @property string $ip | |
16 | + * @property integer $user_id | |
17 | + * @property integer $status | |
18 | + * | |
19 | + * @property User $user | |
20 | + */ | |
21 | +class FeedbackCompany extends \yii\db\ActiveRecord | |
22 | +{ | |
23 | + /** | |
24 | + * @inheritdoc | |
25 | + */ | |
26 | + public static function tableName() | |
27 | + { | |
28 | + return 'feedback_company'; | |
29 | + } | |
30 | + | |
31 | + /** | |
32 | + * @inheritdoc | |
33 | + */ | |
34 | + public function rules() | |
35 | + { | |
36 | + return [ | |
37 | + [['name', 'phone', 'user_id'], 'required'], | |
38 | + [['user_id'], 'integer'], | |
39 | + [['name', 'phone'], 'string', 'max' => 255], | |
40 | + [['phone'], 'match', 'pattern' => '/^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$/'], | |
41 | + [['user_id'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['user_id' => 'id'], 'filter' => ['type' => 2]], | |
42 | + ]; | |
43 | + } | |
44 | + | |
45 | + /** | |
46 | + * @inheritdoc | |
47 | + */ | |
48 | + public function attributeLabels() | |
49 | + { | |
50 | + return [ | |
51 | + 'feedback_company_id' => 'Feedback Company ID', | |
52 | + 'date_add' => Yii::t('app', 'Feedback date add'), | |
53 | + 'name' => Yii::t('app', 'Feedback name'), | |
54 | + 'phone' => Yii::t('app', 'Feedback phone'), | |
55 | + 'ip' => 'Ip', | |
56 | + 'user_id' => 'User ID', | |
57 | + 'status' => Yii::t('app', 'status'), | |
58 | + ]; | |
59 | + } | |
60 | + | |
61 | + /** | |
62 | + * @inheritdoc | |
63 | + */ | |
64 | + public function behaviors() | |
65 | + { | |
66 | + return [ | |
67 | + [ | |
68 | + 'class' => TimestampBehavior::className(), | |
69 | + 'createdAtAttribute' => 'date_add', | |
70 | + 'updatedAtAttribute' => false, | |
71 | + ], | |
72 | + ]; | |
73 | + } | |
74 | + | |
75 | + /** | |
76 | + * @return \yii\db\ActiveQuery | |
77 | + */ | |
78 | + public function getUser() | |
79 | + { | |
80 | + return $this->hasOne(User::className(), ['id' => 'user_id']); | |
81 | + } | |
82 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | + namespace common\models; | |
4 | + | |
5 | + use Yii; | |
6 | + use yii\data\ActiveDataProvider; | |
7 | + | |
8 | + /** | |
9 | + * FeedbackCompanySearch represents the model behind the search form about | |
10 | + * `common\models\FeedbackCompany`. | |
11 | + */ | |
12 | + class FeedbackCompanySearch extends FeedbackCompany | |
13 | + { | |
14 | + | |
15 | + /** | |
16 | + * @inheritdoc | |
17 | + */ | |
18 | + public function rules() | |
19 | + { | |
20 | + return [ | |
21 | + [ | |
22 | + [ | |
23 | + 'name', | |
24 | + 'date_add', | |
25 | + 'phone', | |
26 | + 'status', | |
27 | + ], | |
28 | + 'safe', | |
29 | + ], | |
30 | + ]; | |
31 | + } | |
32 | + | |
33 | + public function search($params) | |
34 | + { | |
35 | + $query = FeedbackCompany::find(); | |
36 | + | |
37 | + $query->where([ 'user_id' => \Yii::$app->user->id ]); | |
38 | + | |
39 | + $dataProvider = new ActiveDataProvider([ | |
40 | + 'query' => $query, | |
41 | + ]); | |
42 | + | |
43 | + $this->load($params); | |
44 | + | |
45 | + if(!$this->validate()) { | |
46 | + return $dataProvider; | |
47 | + } | |
48 | + | |
49 | + $query->andFilterWhere([ | |
50 | + 'like', | |
51 | + 'LOWER(name)', | |
52 | + mb_strtolower($this->name), | |
53 | + ]) | |
54 | + ->andFilterWhere([ | |
55 | + 'like', | |
56 | + 'LOWER(phone)', | |
57 | + mb_strtolower($this->phone), | |
58 | + ]); | |
59 | + | |
60 | + return $dataProvider; | |
61 | + | |
62 | + } | |
63 | + } | ... | ... |
console/migrations/m160519_124222_create_feedback_company.php
0 → 100644
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +/** | |
6 | + * Handles the creation for table `feedback_company`. | |
7 | + */ | |
8 | +class m160519_124222_create_feedback_company extends Migration | |
9 | +{ | |
10 | + /** | |
11 | + * @inheritdoc | |
12 | + */ | |
13 | + public function up() | |
14 | + { | |
15 | + $this->createTable('feedback_company', [ | |
16 | + 'feedback_company_id' => $this->primaryKey(), | |
17 | + 'date_add' => $this->integer()->notNull(), | |
18 | + 'name' => $this->string()->notNull(), | |
19 | + 'phone' => $this->string()->notNull(), | |
20 | + 'ip' => $this->string()->notNull(), | |
21 | + 'user_id' => $this->integer()->notNull(), | |
22 | + 'status' => $this->integer()->notNull()->defaultValue(1), | |
23 | + ]); | |
24 | + | |
25 | + $this->addForeignKey('feedback_company_user', '{{%feedback_company}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); | |
26 | + } | |
27 | + | |
28 | + /** | |
29 | + * @inheritdoc | |
30 | + */ | |
31 | + public function down() | |
32 | + { | |
33 | + $this->dropForeignKey('feedback_company_user', '{{%feedback_company}}'); | |
34 | + $this->dropTable('feedback_company'); | |
35 | + } | |
36 | +} | ... | ... |
frontend/controllers/AccountsController.php
... | ... | @@ -8,6 +8,8 @@ |
8 | 8 | use common\models\Currency; |
9 | 9 | use common\models\Department; |
10 | 10 | use common\models\Employment; |
11 | + use common\models\FeedbackCompany; | |
12 | + use common\models\FeedbackCompanySearch; | |
11 | 13 | use common\models\Fields; |
12 | 14 | use common\models\File; |
13 | 15 | use common\models\Gallery; |
... | ... | @@ -59,7 +61,6 @@ |
59 | 61 | 'class' => AccessControl::className(), |
60 | 62 | 'rules' => [ |
61 | 63 | [ |
62 | - //'actions' => ['cabinet','change-password', 'bookmarks', 'projects'], | |
63 | 64 | 'allow' => true, |
64 | 65 | 'roles' => [ '@' ], |
65 | 66 | ], |
... | ... | @@ -74,6 +75,7 @@ |
74 | 75 | 'projects-delete' => [ 'POST' ], |
75 | 76 | 'blog-delete' => [ 'POST' ], |
76 | 77 | 'gallery-cover' => [ 'POST' ], |
78 | + 'feedback-delete' => [ 'POST' ], | |
77 | 79 | ], |
78 | 80 | ], |
79 | 81 | ]; |
... | ... | @@ -288,6 +290,42 @@ |
288 | 290 | } |
289 | 291 | |
290 | 292 | /** |
293 | + * Page of Company feedback | |
294 | + * @return string | |
295 | + */ | |
296 | + public function actionFeedbackCompany() | |
297 | + { | |
298 | + $searchModel = new FeedbackCompanySearch(); | |
299 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
300 | + | |
301 | + return $this->render('feedback-company', [ | |
302 | + 'searchModel' => $searchModel, | |
303 | + 'dataProvider' => $dataProvider, | |
304 | + ]); | |
305 | + } | |
306 | + | |
307 | + /** | |
308 | + * Delete company feedback | |
309 | + * @return string | |
310 | + */ | |
311 | + public function actionFeedbackDelete($id) | |
312 | + { | |
313 | + $model = FeedbackCompany::find() | |
314 | + ->where([ | |
315 | + 'feedback_company_id' => $id, | |
316 | + 'user_id' => \Yii::$app->user->id, | |
317 | + ]) | |
318 | + ->one(); | |
319 | + | |
320 | + if(empty($model)) { | |
321 | + throw new NotFoundHttpException('Заявка не найдена'); | |
322 | + } else { | |
323 | + $model->delete(); | |
324 | + return $this->redirect(['accounts/feedback-company']); | |
325 | + } | |
326 | + } | |
327 | + | |
328 | + /** | |
291 | 329 | * Page of User's image galleries |
292 | 330 | * @return string |
293 | 331 | */ | ... | ... |
frontend/controllers/AjaxController.php
... | ... | @@ -2,6 +2,7 @@ |
2 | 2 | namespace frontend\controllers; |
3 | 3 | |
4 | 4 | use common\models\Feedback; |
5 | + use common\models\FeedbackCompany; | |
5 | 6 | use common\models\Portfolio; |
6 | 7 | use common\models\PortfolioUser; |
7 | 8 | use common\models\User; |
... | ... | @@ -188,4 +189,18 @@ |
188 | 189 | return ['error' => 'Error detected', 'result' => ['form' => $form]]; |
189 | 190 | } |
190 | 191 | |
192 | + public function actionFeedbackCompany() | |
193 | + { | |
194 | + $request = \Yii::$app->request; | |
195 | + $response = \Yii::$app->response; | |
196 | + $response->format = $response::FORMAT_JSON; | |
197 | + $model = new FeedbackCompany(['ip' => $request->userIP]); | |
198 | + if($model->load($request->post())) { | |
199 | + if($model->save()) { | |
200 | + return ['result' => ['message' => 'Вопрос успешно отправлен, представители компании свяжутся с Вами в ближайшее время']]; | |
201 | + } | |
202 | + } | |
203 | + return ['error' => 'Ошибка формы']; | |
204 | + } | |
205 | + | |
191 | 206 | } | ... | ... |
frontend/messages/ru/app.php
1 | +<?php | |
2 | + use common\models\FeedbackCompanySearch; | |
3 | + use yii\data\ActiveDataProvider; | |
4 | + use yii\grid\ActionColumn; | |
5 | + use yii\grid\GridView; | |
6 | + use yii\grid\SerialColumn; | |
7 | + use yii\helpers\Html; | |
8 | + use yii\web\View; | |
9 | + | |
10 | + /** | |
11 | + * @var View $this | |
12 | + * @var FeedbackCompanySearch $searchModel | |
13 | + * @var ActiveDataProvider $dataProvider | |
14 | + */ | |
15 | + $this->title = 'Заявки'; | |
16 | + $this->params[ 'breadcrumbs' ][] = $this->title; | |
17 | +?> | |
18 | +<div class="login-left-column-title fix"><?= $this->title ?></div> | |
19 | +<div class="admin-table-portfolio"> | |
20 | + <?= GridView::widget([ | |
21 | + 'options' => [ 'class' => 'style admin-all-pages-wr fix_last_td_' ], | |
22 | + 'dataProvider' => $dataProvider, | |
23 | + 'filterModel' => $searchModel, | |
24 | + 'columns' => [ | |
25 | + [ 'class' => SerialColumn::className() ], | |
26 | + [ | |
27 | + 'attribute' => 'date_add', | |
28 | + 'value' => function($model, $key) { | |
29 | + return date('Y-m-d H:i:s', $model->date_add); | |
30 | + } | |
31 | + ], | |
32 | + [ | |
33 | + 'attribute' => 'name', | |
34 | + 'label' => 'Имя и фамилия', | |
35 | + ], | |
36 | + 'phone', | |
37 | + [ | |
38 | + 'attribute' => 'status', | |
39 | + ], | |
40 | + [ | |
41 | + 'class' => ActionColumn::className(), | |
42 | + 'buttons' => [ | |
43 | + 'delete' => function($url, $model, $key) { | |
44 | + return Html::a(Html::tag('span', '', [ | |
45 | + 'class' => 'glyphicon glyphicon-trash', | |
46 | + ]), [ | |
47 | + 'accounts/feedback-delete', | |
48 | + 'id' => $model->feedback_company_id, | |
49 | + ], [ | |
50 | + 'title' => 'Удалить', | |
51 | + 'aria-label' => 'Удалить', | |
52 | + 'data-confirm' => 'Вы уверены, что хотите удалить данную заявку?', | |
53 | + 'data-method' => 'post', | |
54 | + 'data-pjax' => 0, | |
55 | + ]); | |
56 | + }, | |
57 | + ], | |
58 | + 'template' => '{delete}', | |
59 | + ], | |
60 | + ], | |
61 | + ]); ?> | |
62 | +</div> | ... | ... |
1 | +<?php | |
2 | + /** | |
3 | + * @var User $company | |
4 | + * @var User $user | |
5 | + * @var View $this | |
6 | + */ | |
7 | + use common\models\FeedbackCompany; | |
8 | + use common\models\User; | |
9 | + use yii\helpers\Html; | |
10 | + use yii\web\View; | |
11 | + use yii\widgets\ActiveForm; | |
12 | + | |
13 | + $user = \Yii::$app->user->identity; | |
14 | + $model = new FeedbackCompany([ 'user_id' => $company->id ]); | |
15 | + if(!empty( $user )) { | |
16 | + $model->name = $user->name; | |
17 | + $phones = $user->getPhones(); | |
18 | + if(!empty( $phones )) { | |
19 | + $model->phone = $phones[ 1 ][ 'phone' ]; | |
20 | + } | |
21 | + } | |
22 | +?> | |
23 | + <div class="performance-vacancy-call-back"> | |
24 | + <div class="performance-vacancy-call-back-title">Оставьте заявку<br/>и мы вам перезвоним | |
25 | + </div> | |
26 | + <?php | |
27 | + $form = ActiveForm::begin([ | |
28 | + 'action' => [ 'ajax/feedback-company' ], | |
29 | + 'method' => 'POST', | |
30 | + 'options' => [ 'class' => 'callback' ], | |
31 | + ]); | |
32 | + echo $form->field($model, 'user_id') | |
33 | + ->label(false) | |
34 | + ->hiddenInput(); | |
35 | + echo $form->field($model, 'name', [ 'options' => [ 'class' => 'input-blocks-wrapper' ] ]) | |
36 | + ->textInput([ 'placeholder' => 'Иванов Иван' ]); | |
37 | + echo $form->field($model, 'phone', [ 'options' => [ 'class' => 'input-blocks-wrapper' ] ]) | |
38 | + ->textInput([ 'placeholder' => '+38(093)111-11-11' ]); | |
39 | + echo Html::submitInput('Перезвонить мне', [ 'id' => 'feedback_company_submit' ]); | |
40 | + $form->end(); | |
41 | + ?> | |
42 | + <div class="performance-vacancy-call-back-conf">Гарантируем конфидециальность</div> | |
43 | + </div> | |
44 | +<?php | |
45 | + $js = " | |
46 | + $(document).on('click', '#feedback_company_submit', function(e) { | |
47 | + e.preventDefault(); | |
48 | + var form = $(this).parents('form'); | |
49 | + var action = $(form).attr('action'); | |
50 | + var id = $(form).attr('id'); | |
51 | + $('#'+id).data('yiiActiveForm').submitting = true; | |
52 | + $('#'+id).yiiActiveForm('validate'); | |
53 | + if($(form).find('.input-blocks-wrapper.has-error').length <= 0) { | |
54 | + $.post(action, $(form).serialize(), function(data) { | |
55 | + if(data.error) { | |
56 | + alert(data.error); | |
57 | + } else { | |
58 | + alert(data.result.message); | |
59 | + document.getElementById(id).reset(); | |
60 | + } | |
61 | + }); | |
62 | + } | |
63 | + }); | |
64 | + "; | |
65 | + $this->registerJs($js); | |
66 | +?> | |
0 | 67 | \ No newline at end of file | ... | ... |
frontend/views/layouts/admin.php
... | ... | @@ -110,6 +110,9 @@ |
110 | 110 | 'label' => 'Вакансии', |
111 | 111 | 'url' => [ 'accounts/vacancy' ], |
112 | 112 | 'active' => preg_match('/^vacancy.*$/', $this->context->action->id) ? true : false, |
113 | + ], [ | |
114 | + 'label' => 'Заявки', | |
115 | + 'url' => [ 'accounts/feedback-company' ], | |
113 | 116 | ]); |
114 | 117 | |
115 | 118 | } | ... | ... |
frontend/views/layouts/company.php
... | ... | @@ -19,27 +19,9 @@ |
19 | 19 | <div class="box-all"> |
20 | 20 | <?php |
21 | 21 | if($this->params[ 'company' ]->id != \Yii::$app->user->getId()) { |
22 | - ?> | |
23 | - <div class="performance-vacancy-call-back"> | |
24 | - <div class="performance-vacancy-call-back-title">Оставьте заявку<br/>и мы вам перезвоним | |
25 | - </div> | |
26 | - <form class="callback" action=""> | |
27 | - | |
28 | - <div class="input-blocks-wrapper"> | |
29 | - <label for="callbac_name">Имя</label> | |
30 | - <input id="callbac_name" type="text"/> | |
31 | - </div> | |
32 | - | |
33 | - <div class="input-blocks-wrapper"> | |
34 | - <label for="callbac_phone">Телефон</label> | |
35 | - <input id="callbac_phone" type="text"/> | |
36 | - </div> | |
37 | - | |
38 | - <input id="callbac_submit" type="submit" value="Перезвонить мне"/> | |
39 | - </form> | |
40 | - <div class="performance-vacancy-call-back-conf">Гарантируем конфидециальность</div> | |
41 | - </div> | |
42 | - <?php | |
22 | + // Форма "оставить заявку" | |
23 | + echo $this->render('//company/_feedback_company', ['company' => $this->params['company']]); | |
24 | + // Конец формы "оставить заявку" | |
43 | 25 | if(!empty( \Yii::$app->user->identity )) { |
44 | 26 | ?> |
45 | 27 | <div class="performance-vacancy-add-favorite"> | ... | ... |
frontend/views/layouts/gallery-company.php
... | ... | @@ -16,27 +16,9 @@ |
16 | 16 | <div class="box-all"> |
17 | 17 | <?php |
18 | 18 | if($this->params[ 'company' ]->id != \Yii::$app->user->getId()) { |
19 | - ?> | |
20 | - <div class="performance-vacancy-call-back"> | |
21 | - <div class="performance-vacancy-call-back-title">Оставьте заявку<br/>и мы вам перезвоним | |
22 | - </div> | |
23 | - <form class="callback" action=""> | |
24 | - | |
25 | - <div class="input-blocks-wrapper"> | |
26 | - <label for="callbac_name">Имя</label> | |
27 | - <input id="callbac_name" type="text"/> | |
28 | - </div> | |
29 | - | |
30 | - <div class="input-blocks-wrapper"> | |
31 | - <label for="callbac_phone">Телефон</label> | |
32 | - <input id="callbac_phone" type="text"/> | |
33 | - </div> | |
34 | - | |
35 | - <input id="callbac_submit" type="submit" value="Перезвонить мне"/> | |
36 | - </form> | |
37 | - <div class="performance-vacancy-call-back-conf">Гарантируем конфидециальность</div> | |
38 | - </div> | |
39 | - <?php | |
19 | + // Форма "оставить заявку" | |
20 | + echo $this->render('//company/_feedback_company', ['company' => $this->params['company']]); | |
21 | + // Конец формы "оставить заявку" | |
40 | 22 | if(!empty( \Yii::$app->user->identity )) { |
41 | 23 | ?> |
42 | 24 | <div class="performance-vacancy-add-favorite"> | ... | ... |
frontend/views/search/project.php
... | ... | @@ -117,7 +117,7 @@ |
117 | 117 | </div> |
118 | 118 | <div> |
119 | 119 | <?php |
120 | - /* Временно убираем карту 17.05.2016 | |
120 | + | |
121 | 121 | ?> |
122 | 122 | <div class="section-box" style="height: 720px; overflow: hidden"> |
123 | 123 | <div class="map-settings-opacity"></div> |
... | ... | @@ -303,7 +303,7 @@ |
303 | 303 | </div> |
304 | 304 | <div id="map_canvas" style="width: 100%; height:100%;"></div> |
305 | 305 | <?php |
306 | - */ | |
306 | + | |
307 | 307 | /* Решено убрать нижний слайдер |
308 | 308 | ?> |
309 | 309 | <div class="slider_map-wr"> | ... | ... |
frontend/web/css/style.css
... | ... | @@ -2925,7 +2925,6 @@ input[type=file]::-webkit-file-upload-button { |
2925 | 2925 | .company-performer-comments-bl .rating { |
2926 | 2926 | padding-left: 0; |
2927 | 2927 | margin-left: -4px; |
2928 | - width: 2000px; | |
2929 | 2928 | overflow: hidden |
2930 | 2929 | } |
2931 | 2930 | |
... | ... | @@ -7846,10 +7845,14 @@ input.disabled.admin-check:checked + label, input.disabled.admin-check:checked + |
7846 | 7845 | background: #fff |
7847 | 7846 | } |
7848 | 7847 | |
7849 | -.field_list .help-block, .admin-avatar .help-block { | |
7848 | +.field_list .help-block, .admin-avatar .help-block, .performance-vacancy-call-back .help-block { | |
7850 | 7849 | float: left; |
7851 | 7850 | } |
7852 | 7851 | |
7852 | +.performance-vacancy-call-back .help-block { | |
7853 | + width: auto; | |
7854 | +} | |
7855 | + | |
7853 | 7856 | .help-block:before { |
7854 | 7857 | content: ''; |
7855 | 7858 | width: 20px; | ... | ... |