diff --git a/backend/components/AdminMenuStructure.php b/backend/components/AdminMenuStructure.php
index 86bcd13..f0c49be 100644
--- a/backend/components/AdminMenuStructure.php
+++ b/backend/components/AdminMenuStructure.php
@@ -166,6 +166,7 @@ class AdminMenuStructure{
/////////////////////////////
if ( Yii::$app->user ){
$items = [];
+ $items[] = ['label' => 'Felszerelés', 'url' => ['/event-equipment-type' ] ];
$items[] = ['label' => 'Edzők', 'url' => ['/trainer' ] ];
$items[] = ['label' => 'Termek', 'url' => ['/room' ] ];
$items[] = ['label' => 'Esemény típusok', 'url' => ['/event-type' ] ];
diff --git a/backend/controllers/EventEquipmentTypeController.php b/backend/controllers/EventEquipmentTypeController.php
new file mode 100644
index 0000000..9dcdc90
--- /dev/null
+++ b/backend/controllers/EventEquipmentTypeController.php
@@ -0,0 +1,109 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['post'],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Lists all EventEquipmentType models.
+ * @return mixed
+ */
+ public function actionIndex()
+ {
+ $searchModel = new EventEquipmentTypeSearch();
+ $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
+
+ return $this->render('index', [
+ 'searchModel' => $searchModel,
+ 'dataProvider' => $dataProvider,
+ ]);
+ }
+
+ /**
+ * Displays a single EventEquipmentType model.
+ * @param integer $id
+ * @return mixed
+ */
+ public function actionView($id)
+ {
+ return $this->render('view', [
+ 'model' => $this->findModel($id),
+ ]);
+ }
+
+ /**
+ * Creates a new EventEquipmentType model.
+ * If creation is successful, the browser will be redirected to the 'view' page.
+ * @return mixed
+ */
+ public function actionCreate()
+ {
+ $model = new EventEquipmentType();
+
+ 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 EventEquipmentType 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,
+ ]);
+ }
+ }
+
+
+ /**
+ * Finds the EventEquipmentType model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return EventEquipmentType the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = EventEquipmentType::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+}
diff --git a/backend/models/EventEquipmentTypeSearch.php b/backend/models/EventEquipmentTypeSearch.php
new file mode 100644
index 0000000..b1754e8
--- /dev/null
+++ b/backend/models/EventEquipmentTypeSearch.php
@@ -0,0 +1,67 @@
+ $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/views/event-equipment-type/_form.php b/backend/views/event-equipment-type/_form.php
new file mode 100644
index 0000000..dbb984c
--- /dev/null
+++ b/backend/views/event-equipment-type/_form.php
@@ -0,0 +1,23 @@
+
+
+
-
= Html::encode($this->title) ?>
= $this->render('_form', [
diff --git a/common/messages/hu/common/event-equipment-type.php b/common/messages/hu/common/event-equipment-type.php
new file mode 100644
index 0000000..1fe59e1
--- /dev/null
+++ b/common/messages/hu/common/event-equipment-type.php
@@ -0,0 +1,14 @@
+ "Megnevezés",
+ "Search" => "Keresés",
+ "Create" => "Mentés",
+ "Update" => "Módosít",
+ "Delete" => "Törlés",
+ "Created At" => "Létrehozás dátum, idő",
+ "Updated At" => "Módosítás dátum, idő",
+ "Event Equipment Types" => "Felszerelések",
+ "Create Event Equipment Type" => "Új felszerelés létrehozása",
+ "Update {modelClass}: " => "Felszerelés módosítása: ",
+];
\ No newline at end of file
diff --git a/common/models/Event.php b/common/models/Event.php
index fdbb880..ee491c9 100644
--- a/common/models/Event.php
+++ b/common/models/Event.php
@@ -2,6 +2,7 @@
namespace common\models;
+use customerapi\models\details\EventEquipmentTypeAssignmentView;
use DateTime;
use DateTimeZone;
use Exception;
@@ -147,6 +148,14 @@ class Event extends ActiveRecord
return $this->hasMany(EventRegistration::class,['id_event' => 'id']);
}
+ /**
+ * @return EventEquipmentTypeAssignment[]|ActiveQuery
+ */
+ public function getEquipmentTypeAssignments(){
+ return $this->hasMany($this->getEquipmentTypeAssignmentsClass(),['id_event' => 'id']);
+ }
+
+
/**
* @return EventRegistration[]|ActiveQuery
@@ -167,6 +176,11 @@ class Event extends ActiveRecord
return count($this->getActiveEventRegistrations()->all());
}
+ protected function getEquipmentTypeAssignmentsClass()
+ {
+ return EventEquipmentTypeAssignment::class;
+ }
+
/** @noinspection PhpUnused */
public function getOpenSeatCount(){
return $this->seat_count - $this->getEventRegistrationCount();
diff --git a/common/models/EventEquipmentType.php b/common/models/EventEquipmentType.php
index 4520f14..c1cfe15 100644
--- a/common/models/EventEquipmentType.php
+++ b/common/models/EventEquipmentType.php
@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type".
@@ -31,22 +33,32 @@ class EventEquipmentType extends \yii\db\ActiveRecord
public function rules()
{
return [
- [['created_at', 'updated_at'], 'required'],
- [['created_at', 'updated_at'], 'safe'],
+ [['name'], 'required'],
[['name'], 'string', 'max' => 255]
];
}
+ public function behaviors()
+ {
+ return ArrayHelper::merge( [
+ [
+ 'class' => TimestampBehavior::className(),
+ 'value' => function(){ return date('Y-m-d H:i:s' ); }
+ ]
+ ],
+ parent::behaviors());
+ }
+
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
- 'id' => Yii::t('common/event', 'ID'),
- 'name' => Yii::t('common/event', 'Name'),
- 'created_at' => Yii::t('common/event', 'Created At'),
- 'updated_at' => Yii::t('common/event', 'Updated At'),
+ 'id' => Yii::t('common/event-equipment-type', 'ID'),
+ 'name' => Yii::t('common/event-equipment-type', 'Name'),
+ 'created_at' => Yii::t('common/event-equipment-type', 'Created At'),
+ 'updated_at' => Yii::t('common/event-equipment-type', 'Updated At'),
];
}
diff --git a/common/models/EventEquipmentTypeAssignment.php b/common/models/EventEquipmentTypeAssignment.php
index ff27913..88f1876 100644
--- a/common/models/EventEquipmentTypeAssignment.php
+++ b/common/models/EventEquipmentTypeAssignment.php
@@ -3,6 +3,8 @@
namespace common\models;
use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type_assignment".
@@ -39,6 +41,18 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
];
}
+ public function behaviors()
+ {
+ return ArrayHelper::merge( [
+ [
+ 'class' => TimestampBehavior::className(),
+ 'value' => function(){ return date('Y-m-d H:i:s' ); }
+ ]
+ ],
+ parent::behaviors());
+ }
+
+
/**
* @inheritdoc
*/
@@ -57,7 +71,7 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
- public function getIdEvent()
+ public function getEvent()
{
return $this->hasOne(Event::className(), ['id' => 'id_event']);
}
@@ -65,7 +79,7 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
- public function getIdEventEquipmentType()
+ public function getEventEquipmentType()
{
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
}
diff --git a/common/modules/event/controllers/EventController.php b/common/modules/event/controllers/EventController.php
index d396e9e..d6dea32 100644
--- a/common/modules/event/controllers/EventController.php
+++ b/common/modules/event/controllers/EventController.php
@@ -4,9 +4,13 @@ namespace common\modules\event\controllers;
use common\manager\EventRegistrationManager;
use common\models\CardEventRegistrationForm;
+use common\models\EventEquipmentType;
+use common\models\EventEquipmentTypeAssignment;
+use common\models\EventRegistrationEquipmentTypeAssignment;
use common\modules\event\EventModule;
use common\modules\event\models\copy\ClearWeekForm;
use common\modules\event\models\copy\CopyWeekSearch;
+use common\modules\event\models\EventEquipmentTypeForm;
use common\modules\event\models\EventPermissions;
use common\modules\event\models\timetable\TimeTableSearch;
use DateTime;
@@ -43,11 +47,12 @@ class EventController extends Controller
$module = EventModule::getInstance();
assert(isset($module), 'event module not set');
- $allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable', 'copy-week','clear-week'];
+ $allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable', 'copy-week','clear-week',];
if ($module->mode === 'backend') {
$allowedActions[] = 'create';
$allowedActions[] = 'update';
$allowedActions[] = 'delete';
+ $allowedActions[] = 'equipment-types-assignment';
}
$behaviors['access'] = [
'class' => AccessControl::class,
@@ -93,14 +98,19 @@ class EventController extends Controller
{
$eventRegistrationManager = new EventRegistrationManager();
-
$dataProvider = new ActiveDataProvider([
'query' => $eventRegistrationManager->createFindRegistrationsQuery($id),
]
);
+
+ $equipmentAssignmentDataProvider = new ActiveDataProvider([
+ 'query' => EventEquipmentTypeAssignment::find()->andWhere(['id_event' => $id]),
+ ]
+ );
return $this->render('view', [
'model' => $this->findModel($id),
'dataProvider' => $dataProvider,
+ 'equipmentAssignmentDataProvider' => $equipmentAssignmentDataProvider,
'permissions' => new EventPermissions()
]);
}
@@ -295,6 +305,36 @@ class EventController extends Controller
return $this->redirect(['timetable', []]);
}
+ /**
+ * @param $id the id
+ * @return string
+ * @throws NotFoundHttpException
+ */
+ public function actionEquipmentTypesAssignment($id)
+ {
+// $event = $this->findModel($id);
+ $formModel = new EventEquipmentTypeForm(
+ ['idEvent' => $id]
+ );
+ $formModel->loadEvent();
+ $formModel->loadAssignedEquipment();
+ if (Yii::$app->request->isPost) {
+ if ($formModel->load(Yii::$app->request->post()) && $formModel->save()) {
+ $this->redirect(['view','id' => $formModel->event->id]);
+ }
+ }else{
+ if ( !isset($formModel->event) ){
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+
+ $formModel->equipmentTypeList = EventEquipmentType::find()->orderBy(['name' => SORT_ASC])->all();
+
+ return $this->render('equipment-types-assignment', [
+ 'formModel' => $formModel
+ ]);
+ }
+
/**
* Finds the Event model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
diff --git a/common/modules/event/models/EventEquipmentTypeForm.php b/common/modules/event/models/EventEquipmentTypeForm.php
new file mode 100644
index 0000000..7ec8ced
--- /dev/null
+++ b/common/modules/event/models/EventEquipmentTypeForm.php
@@ -0,0 +1,118 @@
+equipmentType = EventEquipmentType::find()->andWhere(['id'=> $this->idEquipmentType])->one();
+ if ( !isset($this->equipmentType)){
+ $this->addError("idEquipmentType","Hibás Felszerelés típus");
+ }
+ }
+
+ public function validateIdEvent(){
+ $this->loadEvent();
+ if ( !isset($this->event)){
+ $this->addError("idEvent","Esemény nem található");
+ }
+ }
+
+ public function loadEvent(){
+ $this->event = Event::find()->andWhere(['id'=> $this->idEvent])->one();
+ }
+
+ public function loadAssignedEquipment(){
+ $this->assignedEquipmentTypes = new ActiveDataProvider(
+ [
+ 'query' => EventEquipmentTypeAssignment::find()->andWhere(['id_event' => $this->event->id]),
+ 'pagination' => false,
+// 'sort' => [
+// 'defaultOrder' => [
+// 'created_at' => SORT_DESC,
+// 'title' => SORT_ASC,
+// ]
+// ],
+ ]
+ );
+
+ }
+
+ /**
+ * @throws Exception
+ */
+ public function save(){
+ $result = $this->validate();
+ if ( $result === false ){
+ return false;
+ }
+
+ // delete assignments with the same type
+ EventEquipmentTypeAssignment::deleteAll(
+ [
+ 'id_event' => $this->event->id,
+ 'id_event_equipment_type' => $this->equipmentType->id
+ ]
+ );
+
+ if ( $this->count > 0 ){
+ $assignment = new EventEquipmentTypeAssignment();
+ $assignment->id_event = $this->event->id;
+ $assignment->id_event_equipment_type = $this->equipmentType->id;
+ $assignment->count = $this->count;
+ $assignment->save(false);
+ }
+
+ return true;
+ }
+
+ public function attributeLabels(){
+ return [
+ "count" => "Mennyiség"
+ ];
+ }
+
+
+
+}
diff --git a/common/modules/event/views/event/_equipment-types-assignment_form.php b/common/modules/event/views/event/_equipment-types-assignment_form.php
new file mode 100644
index 0000000..a769956
--- /dev/null
+++ b/common/modules/event/views/event/_equipment-types-assignment_form.php
@@ -0,0 +1,84 @@
+
+
Szükséges felszerelés hozzáadása eseményhez
+
+
Esemény
+
+ $model->event,
+ 'attributes' => [
+ 'id',
+ 'start:datetime',
+ [
+ 'attribute' => 'eventType.name',
+ 'label' => 'Típus'
+ ],
+ [
+ 'attribute' => 'trainer.name',
+ 'label' => 'Edző'
+ ]
+ ],
+ ]);
+ } catch (Exception $e) {
+ echo "failed to render event details ";
+ }
+ echo Html::a(Yii::t('event', 'Vissza az eseményhez'), ['view', 'id' => $model->event->id], ['class' => 'btn btn-primary']);
+ ?>
+
+
+
+
+
Felszerelés hozzáadása/módosítása
+
+
+
+ = $form->field($model, 'idEvent')->hiddenInput()->label(false) ?>
+
+
+ = $form->field($model, 'idEquipmentType')->dropDownList(ArrayHelper::map($model->equipmentTypeList, 'id', 'name'))->label("Felszerelés") ?>
+
+
+
+ = $form->field($model, 'count')->textInput()->label("Mennyiség") ?>
+
+ = Html::submitButton( 'Hozzáad/Módosít', ['class' => 'btn btn-success' ]) ?>
+
+
+
+
+
+
+
Szükséges felszerelés
+
+ $model->assignedEquipmentTypes,
+ 'columns' => [
+ [
+ 'label' => "Felszerelés",
+ 'value' => function ($data) {
+ return $data->eventEquipmentType->name;
+ },
+ ],
+ [
+ 'label' => "Rendelkezésre álló mennyiség",
+ 'value' => function ($data) {
+ return $data->count;
+ },
+ ],
+ ],
+ ]);
+ ?>
+
+
diff --git a/common/modules/event/views/event/equipment-types-assignment.php b/common/modules/event/views/event/equipment-types-assignment.php
new file mode 100644
index 0000000..5c41c5b
--- /dev/null
+++ b/common/modules/event/views/event/equipment-types-assignment.php
@@ -0,0 +1,6 @@
+render('_equipment-types-assignment_form', ['model' => $formModel]);
+
diff --git a/common/modules/event/views/event/index.php b/common/modules/event/views/event/index.php
index 2f78e26..db514b4 100644
--- a/common/modules/event/views/event/index.php
+++ b/common/modules/event/views/event/index.php
@@ -16,6 +16,7 @@ if ( $permissions->allowCreate ){
$indexTableTemplateButtons[] = '{update}';
}
$indexTableTemplateButtons[] = '{reserve-card}';
+$indexTableTemplateButtons[] = '{equipment-types-assignment}';
?>
@@ -108,7 +109,7 @@ $indexTableTemplateButtons[] = '{reserve-card}';
],
[
'class' => 'yii\grid\ActionColumn',
- 'template' => join("",$indexTableTemplateButtons),
+ 'template' => join(" ",$indexTableTemplateButtons),
'urlCreator' => function ($action, $model, $key, $index) {
$params = ['id' => $model['event_id']];
$params[0] = "event" . '/' . $action;
@@ -148,6 +149,14 @@ $indexTableTemplateButtons[] = '{reserve-card}';
'data-pjax' => '0',
];
return Html::a('
', $url, $options);
+ },
+ 'equipment-types-assignment' => function ($url, $model, $key) {
+ $options = [
+ 'title' => Yii::t('yii', 'Equipment Types'),
+ 'aria-label' => Yii::t('yii', 'Equipment Types'),
+ 'data-pjax' => '0',
+ ];
+ return Html::a('
', $url, $options);
}
]
diff --git a/common/modules/event/views/event/update.php b/common/modules/event/views/event/update.php
index 19874fe..4633a75 100644
--- a/common/modules/event/views/event/update.php
+++ b/common/modules/event/views/event/update.php
@@ -5,7 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
-$this->title = Yii::t('event', 'Update Event:') . ' ' . $model->id;
+$this->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');
diff --git a/common/modules/event/views/event/view.php b/common/modules/event/views/event/view.php
index 69afa98..8cd332f 100644
--- a/common/modules/event/views/event/view.php
+++ b/common/modules/event/views/event/view.php
@@ -1,5 +1,6 @@
allowEdit) {
echo Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
+ echo " ";
+ echo Html::a("Felszerelés", ['equipment-types-assignment', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
if ($model->canReserve()) {
+ echo " ";
echo Html::a(Yii::t('event', 'Reservation'), ['reserve-card', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
?>
@@ -65,13 +69,38 @@ function getCommonColumnsHtmlOptions($model)
render('_view', ['model' => $model]); ?>
+
+
Szükséges felszerelés
+
+ $equipmentAssignmentDataProvider,
+ 'columns' => [
+ [
+ 'label' => "Felszerelés",
+ 'value' => function ($data) {
+ return $data->eventEquipmentType->name;
+ },
+ ],
+ [
+ 'label' => "Rendelkezésre álló mennyiség",
+ 'value' => function ($data) {
+ return $data->count;
+ },
+ ],
+ ],
+ ]);
+ ?>
+
+
+
Foglalások
$dataProvider,
'columns' => [
[
diff --git a/customer/app/angular.json b/customer/app/angular.json
index dab6ea7..c7ab20d 100644
--- a/customer/app/angular.json
+++ b/customer/app/angular.json
@@ -64,7 +64,8 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
- "browserTarget": "app:build"
+ "browserTarget": "app:build",
+ "port": 4260
},
"configurations": {
"production": {
diff --git a/customer/app/src/app/pages/event-details/event-details.component.html b/customer/app/src/app/pages/event-details/event-details.component.html
index e6e32bb..7243ff6 100644
--- a/customer/app/src/app/pages/event-details/event-details.component.html
+++ b/customer/app/src/app/pages/event-details/event-details.component.html
@@ -1,37 +1,76 @@
Jelentkezés
-
-
Edzés típusa
-
{{event.eventType.name}}
-
-
-
Edző
-
{{event?.trainer?.name}}
-
-
-
Edzés kezdési időpontja
-
{{event.start * 1000 | date:'yyyy.MM.dd HH:mm'}}
-
-
-
Edzés vége
-
{{event.end * 1000 | date:'yyyy.MM.dd HH:mm'}}
-
-
-
Férőhelyek száma
-
{{event.seat_count }}
-
-
-
Terem
-
{{event?.room?.name }}
-
-
-
diff --git a/customer/app/src/app/pages/event-details/event-details.component.ts b/customer/app/src/app/pages/event-details/event-details.component.ts
index b5e7b20..66fb1d7 100644
--- a/customer/app/src/app/pages/event-details/event-details.component.ts
+++ b/customer/app/src/app/pages/event-details/event-details.component.ts
@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
-import {Event, EventService} from "../../services/event.service";
+import {Event, EventService, RegisterEventRequest} from "../../services/event.service";
import {ActivatedRoute} from "@angular/router";
import {NavigationService} from "../../services/navigation.service";
+import {FormBuilder, FormGroup, Validators} from "@angular/forms";
@Component({
selector: 'app-event-details',
@@ -12,16 +13,31 @@ export class EventDetailsComponent implements OnInit {
event: Event;
+ eventForm: FormGroup;
+ formControls: any;
+
constructor(
+ private fb: FormBuilder,
private eventService: EventService,
private route: ActivatedRoute,
private navigationService: NavigationService
) { }
ngOnInit() {
+ this.formControls = {
+ idEvent: ["", [Validators.required ]],
+ }
let idEvent = +this.route.snapshot.paramMap.get('idEvent');
this.eventService.findEvent(idEvent).subscribe(
- value => this.event = value
+ value => {
+
+ this.event = value;
+ this.event.equipmentTypeAssignments.forEach((assignment,index) =>{
+ this.formControls['equipment'+assignment.id] = ["", [Validators.required ]]
+ })
+ this.eventForm = this.fb.group(this.formControls);
+ this.eventForm.patchValue({"idEvent": this.event.id})
+ }
);
}
@@ -44,7 +60,24 @@ export class EventDetailsComponent implements OnInit {
register(event: Event) {
console.info("register", event);
- this.eventService.register(event.id)
+ console.info(this.eventForm.value);
+
+ let request :RegisterEventRequest= {
+ idEvent: this.eventForm.value.idEvent,
+ equipment: []
+
+ };
+ this.event.equipmentTypeAssignments.forEach((value, index) => {
+ if ( this.eventForm.value.hasOwnProperty('equipment'+value.id) ){
+ if ( this.eventForm.value['equipment'+value.id] === "1"){
+ request.equipment.push(value.id);
+ }
+ }
+ });
+
+ console.info(request);
+
+ this.eventService.register(request)
.subscribe(
value => {},
value => {},
diff --git a/customer/app/src/app/services/event.service.ts b/customer/app/src/app/services/event.service.ts
index 6f48c9b..9b5f667 100644
--- a/customer/app/src/app/services/event.service.ts
+++ b/customer/app/src/app/services/event.service.ts
@@ -23,8 +23,8 @@ export class EventService {
return this.http.get(Endpoints.GET_EVENT( idEvent )) as Observable
;
}
- register(idEvent: number ): Observable {
- return this.http.post(Endpoints.POST_EVENT_REGISTRATIONS_REGISTER( idEvent ),{}) as Observable;
+ register(registerEventRequest: RegisterEventRequest ): Observable {
+ return this.http.post(Endpoints.POST_EVENT_REGISTRATIONS_REGISTER( registerEventRequest.idEvent ),registerEventRequest) as Observable;
}
findRegistrations(): Observable {
@@ -65,6 +65,20 @@ export interface Event {
eventType: EventType;
reservedAt: number;
room: Room;
+ equipmentTypeAssignments?: EquipmentTypeAssignment[];
+}
+
+export interface EquipmentTypeAssignment {
+ id: number;
+ count: number;
+ equipmentType: EquipmentType;
+
+}
+
+export interface EquipmentType {
+ id: number;
+ name: string;
+
}
export interface Room {
@@ -93,3 +107,8 @@ export interface Registration {
created_at: number;
event: Event
}
+
+export interface RegisterEventRequest{
+ idEvent: number;
+ equipment: number[];
+}
diff --git a/customerapi/models/details/EventDetailsView.php b/customerapi/models/details/EventDetailsView.php
index b64193d..76570e2 100644
--- a/customerapi/models/details/EventDetailsView.php
+++ b/customerapi/models/details/EventDetailsView.php
@@ -32,6 +32,12 @@ class EventDetailsView extends Event
return RoomDetailsView::class;
}
+ protected function getEquipmentTypeAssignmentsClass()
+ {
+ return EventEquipmentTypeAssignmentView::class;
+ }
+
+
/**
* @Override
* @return array|false
@@ -50,6 +56,7 @@ class EventDetailsView extends Event
$fields['trainer'] = 'trainer';
$fields['eventType'] = 'eventType';
$fields['room'] = 'room';
+ $fields['equipmentTypeAssignments'] = 'equipmentTypeAssignments';
return $fields;
}
diff --git a/customerapi/models/details/EventEquipmentTypeAssignmentView.php b/customerapi/models/details/EventEquipmentTypeAssignmentView.php
new file mode 100644
index 0000000..ea4354c
--- /dev/null
+++ b/customerapi/models/details/EventEquipmentTypeAssignmentView.php
@@ -0,0 +1,24 @@
+ "id",
+ "count" => "count",
+ ];
+ $fields['equipmentType'] = 'eventEquipmentType';
+ return $fields;
+ }
+
+}
\ No newline at end of file