diff --git a/Gruntfile.coffee b/Gruntfile.coffee new file mode 100644 index 0000000..c663c91 --- /dev/null +++ b/Gruntfile.coffee @@ -0,0 +1,62 @@ +module.exports = (grunt) -> + + # Project configuration. + grunt.initConfig + pkg: grunt.file.readJSON('package.json') + + config: + src: 'assets/coffee' + dest: 'assets/js' + + clean: + build: + src: [ 'frontend/web/stylesheet','backend/web/stylesheet' ] + + compass: + frontend: + options: + sassDir: 'frontend/web/scss' + cssDir: 'frontend/web/stylesheet' + backend: + options: + sassDir: 'backend/web/scss' + cssDir: 'backend/web/stylesheet' + + coffee: + frontend: + options: + sourceMap: true + bare: false + join: true + files: + 'frontend/web/js/frontend.js': ['frontend/web/coffee/**/*.coffee'] + backend: + options: + sourceMap: true + bare: false + join: true + files: + 'backend/web/js/backend.js': ['backend/web/coffee/**/*.coffee'] + + watch: + options: + spawn: false + interrupt: true + atBegin: true + interval: 500 + coffeewatch: + files: ['frontend/web/coffee/**/*.coffee','backend/web/coffee/**/*.coffee'] + tasks: ['any-newer:coffee'] + sasswatch: + files: ['frontend/web/scss/*.scss','backend/web/scss/*.scss'] + tasks: ['compass'] + + + #grunt.loadNpmTasks 'grunt-contrib-compass' + + require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks + + # Tasks + #grunt.registerTask 'default', ['concurrent:compile'] + grunt.registerTask 'default', ['compass','coffee'] + #grunt.registerTask 'production', ['clean', 'concurrent:compile', 'concurrent:optimize'] \ No newline at end of file diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index ae957ec..153b0ff 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -40,6 +40,7 @@ class AdminMenuStructure{ $items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ]; $items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ]; $items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ]; + $items[] = ['label' => 'Termékek', 'url' => ['/product/index'] ]; if ( count($items) > 0 ){ $userMainMenu = ['label' => 'Beállítások', 'url' => null, diff --git a/backend/controllers/ProductController.php b/backend/controllers/ProductController.php new file mode 100644 index 0000000..3ce635f --- /dev/null +++ b/backend/controllers/ProductController.php @@ -0,0 +1,125 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Product models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new ProductSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Product model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Product model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Product(); + $accounts = Account::readAccounts(null); + + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_product]); + } else { + return $this->render('create', [ + 'model' => $model, + 'accounts' => $accounts, + ]); + } + } + + /** + * Updates an existing Product 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_product]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Product 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 Product model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Product the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Product::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/ProductSearch.php b/backend/models/ProductSearch.php new file mode 100644 index 0000000..a528662 --- /dev/null +++ b/backend/models/ProductSearch.php @@ -0,0 +1,76 @@ + $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_product' => $this->id_product, + 'id_product_type' => $this->id_product_type, + 'id_account' => $this->id_account, + 'purchase_price' => $this->purchase_price, + 'sale_price' => $this->sale_price, + 'profit_margins' => $this->profit_margins, + 'status' => $this->status, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'product_number', $this->product_number]) + ->andFilterWhere(['like', 'barcode', $this->barcode]) + ->andFilterWhere(['like', 'description', $this->description]); + + return $dataProvider; + } +} diff --git a/backend/views/product/_form.php b/backend/views/product/_form.php new file mode 100644 index 0000000..941c04d --- /dev/null +++ b/backend/views/product/_form.php @@ -0,0 +1,42 @@ + + +
+ = Html::a(Yii::t('common/ticket_type', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?> +
+ + = GridView::widget([ + 'dataProvider' => $dataProvider, + 'columns' => [ + [ + 'attribute' => 'id_product_type', + 'value' => 'productCategoryName', + ], + [ + 'attribute' => 'id_account', + 'value' => 'accountName', + ], + 'product_number', + 'barcode', + 'purchase_price', + 'sale_price', + 'profit_margins', + 'status', + 'description', + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + ++ = Html::a(Yii::t('common/ticket_type', 'Update'), ['update', 'id' => $model->id_product], ['class' => 'btn btn-primary']) ?> + = Html::a(Yii::t('common/ticket_type', 'Delete'), ['delete', 'id' => $model->id_product], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('common/ticket_type', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +
+ + = DetailView::widget([ + 'model' => $model, + 'attributes' => [ + 'id_product', + 'id_product_type', + 'id_account', + 'product_number', + 'barcode', + 'purchase_price', + 'sale_price', + 'profit_margins', + 'status', + 'description', + 'created_at', + 'updated_at', + ], + ]) ?> + +