add registrations to customer gui
This commit is contained in:
@@ -13,8 +13,11 @@ use common\models\Event;
|
||||
use customerapi\models\available\EventInterval;
|
||||
use customerapi\models\available\EventAvailable;
|
||||
use customerapi\models\DayToDisplay;
|
||||
use customerapi\models\details\EventDetailsView;
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use yii\db\Query;
|
||||
use yii\web\Response;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
|
||||
@@ -82,7 +85,6 @@ class EventController extends CustomerApiController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return
|
||||
$this->asJson([
|
||||
'interval' => $interval,
|
||||
@@ -90,4 +92,41 @@ class EventController extends CustomerApiController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Query $query
|
||||
* @param $interval
|
||||
* @return the query with the added conditions
|
||||
*/
|
||||
private function buildEventQuery($query, $interval)
|
||||
{
|
||||
return $query
|
||||
->innerJoinWith('trainer')
|
||||
->innerJoinWith('eventType')
|
||||
->innerJoinWith('room')
|
||||
->joinWith('activeEventRegistrations')
|
||||
->andWhere(['>=', 'event.start', $interval->firstActiveDate->getTimestamp()])
|
||||
->andWhere(['<', 'event.start', (clone $interval->lastActiveDate)->modify('+1 day')->getTimestamp()])
|
||||
->andWhere(['event.active' => '1']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param integer $id_event the id of the event
|
||||
* @return Response the response
|
||||
* @throws \yii\base\Exception on any error
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionEvent($id_event)
|
||||
{
|
||||
$interval = EventInterval::createInterval();
|
||||
try {
|
||||
$query = EventDetailsView::find();
|
||||
$query = $this->buildEventQuery($query, $interval);
|
||||
$query = $query->andWhere(['event.id' => $id_event]);
|
||||
$event = $query->one();
|
||||
return $this->asJson($event);
|
||||
} catch (Exception $e) {
|
||||
throw new \yii\base\Exception($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user