From 10e0f427440b7e9319c9fbf5b8544d1581ad4c0e Mon Sep 17 00:00:00 2001 From: Karnovsky A Date: Wed, 1 Jun 2016 13:52:05 +0300 Subject: [PATCH] - --- common/modules/product/controllers/ManageController.php | 8 +++++++- common/modules/product/controllers/ProductVariantTypeController.php | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ common/modules/product/models/import.php | 2 +- common/modules/product/views/product-variant-type/_form.php | 25 +++++++++++++++++++++++++ common/modules/product/views/product-variant-type/_search.php | 31 +++++++++++++++++++++++++++++++ common/modules/product/views/product-variant-type/create.php | 21 +++++++++++++++++++++ common/modules/product/views/product-variant-type/index.php | 32 ++++++++++++++++++++++++++++++++ common/modules/product/views/product-variant-type/update.php | 23 +++++++++++++++++++++++ common/modules/product/views/product-variant-type/view.php | 37 +++++++++++++++++++++++++++++++++++++ 9 files changed, 301 insertions(+), 2 deletions(-) create mode 100644 common/modules/product/controllers/ProductVariantTypeController.php create mode 100644 common/modules/product/views/product-variant-type/_form.php create mode 100644 common/modules/product/views/product-variant-type/_search.php create mode 100644 common/modules/product/views/product-variant-type/create.php create mode 100644 common/modules/product/views/product-variant-type/index.php create mode 100644 common/modules/product/views/product-variant-type/update.php create mode 100644 common/modules/product/views/product-variant-type/view.php diff --git a/common/modules/product/controllers/ManageController.php b/common/modules/product/controllers/ManageController.php index 6b56c18..495ae00 100755 --- a/common/modules/product/controllers/ManageController.php +++ b/common/modules/product/controllers/ManageController.php @@ -268,7 +268,13 @@ class ManageController extends Controller if ($model->load(Yii::$app->request->post())) { $file = UploadedFile::getInstances($model, 'file'); $method = 'go'. ucfirst($model->type); - if (!empty($file) && $model->validate()) { + if (empty($file)) { + $model->errors[] = 'File not upload'; + } elseif ($method == 'goPrices' && $file[0]->name != 'file_1.csv') { + $model->errors[] = 'File need "file_1.csv"'; + } elseif ($method == 'goProducts' && $file[0]->name == 'file_1.csv') { + $model->errors[] = 'File can not "file_1.csv"'; + } elseif ($model->validate()) { $file[0]->saveAs(Yii::getAlias('@uploadDir') .'/'. Yii::getAlias('@uploadFile'. ucfirst($model->type))); $model->$method(); } diff --git a/common/modules/product/controllers/ProductVariantTypeController.php b/common/modules/product/controllers/ProductVariantTypeController.php new file mode 100644 index 0000000..840f498 --- /dev/null +++ b/common/modules/product/controllers/ProductVariantTypeController.php @@ -0,0 +1,124 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['POST'], + ], + ], + ]; + } + + /** + * Lists all ProductVariantType models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ProductVariantTypeSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single ProductVariantType model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new ProductVariantType model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new ProductVariantType(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->product_variant_type_id]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing ProductVariantType 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->product_variant_type_id]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing ProductVariantType 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 ProductVariantType model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return ProductVariantType the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = ProductVariantType::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/common/modules/product/models/import.php b/common/modules/product/models/import.php index 6737fa2..f1de8f5 100644 --- a/common/modules/product/models/import.php +++ b/common/modules/product/models/import.php @@ -32,7 +32,7 @@ class Import extends Model { return [ [['type'], 'required'], [['type'], 'string'], - [['file'], 'safe'], +// [['file'], 'safe'], [['file'], 'file', 'extensions' => 'csv'], ]; } diff --git a/common/modules/product/views/product-variant-type/_form.php b/common/modules/product/views/product-variant-type/_form.php new file mode 100644 index 0000000..f0a7cfc --- /dev/null +++ b/common/modules/product/views/product-variant-type/_form.php @@ -0,0 +1,25 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'name2')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? Yii::t('product', 'Create') : Yii::t('product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/common/modules/product/views/product-variant-type/_search.php b/common/modules/product/views/product-variant-type/_search.php new file mode 100644 index 0000000..7b3cdec --- /dev/null +++ b/common/modules/product/views/product-variant-type/_search.php @@ -0,0 +1,31 @@ + + + diff --git a/common/modules/product/views/product-variant-type/create.php b/common/modules/product/views/product-variant-type/create.php new file mode 100644 index 0000000..e7d68c8 --- /dev/null +++ b/common/modules/product/views/product-variant-type/create.php @@ -0,0 +1,21 @@ +title = Yii::t('product', 'Create Product Variant Type'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/product/views/product-variant-type/index.php b/common/modules/product/views/product-variant-type/index.php new file mode 100644 index 0000000..4e44be0 --- /dev/null +++ b/common/modules/product/views/product-variant-type/index.php @@ -0,0 +1,32 @@ +title = Yii::t('product', 'Product Variant Types'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + 'name', + 'name2', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> +
diff --git a/common/modules/product/views/product-variant-type/update.php b/common/modules/product/views/product-variant-type/update.php new file mode 100644 index 0000000..d4eb6de --- /dev/null +++ b/common/modules/product/views/product-variant-type/update.php @@ -0,0 +1,23 @@ +title = Yii::t('product', 'Update {modelClass}: ', [ + 'modelClass' => 'Product Variant Type', +]) . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->product_variant_type_id]]; +$this->params['breadcrumbs'][] = Yii::t('product', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/common/modules/product/views/product-variant-type/view.php b/common/modules/product/views/product-variant-type/view.php new file mode 100644 index 0000000..1a54e27 --- /dev/null +++ b/common/modules/product/views/product-variant-type/view.php @@ -0,0 +1,37 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('product', 'Product Variant Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->product_variant_type_id], ['class' => 'btn btn-primary']) ?> + $model->product_variant_type_id], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('product', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'product_variant_type_id', + 'name', + 'name2', + ], + ]) ?> + +
-- libgit2 0.21.4