diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php new file mode 100644 index 0000000..a036d8f --- /dev/null +++ b/backend/controllers/TicketController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Ticket models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TicketSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Ticket model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Ticket model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Ticket(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Ticket 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_ticket]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Ticket 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 Ticket model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Ticket the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Ticket::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/TicketSearch.php b/backend/models/TicketSearch.php new file mode 100644 index 0000000..19d5813 --- /dev/null +++ b/backend/models/TicketSearch.php @@ -0,0 +1,78 @@ + $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_ticket' => $this->id_ticket, + 'id_user' => $this->id_user, + 'id_ticket_type' => $this->id_ticket_type, + 'id_account' => $this->id_account, + 'id_discount' => $this->id_discount, + 'start' => $this->start, + 'end' => $this->end, + 'max_usage_count' => $this->max_usage_count, + 'usage_count' => $this->usage_count, + 'status' => $this->status, + 'price_brutto' => $this->price_brutto, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/backend/views/ticket/_form.php b/backend/views/ticket/_form.php new file mode 100644 index 0000000..d984294 --- /dev/null +++ b/backend/views/ticket/_form.php @@ -0,0 +1,47 @@ + + +
+ + + + field($model, 'id_user')->textInput() ?> + + field($model, 'id_ticket_type')->textInput() ?> + + field($model, 'id_account')->textInput() ?> + + field($model, 'id_discount')->textInput() ?> + + field($model, 'start')->textInput() ?> + + field($model, 'end')->textInput() ?> + + field($model, 'max_usage_count')->textInput() ?> + + field($model, 'usage_count')->textInput() ?> + + field($model, 'status')->textInput() ?> + + field($model, 'price_brutto')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/ticket/_search.php b/backend/views/ticket/_search.php new file mode 100644 index 0000000..c89f75f --- /dev/null +++ b/backend/views/ticket/_search.php @@ -0,0 +1,53 @@ + + + diff --git a/backend/views/ticket/create.php b/backend/views/ticket/create.php new file mode 100644 index 0000000..67727e3 --- /dev/null +++ b/backend/views/ticket/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/ticket', 'Create Ticket'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_ticket', + 'id_user', + 'id_ticket_type', + 'id_account', + 'id_discount', + // 'start', + // 'end', + // 'max_usage_count', + // 'usage_count', + // 'status', + // 'price_brutto', + // 'comment', + // 'created_at', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/backend/views/ticket/update.php b/backend/views/ticket/update.php new file mode 100644 index 0000000..09f838a --- /dev/null +++ b/backend/views/ticket/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/ticket', 'Update {modelClass}: ', [ + 'modelClass' => 'Ticket', +]) . ' ' . $model->id_ticket; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_ticket, 'url' => ['view', 'id' => $model->id_ticket]]; +$this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/ticket/view.php b/backend/views/ticket/view.php new file mode 100644 index 0000000..7bc9143 --- /dev/null +++ b/backend/views/ticket/view.php @@ -0,0 +1,48 @@ +title = $model->id_ticket; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id_ticket', + 'id_user', + 'id_ticket_type', + 'id_account', + 'id_discount', + 'start', + 'end', + 'max_usage_count', + 'usage_count', + 'status', + 'price_brutto', + 'comment', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/common/models/Ticket.php b/common/models/Ticket.php new file mode 100644 index 0000000..91fa231 --- /dev/null +++ b/common/models/Ticket.php @@ -0,0 +1,70 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id_ticket' => Yii::t('common/ticket', 'Id Ticket'), + 'id_user' => Yii::t('common/ticket', 'Id User'), + 'id_ticket_type' => Yii::t('common/ticket', 'Id Ticket Type'), + 'id_account' => Yii::t('common/ticket', 'Id Account'), + 'id_discount' => Yii::t('common/ticket', 'Id Discount'), + 'start' => Yii::t('common/ticket', 'Start'), + 'end' => Yii::t('common/ticket', 'End'), + 'max_usage_count' => Yii::t('common/ticket', 'Max Usage Count'), + 'usage_count' => Yii::t('common/ticket', 'Usage Count'), + 'status' => Yii::t('common/ticket', 'Status'), + 'price_brutto' => Yii::t('common/ticket', 'Price Brutto'), + 'comment' => Yii::t('common/ticket', 'Comment'), + 'created_at' => Yii::t('common/ticket', 'Created At'), + 'updated_at' => Yii::t('common/ticket', 'Updated At'), + ]; + } +} diff --git a/console/migrations/m151006_100909_create__table__ticket.php b/console/migrations/m151006_100909_create__table__ticket.php new file mode 100644 index 0000000..49aa33b --- /dev/null +++ b/console/migrations/m151006_100909_create__table__ticket.php @@ -0,0 +1,52 @@ +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('{{%ticket}}', [ + 'id_ticket' => $this->primaryKey(), + 'id_user' => $this->integer(), + 'id_ticket_type' => $this->integer(), + 'id_account' => $this->integer(), + 'id_discount' => $this->integer(), + 'start' => $this->timestamp(), + 'end' => $this->timestamp(), + 'max_usage_count' => $this->integer(), + 'usage_count' => $this->integer(), + 'status' => $this->integer(), + 'price_brutto' => $this->integer(), + 'comment' => $this->string(255)->notNull(), + 'created_at' => $this->timestamp()->notNull(), + 'updated_at' => $this->timestamp()->notNull(), + ], $tableOptions); + } + + public function down() + { + echo "m151006_100909_create__table__ticket 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/TicketController.php b/frontend/controllers/TicketController.php new file mode 100644 index 0000000..4a2bdbc --- /dev/null +++ b/frontend/controllers/TicketController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Ticket models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TicketSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Ticket model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Ticket model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Ticket(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_ticket]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Ticket 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_ticket]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Ticket 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 Ticket model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Ticket the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Ticket::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/models/TicketSearch.php b/frontend/models/TicketSearch.php new file mode 100644 index 0000000..92af23b --- /dev/null +++ b/frontend/models/TicketSearch.php @@ -0,0 +1,78 @@ + $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_ticket' => $this->id_ticket, + 'id_user' => $this->id_user, + 'id_ticket_type' => $this->id_ticket_type, + 'id_account' => $this->id_account, + 'id_discount' => $this->id_discount, + 'start' => $this->start, + 'end' => $this->end, + 'max_usage_count' => $this->max_usage_count, + 'usage_count' => $this->usage_count, + 'status' => $this->status, + 'price_brutto' => $this->price_brutto, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'comment', $this->comment]); + + return $dataProvider; + } +} diff --git a/frontend/views/ticket/_form.php b/frontend/views/ticket/_form.php new file mode 100644 index 0000000..d984294 --- /dev/null +++ b/frontend/views/ticket/_form.php @@ -0,0 +1,47 @@ + + +
+ + + + field($model, 'id_user')->textInput() ?> + + field($model, 'id_ticket_type')->textInput() ?> + + field($model, 'id_account')->textInput() ?> + + field($model, 'id_discount')->textInput() ?> + + field($model, 'start')->textInput() ?> + + field($model, 'end')->textInput() ?> + + field($model, 'max_usage_count')->textInput() ?> + + field($model, 'usage_count')->textInput() ?> + + field($model, 'status')->textInput() ?> + + field($model, 'price_brutto')->textInput() ?> + + field($model, 'comment')->textInput(['maxlength' => true]) ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('common/ticket', 'Create') : Yii::t('common/ticket', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/ticket/_search.php b/frontend/views/ticket/_search.php new file mode 100644 index 0000000..bdc5a35 --- /dev/null +++ b/frontend/views/ticket/_search.php @@ -0,0 +1,53 @@ + + + diff --git a/frontend/views/ticket/create.php b/frontend/views/ticket/create.php new file mode 100644 index 0000000..67727e3 --- /dev/null +++ b/frontend/views/ticket/create.php @@ -0,0 +1,21 @@ +title = Yii::t('common/ticket', 'Create Ticket'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_ticket', + 'id_user', + 'id_ticket_type', + 'id_account', + 'id_discount', + // 'start', + // 'end', + // 'max_usage_count', + // 'usage_count', + // 'status', + // 'price_brutto', + // 'comment', + // 'created_at', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/frontend/views/ticket/update.php b/frontend/views/ticket/update.php new file mode 100644 index 0000000..09f838a --- /dev/null +++ b/frontend/views/ticket/update.php @@ -0,0 +1,23 @@ +title = Yii::t('common/ticket', 'Update {modelClass}: ', [ + 'modelClass' => 'Ticket', +]) . ' ' . $model->id_ticket; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id_ticket, 'url' => ['view', 'id' => $model->id_ticket]]; +$this->params['breadcrumbs'][] = Yii::t('common/ticket', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/ticket/view.php b/frontend/views/ticket/view.php new file mode 100644 index 0000000..7bc9143 --- /dev/null +++ b/frontend/views/ticket/view.php @@ -0,0 +1,48 @@ +title = $model->id_ticket; +$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id_ticket', + 'id_user', + 'id_ticket_type', + 'id_account', + 'id_discount', + 'start', + 'end', + 'max_usage_count', + 'usage_count', + 'status', + 'price_brutto', + 'comment', + 'created_at', + 'updated_at', + ], + ]) ?> + +