diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php index cc46a7c..832e656 100644 --- a/backend/components/AdminMenuStructure.php +++ b/backend/components/AdminMenuStructure.php @@ -165,6 +165,21 @@ class AdminMenuStructure{ ]; ///////////////////////////// + // Group Training + ///////////////////////////// + if ( Yii::$app->user ){ + $items = []; + $items[] = ['label' => 'Edzők', 'url' => ['/trainer' ] ]; + $items[] = ['label' => 'Termek', 'url' => ['/room' ] ]; + $items[] = ['label' => 'Esemény típusok', 'url' => ['/event-type' ] ]; + $items[] = ['label' => 'Események', 'url' => ['/event' ] ]; + $items[] = ['label' => 'Esemény regisztrációk', 'url' => ['/event-registration' ] ]; + $this->menuItems[] = ['label' => 'Csoportos edzés', 'url' => $this->emptyUrl, + 'items' => $items + ]; + } + + ///////////////////////////// // Development ///////////////////////////// if ( Yii::$app->user ){ diff --git a/backend/controllers/EventController.php b/backend/controllers/EventController.php new file mode 100644 index 0000000..703e2d8 --- /dev/null +++ b/backend/controllers/EventController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Event models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new EventSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Event model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Event model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Event(); + + 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 Event 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 Event 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 Event model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Event the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Event::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/EventRegistrationController.php b/backend/controllers/EventRegistrationController.php new file mode 100644 index 0000000..91e63b6 --- /dev/null +++ b/backend/controllers/EventRegistrationController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all EventRegistration models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new EventRegistrationSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single EventRegistration model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new EventRegistration model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new EventRegistration(); + + 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 EventRegistration 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 EventRegistration 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 EventRegistration model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return EventRegistration the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = EventRegistration::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/EventTypeController.php b/backend/controllers/EventTypeController.php new file mode 100644 index 0000000..ac24506 --- /dev/null +++ b/backend/controllers/EventTypeController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all EventType models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new EventTypeSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single EventType model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new EventType model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new EventType(); + + 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 EventType 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 EventType 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 EventType model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return EventType the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = EventType::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/RoomController.php b/backend/controllers/RoomController.php new file mode 100644 index 0000000..9dd93f3 --- /dev/null +++ b/backend/controllers/RoomController.php @@ -0,0 +1,121 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Room models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new RoomSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Room model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Room model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Room(); + + 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 Room 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 Room 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 Room model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Room the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Room::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/controllers/TrainerController.php b/backend/controllers/TrainerController.php new file mode 100644 index 0000000..9fc718f --- /dev/null +++ b/backend/controllers/TrainerController.php @@ -0,0 +1,126 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + /** + * Lists all Trainer models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new TrainerSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Trainer model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Trainer model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Trainer(); + + 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 Trainer model. + * If update is successful, the browser will be redirected to the 'view' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException + */ + 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 Trainer model. + * If deletion is successful, the browser will be redirected to the 'index' page. + * @param integer $id + * @return mixed + * @throws NotFoundHttpException + * @throws \yii\db\StaleObjectException + */ + public function actionDelete($id) + { + $trainer = $this->findModel($id); + $trainer->active = Trainer::ACTIVE_OFF; + $trainer->update( ); + + return $this->redirect(['index']); + } + + /** + * Finds the Trainer model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Trainer the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Trainer::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/backend/models/EventRegistrationSearch.php b/backend/models/EventRegistrationSearch.php new file mode 100644 index 0000000..7df53c9 --- /dev/null +++ b/backend/models/EventRegistrationSearch.php @@ -0,0 +1,69 @@ + $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, + 'id_event' => $this->id_event, + 'id_customer' => $this->id_customer, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + 'canceled_at' => $this->canceled_at, + ]); + + return $dataProvider; + } +} diff --git a/backend/models/EventSearch.php b/backend/models/EventSearch.php new file mode 100644 index 0000000..53bc67c --- /dev/null +++ b/backend/models/EventSearch.php @@ -0,0 +1,153 @@ + 250], + [['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'], + [['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'], + ]; + } + + /** + * @inheritdoc + */ + public function scenarios() + { + // bypass scenarios() implementation in the parent class + return Model::scenarios(); + } + + /** + * Creates data provider instance with search query applied + * + * @param array $params + * + * @return ActiveDataProvider + */ + public function search($params) + { + $query = new Query(); + + $query->select([ + 'event.id as event_id', + 'event.start as event_start', + 'event.end as event_end', + 'event.created_at as event_created_at', + 'event.updated_at as event_updated_at', + 'trainer.name as trainer_name', + 'room.name as room_name', + 'event_type.name as event_type_name', + new Expression('count(event_registration.id) as registration_count') + ]); + + $query->from("event"); + $query->innerJoin('trainer', 'event.id_trainer = trainer.id'); + $query->innerJoin('room', 'event.id_room = room.id'); + $query->innerJoin('event_type', 'event_type.id = event.id_event_type'); + $query->leftJoin('event_registration', 'event_registration.id_event = event.id' ); + $query->groupBy( + [ + 'event_id', + 'event_start', + 'event_end', + 'event_created_at', + 'event_updated_at', + 'trainer_name', + 'room_name', + 'event_type_name', + ] + ); + + $dataProvider = new ActiveDataProvider([ + 'query' => $query, + 'sort' => [ + 'defaultOrder' => [ + 'event_start' => SORT_DESC + ], + 'attributes' => Helper::mkYiiSortItems([ + ['event_id'], + ['event_start'], + ['event_end'], + ['trainer_name'], + ['room_name'], + ['event_type_name'], + ['customer_name'], + ['event_created_at'], + ['event_updated_at'], + ['registration_count'], + ]), + ] + ]) ; + + $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([ + 'event.id' => $this->id, + ]); + $query->andFilterWhere( + [ 'room.id' => $this->roomName] + ); + + $query->andFilterWhere( + [ 'trainer.id' => $this->trainerName] + ); + + $query->andFilterWhere( + [ 'event_type.id' => $this->eventTypeName] + ); + + if ( isset($this->start)){ + $query->andWhere( + [ + '>=', + 'start' , + $this->start + ] + ); + } + + if ( isset($this->end)){ + $query->andWhere( + [ + '<=', + 'end' , + $this->end + ] + ); + } + + return $dataProvider; + } +} diff --git a/backend/models/EventTypeSearch.php b/backend/models/EventTypeSearch.php new file mode 100644 index 0000000..fc8f5d7 --- /dev/null +++ b/backend/models/EventTypeSearch.php @@ -0,0 +1,68 @@ + $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, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/RoomSearch.php b/backend/models/RoomSearch.php new file mode 100644 index 0000000..a41a2ae --- /dev/null +++ b/backend/models/RoomSearch.php @@ -0,0 +1,69 @@ + $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, + 'seat_count' => $this->seat_count, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/backend/models/TrainerSearch.php b/backend/models/TrainerSearch.php new file mode 100644 index 0000000..aae4f43 --- /dev/null +++ b/backend/models/TrainerSearch.php @@ -0,0 +1,72 @@ + $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, + 'active' => $this->active, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]) + ->andFilterWhere(['like', 'phone', $this->phone]) + ->andFilterWhere(['like', 'email', $this->email]) + ->andFilterWhere(['like', 'password', $this->password]); + + return $dataProvider; + } +} diff --git a/backend/models/TransferSearch.php b/backend/models/TransferSearch.php index 8f71c80..fcf1fd2 100644 --- a/backend/models/TransferSearch.php +++ b/backend/models/TransferSearch.php @@ -167,6 +167,8 @@ class TransferSearch extends Transfer } } + ['like', 'name', ['test', 'sample']] + $query->andFilterWhere([ 'transfer.id_account' => $this->id_account, 'transfer.status' => $this->status, diff --git a/backend/views/event-registration/_form.php b/backend/views/event-registration/_form.php new file mode 100644 index 0000000..9924d6e --- /dev/null +++ b/backend/views/event-registration/_form.php @@ -0,0 +1,31 @@ + + +
+ + + + field($model, 'id_event')->textInput() ?> + + field($model, 'id_customer')->textInput() ?> + + field($model, 'created_at')->textInput() ?> + + field($model, 'updated_at')->textInput() ?> + + field($model, 'canceled_at')->textInput() ?> + +
+ isNewRecord ? Yii::t('event-registration', 'Create') : Yii::t('event-registration', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/event-registration/_search.php b/backend/views/event-registration/_search.php new file mode 100644 index 0000000..2d919d0 --- /dev/null +++ b/backend/views/event-registration/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/backend/views/event-registration/create.php b/backend/views/event-registration/create.php new file mode 100644 index 0000000..1fc158d --- /dev/null +++ b/backend/views/event-registration/create.php @@ -0,0 +1,21 @@ +title = Yii::t('event-registration', 'Create Event Registration'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/event-registration/index.php b/backend/views/event-registration/index.php new file mode 100644 index 0000000..f6d170b --- /dev/null +++ b/backend/views/event-registration/index.php @@ -0,0 +1,39 @@ +title = Yii::t('event-registration', 'Event Registrations'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id', + 'id_event', + 'id_customer', + 'created_at', + 'updated_at', + // 'canceled_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/backend/views/event-registration/update.php b/backend/views/event-registration/update.php new file mode 100644 index 0000000..e8d862b --- /dev/null +++ b/backend/views/event-registration/update.php @@ -0,0 +1,23 @@ +title = Yii::t('event-registration', 'Update {modelClass}: ', [ + 'modelClass' => 'Event Registration', +]) . ' ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('event-registration', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/event-registration/view.php b/backend/views/event-registration/view.php new file mode 100644 index 0000000..a91fc1f --- /dev/null +++ b/backend/views/event-registration/view.php @@ -0,0 +1,40 @@ +title = $model->id; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'id_event', + 'id_customer', + 'created_at', + 'updated_at', + 'canceled_at', + ], + ]) ?> + +
diff --git a/backend/views/event-type/_form.php b/backend/views/event-type/_form.php new file mode 100644 index 0000000..02abc8a --- /dev/null +++ b/backend/views/event-type/_form.php @@ -0,0 +1,23 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + +
+ isNewRecord ? Yii::t('event-type', 'Create') : Yii::t('event-type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/event-type/_search.php b/backend/views/event-type/_search.php new file mode 100644 index 0000000..b83acf8 --- /dev/null +++ b/backend/views/event-type/_search.php @@ -0,0 +1,36 @@ + + + diff --git a/backend/views/event-type/create.php b/backend/views/event-type/create.php new file mode 100644 index 0000000..bd54799 --- /dev/null +++ b/backend/views/event-type/create.php @@ -0,0 +1,21 @@ +title = Yii::t('event-type', 'Create Event Type'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/event-type/index.php b/backend/views/event-type/index.php new file mode 100644 index 0000000..3163e74 --- /dev/null +++ b/backend/views/event-type/index.php @@ -0,0 +1,36 @@ +title = Yii::t('event-type', 'Event Types'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + 'id', + 'name', + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/event-type/update.php b/backend/views/event-type/update.php new file mode 100644 index 0000000..c32bbcd --- /dev/null +++ b/backend/views/event-type/update.php @@ -0,0 +1,21 @@ +title = Yii::t('event-type', 'Update Event Type:') . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('event-type', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/event-type/view.php b/backend/views/event-type/view.php new file mode 100644 index 0000000..1a6a8cd --- /dev/null +++ b/backend/views/event-type/view.php @@ -0,0 +1,38 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'name', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/backend/views/event/_form.php b/backend/views/event/_form.php new file mode 100644 index 0000000..cf5e01c --- /dev/null +++ b/backend/views/event/_form.php @@ -0,0 +1,49 @@ + + +
+ + + + field($model, 'startDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd hh:ii' + ], + 'options' => [ + 'autocomplete' => 'off' + ] + ]); + ?> + + field($model, 'endDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [ + 'pluginOptions' => [ + 'autoclose'=>true, + 'format' => 'yyyy.mm.dd hh:ii' + ], + 'options' => [ + 'autocomplete' => 'off' + ] + ]) + ?> + + field($model, 'id_room')->dropDownList(\common\models\Room::roomOptions(false, true) ) ?> + + field($model, 'id_trainer')->dropDownList(\common\models\Trainer::trainerOptions(false, true) ) ?> + + field($model, 'id_event_type')->dropDownList(\common\models\EventType::eventTypeOptions(false, true) ) ?> + +
+ isNewRecord ? Yii::t('event', 'Create') : Yii::t('event', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/event/_search.php b/backend/views/event/_search.php new file mode 100644 index 0000000..ccfe966 --- /dev/null +++ b/backend/views/event/_search.php @@ -0,0 +1,74 @@ + + + diff --git a/backend/views/event/create.php b/backend/views/event/create.php new file mode 100644 index 0000000..de74c84 --- /dev/null +++ b/backend/views/event/create.php @@ -0,0 +1,21 @@ +title = Yii::t('event', 'Create Event'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + [ + 'attribute' => 'event_id', + 'label' => \Yii::t('event', 'ID') + ], + [ + 'attribute' => 'event_type_name', + 'label' => \Yii::t('event', 'Id Event Type') + ], + [ + 'attribute' => 'event_start', + 'label' => \Yii::t('event', 'Start'), + 'format' => 'datetime' + ], + [ + 'attribute' => 'event_end', + 'label' => \Yii::t('event', 'End'), + 'format' => 'datetime' + ], + [ + 'attribute' => 'registration_count', + 'label' => \Yii::t('event', 'Registration Count') + ], + [ + 'attribute' => 'room_name', + 'label' => \Yii::t('event', 'Room Name') + ], + [ + 'attribute' => 'trainer_name', + 'label' => \Yii::t('event', 'Trainer Name') + ], + [ + 'attribute' => 'event_created_at', + 'label' => \Yii::t('event', 'Created At'), + 'format' => 'datetime' + ], + [ + 'attribute' => 'event_updated_at', + 'label' => \Yii::t('event', 'Updated At'), + 'format' => 'datetime' + ], + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/backend/views/event/update.php b/backend/views/event/update.php new file mode 100644 index 0000000..19874fe --- /dev/null +++ b/backend/views/event/update.php @@ -0,0 +1,21 @@ +title = Yii::t('event', 'Update Event:') . ' ' . $model->id; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('event', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/backend/views/event/view.php b/backend/views/event/view.php new file mode 100644 index 0000000..f060a80 --- /dev/null +++ b/backend/views/event/view.php @@ -0,0 +1,51 @@ +title = $model->trainer->name . "/" . $model->eventType->name . "/" . $model->room->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'start:datetime', + 'end:datetime', + [ + 'attribute' => 'room.name', + 'label' => $model->getAttributeLabel('id_room') + ], + [ + 'attribute' => 'trainer.name', + 'label' => $model->getAttributeLabel('id_trainer') + ], + [ + 'attribute' => 'eventType.name', + 'label' => $model->getAttributeLabel('id_event_type') + ], + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/backend/views/room/_form.php b/backend/views/room/_form.php new file mode 100644 index 0000000..ea8b685 --- /dev/null +++ b/backend/views/room/_form.php @@ -0,0 +1,25 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'seat_count')->textInput(['type' => 'number']) ?> + +
+ isNewRecord ? Yii::t('room', 'Create') : Yii::t('room', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/backend/views/room/_search.php b/backend/views/room/_search.php new file mode 100644 index 0000000..4071472 --- /dev/null +++ b/backend/views/room/_search.php @@ -0,0 +1,48 @@ + + + diff --git a/backend/views/room/create.php b/backend/views/room/create.php new file mode 100644 index 0000000..d892c43 --- /dev/null +++ b/backend/views/room/create.php @@ -0,0 +1,21 @@ +title = Yii::t('room', 'Create Room'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('room', 'Rooms'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + 'id', + 'name', + 'seat_count', + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn', + 'template' => '{view} {update}' + ], + ], + ]); ?> + +
diff --git a/backend/views/room/update.php b/backend/views/room/update.php new file mode 100644 index 0000000..2f6f3ca --- /dev/null +++ b/backend/views/room/update.php @@ -0,0 +1,21 @@ +title = Yii::t('room', 'Update Room: ') . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('room', 'Rooms'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('room', 'Update'); +?> +
+ +

title) ?>

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

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'name', + 'seat_count', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/backend/views/trainer/_form.php b/backend/views/trainer/_form.php new file mode 100644 index 0000000..2500092 --- /dev/null +++ b/backend/views/trainer/_form.php @@ -0,0 +1,20 @@ + +
+ + field($model, 'name')->textInput(['maxlength' => true]) ?> + field($model, 'phone')->textInput(['maxlength' => true]) ?> + field($model, 'email')->textInput(['maxlength' => true]) ?> + field($model, 'active')->checkbox() ?> +
+ isNewRecord ? Yii::t('trainer', 'Create') : Yii::t('trainer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ +
diff --git a/backend/views/trainer/_search.php b/backend/views/trainer/_search.php new file mode 100644 index 0000000..0e2a191 --- /dev/null +++ b/backend/views/trainer/_search.php @@ -0,0 +1,49 @@ + +
+
+

Keresés

+
+
+ +
+
diff --git a/backend/views/trainer/create.php b/backend/views/trainer/create.php new file mode 100644 index 0000000..73e7b43 --- /dev/null +++ b/backend/views/trainer/create.php @@ -0,0 +1,21 @@ +title = Yii::t('trainer', 'Create Trainer'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('trainer', 'Trainers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

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

title) ?>

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

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

+ + $dataProvider, + 'columns' => [ + 'id', + 'name', + 'phone', + 'email:email', + ['attribute' => 'active' , 'value' => function ($model){ return \common\models\Trainer::prettyPrintActive($model->active) ;} ], + 'created_at:datetime', + 'updated_at:datetime', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/backend/views/trainer/update.php b/backend/views/trainer/update.php new file mode 100644 index 0000000..54be292 --- /dev/null +++ b/backend/views/trainer/update.php @@ -0,0 +1,21 @@ +title = Yii::t('trainer', 'Update Trainer:' ) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('trainer', 'Trainers'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]]; +$this->params['breadcrumbs'][] = Yii::t('trainer', 'Update'); +?> +
+ +

title) ?>

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

title) ?>

+ +

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

+ + $model, + 'attributes' => [ + 'id', + 'name', + 'phone', + 'email:email', + [ + 'attribute' => 'active', + 'value' => \common\models\Trainer::prettyPrintActive($model->active) + ], + 'created_at:datetime', + 'updated_at:datetime', + ], + ]) ?> + +
diff --git a/common/messages/hu/event-type.php b/common/messages/hu/event-type.php new file mode 100644 index 0000000..ad9054b --- /dev/null +++ b/common/messages/hu/event-type.php @@ -0,0 +1,24 @@ + 'ID', + 'Name' => 'Név', + 'Create Event Type' => 'Új esemény Típus', + 'Update Event Type:' => 'Esemény Típus adatainak módosítása:', + + 'Event Types' => 'Esemény Típusok', + 'Created At' => 'Létrehozási dátum, idő', + 'Updated At' => 'Módosítási dátum, idő', + 'Search' => 'Keres', + 'Create' => 'Mentés', + 'Update' => 'Módosít', + 'Delete' => 'Törlés', + 'All' => 'Mind', +]; \ No newline at end of file diff --git a/common/messages/hu/event.php b/common/messages/hu/event.php new file mode 100644 index 0000000..c7c3623 --- /dev/null +++ b/common/messages/hu/event.php @@ -0,0 +1,36 @@ + 'ID', + 'Name' => 'Név', + 'Seat Count' => 'Férőhelyek száma', + 'Create Event' => 'Új esemény', + 'Update Event:' => 'Esemény adatainak módosítása:', + + 'Events' => 'Események', + 'Created At' => 'Létrehozási dátum, idő', + 'Updated At' => 'Módosítási dátum, idő', + 'Search' => 'Keres', + 'Create' => 'Mentés', + 'Update' => 'Módosít', + 'Delete' => 'Törlés', + 'All' => 'Mind', + 'Start' => 'Esemény kezdete', + 'End' => 'Esemény vége', + 'Room Name' => 'Terem', + 'Trainer Name' => 'Edző', + + 'Event start' => 'Esemény Kezdete', + 'Event end' => 'Esemény vége', + 'Id Room' => 'Terem', + 'Id Trainer' => 'Edző', + 'Id Event Type' => 'Esemény Típus', + 'Registration Count' => 'Résztvevők' +]; \ No newline at end of file diff --git a/common/messages/hu/room.php b/common/messages/hu/room.php new file mode 100644 index 0000000..46a2444 --- /dev/null +++ b/common/messages/hu/room.php @@ -0,0 +1,25 @@ + 'ID', + 'Name' => 'Név', + 'Seat Count' => 'Férőhelyek száma', + 'Create Room' => 'Új terem', + 'Update Room:' => 'Terem adatainak módosítása:', + + 'Rooms' => 'Termek', + 'Created At' => 'Létrehozási dátum, idő', + 'Updated At' => 'Módosítási dátum, idő', + 'Search' => 'Keres', + 'Create' => 'Mentés', + 'Update' => 'Módosít', + 'Delete' => 'Törlés', + 'All' => 'Mind', +]; \ No newline at end of file diff --git a/common/messages/hu/trainer.php b/common/messages/hu/trainer.php new file mode 100644 index 0000000..6582ca9 --- /dev/null +++ b/common/messages/hu/trainer.php @@ -0,0 +1,38 @@ + 'ID', + 'Name' => 'Név', + 'Phone' => 'Telefon', + 'Email' => 'E-Mail', + 'Password' => 'Jelszó', + 'Active' => 'Aktív', + 'Created At' => 'Létrehozási dátum, idő', + 'Updated At' => 'Módosítási dátum, idő', + 'Create Trainer' => 'Új edző', + 'Trainers' => 'Edzők', + 'Search' => 'Keres', + 'Create' => 'Mentés', + 'Update' => 'Módosít', + 'Delete' => 'Törlés', + 'active_on' => 'Aktív', + 'active_off' => 'Inaktív', + 'Update Trainer:' => 'Edző adatainak módosítása:', + 'All' => 'Mind', +]; \ No newline at end of file diff --git a/common/models/Event.php b/common/models/Event.php new file mode 100644 index 0000000..7e6e579 --- /dev/null +++ b/common/models/Event.php @@ -0,0 +1,111 @@ + Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'], + [['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'], + [['id_trainer','id_room', 'id_event_type'], 'required'], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('event', 'ID'), + 'start' => Yii::t('event', 'Start'), + 'end' => Yii::t('event', 'End'), + 'id_room' => Yii::t('event', 'Id Room'), + 'id_trainer' => Yii::t('event', 'Id Trainer'), + 'id_event_type' => Yii::t('event', 'Id Event Type'), + 'created_at' => Yii::t('event', 'Created At'), + 'updated_at' => Yii::t('event', 'Updated At'), + 'trainerName' => Yii::t('event', 'Trainer Name'), + 'roomName' => Yii::t('event', 'Room Name'), + 'eventTypeName' => Yii::t('event', 'Típus'), + + 'event_start' => Yii::t('event', 'Start'), + 'event_end' => Yii::t('event', 'End'), + 'startDateString' => Yii::t('event', 'Start'), + 'endDateString' => Yii::t('event', 'End'), + 'status' => Yii::t('event', 'Status'), + ]; + } + + public function afterFind() + { + parent::afterFind(); // TODO: Change the autogenerated stub + $format = "Y.m.d H:i"; + $date = new \DateTime(); + $date->setTimestamp($this->start); + $date->setTimezone(new \DateTimeZone('UTC')); + $this->startDateString = $date->format($format); + $date->setTimestamp($this->end); + $this->endDateString = $date->format($format); + } + + public function behaviors() + { + return ArrayHelper::merge( [ + [ + 'class' => TimestampBehavior::className(), + 'value' => function(){ return date('Y-m-d H:i:s' ); } + ] + ], + parent::behaviors()); + } + + public function getEventType(){ + return $this->hasOne(EventType::className(),['id' => 'id_event_type']); + } + + public function getTrainer(){ + return $this->hasOne(Trainer::className(),['id' => 'id_trainer']); + } + + public function getRoom(){ + return $this->hasOne(Room::className(),['id' => 'id_room']); + } + +} diff --git a/common/models/EventRegistration.php b/common/models/EventRegistration.php new file mode 100644 index 0000000..55dd92d --- /dev/null +++ b/common/models/EventRegistration.php @@ -0,0 +1,53 @@ + Yii::t('event-registration', 'ID'), + 'id_event' => Yii::t('event-registration', 'Id Event'), + 'id_customer' => Yii::t('event-registration', 'Id Customer'), + 'created_at' => Yii::t('event-registration', 'Created At'), + 'updated_at' => Yii::t('event-registration', 'Updated At'), + 'canceled_at' => Yii::t('event-registration', 'Canceled At'), + ]; + } +} diff --git a/common/models/EventType.php b/common/models/EventType.php new file mode 100644 index 0000000..0666a6c --- /dev/null +++ b/common/models/EventType.php @@ -0,0 +1,79 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('event-type', 'ID'), + 'name' => Yii::t('event-type', 'Name'), + 'created_at' => Yii::t('event-type', 'Created At'), + 'updated_at' => Yii::t('event-type', 'Updated At'), + ]; + } + + public function behaviors() + { + return ArrayHelper::merge( [ + [ + 'class' => TimestampBehavior::className(), + 'value' => function(){ return date('Y-m-d H:i:s' ); } + ] + ], + parent::behaviors()); + } + + public function asOptions(){ + $items = ArrayHelper::map(EventType::find()->all(),'id','name'); + return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items); + } + + public static function eventTypeOptions($all = false, $emptyString = false){ + $items = ArrayHelper::map(EventType::find()->all(),'id','name'); + $extra = []; + if ( $all ) { + $extra = ['' => \Yii::t('event-type','All')]; + } + if ( $emptyString ) { + $extra = ['' => '' ]; + } + return ArrayHelper::merge($extra,$items); + } +} diff --git a/common/models/Room.php b/common/models/Room.php new file mode 100644 index 0000000..4b9252a --- /dev/null +++ b/common/models/Room.php @@ -0,0 +1,83 @@ + 255] + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('room', 'ID'), + 'name' => Yii::t('room', 'Name'), + 'seat_count' => Yii::t('room', 'Seat Count'), + 'created_at' => Yii::t('room', 'Created At'), + 'updated_at' => Yii::t('room', 'Updated At'), + ]; + } + + public function behaviors() + { + return ArrayHelper::merge( [ + [ + 'class' => TimestampBehavior::className(), + 'value' => function(){ return date('Y-m-d H:i:s' ); } + ] + ], + parent::behaviors()); + } + + public function asOptions(){ + $items = ArrayHelper::map(Room::find()->all(),'id','name'); + return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items); + } + + public static function roomOptions($all = false, $emtpyString = false){ + $items = ArrayHelper::map(Room::find()->all(),'id','name'); + $extra = []; + if ( $all ) { + $extra = ['' => \Yii::t('room','All')]; + } + if ( $emtpyString ) { + $extra = ['' => '' ]; + } + return ArrayHelper::merge($extra,$items); + } + +} diff --git a/common/models/Trainer.php b/common/models/Trainer.php new file mode 100644 index 0000000..18ec78d --- /dev/null +++ b/common/models/Trainer.php @@ -0,0 +1,94 @@ + 255], + [['phone'], 'string', 'max' => 20], + [['name','phone','email'] , 'required'], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => Yii::t('trainer', 'ID'), + 'name' => Yii::t('trainer', 'Name'), + 'phone' => Yii::t('trainer', 'Phone'), + 'email' => Yii::t('trainer', 'Email'), + 'password' => Yii::t('trainer', 'Password'), + 'active' => Yii::t('trainer', 'Active'), + 'created_at' => Yii::t('trainer', 'Created At'), + 'updated_at' => Yii::t('trainer', 'Updated At'), + ]; + } + + public function behaviors() + { + return ArrayHelper::merge( [ + [ + 'class' => TimestampBehavior::className(), + 'value' => function(){ return date('Y-m-d H:i:s' ); } + ] + ], + parent::behaviors()); + } + + public static function prettyPrintActive($active){ + if ( $active == Trainer::ACTIVE_ON ){ + return \Yii::t("trainer",'active_on'); + } + return \Yii::t("trainer",'active_off'); + } + + public static function trainerOptions($all = false, $emptyString = false){ + $items = ArrayHelper::map(Trainer::find()->all(),'id','name'); + $extra = []; + if ( $all ) { + $extra = ['' => \Yii::t('trainer','All')]; + } + if ( $emptyString ) { + $extra = ['' => '' ]; + } + return ArrayHelper::merge($extra,$items); + } + +} diff --git a/console/migrations/m181129_054015_add_group_training_tables.php b/console/migrations/m181129_054015_add_group_training_tables.php new file mode 100644 index 0000000..6f49110 --- /dev/null +++ b/console/migrations/m181129_054015_add_group_training_tables.php @@ -0,0 +1,96 @@ +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('{{%trainer}}', [ + 'id' => $this->primaryKey(), + 'name' => $this->string(255), + 'phone' => $this->string(20), + 'email' => $this->string(255), + 'password' => $this->string(255), + 'active' => $this->integer(), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + + $this->createTable('{{%room}}', [ + 'id' => $this->primaryKey(), + 'name' => $this->string(255), + 'seat_count' => $this->integer(), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + $this->createTable('{{%event_type}}', [ + 'id' => $this->primaryKey(), + 'name' => $this->string(255), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + $this->createTable('{{%event}}', [ + 'id' => $this->primaryKey(), + 'start' => $this->integer(), + 'end' => $this->integer(), + 'id_room' => $this->integer(), + 'id_trainer' => $this->integer(), + 'id_event_type' => $this->integer(), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + $this->createTable('{{%event_registration}}', [ + 'id' => $this->primaryKey(), + 'id_event' => $this->integer(), + 'id_customer' => $this->integer(), + 'created_at' => $this->dateTime()->notNull(), + 'updated_at' => $this->dateTime()->notNull(), + 'canceled_at' => $this->dateTime()->notNull(), + ], $tableOptions); + + +// $this->execute("DELIMITER $$ +// +//CREATE TRIGGER event_seat_count_check +// AFTER INSERT ON event_registration FOR EACH ROW +// BEGIN +// IF (SELECT COUNT(id) FROM event_registration +// WHERE canceled_at is null AND id_event = NEW.id_event) > ( select +// THEN +// SIGNAL SQLSTATE '45000' +// SET MESSAGE_TEXT = 'Max seat count exceeded!'; +// END IF; +// END; +//$$"); + + + } + + public function down() + { + echo "m181129_054015_add_group_training_tables 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/m181205_050104_create_trigger_event_registration.php b/console/migrations/m181205_050104_create_trigger_event_registration.php new file mode 100644 index 0000000..41c9543 --- /dev/null +++ b/console/migrations/m181205_050104_create_trigger_event_registration.php @@ -0,0 +1,41 @@ +addColumn('{{%event}}',"seat_count",$this->integer()); + $this->execute("CREATE TRIGGER event_seat_count_check + AFTER INSERT ON event_registration FOR EACH ROW + BEGIN + IF (SELECT coalesce(COUNT(id),0) FROM event_registration + WHERE canceled_at is null AND id_event = NEW.id_event) + > + (SELECT coalesce(seat_count,0) from event where id_event = NEW.id_event) + THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = 'MAX_SEAT_COUNT_EXCEEDED'; + END IF; + END; + "); + } + + public function down() + { + $this->execute("DROP TRIGGER IF EXISTS event_seat_count_check;"); + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/doc/group_training.txt b/doc/group_training.txt new file mode 100644 index 0000000..fa69123 --- /dev/null +++ b/doc/group_training.txt @@ -0,0 +1,38 @@ + +trainer + id + name + phone + email + password + active + +room + id + name + seats + +event_type + id + type + created_at + updated_at + +event + id + start + end + id_room + id_trainer + id_type + seats_reserved + created_at + updated_at + +event_registration + id + id_event + id_customer + status + created_at + canceled_at \ No newline at end of file