minor changes
This commit is contained in:
@@ -7,6 +7,7 @@ use common\manager\EventRegistrationManager;
|
||||
use common\models\CardEventRegistrationForm;
|
||||
use common\models\EventEquipmentType;
|
||||
use common\models\EventEquipmentTypeAssignment;
|
||||
use common\models\EventRegistration;
|
||||
use common\models\EventRegistrationEquipmentTypeAssignment;
|
||||
use common\models\Trainer;
|
||||
use common\modules\event\EventModule;
|
||||
@@ -31,6 +32,7 @@ use yii\web\HttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\web\Response;
|
||||
use yii\web\UnauthorizedHttpException;
|
||||
|
||||
/** @noinspection PhpUnused */
|
||||
|
||||
@@ -127,6 +129,10 @@ class EventController extends Controller
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
if ( !RoleDefinition::canAny([RoleDefinition::$ROLE_TRAINER, RoleDefinition::$ROLE_ADMIN])){
|
||||
throw new UnauthorizedHttpException();
|
||||
}
|
||||
|
||||
$modelAndView = new CreateEventModelAndView();
|
||||
|
||||
$event = new EventCreate();
|
||||
@@ -166,6 +172,9 @@ class EventController extends Controller
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
if ( !RoleDefinition::canAny([RoleDefinition::$ROLE_TRAINER, RoleDefinition::$ROLE_ADMIN])){
|
||||
throw new UnauthorizedHttpException();
|
||||
}
|
||||
$modelAndView = new CreateEventModelAndView();
|
||||
$event = EventCreate::findOne($id);
|
||||
if ( !isset($event)){
|
||||
@@ -220,8 +229,8 @@ class EventController extends Controller
|
||||
$db = Yii::$app->db;
|
||||
$tx = $db->beginTransaction();
|
||||
try {
|
||||
$registration = $eventRegistrationManager->loadRegistration($id);
|
||||
$eventRegistrationManager->cancelRegistration($registration);
|
||||
$registration = $eventRegistrationManager->loadRegistration($id,null);
|
||||
$eventRegistrationManager->cancelRegistration($registration,null,EventRegistration::CANCEL_REASON_CUSTOMER);
|
||||
$tx->commit();
|
||||
return $this->redirect(['view', 'id' => $registration->id_event]);
|
||||
} catch (Exception $ex) {
|
||||
@@ -230,26 +239,26 @@ class EventController extends Controller
|
||||
}
|
||||
}/** @noinspection PhpUnused */
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return Response
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionDeleteRegistration($id)
|
||||
{
|
||||
$eventRegistrationManager = new EventRegistrationManager();
|
||||
$db = Yii::$app->db;
|
||||
$tx = $db->beginTransaction();
|
||||
try {
|
||||
$registration = $eventRegistrationManager->loadRegistration($id);
|
||||
$eventRegistrationManager->deleteRegistration($registration);
|
||||
$tx->commit();
|
||||
return $this->redirect(['view', 'id' => $registration->id_event]);
|
||||
} catch (Exception $ex) {
|
||||
$tx->rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
}/** @noinspection PhpUnused */
|
||||
// /**
|
||||
// * @param $id
|
||||
// * @return Response
|
||||
// * @throws Exception
|
||||
// */
|
||||
// public function actionDeleteRegistration($id)
|
||||
// {
|
||||
// $eventRegistrationManager = new EventRegistrationManager();
|
||||
// $db = Yii::$app->db;
|
||||
// $tx = $db->beginTransaction();
|
||||
// try {
|
||||
// $registration = $eventRegistrationManager->loadRegistration($id);
|
||||
// $eventRegistrationManager->deleteRegistration($registration);
|
||||
// $tx->commit();
|
||||
// return $this->redirect(['view', 'id' => $registration->id_event]);
|
||||
// } catch (Exception $ex) {
|
||||
// $tx->rollBack();
|
||||
// throw $ex;
|
||||
// }
|
||||
// }/** @noinspection PhpUnused */
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
|
||||
Reference in New Issue
Block a user