Commit 2de24e5dbb5f8089e4d86be303e7e562618bdb0e
1 parent
51413d10
-Feedback extended and sms log ready for test
Showing
2 changed files
with
38 additions
and
3 deletions
Show diff stats
models/Feedback.php
| @@ -2,6 +2,7 @@ | @@ -2,6 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | namespace artweb\artbox\models; | 3 | namespace artweb\artbox\models; |
| 4 | 4 | ||
| 5 | + use backend\models\User; | ||
| 5 | use Yii; | 6 | use Yii; |
| 6 | use yii\behaviors\AttributeBehavior; | 7 | use yii\behaviors\AttributeBehavior; |
| 7 | use yii\behaviors\TimestampBehavior; | 8 | use yii\behaviors\TimestampBehavior; |
| @@ -14,10 +15,20 @@ | @@ -14,10 +15,20 @@ | ||
| 14 | * @property string $name | 15 | * @property string $name |
| 15 | * @property string $phone | 16 | * @property string $phone |
| 16 | * @property integer $created_at | 17 | * @property integer $created_at |
| 18 | + * @property integer $updated_at | ||
| 17 | * @property string $ip | 19 | * @property string $ip |
| 20 | + * @property integer $status | ||
| 21 | + * @property integer $manager_id | ||
| 22 | + * @property User $manager | ||
| 18 | */ | 23 | */ |
| 19 | class Feedback extends ActiveRecord | 24 | class Feedback extends ActiveRecord |
| 20 | { | 25 | { |
| 26 | + const STATUSES = [ | ||
| 27 | + 0 => 'Новый', | ||
| 28 | + 1 => 'Обрабатывается', | ||
| 29 | + 2 => 'Нет ответа', | ||
| 30 | + 3 => 'Завершен', | ||
| 31 | + ]; | ||
| 21 | 32 | ||
| 22 | const SCENARIO_FEEDBACK = 'feedback'; | 33 | const SCENARIO_FEEDBACK = 'feedback'; |
| 23 | const SCENARIO_CALLBACK = 'callback'; | 34 | const SCENARIO_CALLBACK = 'callback'; |
| @@ -56,8 +67,7 @@ | @@ -56,8 +67,7 @@ | ||
| 56 | { | 67 | { |
| 57 | return [ | 68 | return [ |
| 58 | [ | 69 | [ |
| 59 | - 'class' => TimestampBehavior::className(), | ||
| 60 | - 'updatedAtAttribute' => false, | 70 | + 'class' => TimestampBehavior::className(), |
| 61 | ], | 71 | ], |
| 62 | [ | 72 | [ |
| 63 | 'class' => AttributeBehavior::className(), | 73 | 'class' => AttributeBehavior::className(), |
| @@ -78,6 +88,10 @@ | @@ -78,6 +88,10 @@ | ||
| 78 | { | 88 | { |
| 79 | return [ | 89 | return [ |
| 80 | [ | 90 | [ |
| 91 | + [ 'status' ], | ||
| 92 | + 'integer', | ||
| 93 | + ], | ||
| 94 | + [ | ||
| 81 | [ | 95 | [ |
| 82 | 'phone', | 96 | 'phone', |
| 83 | 'name', | 97 | 'name', |
| @@ -111,6 +125,19 @@ | @@ -111,6 +125,19 @@ | ||
| 111 | 'phone' => Yii::t('app', 'phone'), | 125 | 'phone' => Yii::t('app', 'phone'), |
| 112 | 'created_at' => Yii::t('app', 'created_at'), | 126 | 'created_at' => Yii::t('app', 'created_at'), |
| 113 | 'ip' => Yii::t('app', 'ip'), | 127 | 'ip' => Yii::t('app', 'ip'), |
| 128 | + 'status' => Yii::t('app', 'status'), | ||
| 129 | + 'manager_id' => Yii::t('app', 'manager'), | ||
| 130 | + 'updated_at' => Yii::t('app', 'updated_at'), | ||
| 114 | ]; | 131 | ]; |
| 115 | } | 132 | } |
| 133 | + | ||
| 134 | + /** | ||
| 135 | + * Manager wich first ecited status field | ||
| 136 | + * | ||
| 137 | + * @return \yii\db\ActiveQuery | ||
| 138 | + */ | ||
| 139 | + public function getManager() | ||
| 140 | + { | ||
| 141 | + return $this->hasOne(User::className(), [ 'id' => 'manager_id' ]); | ||
| 142 | + } | ||
| 116 | } | 143 | } |
models/FeedbackSearch.php
| @@ -46,13 +46,21 @@ | @@ -46,13 +46,21 @@ | ||
| 46 | */ | 46 | */ |
| 47 | public function search($params) | 47 | public function search($params) |
| 48 | { | 48 | { |
| 49 | - $query = Feedback::find(); | 49 | + $query = Feedback::find() |
| 50 | + ->orderBy( | ||
| 51 | + [ | ||
| 52 | + 'created_at' => SORT_DESC, | ||
| 53 | + ] | ||
| 54 | + )->with('manager'); | ||
| 50 | 55 | ||
| 51 | // add conditions that should always apply here | 56 | // add conditions that should always apply here |
| 52 | 57 | ||
| 53 | $dataProvider = new ActiveDataProvider( | 58 | $dataProvider = new ActiveDataProvider( |
| 54 | [ | 59 | [ |
| 55 | 'query' => $query, | 60 | 'query' => $query, |
| 61 | + 'pagination' => [ | ||
| 62 | + 'pageSize' => 50, | ||
| 63 | + ], | ||
| 56 | ] | 64 | ] |
| 57 | ); | 65 | ); |
| 58 | 66 |