diff --git a/models/Order.php b/models/Order.php index f75134c..0f7d256 100755 --- a/models/Order.php +++ b/models/Order.php @@ -5,13 +5,14 @@ use Yii; use yii\behaviors\TimestampBehavior; use yii\db\ActiveRecord; - + /** * This is the model class for table "order". * * @property integer $id * @property integer $user_id * @property string $name + * @property string $secondname * @property string $phone * @property string $email * @property string $city @@ -38,7 +39,7 @@ { return 'order'; } - + public function behaviors() { return [ @@ -136,7 +137,7 @@ 'created_at' => Yii::t('order', 'Created At'), 'updated_at' => Yii::t('order', 'Updated At'), 'deleted_at' => Yii::t('order', 'Deleted At'), - 'secondname' => \Yii::t('order', 'Фамилия'), + 'secondname' => \Yii::t('order', 'Фамилия'), ]; } @@ -179,7 +180,7 @@ { return $this->hasMany(OrderProduct::className(), [ 'order_id' => 'id' ]); } - + public function getCustomer() { return $this->hasOne(Customer::className(), [ 'id' => 'user_id' ]); diff --git a/models/OrderProduct.php b/models/OrderProduct.php index 21c4a9b..28f3261 100755 --- a/models/OrderProduct.php +++ b/models/OrderProduct.php @@ -171,6 +171,7 @@ } } $orderProducts = array_merge($orderProducts, $newItems); + foreach ($orderProducts as $orderProduct) { $orderProduct->save(); } diff --git a/models/OrderSearch.php b/models/OrderSearch.php index 6137063..7c24595 100755 --- a/models/OrderSearch.php +++ b/models/OrderSearch.php @@ -21,7 +21,7 @@ return [ [ [ - 'id', + // 'id', 'user_id', 'label_id', ], @@ -30,6 +30,7 @@ [ [ 'name', + 'secondname', 'phone', 'email', ], @@ -65,12 +66,7 @@ 'count(*)', ] ) - ->groupBy('order.id') - ->orderBy( - [ - 'order.id' => SORT_DESC, - ] - ); + ->groupBy('order.id'); // add conditions that should always apply here @@ -78,16 +74,20 @@ [ 'query' => $query, 'sort' => [ - 'attributes' => [ + 'attributes' => [ 'count', 'id', 'user_id', 'name', + 'secondname', 'label_id', 'created_at', 'phone', 'email', ], + 'defaultOrder' => [ + 'created_at' => SORT_DESC, + ], ], ] ); @@ -103,7 +103,7 @@ // grid filtering conditions $query->andFilterWhere( [ - 'id' => $this->id, + // 'id' => $this->id, 'user_id' => $this->user_id, 'label_id' => $this->label_id, 'delivery_id' => $this->delivery_id, @@ -117,13 +117,20 @@ $query->andFilterWhere( [ - 'like', + 'ilike', 'name', $this->name, ] ) ->andFilterWhere( [ + 'ilike', + 'secondname', + $this->secondname, + ] + ) + ->andFilterWhere( + [ 'like', 'phone', $this->phone, @@ -131,28 +138,28 @@ ) ->andFilterWhere( [ - 'like', + 'ilike', 'email', $this->email, ] ) ->andFilterWhere( [ - 'like', + 'ilike', 'city', $this->city, ] ) ->andFilterWhere( [ - 'like', + 'ilike', 'address', $this->address, ] ) ->andFilterWhere( [ - 'like', + 'ilike', 'comment', $this->comment, ] diff --git a/views/order/_form.php b/views/order/_form.php index eb58a30..a236734 100755 --- a/views/order/_form.php +++ b/views/order/_form.php @@ -58,43 +58,6 @@ ->dropDownList($payments) ?>