add registrations to customer gui
This commit is contained in:
@@ -13,9 +13,12 @@ use common\manager\EventRegistrationManager;
|
||||
use common\models\CardEventRegistrationForm;
|
||||
use common\models\Customer;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use customerapi\models\available\EventRegistrationAvailable;
|
||||
use customerapi\models\registrations\EventRegistrationAvailable;
|
||||
use Exception;
|
||||
use Throwable;
|
||||
use Yii;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\web\Response;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
|
||||
@@ -23,37 +26,62 @@ class EventRegistrationController extends CustomerApiController
|
||||
{
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
/**
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$interval = EventInterval::createInterval();
|
||||
|
||||
$registrations = EventRegistrationAvailable::find()
|
||||
->innerJoinWith('event')
|
||||
->andWhere(['and',
|
||||
['>=', 'event.start', $interval->firstActiveDate->getTimestamp()],
|
||||
['<', 'event.start', $interval->lastActiveDate->getTimestamp()],
|
||||
['id_customer' => Yii::$app->user->getId()]
|
||||
])->all();
|
||||
$registrations =$this->prepareQueryFindRegistrationsForCustomer()->all();
|
||||
return $this->asJson( $registrations );
|
||||
}
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
/***
|
||||
* @param $id_registration
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionRegistration($id_registration)
|
||||
{
|
||||
$registrations = $this->prepareQueryFindRegistrationsForCustomer()
|
||||
->andWhere(['id_event_registration' => $id_registration])
|
||||
->one();
|
||||
return $this->asJson(
|
||||
|
||||
$registrations
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare a query to get registrations for customer
|
||||
*
|
||||
* @return ActiveQuery
|
||||
* @throws Exception
|
||||
*/
|
||||
private function prepareQueryFindRegistrationsForCustomer(){
|
||||
$interval = EventInterval::createInterval();
|
||||
return EventRegistrationAvailable::find()
|
||||
->innerJoinWith('event')
|
||||
->andWhere(['and',
|
||||
['>=', 'event.start', $interval->firstActiveDate->getTimestamp()],
|
||||
['id_customer' => Yii::$app->user->getId()]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @noinspection PhpUnused
|
||||
* @param $idEvent
|
||||
* @param $id_event
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function actionRegister($idEvent) {
|
||||
public function actionRegister($id_event) {
|
||||
/** @var Customer $customer */
|
||||
$customer = Yii::$app->user->getIdentity();
|
||||
$card =$customer->card;
|
||||
|
||||
$form = new CardEventRegistrationForm();
|
||||
$form->event_id = $idEvent;
|
||||
$form->event_id = $id_event;
|
||||
$form->card_number = $card->number;
|
||||
|
||||
$manager = new EventRegistrationManager();
|
||||
|
||||
Reference in New Issue
Block a user