diff --git a/common/manager/EventRegistrationManager.php b/common/manager/EventRegistrationManager.php
index 7a15315..2fd8b94 100644
--- a/common/manager/EventRegistrationManager.php
+++ b/common/manager/EventRegistrationManager.php
@@ -63,6 +63,8 @@ class EventRegistrationManager extends BaseObject
try {
if ($cardEventForm->validate()) {
+ $requiresTicket = false;
+
/** @var Card $card */
$card = Card::readCard($cardEventForm->card_number, false);
if (!isset($card)) {
@@ -73,10 +75,10 @@ class EventRegistrationManager extends BaseObject
throw new NotFoundHttpException('Customer not found', self::CUSTOMER_NOT_FOUND);
}
- $activeTickets = $card->getActiveTickets();
- if (count($activeTickets) === 0) {
- throw new NotFoundHttpException('Ticket not found', self::TICKET_NOT_FOUND);
- }
+// $activeTickets = $card->getActiveTickets();
+// if (count($activeTickets) === 0) {
+// throw new NotFoundHttpException('Ticket not found', self::TICKET_NOT_FOUND);
+// }
/** @var Event $event */
$event = Event::find()->andWhere(['id' => $cardEventForm->event_id])->one();
@@ -98,22 +100,22 @@ class EventRegistrationManager extends BaseObject
throw new ServerErrorHttpException('Event type not found', self::EVENT_TYPE_NOT_FOUND);
}
- $selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
-
-
- if (!isset($selectedTicket)) {
- throw new NotFoundHttpException('Ticket not found', self::TICKET_INSUFFICIENT);
- }
-
- if ($selectedTicket->hasOpenReservationCount()) {
- $selectedTicket->consumeReservationCount(1);
- }
- $selectedTicket->save();
+// $selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
+//
+//
+// if (!isset($selectedTicket)) {
+// throw new NotFoundHttpException('Ticket not found', self::TICKET_INSUFFICIENT);
+// }
+//
+// if ($selectedTicket->hasOpenReservationCount()) {
+// $selectedTicket->consumeReservationCount(1);
+// }
+// $selectedTicket->save();
$registration = new EventRegistration();
$registration->id_event = $event->id;
$registration->id_card = $card->id_card;
- $registration->id_ticket = $selectedTicket->id_ticket;
+// $registration->id_ticket = $selectedTicket->id_ticket;
$registration->id_customer = $card->customer->id_customer;
try {
$registration->save(false);
@@ -200,13 +202,13 @@ class EventRegistrationManager extends BaseObject
return false;
}
- $ticket = Ticket::findOne(['id_ticket' => $registration->id_ticket]);
- if( !isset($ticket ) ) {
- throw new \yii\base\Exception('Ticket not found: ' . $registration->id_ticket);
- }
-
- $ticket->restoreReservationCount(1);
- $ticket->save(false);
+// $ticket = Ticket::findOne(['id_ticket' => $registration->id_ticket]);
+// if( !isset($ticket ) ) {
+// throw new \yii\base\Exception('Ticket not found: ' . $registration->id_ticket);
+// }
+//
+// $ticket->restoreReservationCount(1);
+// $ticket->save(false);
$registration->deleted_at = date('Y-m-d H:i:s');
return $registration->save(false);
diff --git a/customer/app/src/app/pages/registration/registration.component.html b/customer/app/src/app/pages/registration/registration.component.html
index 051600d..95ad58d 100644
--- a/customer/app/src/app/pages/registration/registration.component.html
+++ b/customer/app/src/app/pages/registration/registration.component.html
@@ -1,7 +1,41 @@
-
-
- {{registration | json}}
+
+ Foglalás
+
+
Edzés típusa
+
{{registration.event.eventType.name}}
+
+
+
Edző
+
{{registration.event?.trainer?.name}}
+
+
+
Edzés kezdési időpontja
+
{{registration.event.start * 1000 | date:'yyyy.MM.dd HH:mm'}}
+
+
+
Edzés vége
+
{{registration.event.end * 1000 | date:'yyyy.MM.dd HH:mm'}}
+
+
+
Férőhelyek száma
+
{{registration.event.seat_count }}
+
+
+
Terem
+
{{registration.event?.room?.name }}
+
+
+
diff --git a/customer/app/src/app/pages/registration/registration.component.ts b/customer/app/src/app/pages/registration/registration.component.ts
index f134615..24f3aac 100644
--- a/customer/app/src/app/pages/registration/registration.component.ts
+++ b/customer/app/src/app/pages/registration/registration.component.ts
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {EventService, Registration} from "../../services/event.service";
import {Observable} from "rxjs";
import {ActivatedRoute, Router} from "@angular/router";
+import {tap} from "rxjs/operators";
@Component({
selector: 'app-registration',
@@ -10,7 +11,7 @@ import {ActivatedRoute, Router} from "@angular/router";
})
export class RegistrationComponent implements OnInit {
- registration: Observable;
+ registration: Registration;
constructor(private eventService: EventService,
private route: Router,
@@ -19,9 +20,34 @@ export class RegistrationComponent implements OnInit {
ngOnInit() {
this.activeRoute.params.subscribe( value => {
console.info("map: ", this.activeRoute.snapshot.paramMap);
- this.registration = this.eventService.findRegistration(+this.activeRoute.snapshot.paramMap.get('idRegistration'));
+ let registration = this.eventService.findRegistration(+this.activeRoute.snapshot.paramMap.get('idRegistration'));
+ registration = registration.pipe(
+ tap(x => {
+ console.info("reg",x);
+ })
+ );
+
+ registration.subscribe(
+ value1 => {
+ this.registration = value1;
+ }
+ )
});
}
+ cancel(registration: Registration) {
+ this.eventService.cancelRegistration(registration.id).subscribe(
+ value => {
+ this.route.navigate(['registrations']);
+ },
+ error => {
+ alert('Hiba történt!');
+ }
+ )
+ }
+
+ mayCancel(registration: Registration) {
+ return true;
+ }
}
diff --git a/customer/app/src/app/services/endpoints.ts b/customer/app/src/app/services/endpoints.ts
index 8450ab7..59ae9d6 100644
--- a/customer/app/src/app/services/endpoints.ts
+++ b/customer/app/src/app/services/endpoints.ts
@@ -31,6 +31,10 @@ export class Endpoints {
return `${this.baseUrl}/event/cancel&id_event=${id}`;
}
+ public static POST_EVENT_REGISTRATION_CANCEL( id: number){
+ return `${this.baseUrl}/event-registration/cancel&idRegistration=${id}`;
+ }
+
public static GET_EVENT_TYPES(){
return `${this.baseUrl}/event-type`;
}
diff --git a/customer/app/src/app/services/event.service.ts b/customer/app/src/app/services/event.service.ts
index 50da7a3..6f48c9b 100644
--- a/customer/app/src/app/services/event.service.ts
+++ b/customer/app/src/app/services/event.service.ts
@@ -39,6 +39,10 @@ export class EventService {
return this.http.post(Endpoints.POST_EVENT_CANCEL( idEvent ),{}) as Observable;
}
+ cancelRegistration(idRegistration: number ): Observable {
+ return this.http.post(Endpoints.POST_EVENT_REGISTRATION_CANCEL( idRegistration ),{}) as Observable;
+ }
+
findEventsAvailable(): Observable{
return this.http.get(Endpoints.GET_EVENTS_AVAILABLE()) as Observable;
}
diff --git a/customerapi/controllers/EventController.php b/customerapi/controllers/EventController.php
index 1930414..c3bc25d 100644
--- a/customerapi/controllers/EventController.php
+++ b/customerapi/controllers/EventController.php
@@ -10,6 +10,7 @@ namespace customerapi\controllers;
use common\models\Event;
+use common\models\EventRegistration;
use customerapi\models\available\EventInterval;
use customerapi\models\available\EventAvailable;
use customerapi\models\DayToDisplay;
diff --git a/customerapi/controllers/EventRegistrationController.php b/customerapi/controllers/EventRegistrationController.php
index 121ca06..d41e983 100644
--- a/customerapi/controllers/EventRegistrationController.php
+++ b/customerapi/controllers/EventRegistrationController.php
@@ -45,12 +45,11 @@ class EventRegistrationController extends CustomerApiController
public function actionRegistration($id_registration)
{
$registrations = $this->prepareQueryFindRegistrationsForCustomer()
- ->andWhere(['id_event_registration' => $id_registration])
+ ->andWhere(['event_registration.id' => $id_registration])
->one();
return $this->asJson(
$registrations
);
-
}
/**
@@ -92,4 +91,19 @@ class EventRegistrationController extends CustomerApiController
}
+ /**
+ * Cancel a registration by id
+ * @noinspection PhpUnused
+ * @param $idRegistraton
+ * @throws Throwable
+ * @return Response
+ */
+ public function actionCancel($idRegistraton) {
+ $manager = new EventRegistrationManager();
+ $registration = $manager->loadRegistration($idRegistraton);
+ $manager->deleteRegistration($registration);
+ $registration = $manager->loadRegistration($idRegistraton);
+ return $this->asJson($registration);
+ }
+
}