From e3d6c0b902a805a9cefeb7308b5ecc9e02b855b4 Mon Sep 17 00:00:00 2001 From: rocho Date: Thu, 1 Oct 2015 09:37:34 +0200 Subject: [PATCH] add product sale changes --- backend/components/AdminMenuStructure.php | 2 + backend/controllers/CurrencyController.php | 109 +++++++++++ backend/controllers/TransferController.php | 92 +++++++++ backend/models/CurrencySearch.php | 70 +++++++ backend/models/TransferSearch.php | 79 ++++++++ backend/views/currency/_form.php | 28 +++ backend/views/currency/_search.php | 37 ++++ backend/views/currency/create.php | 21 ++ backend/views/currency/index.php | 37 ++++ backend/views/currency/update.php | 23 +++ backend/views/currency/view.php | 32 ++++ backend/views/transfer/_form.php | 49 +++++ backend/views/transfer/_search.php | 55 ++++++ backend/views/transfer/create.php | 21 ++ backend/views/transfer/index.php | 47 +++++ backend/views/transfer/update.php | 23 +++ backend/views/transfer/view.php | 49 +++++ common/models/Currency.php | 54 ++++++ common/models/Transfer.php | 75 ++++++++ common/models/TransferSearch.php | 79 ++++++++ .../m150930_140224_add__table__transfer.php | 72 +++++++ .../m150930_140728_add__table__currency.php | 43 +++++ frontend/controllers/ProductController.php | 36 ++++ frontend/controllers/TransferController.php | 121 ++++++++++++ frontend/models/ProductSaleForm.php | 46 +++++ frontend/models/TransferSearch.php | 79 ++++++++ frontend/views/common/_menu_reception.php | 2 +- frontend/views/product/sale.php | 180 ++++++++++++++++++ frontend/views/transfer/_form.php | 45 +++++ frontend/views/transfer/_search.php | 55 ++++++ frontend/views/transfer/create.php | 21 ++ frontend/views/transfer/index.php | 48 +++++ frontend/views/transfer/update.php | 23 +++ frontend/views/transfer/view.php | 49 +++++ 34 files changed, 1801 insertions(+), 1 deletion(-) create mode 100644 backend/controllers/CurrencyController.php create mode 100644 backend/controllers/TransferController.php create mode 100644 backend/models/CurrencySearch.php create mode 100644 backend/models/TransferSearch.php create mode 100644 backend/views/currency/_form.php create mode 100644 backend/views/currency/_search.php create mode 100644 backend/views/currency/create.php create mode 100644 backend/views/currency/index.php create mode 100644 backend/views/currency/update.php create mode 100644 backend/views/currency/view.php create mode 100644 backend/views/transfer/_form.php create mode 100644 backend/views/transfer/_search.php create mode 100644 backend/views/transfer/create.php create mode 100644 backend/views/transfer/index.php create mode 100644 backend/views/transfer/update.php create mode 100644 backend/views/transfer/view.php create mode 100644 common/models/Currency.php create mode 100644 common/models/Transfer.php create mode 100644 common/models/TransferSearch.php create mode 100644 console/migrations/m150930_140224_add__table__transfer.php create mode 100644 console/migrations/m150930_140728_add__table__currency.php create mode 100644 frontend/controllers/TransferController.php create mode 100644 frontend/models/ProductSaleForm.php create mode 100644 frontend/models/TransferSearch.php create mode 100644 frontend/views/product/sale.php create mode 100644 frontend/views/transfer/_form.php create mode 100644 frontend/views/transfer/_search.php create mode 100644 frontend/views/transfer/create.php create mode 100644 frontend/views/transfer/index.php create mode 100644 frontend/views/transfer/update.php create mode 100644 frontend/views/transfer/view.php diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index 9611261..0a51e6c 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -44,6 +44,8 @@ class AdminMenuStructure{ $items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ]; $items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ]; $items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ]; + $items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ]; + $items[] = ['label' => 'Transfer', 'url' => ['/transfer/index'] ]; if ( count($items) > 0 ){ $userMainMenu = ['label' => 'Beállítások', 'url' => null, diff --git a/backend/controllers/CurrencyController.php b/backend/controllers/CurrencyController.php new file mode 100644 index 0000000..6f77f3a --- /dev/null +++ b/backend/controllers/CurrencyController.php @@ -0,0 +1,109 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Currency models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new CurrencySearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Currency model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Currency model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Currency(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_currency]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Currency 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_currency]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the Currency model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Currency the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Currency::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/TransferController.php b/backend/controllers/TransferController.php new file mode 100644 index 0000000..a41f25c --- /dev/null +++ b/backend/controllers/TransferController.php @@ -0,0 +1,92 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Transfer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TransferSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Transfer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + + /** + * Updates an existing Transfer 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_transfer]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + + /** + * Finds the Transfer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Transfer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Transfer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/CurrencySearch.php b/backend/models/CurrencySearch.php new file mode 100644 index 0000000..10d7906 --- /dev/null +++ b/backend/models/CurrencySearch.php @@ -0,0 +1,70 @@ + $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_currency' => $this->id_currency, + 'rate' => $this->rate, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'currency', $this->currency]) + ->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php new file mode 100644 index 0000000..903aaeb --- /dev/null +++ b/backend/models/TransferSearch.php @@ -0,0 +1,79 @@ + $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_transfer' => $this->id_transfer, + 'id_discount' => $this->id_discount, + 'id_currency' => $this->id_currency, + 'id_object' => $this->id_object, + 'status' => $this->status, + 'type' => $this->type, + 'item_price' => $this->item_price, + 'count' => $this->count, + 'money' => $this->money, + 'money_currency' => $this->money_currency, + 'rate' => $this->rate, + 'id_user' => $this->id_user, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/backend/views/currency/_form.php b/backend/views/currency/_form.php new file mode 100644 index 0000000..7e9f12b --- /dev/null +++ b/backend/views/currency/_form.php @@ -0,0 +1,28 @@ + + +
+ + + + field($model, 'currency')->textInput(['maxlength' => true]) ?> + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'rate')->textInput() ?> + + +
+ isNewRecord ? Yii::t('frontend/currency', 'Create') : Yii::t('frontend/currency', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/currency/_search.php b/backend/views/currency/_search.php new file mode 100644 index 0000000..d0a3166 --- /dev/null +++ b/backend/views/currency/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/currency/create.php b/backend/views/currency/create.php new file mode 100644 index 0000000..818df07 --- /dev/null +++ b/backend/views/currency/create.php @@ -0,0 +1,21 @@ +title = Yii::t('frontend/currency', 'Create Currency'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/currency/index.php b/backend/views/currency/index.php new file mode 100644 index 0000000..db7896b --- /dev/null +++ b/backend/views/currency/index.php @@ -0,0 +1,37 @@ +title = Yii::t('frontend/currency', 'Currencies'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + 'currency', + 'name', + 'rate', +// 'created_at:datetime', + 'updated_at:datetime:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' =>'{view} {update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/currency/update.php b/backend/views/currency/update.php new file mode 100644 index 0000000..6f2ebd8 --- /dev/null +++ b/backend/views/currency/update.php @@ -0,0 +1,23 @@ +title = Yii::t('frontend/currency', 'Update {modelClass}: ', [ + 'modelClass' => 'Currency', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_currency]]; +$this->params['breadcrumbs'][] = Yii::t('frontend/currency', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/currency/view.php b/backend/views/currency/view.php new file mode 100644 index 0000000..974115c --- /dev/null +++ b/backend/views/currency/view.php @@ -0,0 +1,32 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_currency], ['class' => 'btn btn-primary']) ?> +

+ + $model, + 'attributes' => [ + 'currency', + 'name', + 'rate', + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/transfer/_form.php b/backend/views/transfer/_form.php new file mode 100644 index 0000000..1fbe83d --- /dev/null +++ b/backend/views/transfer/_form.php @@ -0,0 +1,49 @@ + + +
+ + + + field($model, 'id_discount')->textInput() ?> + + field($model, 'id_currency')->textInput() ?> + + field($model, 'id_object')->textInput() ?> + + field($model, 'status')->textInput() ?> + + field($model, 'type')->textInput() ?> + + field($model, 'item_price')->textInput() ?> + + field($model, 'count')->textInput() ?> + + field($model, 'money')->textInput() ?> + + field($model, 'money_currency')->textInput() ?> + + field($model, 'rate')->textInput() ?> + + field($model, 'id_user')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('frontend/transfer', 'Create') : Yii::t('frontend/transfer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/transfer/_search.php b/backend/views/transfer/_search.php new file mode 100644 index 0000000..3e67083 --- /dev/null +++ b/backend/views/transfer/_search.php @@ -0,0 +1,55 @@ + + + diff --git a/backend/views/transfer/create.php b/backend/views/transfer/create.php new file mode 100644 index 0000000..c256a17 --- /dev/null +++ b/backend/views/transfer/create.php @@ -0,0 +1,21 @@ +title = Yii::t('frontend/transfer', 'Create Transfer'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/transfer/index.php b/backend/views/transfer/index.php new file mode 100644 index 0000000..2d0a0c8 --- /dev/null +++ b/backend/views/transfer/index.php @@ -0,0 +1,47 @@ +title = Yii::t('frontend/transfer', 'Transfers'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + + 'id_discount', + 'id_currency', + 'id_object', + 'status', + // 'type', + // 'item_price', + // 'count', + // 'money', + // 'money_currency', + // 'rate', + // 'id_user', + // 'comment', + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view}' + ], + ], + ]); ?> + +
diff --git a/backend/views/transfer/update.php b/backend/views/transfer/update.php new file mode 100644 index 0000000..053729b --- /dev/null +++ b/backend/views/transfer/update.php @@ -0,0 +1,23 @@ +title = Yii::t('frontend/transfer', 'Update {modelClass}: ', [ + 'modelClass' => 'Transfer', +]) . ' ' . $model->id_transfer; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_transfer, 'url' => ['view', 'id' => $model->id_transfer]]; +$this->params['breadcrumbs'][] = Yii::t('frontend/transfer', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/transfer/view.php b/backend/views/transfer/view.php new file mode 100644 index 0000000..9fff603 --- /dev/null +++ b/backend/views/transfer/view.php @@ -0,0 +1,49 @@ +title = $model->id_transfer; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id_transfer', + 'id_discount', + 'id_currency', + 'id_object', + 'status', + 'type', + 'item_price', + 'count', + 'money', + 'money_currency', + 'rate', + 'id_user', + 'comment', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/common/models/Currency.php b/common/models/Currency.php new file mode 100644 index 0000000..b2bd95e --- /dev/null +++ b/common/models/Currency.php @@ -0,0 +1,54 @@ + 10], + [['name'], 'string', 'max' => 32] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id_currency' => Yii::t('common/currency', 'Id Currency'), + 'currency' => Yii::t('common/currency', 'Currency'), + 'name' => Yii::t('common/currency', 'Name'), + 'rate' => Yii::t('common/currency', 'Rate'), + 'created_at' => Yii::t('common/currency', 'Created At'), + 'updated_at' => Yii::t('common/currency', 'Updated At'), + ]; + } +} diff --git a/common/models/Transfer.php b/common/models/Transfer.php new file mode 100644 index 0000000..cd4395d --- /dev/null +++ b/common/models/Transfer.php @@ -0,0 +1,75 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id_transfer' => Yii::t('common/transfer', 'Id Transfer'), + 'id_discount' => Yii::t('common/transfer', 'Id Discount'), + 'id_currency' => Yii::t('common/transfer', 'Id Currency'), + 'id_object' => Yii::t('common/transfer', 'Id Object'), + 'status' => Yii::t('common/transfer', 'Status'), + 'type' => Yii::t('common/transfer', 'Type'), + 'item_price' => Yii::t('common/transfer', 'Item Price'), + 'count' => Yii::t('common/transfer', 'Count'), + 'money' => Yii::t('common/transfer', 'Money'), + 'money_currency' => Yii::t('common/transfer', 'Money Currency'), + 'rate' => Yii::t('common/transfer', 'Rate'), + 'id_user' => Yii::t('common/transfer', 'Id User'), + 'comment' => Yii::t('common/transfer', 'Comment'), + 'created_at' => Yii::t('common/transfer', 'Created At'), + 'updated_at' => Yii::t('common/transfer', 'Updated At'), + ]; + } +} diff --git a/common/models/TransferSearch.php b/common/models/TransferSearch.php new file mode 100644 index 0000000..322f7d7 --- /dev/null +++ b/common/models/TransferSearch.php @@ -0,0 +1,79 @@ + $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_transfer' => $this->id_transfer, + 'id_discount' => $this->id_discount, + 'id_currency' => $this->id_currency, + 'id_object' => $this->id_object, + 'status' => $this->status, + 'type' => $this->type, + 'item_price' => $this->item_price, + 'count' => $this->count, + 'money' => $this->money, + 'money_currency' => $this->money_currency, + 'rate' => $this->rate, + 'id_user' => $this->id_user, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/console/migrations/m150930_140224_add__table__transfer.php b/console/migrations/m150930_140224_add__table__transfer.php new file mode 100644 index 0000000..f25bb87 --- /dev/null +++ b/console/migrations/m150930_140224_add__table__transfer.php @@ -0,0 +1,72 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable('{{%transfer}}', [ + 'id_transfer' => $this->primaryKey(), + 'id_discount' => $this->integer(11) , + 'id_currency' => $this->integer(11) , + 'id_discount' => $this->integer(11) , + 'id_object' => $this->integer(11) , + 'status' => $this->smallInteger(), + 'type' => $this->smallInteger(), + 'item_price' => $this->integer(11), + 'count' => $this->integer(11), + 'money' => $this->integer(11), + 'money_currency' => $this->integer(11), + 'rate' => $this->integer(11), + 'id_user' => $this->integer(11), + 'comment' => $this->string(255), + 'created_at' => $this->timestamp()->notNull(), + 'updated_at' => $this->timestamp()->notNull(), + ], $tableOptions); + } + + public function down() + { + echo "m150930_140224_add__table__transfer cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/console/migrations/m150930_140728_add__table__currency.php b/console/migrations/m150930_140728_add__table__currency.php new file mode 100644 index 0000000..71daf34 --- /dev/null +++ b/console/migrations/m150930_140728_add__table__currency.php @@ -0,0 +1,43 @@ +db->driverName === 'mysql') { + // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci + $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB'; + } + + $this->createTable('{{%currency}}', [ + 'id_currency' => $this->primaryKey(), + 'currency' => $this->string(10)->notNull(), + 'name' => $this->string(32)->notNull(), + 'rate' => $this->integer(11) , + 'created_at' => $this->timestamp()->notNull(), + 'updated_at' => $this->timestamp()->notNull(), + ], $tableOptions); + } + + public function down() + { + echo "m150930_140728_add__table__currency cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/controllers/ProductController.php b/frontend/controllers/ProductController.php index 8fd758c..9c0fb34 100644 --- a/frontend/controllers/ProductController.php +++ b/frontend/controllers/ProductController.php @@ -8,12 +8,19 @@ use frontend\models\ProductSearch; use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; +use frontend\models\ProductSaleForm; +use common\models\Card; +use common\models\Customer; /** * ProductController implements the CRUD actions for Product model. */ class ProductController extends Controller { + + protected $card; + protected $customer; + public function behaviors() { return [ @@ -26,6 +33,21 @@ class ProductController extends Controller ]; } + + public function actionSale( $number = null){ + + $this->findByNumber($number); + + $model = new ProductSaleForm(); + + return $this->render("sale",[ + 'customer' => $this->customer, + 'card' => $this->card + ]); + + + } + /** * Lists all Product models. * @return mixed @@ -118,4 +140,18 @@ class ProductController extends Controller throw new NotFoundHttpException('The requested page does not exist.'); } } + + protected function findByNumber($number){ + $this->card = null; + $this->customer = null; + if ( $number != null ){ + $this->card = Card::readCard($number); + if ( $this->card != null ){ + $this->customer = Customer::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->andWhere( [ 'customer.id_customer_card' => $this->card->id_card ])->one(); + } + } + + + } + } diff --git a/frontend/controllers/TransferController.php b/frontend/controllers/TransferController.php new file mode 100644 index 0000000..a0677f8 --- /dev/null +++ b/frontend/controllers/TransferController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Transfer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TransferSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Transfer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Transfer model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Transfer(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_transfer]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Transfer 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_transfer]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Transfer 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 Transfer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Transfer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Transfer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/models/ProductSaleForm.php b/frontend/models/ProductSaleForm.php new file mode 100644 index 0000000..36b2238 --- /dev/null +++ b/frontend/models/ProductSaleForm.php @@ -0,0 +1,46 @@ + 'Verification Code', + ]; + } + + +} diff --git a/frontend/models/TransferSearch.php b/frontend/models/TransferSearch.php new file mode 100644 index 0000000..e920478 --- /dev/null +++ b/frontend/models/TransferSearch.php @@ -0,0 +1,79 @@ + $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_transfer' => $this->id_transfer, + 'id_discount' => $this->id_discount, + 'id_currency' => $this->id_currency, + 'id_object' => $this->id_object, + 'status' => $this->status, + 'type' => $this->type, + 'item_price' => $this->item_price, + 'count' => $this->count, + 'money' => $this->money, + 'money_currency' => $this->money_currency, + 'rate' => $this->rate, + 'id_user' => $this->id_user, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/frontend/views/common/_menu_reception.php b/frontend/views/common/_menu_reception.php index 52d5a70..40e1037 100644 --- a/frontend/views/common/_menu_reception.php +++ b/frontend/views/common/_menu_reception.php @@ -72,7 +72,7 @@ function mkBtn($card, $label,$route = null ){
'btn btn-primary btn-reception'] )?> - +
diff --git a/frontend/views/product/sale.php b/frontend/views/product/sale.php new file mode 100644 index 0000000..aff1bfd --- /dev/null +++ b/frontend/views/product/sale.php @@ -0,0 +1,180 @@ + + + + +
+
+ $customer, 'card' => $card] ) ?> +
+
+ $customer, 'card' =>$card, 'route' => ['product/sale'] ] )?> +
+
+
+
+ +

+ +
+
+ + +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ 'product product-name']); ?> +
+
+
+
+ +
+
+ 'product product-price']); ?> +
+
+
+
+ +
+
+ 'product product-number']); ?> +
+
+
+
+ +
+
+ 'product barcode']); ?> +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + +
     
     
     
+
+
+
+
\ No newline at end of file diff --git a/frontend/views/transfer/_form.php b/frontend/views/transfer/_form.php new file mode 100644 index 0000000..3ae6209 --- /dev/null +++ b/frontend/views/transfer/_form.php @@ -0,0 +1,45 @@ + + +
+ + + + field($model, 'id_discount')->textInput() ?> + + field($model, 'id_currency')->textInput() ?> + + field($model, 'id_object')->textInput() ?> + + field($model, 'status')->textInput() ?> + + field($model, 'type')->textInput() ?> + + field($model, 'item_price')->textInput() ?> + + field($model, 'count')->textInput() ?> + + field($model, 'money')->textInput() ?> + + field($model, 'money_currency')->textInput() ?> + + field($model, 'rate')->textInput() ?> + + field($model, 'id_user')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? Yii::t('frontend/transfer', 'Create') : Yii::t('frontend/transfer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/transfer/_search.php b/frontend/views/transfer/_search.php new file mode 100644 index 0000000..d910cf8 --- /dev/null +++ b/frontend/views/transfer/_search.php @@ -0,0 +1,55 @@ + + + diff --git a/frontend/views/transfer/create.php b/frontend/views/transfer/create.php new file mode 100644 index 0000000..c256a17 --- /dev/null +++ b/frontend/views/transfer/create.php @@ -0,0 +1,21 @@ +title = Yii::t('frontend/transfer', 'Create Transfer'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/transfer/index.php b/frontend/views/transfer/index.php new file mode 100644 index 0000000..43c9b60 --- /dev/null +++ b/frontend/views/transfer/index.php @@ -0,0 +1,48 @@ +title = Yii::t('frontend/transfer', 'Transfers'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_transfer', + 'id_discount', + 'id_currency', + 'id_object', + 'status', + // 'type', + // 'item_price', + // 'count', + // 'money', + // 'money_currency', + // 'rate', + // 'id_user', + // 'comment', + // 'created_at', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/frontend/views/transfer/update.php b/frontend/views/transfer/update.php new file mode 100644 index 0000000..053729b --- /dev/null +++ b/frontend/views/transfer/update.php @@ -0,0 +1,23 @@ +title = Yii::t('frontend/transfer', 'Update {modelClass}: ', [ + 'modelClass' => 'Transfer', +]) . ' ' . $model->id_transfer; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_transfer, 'url' => ['view', 'id' => $model->id_transfer]]; +$this->params['breadcrumbs'][] = Yii::t('frontend/transfer', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/transfer/view.php b/frontend/views/transfer/view.php new file mode 100644 index 0000000..9fff603 --- /dev/null +++ b/frontend/views/transfer/view.php @@ -0,0 +1,49 @@ +title = $model->id_transfer; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id_transfer', + 'id_discount', + 'id_currency', + 'id_object', + 'status', + 'type', + 'item_price', + 'count', + 'money', + 'money_currency', + 'rate', + 'id_user', + 'comment', + 'created_at', + 'updated_at', + ], + ]) ?> + +