diff --git a/backend/assets/AdminLteAsset.php b/backend/assets/AdminLteAsset.php index 758a62a..c4a7c67 100755 --- a/backend/assets/AdminLteAsset.php +++ b/backend/assets/AdminLteAsset.php @@ -27,9 +27,9 @@ class AdminLteAsset extends AssetBundle ]; public $depends = [ 'yii\web\YiiAsset', - 'yii\bootstrap\BootstrapAsset', + 'common\modules\file\FileUploadAsset', 'yii\bootstrap\BootstrapPluginAsset', 'backend\assets\FontAwesomeAsset', - 'common\modules\file\FileUploadAsset' + ]; } \ No newline at end of file diff --git a/backend/controllers/OrdersController.php b/backend/controllers/OrdersController.php index 8b284a6..2f03b44 100644 --- a/backend/controllers/OrdersController.php +++ b/backend/controllers/OrdersController.php @@ -2,16 +2,16 @@ namespace backend\controllers; +use backend\models\OrdersSearch; use Yii; use yii\web\Controller; -use yii\filters\AccessControl; use yii\filters\VerbFilter; use yii\data\ActiveDataProvider; use yii\web\HttpException; use backend\models\Orders; use backend\models\OrdersProducts; use common\modules\product\models\ProductVariant; - +use yii\web\NotFoundHttpException; class OrdersController extends Controller @@ -33,29 +33,9 @@ class OrdersController extends Controller public function actionIndex() { - $searchModel = new Orders; - $searchModel->load(Yii::$app->request->queryParams); - $query = Orders::find(); - if(!empty($searchModel->labels))$query->andWhere(['label'=>$searchModel->labels]); - //if(!empty($searchModel->date_time))$query->andFilterWhere(['like', 'date_time', $searchModel->date_time]); - if(!empty($searchModel->username))$query->andFilterWhere(['like', 'username', $searchModel->username]); - if(!empty($searchModel->id))$query->andFilterWhere(['like', 'id', $searchModel->id]); - if(!empty($searchModel->phone))$query->andFilterWhere(['like', 'phone', $searchModel->phone]); - if(!empty($searchModel->name))$query->andFilterWhere(['like', 'name', $searchModel->name]); - if(!empty($searchModel->total))$query->andFilterWhere(['like', 'total', $searchModel->total]); - if(!empty($searchModel->reserve))$query->andFilterWhere(['like', 'reserve', $searchModel->reserve]); - if(!empty($searchModel->status))$query->andFilterWhere(['like', 'status', $searchModel->status]); - -// var_dump($searchModel->name); -// die; - $dataProvider = new ActiveDataProvider([ - 'query' =>$query, - 'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]], - 'pagination' => [ - 'pageSize' => 20, - ], - ]); - + $searchModel = new OrdersSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + return $this->render('index', [ 'dataProvider'=>$dataProvider, 'searchModel'=>$searchModel, @@ -78,7 +58,7 @@ class OrdersController extends Controller $model_orderproducts = new OrdersProducts; - return $this->renderPartial('show', [ + return $this->renderAjax('show', [ 'model' => $model, 'model_orderproducts'=>$model_orderproducts, 'dataProvider' => $dataProvider, @@ -90,14 +70,12 @@ class OrdersController extends Controller $model = Orders::findOne($_POST['order_id']); $model->label = $_POST['label_id']; $model->save(); - Yii::$app->and(); } public function actionPayupdate(){ $model = Orders::findOne($_POST['order_id']); $model->pay = $_POST['pay_id']; $model->save(); - Yii::$app->and(); } public function actionDelete(){ @@ -111,15 +89,15 @@ class OrdersController extends Controller $model = new OrdersProducts; if ($model->load(Yii::$app->request->post())) { - if(!$modelMod = ProductVariant::find()->with(['product'])->where(['sku'=>$model->sku])->one()) - throw new HttpException(404, 'Данного артикля не существует!'); - $model->product_name = $modelMod->product->name; - $model->name = $modelMod->name; - $model->sku = $modelMod->sku; - $model->price = $modelMod->price; - $model->sum_cost = $model->count*$modelMod->price; - $model->mod_id = $modelMod->id; - $model->save(); + if(!$modelMod = ProductVariant::find()->with(['product'])->where(['sku'=>$model->sku])->one()) + throw new HttpException(404, 'Данного артикля не существует!'); + $model->product_name = $modelMod->product->name; + $model->name = $modelMod->name; + $model->sku = $modelMod->sku; + $model->price = $modelMod->price; + $model->sum_cost = $model->count*$modelMod->price; + $model->mod_id = $modelMod->id; + $model->save(); //return Yii::$app->response->redirect(['/admin/orders/show','id'=>$_GET['order_id']]); } diff --git a/backend/models/Orders.php b/backend/models/Orders.php index abfcf55..982e623 100644 --- a/backend/models/Orders.php +++ b/backend/models/Orders.php @@ -16,7 +16,7 @@ class Orders extends \yii\db\ActiveRecord { return [ [['name'], 'required'], - [['user_id','adress','body','total','status','email','patronymic','surname', + [['user_id','adress','body','total','status','email', 'comment','labels','pay','date_dedline','phone','phone2','numbercard','delivery', 'declaration','stock','consignment','payment', 'insurance', 'amount_imposed','shipping_by','city','date_time', 'id' ], 'safe'], @@ -28,31 +28,29 @@ class Orders extends \yii\db\ActiveRecord { return [ 'id'=>'№ заказа', - 'name'=>'Имя', + 'name'=>'ФИО', 'phone'=>'Телефон', - 'phone2'=>'Телефон 2', + 'phone2'=>'Телефон 2', 'adress'=>'Адрес', - 'body'=>'Сообщение', - 'reserve'=>'Резерв', - 'status'=>'Статус', - 'email'=>'E-mail', - 'patronymic'=>'Очество', - 'surname'=>'Фамилия', - 'total'=>'Сумма', - 'labels'=>'Метки', - 'label'=>'Метка', - 'comment'=>'Комментарий менеджера', - 'date_dedline'=>'Дедлайн', - 'numbercard'=>'№ карточки', - 'delivery'=>'Доставка', - 'declaration'=>'Декларация №', - 'stock'=>'№ склада', - 'consignment'=>'№ накладной', - 'payment'=>'Способ оплаты', - 'insurance'=>'Страховка', - 'amount_imposed'=>'Сумма наложенного', - 'shipping_by'=>'Отправка за счет', - 'city'=>'Город' + 'body'=>'Сообщение', + 'reserve'=>'Резерв', + 'status'=>'Статус', + 'email'=>'E-mail', + 'total'=>'Сумма', + 'labels'=>'Метки', + 'label'=>'Метка', + 'comment'=>'Комментарий менеджера', + 'date_dedline'=>'Дедлайн', + 'numbercard'=>'№ карточки', + 'delivery'=>'Доставка', + 'declaration'=>'Декларация №', + 'stock'=>'№ склада', + 'consignment'=>'№ накладной', + 'payment'=>'Способ оплаты', + 'insurance'=>'Страховка', + 'amount_imposed'=>'Сумма наложенного', + 'shipping_by'=>'Отправка за счет', + 'city'=>'Город' ]; } diff --git a/backend/models/OrdersSearch.php b/backend/models/OrdersSearch.php new file mode 100644 index 0000000..5183ad6 --- /dev/null +++ b/backend/models/OrdersSearch.php @@ -0,0 +1,98 @@ + $query, + 'sort'=> ['defaultOrder' => ['id'=>SORT_DESC]], + 'pagination' => [ + 'pageSize' => 20, + ] + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + // grid filtering conditions + $query->andFilterWhere([ + 'id' => $this->id, + 'user_id' => $this->user_id, + 'total' => $this->total, + 'date_time' => $this->date_time, + 'date_dedline' => $this->date_dedline, + 'label' => $this->label, + 'pay' => $this->pay, + 'numbercard' => $this->numbercard, + 'amount_imposed' => $this->amount_imposed, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'phone', $this->phone]) + ->andFilterWhere(['like', 'phone2', $this->phone2]) + ->andFilterWhere(['like', 'email', $this->email]) + ->andFilterWhere(['like', 'adress', $this->adress]) + ->andFilterWhere(['like', 'body', $this->body]) + ->andFilterWhere(['like', 'reserve', $this->reserve]) + ->andFilterWhere(['like', 'status', $this->status]) + ->andFilterWhere(['like', 'comment', $this->comment]) + ->andFilterWhere(['like', 'delivery', $this->delivery]) + ->andFilterWhere(['like', 'declaration', $this->declaration]) + ->andFilterWhere(['like', 'stock', $this->stock]) + ->andFilterWhere(['like', 'consignment', $this->consignment]) + ->andFilterWhere(['like', 'payment', $this->payment]) + ->andFilterWhere(['like', 'insurance', $this->insurance]) + ->andFilterWhere(['like', 'shipping_by', $this->shipping_by]) + ->andFilterWhere(['like', 'city', $this->city]); + + return $dataProvider; + } +} diff --git a/backend/views/event/_form.php b/backend/views/event/_form.php index 12c30c5..51f0b57 100755 --- a/backend/views/event/_form.php +++ b/backend/views/event/_form.php @@ -1,6 +1,6 @@ field($model, 'end_at') ->widget(DatePicker::className(), [ - 'dateFormat' => 'yyyy-MM-dd', - 'clientOptions' => [ 'minDate' => 1 ], - ]) ?> + 'pluginOptions' => [ + 'format' => 'dd-M-yyyy', + 'todayHighlight' => true + ]]) ?> \ No newline at end of file diff --git a/backend/views/layouts/main-sidebar.php b/backend/views/layouts/main-sidebar.php index 463e835..9e7010a 100755 --- a/backend/views/layouts/main-sidebar.php +++ b/backend/views/layouts/main-sidebar.php @@ -4,25 +4,12 @@ use yii\widgets\Menu;