prepare customer registration cancel
This commit is contained in:
parent
f175258bc9
commit
e87adb36fd
@ -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);
|
||||
|
||||
@ -1,7 +1,41 @@
|
||||
<div class="container">
|
||||
<!-- <app-fit-weekday-selector [days]="(availableEvents | async)?.days" ></app-fit-weekday-selector>-->
|
||||
<ng-container *ngIf="registration | async">
|
||||
{{registration | json}}
|
||||
<ng-container *ngIf="registration ">
|
||||
<h1>Foglalás</h1>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Edzés típusa</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event.eventType.name}}</span></div>
|
||||
</div>
|
||||
<div class="row" *ngIf="registration.event.trainer">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Edző</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event?.trainer?.name}}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Edzés kezdési időpontja</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event.start * 1000 | date:'yyyy.MM.dd HH:mm'}}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Edzés vége</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event.end * 1000 | date:'yyyy.MM.dd HH:mm'}}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Férőhelyek száma</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event.seat_count }}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-3 col-sm-12"><span class="title">Terem</span></div>
|
||||
<div class="col-lg-9 col-sm-12"><span>{{registration.event?.room?.name }}</span></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-9 col-sm-12 pt-2">
|
||||
<!-- <a *ngIf="mayRegister(event)" class="btn btn-primary " (click)="register(event)">Foglalás</a>-->
|
||||
<a *ngIf="mayCancel(event)" class="btn btn-primary" (click)="cancel(registration)">Lemondás</a>
|
||||
<!-- <span *ngIf="!mayCancel(event) && noFreeSeat(event)">Már nincs szabad hely</span>-->
|
||||
</div>
|
||||
<div class="col-lg-3 text-lg-right col-sm-12 pt-2">
|
||||
<!-- <a class="btn btn-primary " (click)="goBack(event)">Vissza</a>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ng-container>
|
||||
</div>
|
||||
|
||||
|
||||
@ -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: 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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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`;
|
||||
}
|
||||
|
||||
@ -39,6 +39,10 @@ export class EventService {
|
||||
return this.http.post(Endpoints.POST_EVENT_CANCEL( idEvent ),{}) as Observable<Event>;
|
||||
}
|
||||
|
||||
cancelRegistration(idRegistration: number ): Observable<Event> {
|
||||
return this.http.post(Endpoints.POST_EVENT_REGISTRATION_CANCEL( idRegistration ),{}) as Observable<Event>;
|
||||
}
|
||||
|
||||
findEventsAvailable(): Observable<EventsAvailableResponse>{
|
||||
return this.http.get(Endpoints.GET_EVENTS_AVAILABLE()) as Observable<EventsAvailableResponse>;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user