diff --git a/backend/controllers/ImportersController.php b/backend/controllers/ImportersController.php new file mode 100644 index 0000000..8d9dd30 --- /dev/null +++ b/backend/controllers/ImportersController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Importers models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ImportersSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Importers model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Importers model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Importers(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Importers model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + */ + public function actionUpdate($id) + { + $model = $this->findModel($id); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Importers model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + */ + public function actionDelete($id) + { + $this->findModel($id)->delete(); + + return $this->redirect(['index']); + } + + /** + * Finds the Importers model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Importers the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Importers::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/ImportersSearch.php b/backend/models/ImportersSearch.php new file mode 100644 index 0000000..493184c --- /dev/null +++ b/backend/models/ImportersSearch.php @@ -0,0 +1,87 @@ + $query, + ]); + + $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; + } + + $query->andFilterWhere([ + 'id' => $this->id, + 'currency_id' => $this->currency_id, + 'active' => $this->active, + 'PARSER_IS_ACTIVE' => $this->PARSER_IS_ACTIVE, + 'PARSER_COLUMN_COUNT' => $this->PARSER_COLUMN_COUNT, + 'PARSER_FIELD_BRAND' => $this->PARSER_FIELD_BRAND, + 'PARSER_FIELD_ARTICLE' => $this->PARSER_FIELD_ARTICLE, + 'PARSER_FIELD_ARTICLE_PREFIX' => $this->PARSER_FIELD_ARTICLE_PREFIX, + 'PARSER_FIELD_PRICE' => $this->PARSER_FIELD_PRICE, + 'PARSER_FIELD_DESCR' => $this->PARSER_FIELD_DESCR, + 'PARSER_FIELD_BOX' => $this->PARSER_FIELD_BOX, + 'PARSER_FIELD_ADD_BOX' => $this->PARSER_FIELD_ADD_BOX, + 'PARSER_FIELD_GROUP_RG' => $this->PARSER_FIELD_GROUP_RG, + 'PARSER_FIELD_MULTIPLIER' => $this->PARSER_FIELD_MULTIPLIER, + 'price_date_update' => $this->price_date_update, + ]); + + $query->andFilterWhere(['like', 'code', $this->code]) + ->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'name_price', $this->name_price]) + ->andFilterWhere(['like', 'delivery', $this->delivery]) + ->andFilterWhere(['like', 'email', $this->email]) + ->andFilterWhere(['like', 'info', $this->info]) + ->andFilterWhere(['like', 'PARSER_FIELD_SIGN', $this->PARSER_FIELD_SIGN]); + + return $dataProvider; + } +} diff --git a/backend/views/importers/_form.php b/backend/views/importers/_form.php new file mode 100644 index 0000000..bf9036b --- /dev/null +++ b/backend/views/importers/_form.php @@ -0,0 +1,63 @@ + + +
+ = Html::a('Create Importers', ['create'], ['class' => 'btn btn-success']) ?> +
+ + = GridView::widget([ + 'dataProvider' => $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'code', + 'name', + 'name_price', + 'currency_id', + // 'delivery', + // 'email:email', + // 'info:ntext', + // 'active', + // 'PARSER_IS_ACTIVE', + // 'PARSER_COLUMN_COUNT', + // 'PARSER_FIELD_BRAND', + // 'PARSER_FIELD_ARTICLE', + // 'PARSER_FIELD_ARTICLE_PREFIX', + // 'PARSER_FIELD_PRICE', + // 'PARSER_FIELD_DESCR', + // 'PARSER_FIELD_BOX', + // 'PARSER_FIELD_ADD_BOX', + // 'PARSER_FIELD_GROUP_RG', + // 'PARSER_FIELD_SIGN', + // 'PARSER_FIELD_MULTIPLIER', + // 'price_date_update', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + ++ = Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> + = Html::a('Delete', ['delete', 'id' => $model->id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => 'Are you sure you want to delete this item?', + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'id', + 'code', + 'name', + 'name_price', + 'currency_id', + 'delivery', + 'email:email', + 'info:ntext', + 'active', + 'PARSER_IS_ACTIVE', + 'PARSER_COLUMN_COUNT', + 'PARSER_FIELD_BRAND', + 'PARSER_FIELD_ARTICLE', + 'PARSER_FIELD_ARTICLE_PREFIX', + 'PARSER_FIELD_PRICE', + 'PARSER_FIELD_DESCR', + 'PARSER_FIELD_BOX', + 'PARSER_FIELD_ADD_BOX', + 'PARSER_FIELD_GROUP_RG', + 'PARSER_FIELD_SIGN', + 'PARSER_FIELD_MULTIPLIER', + 'price_date_update', + ], + ]) ?> + +