implement registration in backend
This commit is contained in:
@@ -7,6 +7,7 @@ use common\models\CardEventRegistrationForm;
|
||||
use Yii;
|
||||
use common\models\Event;
|
||||
use backend\models\EventSearch;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\Controller;
|
||||
use yii\web\HttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
@@ -48,11 +49,20 @@ class EventController extends Controller
|
||||
* Displays a single Event model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
$eventRegistrationManager = new EventRegistrationManager();
|
||||
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $eventRegistrationManager->createFindRegistrationsQuery($id),
|
||||
]
|
||||
);
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
'dataProvider' => $dataProvider
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -79,6 +89,7 @@ class EventController extends Controller
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
@@ -109,28 +120,65 @@ class EventController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function actionRegisterCard($id){
|
||||
/**
|
||||
* @param $id
|
||||
* @return \yii\web\Response
|
||||
* @throws \yii\db\Exception
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function actionCancelRegistration($id)
|
||||
{
|
||||
$eventRegistrationManager = new EventRegistrationManager();
|
||||
$db = \Yii::$app->db;
|
||||
$tx = $db->beginTransaction();
|
||||
try{
|
||||
$registration = $eventRegistrationManager->loadRegistration($id);
|
||||
$eventRegistrationManager->cancelRegistration($registration);
|
||||
$tx->commit();
|
||||
return $this->redirect(['view', 'id' => $registration->id_event]);
|
||||
}catch (\Exception $ex){
|
||||
$tx->rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param $id
|
||||
* @return string|\yii\web\Response
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionRegisterCard($id)
|
||||
{
|
||||
|
||||
$event = $this->findModel($id);
|
||||
|
||||
$model = new CardEventRegistrationForm();
|
||||
$model->event_id = $id;
|
||||
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
|
||||
$manager = new EventRegistrationManager();
|
||||
try {
|
||||
$manager->registerCard($model);
|
||||
} catch (HttpException $e) {
|
||||
if ( array_key_exists($e->getCode(),EventRegistrationManager::$STATES)) {
|
||||
$model->addError("id_event", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
|
||||
} else {
|
||||
$model->addError("id_event", Yii::t('event-registration', "Unknown Error"));
|
||||
if ($model->load(Yii::$app->request->post())) {
|
||||
if ($model->validate()) {
|
||||
$manager = new EventRegistrationManager();
|
||||
try {
|
||||
$manager->registerCard($model);
|
||||
} catch (HttpException $e) {
|
||||
if (array_key_exists($e->getCode(), EventRegistrationManager::$STATES)) {
|
||||
$model->addError("card_number", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
|
||||
} else {
|
||||
$model->addError("card_number", Yii::t('event-registration', "Unknown Error"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($model->hasErrors()) {
|
||||
return $this->render('register_card', [
|
||||
'model' => $model,
|
||||
'event' => $event,
|
||||
]);
|
||||
} else {
|
||||
return $this->redirect(['view', 'id' => $id]);
|
||||
}
|
||||
}
|
||||
if ( $model->hasErrors() ){
|
||||
return $this->redirect(['view', 'id' => $model->registration->id]);
|
||||
} else {
|
||||
return $this->render('register_card', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
return $this->render('register_card', [
|
||||
'model' => $model,
|
||||
'event' => $event,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,15 +5,13 @@ namespace backend\controllers;
|
||||
use Yii;
|
||||
use common\models\TicketType;
|
||||
use backend\models\TicketTypeSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* TicketTypeController implements the CRUD actions for TicketType model.
|
||||
*/
|
||||
class TicketTypeController extends \backend\controllers\BackendController
|
||||
class TicketTypeController extends BackendController
|
||||
{
|
||||
|
||||
|
||||
@@ -60,6 +58,7 @@ class TicketTypeController extends \backend\controllers\BackendController
|
||||
* Displays a single TicketType model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
@@ -82,6 +81,7 @@ class TicketTypeController extends \backend\controllers\BackendController
|
||||
$model->time_unit_type = TicketType::TIME_UNIT_MONTH;
|
||||
$model->time_unit_count = 1;
|
||||
$model->max_usage_count = 0;
|
||||
$model->max_reservation_count = 0;
|
||||
$accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
@@ -99,6 +99,7 @@ class TicketTypeController extends \backend\controllers\BackendController
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user