Merge branch 'feature/group_training' into develop

This commit is contained in:
Roland Schneider 2021-09-27 20:55:07 +02:00
commit f0e52f59c3
573 changed files with 101105 additions and 541 deletions

5
.gitignore vendored
View File

@ -49,9 +49,10 @@ phpunit.phar
/rest/web/assets/** /rest/web/assets/**
!/rest/web/assets/.gitkeep !/rest/web/assets/.gitkeep
/customerapi/web/assets/**
!/customerapi/web/assets/.gitkeep
/customerapi/config/*-local.php /customerapi/config/*-local.php
/customerapi/runtime/logs/** /customerapi/runtime/logs/**
!/customerapi/runtime/.gitkeep !/customerapi/runtime/.gitkeep
/customerapi/web/assets/**
!/customerapi/assets/.gitkeep

View File

@ -2,10 +2,7 @@
namespace backend\components; namespace backend\components;
use Yii; use Yii;
use common\models\Order;
use yii\helpers\Html;
use common\components\RoleDefinition; use common\components\RoleDefinition;
use common\components\Helper;
class AdminMenuStructure{ class AdminMenuStructure{
@ -25,10 +22,10 @@ class AdminMenuStructure{
} }
/**
* @throws \yii\base\InvalidConfigException
*/
protected function addUserMainMenu(){ protected function addUserMainMenu(){
$userMainMenu = null; $userMainMenu = null;
$items = []; $items = [];
@ -165,6 +162,23 @@ class AdminMenuStructure{
]; ];
///////////////////////////// /////////////////////////////
// Group Training
/////////////////////////////
if ( Yii::$app->user ){
$items = [];
$items[] = ['label' => 'Felszerelés', 'url' => ['/event-equipment-type' ] ];
$items[] = ['label' => 'Edzők', 'url' => ['/trainer' ] ];
$items[] = ['label' => 'Termek', 'url' => ['/room' ] ];
$items[] = ['label' => 'Esemény típusok', 'url' => ['/event-type' ] ];
$items[] = ['label' => 'Események', 'url' => ['/event/event/index' ] ];
$items[] = ['label' => 'Órarend', 'url' => ['/event/event/timetable' ] ];
$items[] = ['label' => 'Hét másolása', 'url' => ['/event/event/copy-week' ] ];
$this->menuItems[] = ['label' => 'Csoportos edzés', 'url' => $this->emptyUrl,
'items' => $items
];
}
/////////////////////////////
// Development // Development
///////////////////////////// /////////////////////////////
if ( Yii::$app->user ){ if ( Yii::$app->user ){
@ -184,7 +198,8 @@ class AdminMenuStructure{
if (Yii::$app->user->isGuest) { if (Yii::$app->user->isGuest) {
$mainMenuItem= ['label' => Yii::t('common/site','Login'), 'url' => ['/site/login']]; $mainMenuItem= ['label' => Yii::t('common/site','Login'), 'url' => ['/site/login']];
} else { } else {
$mainMenuItem= [ /** @noinspection PhpUndefinedFieldInspection */
$mainMenuItem= [
'label' => Yii::t('common/site','Logout') . '(' . Yii::$app->user->identity->username . ')', 'label' => Yii::t('common/site','Logout') . '(' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'], 'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post'] 'linkOptions' => ['data-method' => 'post']
@ -194,7 +209,11 @@ class AdminMenuStructure{
} }
public function run(){ /**
* @return array
* @throws \yii\base\InvalidConfigException
*/
public function run(){
$this->addUserMainMenu(); $this->addUserMainMenu();
// $this->addLoginMainMenu(); // $this->addLoginMainMenu();
return $this->menuItems; return $this->menuItems;

View File

@ -12,7 +12,6 @@ return [
'basePath' => dirname(__DIR__), 'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers', 'controllerNamespace' => 'backend\controllers',
'bootstrap' => ['log'], 'bootstrap' => ['log'],
'modules' => [],
'components' => [ 'components' => [
'request' => [ 'request' => [
'enableCsrfValidation'=>false, 'enableCsrfValidation'=>false,
@ -46,5 +45,11 @@ return [
'errorAction' => 'site/error', 'errorAction' => 'site/error',
], ],
], ],
'modules' => [
'event' => [
'class' => 'common\modules\event\EventModule',
'mode' => 'backend'
],
],
'params' => $params, 'params' => $params,
]; ];

View File

@ -149,6 +149,8 @@ class CustomerController extends \backend\controllers\BackendController
* If update is successful, the browser will be redirected to the 'view' page. * If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id * @param integer $id
* @return mixed * @return mixed
* @throws NotFoundHttpException
* @throws \yii\base\InvalidConfigException
*/ */
public function actionUpdate($id) public function actionUpdate($id)
{ {

View File

@ -0,0 +1,109 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\EventEquipmentType;
use backend\models\EventEquipmentTypeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* EventEquipmentTypeController implements the CRUD actions for EventEquipmentType model.
*/
class EventEquipmentTypeController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all EventEquipmentType models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new EventEquipmentTypeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single EventEquipmentType model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new EventEquipmentType model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new EventEquipmentType();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing EventEquipmentType model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Finds the EventEquipmentType model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return EventEquipmentType the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = EventEquipmentType::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,152 @@
<?php
namespace backend\controllers;
use common\manager\EventRegistrationManager;
use common\models\CardEventRegistrationForm;
use Yii;
use common\models\EventRegistration;
use backend\models\EventRegistrationSearch;
use yii\web\BadRequestHttpException;
use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\ServerErrorHttpException;
/**
* EventRegistrationController implements the CRUD actions for EventRegistration model.
*/
class EventRegistrationController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all EventRegistration models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new EventRegistrationSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single EventRegistration model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new EventRegistration model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new EventRegistration();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing EventRegistration model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing EventRegistration model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws \yii\db\StaleObjectException
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
public function actionRegisterCard(){
$model = new CardEventRegistrationForm();
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->hasErrors() ){
return $this->redirect(['view', 'id' => $model->registration->id]);
} else {
return $this->render('register_card', [
'model' => $model,
]);
}
}
/**
* Finds the EventRegistration model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return EventRegistration the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = EventRegistration::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\EventType;
use backend\models\EventTypeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* EventTypeController implements the CRUD actions for EventType model.
*/
class EventTypeController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all EventType models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new EventTypeSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single EventType model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new EventType model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new EventType();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing EventType model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing EventType model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the EventType model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return EventType the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = EventType::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,121 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Room;
use backend\models\RoomSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* RoomController implements the CRUD actions for Room model.
*/
class RoomController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Room models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new RoomSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Room model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Room model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Room();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Room model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Room model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Room model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Room the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Room::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -71,7 +71,8 @@ class SiteController extends Controller
$model = new LoginForm(); $model = new LoginForm();
$model->roles = [ $model->roles = [
'admin', 'admin',
'employee' 'employee',
'trainer',
]; ];
if ($model->load(Yii::$app->request->post()) && $model->login()) { if ($model->load(Yii::$app->request->post()) && $model->login()) {

View File

@ -5,15 +5,13 @@ namespace backend\controllers;
use Yii; use Yii;
use common\models\TicketType; use common\models\TicketType;
use backend\models\TicketTypeSearch; use backend\models\TicketTypeSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use common\models\Account; use common\models\Account;
/** /**
* TicketTypeController implements the CRUD actions for TicketType model. * 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. * Displays a single TicketType model.
* @param integer $id * @param integer $id
* @return mixed * @return mixed
* @throws NotFoundHttpException
*/ */
public function actionView($id) 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_type = TicketType::TIME_UNIT_MONTH;
$model->time_unit_count = 1; $model->time_unit_count = 1;
$model->max_usage_count = 0; $model->max_usage_count = 0;
$model->max_reservation_count = 0;
$accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all(); $accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all();
if ($model->load(Yii::$app->request->post()) && $model->save()) { 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. * If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id * @param integer $id
* @return mixed * @return mixed
* @throws NotFoundHttpException
*/ */
public function actionUpdate($id) public function actionUpdate($id)
{ {

View File

@ -0,0 +1,126 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Trainer;
use backend\models\TrainerSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TrainerController implements the CRUD actions for Trainer model.
*/
class TrainerController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Trainer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TrainerSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Trainer model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Trainer model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Trainer();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Trainer model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Trainer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws \yii\db\StaleObjectException
*/
public function actionDelete($id)
{
$trainer = $this->findModel($id);
$trainer->active = Trainer::ACTIVE_OFF;
$trainer->update( );
return $this->redirect(['index']);
}
/**
* Finds the Trainer model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Trainer the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Trainer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -33,12 +33,11 @@ use common\models\Customer;
*/ */
class CustomerUpdate extends \common\models\Customer class CustomerUpdate extends \common\models\Customer
{ {
public $password_plain;
public $cardNumber; public $cardNumber;
public $partnerCardNumber; public $partnerCardNumber;
public $password_plain;
public $password_repeat;
/** /**
* @inheritdoc * @inheritdoc
@ -58,6 +57,8 @@ class CustomerUpdate extends \common\models\Customer
// [['cardNumber'], 'string', 'max' => 10], // [['cardNumber'], 'string', 'max' => 10],
// [['cardNumber'], 'validateCustomerCard' ], // [['cardNumber'], 'validateCustomerCard' ],
[['password_plain' ] ,'string','min' =>6 ],
[['partnerCardNumber'], 'string', 'max' => 10], [['partnerCardNumber'], 'string', 'max' => 10],
[['partnerCardNumber'], 'validatePartnerCard' ], [['partnerCardNumber'], 'validatePartnerCard' ],
@ -78,7 +79,7 @@ class CustomerUpdate extends \common\models\Customer
], ],
[['password_plain','password_repeat'], 'string', 'max' => 32], [['password_plain' ], 'string', 'max' => 32],
[['sex'], 'integer'], [['sex'], 'integer'],
@ -114,4 +115,21 @@ class CustomerUpdate extends \common\models\Customer
// Customer::find()->andWhere( [$this->cardNumber ) // Customer::find()->andWhere( [$this->cardNumber )
} }
/**
* @param bool $insert
* @return bool
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/
public function beforeSave($insert)
{
$result = parent::beforeSave($insert);
if ($result && !empty($this->password_plain)) {
$this->setPassword($this->password_plain);
return true;
}
return $result;
}
} }

View File

@ -0,0 +1,67 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\EventEquipmentType;
/**
* EventEquipmentTypeSearch represents the model behind the search form about `common\models\EventEquipmentType`.
*/
class EventEquipmentTypeSearch extends EventEquipmentType
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = EventEquipmentType::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\EventRegistration;
/**
* EventRegistrationSearch represents the model behind the search form about `common\models\EventRegistration`.
*/
class EventRegistrationSearch extends EventRegistration
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'id_event', 'id_customer'], 'integer'],
[['created_at', 'updated_at', 'canceled_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = EventRegistration::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'id_event' => $this->id_event,
'id_customer' => $this->id_customer,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
'canceled_at' => $this->canceled_at,
]);
return $dataProvider;
}
}

View File

@ -0,0 +1,68 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\EventType;
/**
* EventTypeSearch represents the model behind the search form about `common\models\EventType`.
*/
class EventTypeSearch extends EventType
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = EventType::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,69 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Room;
/**
* RoomSearch represents the model behind the search form about `common\models\Room`.
*/
class RoomSearch extends Room
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'seat_count'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Room::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'seat_count' => $this->seat_count,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Trainer;
/**
* TrainerSearch represents the model behind the search form about `common\models\Trainer`.
*/
class TrainerSearch extends Trainer
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id', 'active'], 'integer'],
[['name', 'phone', 'email', 'password', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Trainer::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id' => $this->id,
'active' => $this->active,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name])
->andFilterWhere(['like', 'phone', $this->phone])
->andFilterWhere(['like', 'email', $this->email])
->andFilterWhere(['like', 'password', $this->password]);
return $dataProvider;
}
}

View File

@ -8,7 +8,6 @@ use yii\data\ActiveDataProvider;
use common\models\Transfer; use common\models\Transfer;
use yii\db\Expression; use yii\db\Expression;
use yii\db\Query; use yii\db\Query;
use yii\helpers\ArrayHelper;
use common\models\Account; use common\models\Account;
use common\components\Helper; use common\components\Helper;
use common\components\RoleDefinition; use common\components\RoleDefinition;
@ -278,11 +277,12 @@ class TransferSearch extends Transfer
} }
/**
* @throws \yii\db\Exception
*/
public function totalsTransfers() public function totalsTransfers()
{ {
$accounts = Account::read(); $accounts = Account::read();
$accountMap = ArrayHelper::map($accounts, 'id_account', 'name');
$idUser = $this->id_user; $idUser = $this->id_user;
/**mk totals need date time format*/ /**mk totals need date time format*/
@ -291,8 +291,7 @@ class TransferSearch extends Transfer
$start .= ' 00:00'; $start .= ' 00:00';
} }
$this->totals = Transfer::mkTotals($start, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts);
$this->totals = Transfer::mkTotals($start, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
} }

View File

@ -69,6 +69,11 @@ use kartik\widgets\DatePicker;
</div> </div>
<div class='row'> <div class='row'>
<div class='col-md-6'>
<?= $form->field($model, 'password_plain')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class='row'>
<div class='col-md-6'> <div class='col-md-6'>
<?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?> <?= $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
</div> </div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\EventEquipmentType */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-equipment-type-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/event-equipment-type', 'Create') : Yii::t('common/event-equipment-type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,26 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\EventEquipmentTypeSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-equipment-type-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'name') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('common/event-equipment-type', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventEquipmentType */
$this->title = Yii::t('common/event-equipment-type', 'Create Event Equipment Type');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/event-equipment-type', 'Event Equipment Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-equipment-type-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,34 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\EventEquipmentTypeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common/event-equipment-type', 'Event Equipment Types');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-equipment-type-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('common/event-equipment-type', 'Create Event Equipment Type'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventEquipmentType */
$this->title = Yii::t('common/event-equipment-type', 'Update {modelClass}: ', [
'modelClass' => 'Event Equipment Type',
]) . ' #' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/event-equipment-type', 'Event Equipment Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('common/event-equipment-type', 'Update');
?>
<div class="event-equipment-type-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,31 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\EventEquipmentType */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/event-equipment-type', 'Event Equipment Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-equipment-type-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('common/event-equipment-type', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -0,0 +1,24 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\EventRegistration */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-registration-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_event')->textInput() ?>
<?= $form->field($model, 'id_customer')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('event-registration', 'Create') : Yii::t('event-registration', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,24 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\CardEventRegistrationForm */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-registration-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'card_number')->textInput() ?>
<?= $form->field($model, 'event_id')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('event-registration', 'Create') : Yii::t('event-registration', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,51 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\EventRegistrationSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-registration-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="panel panel-default">
<div class="panel-heading">
Keresés
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'id') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'id_event') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'id_customer') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div>
</div>
<?php // echo $form->field($model, 'canceled_at') ?>
</div>
<div class="panel-footer">
<?= Html::submitButton(Yii::t('event-registration', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventRegistration */
$this->title = Yii::t('event-registration', 'Create Event Registration');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-registration-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\EventRegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('event-registration', 'Event Registrations');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-registration-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('event-registration', 'Create Event Registration'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id',
'id_event',
'id_customer',
'created_at:datetime',
'updated_at:datetime',
'canceled_at:datetime',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\CardEventRegistrationForm */
$this->title = Yii::t('event-registration', 'Create Event Registration');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-registration-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_register_card', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventRegistration */
$this->title = Yii::t('event-registration', 'Update {modelClass}: ', [
'modelClass' => 'Event Registration',
]) . ' ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('event-registration', 'Update');
?>
<div class="event-registration-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,40 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\EventRegistration */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-registration-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('event-registration', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('event-registration', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('event-registration', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'id_event',
'id_customer',
'created_at',
'updated_at',
'canceled_at',
],
]) ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\EventType */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-type-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('event-type', 'Create') : Yii::t('event-type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,36 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\EventTypeSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-type-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Keresés</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'name') ?>
</div>
</div>
</div>
<div class="panel-footer">
<?= Html::submitButton(Yii::t('event-type', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventType */
$this->title = Yii::t('event-type', 'Create Event Type');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-type-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,36 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\EventTypeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('event-type', 'Event Types');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-type-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('event-type', 'Create Event Type'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
'created_at:datetime',
'updated_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\EventType */
$this->title = Yii::t('event-type', 'Update Event Type:') . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('event-type', 'Update');
?>
<div class="event-type-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,38 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\EventType */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-type', 'Event Types'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-type-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('event-type', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('event-type', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('event-type', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -0,0 +1,54 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-form">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'startDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose' => true,
'format' => 'yyyy.mm.dd hh:ii'
],
'options' => [
'autocomplete' => 'off'
]
]);
?>
<?= $form->field($model, 'endDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose' => true,
'format' => 'yyyy.mm.dd hh:ii'
],
'options' => [
'autocomplete' => 'off'
]
])
?>
<?= $form->field($model, 'seat_count')->textInput() ?>
<?= $form->field($model, 'id_room')->dropDownList(\common\models\Room::roomOptions(false, true)) ?>
<?= $form->field($model, 'id_trainer')->dropDownList(\common\models\Trainer::trainerOptions(false, true)) ?>
<?= $form->field($model, 'id_event_type')->dropDownList(\common\models\EventType::eventTypeOptions(false, true)) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('event', 'Create') : Yii::t('event', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\CardEventRegistrationForm */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-registration-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'card_number')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('event-registration', 'Create') : Yii::t('event-registration', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,74 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\EventSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="event-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Keresés</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'id') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'startDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
],
'options' => [
'autocomplete' => 'off'
]
]); ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'endDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd hh:ii'
],
'options' => [
'autocomplete' => 'off'
]
])
?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'roomName')->dropDownList(\common\models\Room::roomOptions(true)) ?>
</div>
</div>
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'trainerName')->dropDownList(\common\models\Trainer::trainerOptions(true)) ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $form->field($model, 'eventTypeName')->dropDownList(\common\models\EventType::eventTypeOptions(true)) ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div>
</div>
</div>
<div class="panel-footer">
<?= Html::submitButton(Yii::t('event', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,74 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Esemény</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<?php try {
echo DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'created_at:datetime',
'updated_at:datetime',
'deleted_at:datetime',
],
]);
} catch (Exception $e) {
echo "failed to render event details ";
} ?>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<?php try {
echo DetailView::widget([
'model' => $model,
'attributes' => [
[
'attribute' => 'eventType.name',
'label' => $model->getAttributeLabel('id_event_type')
],
'start:datetime',
'end:datetime',
[
'attribute' => 'room.name',
'label' => $model->getAttributeLabel('id_room')
],
[
'attribute' => 'trainer.name',
'label' => $model->getAttributeLabel('id_trainer')
],
],
]);
} catch (Exception $e) {
echo "Failed to render view";
} ?>
</div>
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
<?php try {
echo DetailView::widget([
'model' => $model,
'attributes' => [
'seat_count',
'eventRegistrationCount',
'openSeatCount',
],
]);
} catch (Exception $e) {
echo "Failed to render view";
} ?>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
$this->title = Yii::t('event', 'Create Event');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,123 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\EventSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('event', 'Events');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('event', 'Create Event'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'event_id',
'label' => \Yii::t('event', 'ID')
],
[
'attribute' => 'event_type_name',
'label' => \Yii::t('event', 'Id Event Type')
],
[
'attribute' => 'event_start',
'label' => \Yii::t('event', 'Start'),
'format' => 'datetime'
],
[
'attribute' => 'event_end',
'label' => \Yii::t('event', 'End'),
'format' => 'time'
],
[
'attribute' => 'event_seat_count',
'label' => \Yii::t('event', 'Seat Count')
],
[
'attribute' => 'registration_count',
'label' => \Yii::t('event', 'Registration Count')
],
[
'attribute' => 'room_name',
'label' => \Yii::t('event', 'Room Name')
],
[
'attribute' => 'trainer_name',
'label' => \Yii::t('event', 'Trainer Name')
],
[
'attribute' => 'event_created_at',
'label' => \Yii::t('event', 'Created At'),
'format' => 'datetime'
],
[
'attribute' => 'event_updated_at',
'label' => \Yii::t('event', 'Updated At'),
'format' => 'datetime'
],
[
'attribute' => 'event_deleted_at',
'label' => \Yii::t('event', 'Deleted At'),
'format' => 'datetime'
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {update} {reserve-card}',
'urlCreator' => function ($action, $model, $key, $index) {
$params = ['id' => $model['event_id']];
$params[0] = "event" . '/' . $action;
return \yii\helpers\Url::toRoute($params);
},
'buttons' => [
'view' => function ($url, $model, $key) {
$options = [
'title' => Yii::t('yii', 'View'),
'aria-label' => Yii::t('yii', 'View'),
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, $options);
},
'update' => function ($url, $model, $key) {
$options = [
'title' => Yii::t('yii', 'Update'),
'aria-label' => Yii::t('yii', 'Update'),
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options);
},
'delete' => function ($url, $model, $key) {
$options = [
'title' => Yii::t('yii', 'Delete'),
'aria-label' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
'data-method' => 'post',
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
},
'reserve-card' => function ($url, $model, $key) {
$options = [
'title' => Yii::t('yii', 'Register'),
'aria-label' => Yii::t('yii', 'Register'),
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-user"></span>', $url, $options);
}
]
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\CardEventRegistrationForm */
$this->title = Yii::t('event-registration', 'Create Event Registration');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event-registration', 'Event Registrations'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="event-registration-create">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_view', ['model' => $event]); ?>
<?= $this->render('_form_register_card', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,20 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
$this->title = Yii::t('event', 'Update Event:') . ' ' . $model->id;
$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('event', 'Update');
?>
<div class="event-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,168 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
$this->title = \Yii::t('event', 'Event Details');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
function isReservationOpen($model)
{
$canceled = isset($model['event_registration_canceled_at']);
$deleted = isset($model['event_registration_deleted_at']);
return !$canceled && !$deleted;
}
function getCommonColumnsHtmlOptions($model)
{
$options = [];
if (!isReservationOpen($model)) {
$options['style'] = 'text-decoration: line-through;';
}
return $options;
}
?>
<div class="event-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?php
if ( $model->canReserve()){
echo Html::a(Yii::t('event', 'Reservation'), ['reserve-card', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
?>
<?php
if ($model->canDelete()) {
echo Html::a(Yii::t('event', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger pull-right',
'data' => [
'confirm' => Yii::t('event', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]);
}
?>
</p>
<?php echo $this->render('_view', ['model' => $model]); ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Foglalások</h3>
</div>
<div class="panel-body">
<?php try {
echo \yii\grid\GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[
'attribute' => 'card_number',
'label' => \Yii::t('event', 'Card Number'),
'contentOptions' => function ($model) {
return getCommonColumnsHtmlOptions($model);
},
'format' => 'raw',
'value' => function ($model, $key, $index, $column) {
return Html::a($model['card_number'], ['card/view', 'id' => $model['card_id_card']]);
}
],
[
'attribute' => 'customer_name',
'label' => \Yii::t('event', 'Customer Name'),
'contentOptions' => function ($model) {
return getCommonColumnsHtmlOptions($model);
},
'format' => 'raw',
'value' => function ($model, $key, $index, $column) {
return Html::a($model['customer_name'], ['customer/view', 'id' => $model['customer_id_customer']]);
}
],
[
'attribute' => 'customer_email',
'label' => \Yii::t('event', 'Customer Email'),
'contentOptions' => function ($model) {
return getCommonColumnsHtmlOptions($model);
}
],
[
'attribute' => 'event_registration_created_at',
'label' => \Yii::t('event', 'Event Registration Created At'),
'contentOptions' => function ($model) {
return getCommonColumnsHtmlOptions($model);
}
],
[
'attribute' => 'event_registration_canceled_at',
'format' => 'datetime',
'label' => \Yii::t('event', 'Canceled At'),
'contentOptions' => function () {
$options = [];
return $options;
}
],
[
'attribute' => 'event_registration_deleted_at',
'format' => 'datetime',
'label' => \Yii::t('event', 'Deleted At'),
'contentOptions' => function () {
$options = [];
return $options;
},
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{cancel-registration} {delete-registration}',
'urlCreator' => function ($action, $model) {
$params = ['id' => $model['event_registration_id']];
$params[0] = "event" . '/' . $action;
return \yii\helpers\Url::toRoute($params);
},
'buttons' => [
'cancel-registration' => function ($url, $model) {
if (isset($model['event_registration_canceled_at'])) {
return "";
}
$options = [
'title' => Yii::t('event', 'Cancel'),
'aria-label' => Yii::t('event', 'Cancel'),
'data-confirm' => Yii::t('event', 'Are you sure you want to cancel this item? Usage count won\'t be restored!'),
'data-method' => 'post',
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-ban-circle"></span>', $url, $options);
},
'delete-registration' => function ($url, $model) {
if (isset($model['event_registration_canceled_at'])) {
return "";
}
$options = [
'title' => Yii::t('yii', 'Delete'),
'aria-label' => Yii::t('yii', 'Delete'),
'data-confirm' => Yii::t('event', 'Are you sure you want to delete this item? Usage count will be restored!'),
'data-method' => 'post',
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options);
},
]
],
]
]);
} catch (Exception $e) {
echo "Failed to render registrations";
}
?>
</div>
</div>
</div>

View File

@ -0,0 +1,25 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Room */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="room-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'seat_count')->textInput(['type' => 'number']) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('room', 'Create') : Yii::t('room', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,48 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\RoomSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="room-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?php
// ///////////////////////////////////////
// Search Pane
// ///////////////////////////////////////
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Keresés</h3>
</div>
<div class="panel-body">
<?php
// ///////////////////////////////////////
// Search fields
// ///////////////////////////////////////
?>
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'name') ?>
</div>
</div>
</div>
<div class="panel-footer">
<?php
// ///////////////////////////////////////
// Search button
// ///////////////////////////////////////
?>
<?= Html::submitButton(Yii::t('room', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Room */
$this->title = Yii::t('room', 'Create Room');
$this->params['breadcrumbs'][] = ['label' => Yii::t('room', 'Rooms'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="room-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\RoomSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('room', 'Rooms');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="room-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('room', 'Create Room'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
'seat_count',
'created_at:datetime',
'updated_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' => '{view} {update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Room */
$this->title = Yii::t('room', 'Update Room: ') . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('room', 'Rooms'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('room', 'Update');
?>
<div class="room-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Room */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('room', 'Rooms'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="room-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('room', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('room', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('room', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'seat_count',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -33,6 +33,7 @@ use yii\helpers\ArrayHelper;
<?= mkTitle("Alkalmak")?> <?= mkTitle("Alkalmak")?>
<?= $form->field($model, 'max_usage_count')->textInput() ?> <?= $form->field($model, 'max_usage_count')->textInput() ?>
<?= $form->field($model, 'max_reservation_count')->textInput() ?>
<?= mkTitle("Érvényességi idő belállítások")?> <?= mkTitle("Érvényességi idő belállítások")?>
<div class="row"> <div class="row">

View File

@ -21,49 +21,54 @@ $this->params['breadcrumbs'][] = $this->title;
</p> </p>
<?php }?> <?php }?>
<?= DetailView::widget([ <?php try {
'model' => $model, echo DetailView::widget([
'attributes' => [ 'model' => $model,
'name', 'attributes' => [
[ 'name',
'attribute' => 'type', [
'value' => $model->typeHuman 'attribute' => 'type',
], 'value' => $model->typeHuman
'max_usage_count', ],
[ 'max_usage_count',
'attribute' => 'time_unit_count', 'max_reservation_count',
], [
[ 'attribute' => 'time_unit_count',
'attribute' => 'time_unit_type', ],
'value' => $model->timeUnitHuman [
], 'attribute' => 'time_unit_type',
'price_brutto', 'value' => $model->timeUnitHuman
[ ],
'attribute' => 'id_account', 'price_brutto',
'value' => $model->accountName, [
], 'attribute' => 'id_account',
[ 'value' => $model->accountName,
'attribute' => 'flag_student', ],
'value' => ( $model->isStudent() ? Yii::t('common', 'Yes' ) : Yii::t('common', 'No' ) ), [
], 'attribute' => 'flag_student',
[ 'value' => ($model->isStudent() ? Yii::t('common', 'Yes') : Yii::t('common', 'No')),
'attribute' => 'status', ],
'value' => $model->statusHuman [
], 'attribute' => 'status',
[ 'value' => $model->statusHuman
'attribute' => 'door_allowed', ],
'value' => ( $model->isDoor() ? Yii::t('common', 'Yes' ) : Yii::t('common', 'No' ) ), [
//'visible' => \common\components\Helper::isTicketTypeDoorAllowedCheckOn() 'attribute' => 'door_allowed',
'value' => ($model->isDoor() ? Yii::t('common', 'Yes') : Yii::t('common', 'No')),
//'visible' => \common\components\Helper::isTicketTypeDoorAllowedCheckOn()
],
'created_at:datetime',
'updated_at:datetime',
[
'attribute' => 'installment_enabled',
'value' => ($model->isInstallment() ? Yii::t('common', 'Yes') : Yii::t('common', 'No')),
],
'installment_money',
'installment_count',
], ],
'created_at:datetime', ]);
'updated_at:datetime', } catch (Exception $e) {
[ echo "Failed to render ticket type";
'attribute' => 'installment_enabled', } ?>
'value' => ( $model->isInstallment() ? Yii::t('common', 'Yes' ) : Yii::t('common', 'No' ) ),
],
'installment_money',
'installment_count',
],
]) ?>
</div> </div>

View File

@ -0,0 +1,20 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Trainer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="trainer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'active')->checkbox() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('trainer', 'Create') : Yii::t('trainer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\TrainerSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Keresés</h3>
</div>
<div class="panel-body">
<div class="trainer-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'name') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'phone') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?= $form->field($model, 'email') ?>
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $form->field($model, 'active')->dropDownList([
'' => \Yii::t("trainer","All"),
\common\models\Trainer::ACTIVE_OFF => \Yii::t("trainer","active_off"),
\common\models\Trainer::ACTIVE_ON => \Yii::t("trainer","active_on"),
]) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton(Yii::t('trainer', 'Search'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
</div>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Trainer */
$this->title = Yii::t('trainer', 'Create Trainer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('trainer', 'Trainers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="trainer-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\TrainerSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('trainer', 'Trainers');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="trainer-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('trainer', 'Create Trainer'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id',
'name',
'phone',
'email:email',
['attribute' => 'active' , 'value' => function ($model){ return \common\models\Trainer::prettyPrintActive($model->active) ;} ],
'created_at:datetime',
'updated_at:datetime',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Trainer */
$this->title = Yii::t('trainer', 'Update Trainer:' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('trainer', 'Trainers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Yii::t('trainer', 'Update');
?>
<div class="trainer-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,44 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Trainer */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('trainer', 'Trainers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="trainer-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('trainer', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('trainer', 'Delete'), ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('trainer', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id',
'name',
'phone',
'email:email',
[
'attribute' => 'active',
'value' => \common\models\Trainer::prettyPrintActive($model->active)
],
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -8,6 +8,12 @@
namespace common\components; namespace common\components;
use DateInterval;
use DateTime;
use DateTimeZone;
use Exception;
use Yii;
use yii\base\InvalidConfigException;
use yii\i18n\Formatter; use yii\i18n\Formatter;
class DateUtil class DateUtil
@ -16,12 +22,13 @@ class DateUtil
* Get UTC today @00:00:00 . * Get UTC today @00:00:00 .
* Helper method to generate date for mysql * Helper method to generate date for mysql
* *
* @return \DateTime * @return DateTime
* @throws Exception
*/ */
public static function todayStart( ){ public static function todayStart( ){
$d2 = new \DateTime(); $d2 = new DateTime();
$d2->setTimezone( new \DateTimeZone( "UTC" ) ); $d2->setTimezone( new DateTimeZone('UTC') );
$d2->setTime(0, 0, 0); $d2->setTime(0, 0);
return $d2; return $d2;
} }
@ -29,13 +36,14 @@ class DateUtil
* Get UTC t @00:00:00 . * Get UTC t @00:00:00 .
* Helper method to generate date for mysql * Helper method to generate date for mysql
* *
* @return \DateTime * @return DateTime
* @throws Exception
*/ */
public static function tomorrowStart( ){ public static function tomorrowStart( ){
$d2 = new \DateTime(); $d2 = new DateTime();
$d2->add(new \DateInterval('P1D')); $d2->add(new DateInterval('P1D'));
$d2->setTimezone( new \DateTimeZone( "UTC" ) ); $d2->setTimezone( new DateTimeZone('UTC') );
$d2->setTime(0, 0, 0); $d2->setTime(0, 0);
return $d2; return $d2;
} }
@ -44,11 +52,11 @@ class DateUtil
public static function addMonth($timestamp, $monthCount = 1) public static function addMonth($timestamp, $monthCount = 1)
{ {
if ($timestamp instanceof \DateTime) { if ($timestamp instanceof DateTime) {
$d1 = $timestamp; $d1 = $timestamp;
} else { } else {
$d1 = new \DateTime(); $d1 = new DateTime();
if (isset($timestamp)) { if (isset($timestamp)) {
$d1->setTimestamp($timestamp); $d1->setTimestamp($timestamp);
@ -63,28 +71,34 @@ class DateUtil
$day = $d1->format('d'); $day = $d1->format('d');
$year += floor($monthToAdd / 12); $year += floor($monthToAdd / 12);
$monthToAdd = $monthToAdd % 12; $monthToAdd %= 12;
$month += $monthToAdd; $month += $monthToAdd;
if ($month > 12) { if ($month > 12) {
$year++; $year++;
$month = $month % 12; $month %= 12;
if ($month === 0) if ($month === 0) {
$month = 12; $month = 12;
}
} }
if (!checkdate($month, $day, $year)) { if (!checkdate($month, $day, $year)) {
$d2 = \DateTime::createFromFormat('Y-n-j', $year . '-' . $month . '-1'); $d2 = DateTime::createFromFormat('Y-n-j', $year . '-' . $month . '-1');
$d2->modify('last day of'); $d2->modify('last day of');
} else { } else {
$d2 = \DateTime::createFromFormat('Y-n-d', $year . '-' . $month . '-' . $day); $d2 = DateTime::createFromFormat('Y-n-d', $year . '-' . $month . '-' . $day);
} }
$d2->setTime(0, 0, 0); $d2->setTime(0, 0);
return $d2; return $d2;
} }
/**
* @param $dateTimeObject
* @return string
* @throws InvalidConfigException
*/
public static function formatUtc($dateTimeObject) public static function formatUtc($dateTimeObject)
{ {
$formatter = new Formatter; $formatter = new Formatter;
@ -93,6 +107,11 @@ class DateUtil
return $formatter->asDatetime($dateTimeObject); return $formatter->asDatetime($dateTimeObject);
} }
/**
* @param $dateTimeObject
* @return string
* @throws InvalidConfigException
*/
public static function formatDateUtc($dateTimeObject) public static function formatDateUtc($dateTimeObject)
{ {
$formatter = new Formatter; $formatter = new Formatter;
@ -103,9 +122,27 @@ class DateUtil
public static function parseDate($dateString){ public static function parseDate($dateString){
$date = \DateTime::createFromFormat("Y.m.d", $dateString, new \DateTimeZone( 'UTC')); $date = DateTime::createFromFormat('Y.m.d', $dateString, new DateTimeZone( 'UTC'));
$date->setTime(0, 0, 0); $date->setTime(0, 0);
return $date; return $date;
} }
/**
* @param integer $weekDay Numeric representation of the day of the week. @See https://www.php.net/manual/en/function.date.php
* @return string
*/
public static function getLocalDayName($weekDay){
$translations = [
0 => Yii::t('common', 'Sunday'),
1 => Yii::t('common', 'Monday'),
2 => Yii::t('common', 'Tuesday'),
3 => Yii::t('common', 'Wednesday'),
4 => Yii::t('common', 'Thursday'),
5 => Yii::t('common', 'Friday'),
6 => Yii::t('common', 'Saturday'),
7 => Yii::t('common', 'Sunday'),
];
return $translations[$weekDay];
}
} }

View File

@ -0,0 +1,131 @@
<?php
namespace common\components;
class HttpStatus
{
// const CONTINUE = 100;
const SWITCHING_PROTOCOLS = 101;
const PROCESSING = 102; // RFC2518
const OK = 200;
const CREATED = 201;
const ACCEPTED = 202;
const NON_AUTHORITATIVE_INFORMATION = 203;
const NO_CONTENT = 204;
const RESET_CONTENT = 205;
const PARTIAL_CONTENT = 206;
const MULTI_STATUS = 207; // RFC4918
const ALREADY_REPORTED = 208; // RFC5842
const IM_USED = 226; // RFC3229
const MULTIPLE_CHOICES = 300;
const MOVED_PERMANENTLY = 301;
const FOUND = 302;
const SEE_OTHER = 303;
const NOT_MODIFIED = 304;
const USE_PROXY = 305;
const RESERVED = 306;
const TEMPORARY_REDIRECT = 307;
const PERMANENTLY_REDIRECT = 308; // RFC7238
const BAD_REQUEST = 400;
const UNAUTHORIZED = 401;
const PAYMENT_REQUIRED = 402;
const FORBIDDEN = 403;
const NOT_FOUND = 404;
const METHOD_NOT_ALLOWED = 405;
const NOT_ACCEPTABLE = 406;
const PROXY_AUTHENTICATION_REQUIRED = 407;
const REQUEST_TIMEOUT = 408;
const CONFLICT = 409;
const GONE = 410;
const LENGTH_REQUIRED = 411;
const PRECONDITION_FAILED = 412;
const REQUEST_ENTITY_TOO_LARGE = 413;
const REQUEST_URI_TOO_LONG = 414;
const UNSUPPORTED_MEDIA_TYPE = 415;
const REQUESTED_RANGE_NOT_SATISFIABLE = 416;
const EXPECTATION_FAILED = 417;
const I_AM_A_TEAPOT = 418; // RFC2324
const UNPROCESSABLE_ENTITY = 422; // RFC4918
const LOCKED = 423; // RFC4918
const FAILED_DEPENDENCY = 424; // RFC4918
const RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL = 425; // RFC2817
const UPGRADE_REQUIRED = 426; // RFC2817
const PRECONDITION_REQUIRED = 428; // RFC6585
const TOO_MANY_REQUESTS = 429; // RFC6585
const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; // RFC6585
const INTERNAL_SERVER_ERROR = 500;
const NOT_IMPLEMENTED = 501;
const BAD_GATEWAY = 502;
const SERVICE_UNAVAILABLE = 503;
const GATEWAY_TIMEOUT = 504;
const VERSION_NOT_SUPPORTED = 505;
const VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL = 506; // RFC2295
const INSUFFICIENT_STORAGE = 507; // RFC4918
const LOOP_DETECTED = 508; // RFC5842
const NOT_EXTENDED = 510; // RFC2774
const NETWORK_AUTHENTICATION_REQUIRED = 511; // RFC6585
}

View File

@ -12,6 +12,7 @@ class RoleDefinition{
'reception' => Yii::t('common/role' ,'Reception'), 'reception' => Yii::t('common/role' ,'Reception'),
'admin' => Yii::t('common/role' ,'Administrator'), 'admin' => Yii::t('common/role' ,'Administrator'),
'employee' => Yii::t('common/role' ,'Employee'), 'employee' => Yii::t('common/role' ,'Employee'),
'Trainer' => Yii::t('common/role' ,'Edző'),
]; ];
} }
@ -88,6 +89,15 @@ class RoleDefinition{
return self::can('employee'); return self::can('employee');
} }
public static function isTrainer(){
return self::can('trainer');
}
public static function isLoggedUser(){
return self::isTrainer() || self::isAdmin() || self::isEmployee()
|| self::isReception();
}
/* /*
* [ * [
* 'role1' => 'template1', * 'role1' => 'template1',

File diff suppressed because one or more lines are too long

View File

@ -4,3 +4,4 @@ Yii::setAlias('frontend', dirname(dirname(__DIR__)) . '/frontend');
Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend'); Yii::setAlias('backend', dirname(dirname(__DIR__)) . '/backend');
Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console'); Yii::setAlias('console', dirname(dirname(__DIR__)) . '/console');
Yii::setAlias('rest', dirname(dirname(__DIR__)) . '/rest'); Yii::setAlias('rest', dirname(dirname(__DIR__)) . '/rest');
Yii::setAlias('customerapi', dirname(dirname(__DIR__)) . '/customerapi');

View File

@ -0,0 +1,25 @@
<?php
use yii\helpers\Html;
use yii\helpers\Url;
use common\components\Helper;
?>
<h1 style="font-size: 12px;">Kedves <?php echo $model->customer->name?>!</h1>
<p style="font-size: 12px;">
Az Ön új jelszava:
</p>
<ul style="font-size: 12px;">
<li>
"<?php echo $model->plainPassword ?>"
</li>
</ul>
<p style="font-size: 12px;">
Üdvözlettel:
</p>
<p style="font-size: 12px;">
<?php echo $model->companyName ?>
</p>
<p>
Ez egy automatikus e-mail üzenet, amelyre nem tud válaszolni.
</p>
<?php
?>

View File

@ -0,0 +1,267 @@
<?php
namespace common\manager;
use common\models\Card;
use common\models\CardEventRegistrationForm;
use common\models\Customer;
use common\models\Event;
use common\models\EventRegistration;
use common\models\Ticket;
use customerapi\models\available\EventInterval;
use customerapi\models\registrations\EventRegistrationAvailable;
use customerapi\models\details\EventRegistrationView;
use Exception;
use Yii;
use yii\base\BaseObject;
use yii\db\ActiveRecord;
use yii\db\Query;
use yii\web\BadRequestHttpException;
use yii\web\NotFoundHttpException;
use yii\web\ServerErrorHttpException;
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.17.
* Time: 6:12
*/
class EventRegistrationManager extends BaseObject
{
const CARD_NOT_FOUND = 1;
const CUSTOMER_NOT_FOUND = 2;
const TICKET_NOT_FOUND = 3;
const NO_FREE_SEATS = 4;
const EVENT_TYPE_NOT_FOUND = 5;
const TICKET_INSUFFICIENT = 6;
const UNKNOWN_ERROR = 7;
const MAX_SEAT_COUNT_EXCEEDED = 8;
const EVENT_UNAVAILABLE = 9;
const ALREADY_REGISTERED = 10;
public static $STATES = [
self::CARD_NOT_FOUND => 'CARD_NOT_FOUND',
self::CUSTOMER_NOT_FOUND => 'CUSTOMER_NOT_FOUND',
self::TICKET_NOT_FOUND => 'TICKET_NOT_FOUND',
self::NO_FREE_SEATS => 'NO_FREE_SEATS',
self::EVENT_TYPE_NOT_FOUND => 'EVENT_TYPE_NOT_FOUND',
self::TICKET_INSUFFICIENT => 'TICKET_INSUFFICIENT',
self::UNKNOWN_ERROR => 'UNKNOWN_ERROR',
self::MAX_SEAT_COUNT_EXCEEDED => 'MAX_SEAT_COUNT_EXCEEDED',
self::EVENT_UNAVAILABLE => 'EVENT_UNAVAILABLE',
self::ALREADY_REGISTERED => 'ALREADY_REGISTERED',
];
/**
* @param CardEventRegistrationForm $cardEventForm
* @throws Exception
*/
public function registerCard($cardEventForm)
{
$db = Yii::$app->db;
$tx = $db->beginTransaction();
try {
if ($cardEventForm->validate()) {
$requiresTicket = false;
/** @var Card $card */
$card = Card::readCard($cardEventForm->card_number, false);
if (!isset($card)) {
throw new NotFoundHttpException('Card not found: ' . $cardEventForm->card_number, self::CARD_NOT_FOUND);
}
if ($card->isFree()) {
throw new NotFoundHttpException('Customer not found', self::CUSTOMER_NOT_FOUND);
}
$activeTickets = $card->getActiveTickets();
if (count($activeTickets) === 0) {
throw new NotFoundHttpException('Ticket not found1', self::TICKET_NOT_FOUND);
}
/** @var Event $event */
$event = Event::find()->andWhere(['id' => $cardEventForm->event_id])->one();
if (!isset($event)) {
throw new NotFoundHttpException('Event not found: ' . $cardEventForm->event_id);
}
if ( isset($event->deleted_at)){
throw new BadRequestHttpException('Event deleted', self::EVENT_UNAVAILABLE);
}
if (!$event->hasFreeSeats()) {
throw new BadRequestHttpException('No free seats', self::NO_FREE_SEATS);
}
$eventType = $event->eventType;
if (!isset($eventType)) {
throw new ServerErrorHttpException('Event type not found', self::EVENT_TYPE_NOT_FOUND);
}
//detect if customer is already registered to event
/** @var EventRegistration[] $registrations */
$registrations = $event->getActiveEventRegistrations()->all();
foreach ($registrations as $registration ){
if ($registration->id_customer == $card->customer->id_customer){
throw new BadRequestHttpException("Already registered", self::ALREADY_REGISTERED);
}
}
$selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
if (!isset($selectedTicket)) {
throw new NotFoundHttpException('Ticket not found2', self::TICKET_INSUFFICIENT);
}
$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_customer = $card->customer->id_customer;
try {
$registration->save(false);
} catch (\yii\db\Exception $exception) {
throw new ServerErrorHttpException('Failed to save', self::UNKNOWN_ERROR);
}
$cardEventForm->registration = $registration;
}
$tx->commit();
} catch (Exception $exception) {
$tx->rollBack();
throw $exception;
}
}
public function createFindRegistrationsQuery($idEvent)
{
$query = new Query();
$query->select([
'event_registration.id as event_registration_id',
'event_registration.created_at as event_registration_created_at',
'event_registration.canceled_at as event_registration_canceled_at',
'event_registration.deleted_at as event_registration_deleted_at',
'card.id_card as card_id_card',
'card.number as card_number',
'customer.id_customer as customer_id_customer',
'customer.name as customer_name',
'customer.email as customer_email',
]);
$query->from(EventRegistration::tableName());
$query->innerJoin(Event::tableName(), 'event_registration.id_event = event.id');
$query->innerJoin(Card::tableName(), 'event_registration.id_card = card.id_card');
$query->innerJoin(Customer::tableName(), 'customer.id_customer_card = card.id_card');
$query->andWhere(['event_registration.id_event' => $idEvent]);
return $query;
}
/**
* @param $idRegistration
* @return array|EventRegistration|ActiveRecord|null
* @throws NotFoundHttpException
*/
public function loadRegistration($idRegistration)
{
$registration = EventRegistration::find()->andWhere(['id' => $idRegistration])->one();
if ( $registration === null) {
throw new NotFoundHttpException('The requested registration does not exist.');
}
return $registration;
}
/**
* @param EventRegistration $registration
* @throws ServerErrorHttpException
*/
public function cancelRegistration($registration)
{
if (isset($registration->canceled_at)) {
throw new ServerErrorHttpException('The registration is already canceled');
}
if (isset($registration->deleted_at)) {
throw new ServerErrorHttpException('The reservation is already deleted');
}
$registration->canceled_at = date('Y-m-d H:i:s');
$registration->save(false);
}
/**
* @param EventRegistration $registration
* @return bool
* @throws \yii\base\Exception
*/
public function deleteRegistration($registration)
{
if (isset($registration->deleted_at)) {
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);
$registration->deleted_at = date('Y-m-d H:i:s');
return $registration->save(false);
}
/**
* Delete an event
* @param Event $event
* @throws Exception
* @throws Throwable
*/
public function deleteEvent($event)
{
$db = Yii::$app->db;
$tx = $db->beginTransaction();
try {
$registrations = $event->getEventRegistrations()->all();
// ////////////////////////////////
// if event has no registrations
// we can simply delete it from db
// ////////////////////////////////
if ( count($registrations) === 0 ) {
$event->delete();
} else {
// /////////////////////////////
// otherwise we mark the event deleted
// and we have to delete the registrations
// /////////////////////////////
$event->deleted_at = date('Y-m-d H:i:s');
$event->save(false);
foreach ($registrations as $registration) {
if (!isset($registration->deleted_at)) {
/** @var EventRegistration $registration */
$this->deleteRegistration($registration);
}
}
}
$tx->commit();
} catch (Exception $e) {
$tx->rollBack();
throw $e;
}
}
}

View File

@ -0,0 +1,14 @@
<?php
return [
"Name" => "Megnevezés",
"Search" => "Keresés",
"Create" => "Mentés",
"Update" => "Módosít",
"Delete" => "Törlés",
"Created At" => "Létrehozás dátum, idő",
"Updated At" => "Módosítás dátum, idő",
"Event Equipment Types" => "Felszerelések",
"Create Event Equipment Type" => "Új felszerelés létrehozása",
"Update {modelClass}: " => "Felszerelés módosítása: ",
];

View File

@ -29,7 +29,7 @@ return [
'Inactive' => 'Inaktív', 'Inactive' => 'Inaktív',
'Invalid account (inactive)!' => 'Érvénytelen kassza (inaktív)!', 'Invalid account (inactive)!' => 'Érvénytelen kassza (inaktív)!',
'Invalid account!' => 'Érvénytelen kassza!', 'Invalid account!' => 'Érvénytelen kassza!',
'Max Usage Count' => 'Akalmak', 'Max Usage Count' => 'Belépések száma (f. villa)',
'Month' => 'Hónap', 'Month' => 'Hónap',
'Name' => 'Név', 'Name' => 'Név',
'Normal' => 'Normál', 'Normal' => 'Normál',
@ -45,4 +45,5 @@ return [
'Type' => 'Típus', 'Type' => 'Típus',
'Update' => 'Módosítás', 'Update' => 'Módosítás',
'Updated At' => 'Módosítás ideje', 'Updated At' => 'Módosítás ideje',
'Max Reservation Count' => 'Foglalások száma (csop. edzés)',
]; ];

View File

@ -0,0 +1,32 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Seat Count' => 'Férőhelyek száma',
'Create Event Registration' => 'Új regisztráció',
'Update Event Registration:' => 'Regisztráció módosítása:',
'Event Registrations' => 'Regisztrációk',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
'Unknown Error' => "Ismeretlen Hiba",
'CARD_NOT_FOUND' => 'Kártya nem található',
'CUSTOMER_NOT_FOUND' => 'Vendég nem található',
'TICKET_NOT_FOUND' => 'Nincs aktív bérlet',
'NO_FREE_SEATS' => 'Nincs szabad hely',
'EVENT_TYPE_NOT_FOUND' => 'Az esemény típusa ismereten',
'TICKET_INSUFFICIENT' => 'Nem található az eseményre jogosító aktív bérlet',
];

View File

@ -0,0 +1,24 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Create Event Type' => 'Új esemény Típus',
'Update Event Type:' => 'Esemény Típus adatainak módosítása:',
'Event Types' => 'Esemény Típusok',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
];

View File

@ -0,0 +1,50 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Seat Count' => 'Férőhelyek száma',
'Create Event' => 'Új esemény',
'Update Event:' => 'Esemény adatainak módosítása:',
'Events' => 'Események',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
'Start' => 'Esemény kezdete',
'End' => 'Esemény vége',
'Room Name' => 'Terem',
'Trainer Name' => 'Edző',
'Event start' => 'Esemény Kezdete',
'Event end' => 'Esemény vége',
'Id Room' => 'Terem',
'Id Trainer' => 'Edző',
'Id Event Type' => 'Esemény Típus',
'Registration Count' => 'Résztvevők',
'Card Number' => 'Kártyaszám',
'Customer Name' => 'Vendég Neve',
'Customer Email' => 'Vendég E-Mail címe',
'Canceled At' => 'Sztornó dátum, idő',
'Register' => 'Regisztráció',
'Event Registration Created At' => 'Regisztráció dátum, idő',
'Event Registration Count' => 'Foglalások száma',
'Open Seat Count' => 'Szabad helyek száma',
'Cancel' => 'Lemond',
'Deleted At' => 'Törlés dátum, idő',
'Are you sure you want to cancel this item? Usage count won\'t be restored!' => 'Biztos benne, hogy lemondja ezt az foglalást? A foglalás nem kerül vissza a bérletre!',
'Are you sure you want to delete this item? Usage count will be restored!' => 'Biztos benne, hogy törli ezt az foglalást? A foglalás vissza fog kerülni a bérletre!',
'Reservation' => 'Foglalás',
'Event Details' => "Esemény részletei"
];

View File

@ -0,0 +1,25 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Seat Count' => 'Férőhelyek száma',
'Create Room' => 'Új terem',
'Update Room:' => 'Terem adatainak módosítása:',
'Rooms' => 'Termek',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
];

View File

@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Phone' => 'Telefon',
'Email' => 'E-Mail',
'Password' => 'Jelszó',
'Active' => 'Aktív',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Create Trainer' => 'Új edző',
'Trainers' => 'Edzők',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'active_on' => 'Aktív',
'active_off' => 'Inaktív',
'Update Trainer:' => 'Edző adatainak módosítása:',
'All' => 'Mind',
];

View File

@ -180,15 +180,19 @@ class Card extends \common\models\BaseFitnessActiveRecord
return $this->status == self::STATUS_DELETED; return $this->status == self::STATUS_DELETED;
} }
/**
* Load card from the DB , where the number equals with card number or RFID number
* @param number|string $number the card number or the RFID number
* @param null|boolean $free optional. if set, append free or not free condition.
* @return \common\models\Card|null the card or null, if not found with given conditions
*/
public static function readCard($number,$free = null){ public static function readCard($number,$free = null){
$card = null; $card = null;
$query = Card::find() $query = Card::find()
->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' ); ->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' );
// ->andWhere(['number'=>$number ]);
Card::addCardNumberCondition($query, $number); Card::addCardNumberCondition($query, $number);
if ( isset($free) ){ if ( isset($free) ){
if ( $free == true){ if ( $free == true){
$query->andWhere('customer.id_customer is null'); $query->andWhere('customer.id_customer is null');
@ -317,4 +321,12 @@ class Card extends \common\models\BaseFitnessActiveRecord
\Yii::$app->db->createCommand(self::$SQL_UPDATE_FLAG_STATUS_ACTIVE)->execute(); \Yii::$app->db->createCommand(self::$SQL_UPDATE_FLAG_STATUS_ACTIVE)->execute();
} }
public function isFree(){
return !isset($this->customer);
}
public function getActiveTickets(){
return Ticket::readActive($this);
}
} }

View File

@ -0,0 +1,45 @@
<?php
namespace common\models;
use common\components\Helper;
use yii\base\Model;
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.17.
* Time: 6:14
*/
class CardEventRegistrationForm extends Model
{
public $card_number;
public $event_id;
public $registration;
public function rules()
{
return [
[['card_number'], 'required' ],
[['card_number'], 'validateFormat' ]
];
}
public function validateFormat(){
$this->card_number = Helper::fixAsciiChars( $this->card_number );
}
public function getIsNewRecord(){
return true;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'card_number' => \Yii::t('event', 'Card Number'),
];
}
}

View File

@ -127,7 +127,14 @@ class Collection extends \common\models\BaseFitnessActiveRecord
/** /**
* *
* */ * @param string $mode
* @param $start
* @param $end
* @param $idUser
* @param $types
* @param $idAccount
* @return Query
*/
public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$types,$idAccount){ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$types,$idAccount){
$query = new Query(); $query = new Query();
@ -168,7 +175,7 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
} }
public static function mkTotalsResultWithAllAvailableAccount($queryResult,$accounts,$accountMap,$idAccount){ public static function mkTotalsResultWithAllAvailableAccount($queryResult,$accounts,$idAccount){
$totals = []; $totals = [];
$totals['total'] = 0; $totals['total'] = 0;
@ -228,7 +235,7 @@ public static function mkTotalQuery($mode = 'reception', $start,$end,$idUser,$ty
public static function mkReceptionTotal( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){ public static function mkReceptionTotal( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap){
$result = []; $result = [];
$queryResult = self::exTotalQuery('reception', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery('reception', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount); $result = self::mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $idAccount);
return $result; return $result;
} }
} }

View File

@ -59,7 +59,7 @@ class CollectionCreate extends \common\models\Collection
if (parent::beforeSave($insert)) { if (parent::beforeSave($insert)) {
$this->id_user = Yii::$app->user->id; $this->id_user = Yii::$app->user->id;
$this->created_by = Yii::$app->user->id; $this->created_by = Yii::$app->user->id;
$paidAt = Transfer::mkPaidAtTotals($this->timestampStart, $this->timestampEnd, $this->user->id, null, $this->account->id_account, $this->accounts, $this->accountMap); $paidAt = Transfer::mkPaidAtTotals($this->timestampStart, $this->timestampEnd, $this->user->id, null, $this->account->id_account, $this->accounts );
$this->money = $paidAt['total']; $this->money = $paidAt['total'];
return true; return true;
} else { } else {

View File

@ -19,6 +19,7 @@ use common\components\Helper;
* @property integer $part_count * @property integer $part_count
* @property integer $part_required * @property integer $part_required
* @property integer $id_ticket_type * @property integer $id_ticket_type
* @property integer $id_discount
* @property string $expired_at * @property string $expired_at
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at

View File

@ -1,7 +1,12 @@
<?php <?php
namespace common\models; namespace common\models;
use common\components\Helper;
use Yii; use Yii;
use yii\base\Exception;
use yii\base\InvalidConfigException;
use yii\base\NotSupportedException;
use yii\web\IdentityInterface;
/** /**
* This is the model class for table "customer". * This is the model class for table "customer".
@ -33,8 +38,11 @@ use Yii;
* @property integer towel_count * @property integer towel_count
* @property \common\models\User user * @property \common\models\User user
* @property mixed bank_account * @property mixed bank_account
* @property string password_plain
* @property string password_hash
* @property string auth_key
*/ */
class Customer extends BaseFitnessActiveRecord class Customer extends BaseFitnessActiveRecord implements IdentityInterface
{ {
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
@ -200,5 +208,135 @@ class Customer extends BaseFitnessActiveRecord
} }
/**
* Finds an identity by the given ID.
* @param string|integer $id the ID to be looked for
* @return Customer
* Null should be returned if such an identity cannot be found
* or the identity is not in an active state (disabled, deleted, etc.)
*/
public static function findIdentity($id)
{
return self::findOne(['email' => $id]);
}
/**
* Finds an identity by the given token.
* @param mixed $token the token to be looked for
* @param mixed $type the type of the token. The value of this parameter depends on the implementation.
* For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`.
* @return void the identity object that matches the given token.
* Null should be returned if such an identity cannot be found
* or the identity is not in an active state (disabled, deleted, etc.)
* @throws NotSupportedException
*/
public static function findIdentityByAccessToken($token, $type = null)
{
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
}
/**
* Returns an ID that can uniquely identify a user identity.
* @return string|integer an ID that uniquely identifies a user identity.
*/
public function getId()
{
return $this->id_customer;
}
/**
* Returns a key that can be used to check the validity of a given identity ID.
*
* The key should be unique for each individual user, and should be persistent
* so that it can be used to check the validity of the user identity.
*
* The space of such keys should be big enough to defeat potential identity attacks.
*
* This is required if [[User::enableAutoLogin]] is enabled.
* @return string a key that is used to check the validity of a given identity ID.
* @see validateAuthKey()
*/
public function getAuthKey()
{
// todo: add authkey to customer
}
/**
* Validates the given auth key.
*
* This is required if [[User::enableAutoLogin]] is enabled.
* @param string $authKey the given auth key
* @return boolean whether the given auth key is valid.
* @see getAuthKey()
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* @param $password
* @return bool
* @throws \yii\base\InvalidConfigException
*/
public function validatePassword($password)
{
return Yii::$app->security->validatePassword($password, $this->password_hash);
}
/**
* Generates password hash from password and sets it to the model
*
* @param string $password
* @throws Exception
* @throws \yii\base\InvalidConfigException
*/
public function setPassword($password)
{
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
// \Yii::info("pwd", $this->password_hash);
// echo $this->password_hash;
}
/**
* Generates "remember me" authentication key
* @throws InvalidConfigException if OpenSSL extension is needed but not installed.*@throws \yii\base\Exception
* @throws Exception
*/
public function generateAuthKey()
{
$this->auth_key = Yii::$app->security->generateRandomString();
}
/**
* Generates new password reset token
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->security->generateRandomString() . '_' . time();
}
/**
* Removes password reset token
*/
public function removePasswordResetToken()
{
$this->password_reset_token = null;
}
/**
* @throws InvalidConfigException
* @throws Exception
*/
public function setDefaultPassword(){
$hasEmail = isset($this->email) && $this->email !== '';
$hasBirthday = isset($this->birthdate) ;
if ( $hasEmail && $hasBirthday){
$customerBirthDate = new \DateTime($this->birthdate);
$this->setPassword($customerBirthDate->format('Ymd'));
}
}
} }

242
common/models/Event.php Normal file
View File

@ -0,0 +1,242 @@
<?php
namespace common\models;
use customerapi\models\details\EventEquipmentTypeAssignmentView;
use DateTime;
use DateTimeZone;
use Exception;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event".
*
* @property integer $id
* @property integer $start
* @property integer $end
* @property integer $id_room
* @property integer $id_trainer
* @property integer $id_event_type
* @property integer $seat_count
* @property string $created_at
* @property string $updated_at
* @property string $deleted_at
* @property integer $active
* @property EventType $eventType
* @property Trainer $trainer
* @property Room $room
* @property EventRegistration[] $eventRegistrations
*/
class Event extends ActiveRecord
{
public $startDateString;
public $endDateString;
public $timestampStart;
public $timestampEnd;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
[['id_trainer','id_room', 'id_event_type','seat_count'], 'required'],
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event', 'ID'),
'start' => Yii::t('event', 'Start'),
'end' => Yii::t('event', 'End'),
'id_room' => Yii::t('event', 'Id Room'),
'id_trainer' => Yii::t('event', 'Id Trainer'),
'id_event_type' => Yii::t('event', 'Id Event Type'),
'created_at' => Yii::t('event', 'Created At'),
'updated_at' => Yii::t('event', 'Updated At'),
'deleted_at' => Yii::t('event', 'Deleted At'),
'trainerName' => Yii::t('event', 'Trainer Name'),
'roomName' => Yii::t('event', 'Room Name'),
'eventTypeName' => Yii::t('event', 'Típus'),
'event_start' => Yii::t('event', 'Start'),
'event_end' => Yii::t('event', 'End'),
'startDateString' => Yii::t('event', 'Start'),
'endDateString' => Yii::t('event', 'End'),
'status' => Yii::t('event', 'Status'),
'seat_count' => Yii::t('event', 'Seat Count'),
'eventRegistrationCount' => Yii::t('event', 'Event Registration Count'),
'openSeatCount' => Yii::t('event', 'Open Seat Count'),
];
}
/**
* @throws Exception
*/
public function afterFind()
{
parent::afterFind(); // TODO: Change the autogenerated stub
$format = 'Y.m.d H:i';
$date = new DateTime();
$date->setTimestamp($this->start);
$date->setTimezone(new DateTimeZone('UTC'));
$this->startDateString = $date->format($format);
$date->setTimestamp($this->end);
$this->endDateString = $date->format($format);
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::class,
'value' => static function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
/** @noinspection PhpUnused */
public function getEventType(){
return $this->hasOne($this->getEventTypeClass(),['id' => 'id_event_type']);
}
/** @noinspection PhpUnused */
public function getTrainer(){
return $this->hasOne($this->getTrainerClass(),['id' => 'id_trainer']);
}/** @noinspection PhpUnused */
/**
* @return Room|ActiveQuery
*/
public function getRoom() {
return $this->hasOne($this->getRoomClass(),['id' => 'id_room']);
}/** @noinspection PhpUnused */
/**
* @return Card|ActiveQuery
*/
public function getCard() {
return $this->hasOne(Card::class,['id_card' => 'id_card']);
}
/**
* @return EventRegistration[]|ActiveQuery
*/
public function getEventRegistrations(){
return $this->hasMany(EventRegistration::class,['id_event' => 'id']);
}
/**
* @return EventEquipmentTypeAssignment[]|ActiveQuery
*/
public function getEquipmentTypeAssignments(){
return $this->hasMany($this->getEquipmentTypeAssignmentsClass(),['id_event' => 'id']);
}
/**
* @return EventRegistration[]|ActiveQuery
*/
public function getActiveEventRegistrations(){
return $this->hasMany(EventRegistration::class,['id_event' => 'id'])->andWhere(
[
'event_registration.canceled_at' => null,
'event_registration.deleted_at' => null,
]
);
}
/**
* @return EventRegistration[]|ActiveQuery
*/
public function getActiveEventRegistrationsForCustomer(){
return $this->hasMany(EventRegistration::class,['id_event' => 'id'])->andWhere(
[
'event_registration.canceled_at' => null,
'event_registration.deleted_at' => null,
'event_registration.id_customer' => \Yii::$app->user->id
]
);
}
/**
* @return integer
*/
public function getEventRegistrationCount(){
return count($this->getActiveEventRegistrations()->all());
}
protected function getEquipmentTypeAssignmentsClass()
{
return EventEquipmentTypeAssignment::class;
}
/** @noinspection PhpUnused */
public function getOpenSeatCount(){
return $this->seat_count - $this->getEventRegistrationCount();
}
public function hasFreeSeats(){
$registrationCount = count($this->eventRegistrations) ;
$seatCount = $this->seat_count;
if ( !isset($seatCount ) || $seatCount === 0){
$seatCount = PHP_INT_MAX;
}
return $registrationCount < $seatCount ;
}
public function canReserve(){
if ( isset($this->deleted_at)){
return false;
}
if ( !$this->hasFreeSeats()){
return false;
}
return true;
}
public function canDelete(){
if ( isset($this->deleted_at)){
return false;
}
return true;
}
protected function getTrainerClass(){
return Trainer::class;
}
protected function getEventTypeClass(){
return EventType::class;
}
protected function getRoomClass(){
return Room::class;
}
}

View File

@ -0,0 +1,80 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type".
*
* @property integer $id
* @property string $name
* @property string $created_at
* @property string $updated_at
*
* @property EventEquipmentTypeAssignment[] $eventEquipmentTypeAssignments
* @property EventRegistrationEquipmentTypeAssignment[] $eventRegistrationEquipmentTypeAssignments
*/
class EventEquipmentType extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_equipment_type';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'string', 'max' => 255]
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('common/event-equipment-type', 'ID'),
'name' => Yii::t('common/event-equipment-type', 'Name'),
'created_at' => Yii::t('common/event-equipment-type', 'Created At'),
'updated_at' => Yii::t('common/event-equipment-type', 'Updated At'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getEventEquipmentTypeAssignments()
{
return $this->hasMany(EventEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getEventRegistrationEquipmentTypeAssignments()
{
return $this->hasMany(EventRegistrationEquipmentTypeAssignment::className(), ['id_event_equipment_type' => 'id']);
}
}

View File

@ -0,0 +1,86 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type_assignment".
*
* @property integer $id
* @property integer $id_event
* @property integer $id_event_equipment_type
* @property integer $count
* @property string $created_at
* @property string $updated_at
*
* @property Event $idEvent
* @property EventEquipmentType $idEventEquipmentType
*/
class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_equipment_type_assignment';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_event', 'id_event_equipment_type', 'count'], 'integer'],
[['created_at', 'updated_at'], 'required'],
[['created_at', 'updated_at'], 'safe']
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('common/event', 'ID'),
'id_event' => Yii::t('common/event', 'Id Event'),
'id_event_equipment_type' => Yii::t('common/event', 'Id Event Equipment Type'),
'count' => Yii::t('common/event', 'Count'),
'created_at' => Yii::t('common/event', 'Created At'),
'updated_at' => Yii::t('common/event', 'Updated At'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getEvent()
{
return $this->hasOne(Event::className(), ['id' => 'id_event']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getEventEquipmentType()
{
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
}
}

View File

@ -0,0 +1,138 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_registration".
*
* @property integer $id
* @property integer $id_event
* @property integer $id_customer
* @property integer $id_card
* @property integer $id_ticket
* @property string $created_at
* @property string $updated_at
* @property string $canceled_at
* @property string $deleted_at
*/
class EventRegistration extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_registration';
}
/**
* @inheritdocd
*/
public function rules()
{
return [
[['id_event', 'id_customer'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event-registration', 'ID'),
'id_event' => Yii::t('event-registration', 'Id Event'),
'id_customer' => Yii::t('event-registration', 'Id Customer'),
'created_at' => Yii::t('event-registration', 'Created At'),
'updated_at' => Yii::t('event-registration', 'Updated At'),
'canceled_at' => Yii::t('event-registration', 'Canceled At'),
'deleted_at' => Yii::t('event-registration', 'Deleted At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function getEvent(){
return $this->hasOne($this->getEventClass(),['id' => 'id_event']);
}
public function getCustomer(){
return $this->hasOne($this->getCustomerClass(),['id' => 'id_customer']);
}
public function getEventClass(){
return Event::class;
}
public function getCustomerClass(){
return Customer::class;
}
/**
* @param EventRegistration $eventRegistration
*/
public static function isActive($eventRegistration){
if ( !isset($eventRegistration ) ){
return false;
}
if ( isset($eventRegistration->canceled_at ) ){
return false;
}
if ( isset($eventRegistration->deleted_at ) ){
return false;
}
return true;
}
/**
* @param EventRegistration $eventRegistration
*/
public static function isForCustomer($eventRegistration,$idCustomer){
if ( !isset($eventRegistration ) ){
return false;
}
if ( !isset($eventRegistration->id_customer ) ){
return false;
}
return $eventRegistration->id_customer == $idCustomer;
}
/**
* @param EventRegistration[] $eventRegistrations
*/
public static function filterActive($eventRegistrations){
return array_filter($eventRegistrations, EventRegistration::class.'::isActive' );
}
/**
* @param EventRegistration[] $eventRegistrations
*/
public static function filterForCustomer($eventRegistrations,$idCustomer){
$result = [];
foreach ($eventRegistrations as $eventRegistration){
if ( EventRegistration::isForCustomer($eventRegistration,$idCustomer)){
$result[] = $eventRegistration;
}
}
return $result;
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "event_registration_equipment_type_assignment".
*
* @property integer $id
* @property integer $id_event_equipment_type
* @property integer $id_event_registration
* @property string $created_at
* @property string $updated_at
*
* @property EventRegistration $idEventRegistration
* @property EventEquipmentType $idEventEquipmentType
*/
class EventRegistrationEquipmentTypeAssignment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_registration_equipment_type_assignment';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_event_equipment_type', 'id_event_registration'], 'integer'],
[['created_at', 'updated_at'], 'required'],
[['created_at', 'updated_at'], 'safe']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('common/event', 'ID'),
'id_event_equipment_type' => Yii::t('common/event', 'Id Event Equipment Type'),
'id_event_registration' => Yii::t('common/event', 'Id Event Registration'),
'created_at' => Yii::t('common/event', 'Created At'),
'updated_at' => Yii::t('common/event', 'Updated At'),
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getIdEventRegistration()
{
return $this->hasOne(EventRegistration::className(), ['id' => 'id_event_registration']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getIdEventEquipmentType()
{
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
}
}

107
common/models/EventType.php Normal file
View File

@ -0,0 +1,107 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_type".
*
* @property integer $id
* @property string $name
* @property string $created_at
* @property string $updated_at
*/
class EventType extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_type';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'unique'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event-type', 'ID'),
'name' => Yii::t('event-type', 'Name'),
'created_at' => Yii::t('event-type', 'Created At'),
'updated_at' => Yii::t('event-type', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function asOptions(){
$items = ArrayHelper::map(EventType::find()->all(),'id','name');
return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items);
}
public static function eventTypeOptions($all = false, $emptyString = false){
$items = ArrayHelper::map(EventType::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('event-type','All')];
}
if ( $emptyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
/**
* Find the first ticket, which allows this event type
* @param \common\models\Ticket[] $tickets the list of active tickets
* @return Ticket|null
*/
public function findTicketAllowingEventType($tickets){
if (!isset($tickets)){
return null;
}
if ( sizeof($tickets) == 0 ){
return null;
}
$possibleTickets = [];
foreach ($tickets as $ticket ){
if ( $ticket->hasOpenReservationCount() ){
$possibleTickets[] = $ticket;
}
}
if ( sizeof($possibleTickets) == 0 ){
return null;
}
// TODO: implement bossiness logic to select ticket
return $possibleTickets[0];
}
}

83
common/models/Room.php Normal file
View File

@ -0,0 +1,83 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "room".
*
* @property integer $id
* @property string $name
* @property integer $seat_count
* @property string $created_at
* @property string $updated_at
*/
class Room extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'room';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'seat_count'], 'required'],
[['seat_count'], 'integer'],
[['name'], 'unique'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('room', 'ID'),
'name' => Yii::t('room', 'Name'),
'seat_count' => Yii::t('room', 'Seat Count'),
'created_at' => Yii::t('room', 'Created At'),
'updated_at' => Yii::t('room', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function asOptions(){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items);
}
public static function roomOptions($all = false, $emtpyString = false){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('room','All')];
}
if ( $emtpyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}

View File

@ -2,10 +2,12 @@
namespace common\models; namespace common\models;
use common\manager\EventRegistrationManager;
use Yii; use Yii;
use yii\db\Query; use yii\db\Query;
use yii\db\Expression; use yii\db\Expression;
use common\components\Helper; use common\components\Helper;
use yii\web\HttpException;
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ /** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
@ -33,6 +35,8 @@ use common\components\Helper;
* @property int id_contract * @property int id_contract
* @property integer $original_price * @property integer $original_price
* @property string $original_end; * @property string $original_end;
* @property integer $reservation_count
* @property integer $max_reservation_count
* *
* @property \common\models\Card card * @property \common\models\Card card
* @property \common\models\Ticket transfer * @property \common\models\Ticket transfer
@ -442,6 +446,30 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
} }
} }
public function hasOpenReservationCount(){
return $this->reservation_count < $this->max_reservation_count;
}
/**
* @param $count
* @throws HttpException
*/
public function consumeReservationCount($count){
$newReservationCount = $this->reservation_count + $count;
if ( $newReservationCount > $this->max_reservation_count ){
throw new HttpException(400, 'Max ticket seat count exceeded',EventRegistrationManager::MAX_SEAT_COUNT_EXCEEDED);
}
$this->reservation_count = $newReservationCount;
}
public function restoreReservationCount($usagesToRestore){
$this->reservation_count -= $usagesToRestore;
if ( $this->reservation_count < 0 ){
$this->reservation_count = 0;
}
}
public function afterSave($insert, $changedAttributes) { public function afterSave($insert, $changedAttributes) {
Card::updateCardFlagTicket($this->id_card);; Card::updateCardFlagTicket($this->id_card);;
} }

View File

@ -24,13 +24,22 @@ use yii\helpers\ArrayHelper;
* @property integer door_allowed * @property integer door_allowed
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
* @property integer $max_reservation_count
* @property \common\models\Account $account
* @property string $typeHuman
* @property string $timeUnitHuman
* @property string $accountName
*/ */
class TicketType extends \common\models\BaseFitnessActiveRecord { class TicketType extends BaseFitnessActiveRecord
{
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10; const STATUS_ACTIVE = 10;
CONST TIME_UNIT_DAY = 10;//nap // day
CONST TIME_UNIT_MONTH = 20;//hónap CONST TIME_UNIT_DAY = 10;
CONST TIME_UNIT_MONTH_REFERENCE = 30; //tárgy hónap // month
CONST TIME_UNIT_MONTH = 20;
// subject month
CONST TIME_UNIT_MONTH_REFERENCE = 30;
const TYPE_NORMAL = 10; const TYPE_NORMAL = 10;
const TYPE_DEFAULT = self::TYPE_NORMAL; const TYPE_DEFAULT = self::TYPE_NORMAL;
@ -57,7 +66,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
public function rules() public function rules()
{ {
return [ return [
[['name', 'id_account','time_unit_count','type' ,'time_unit_type' ,'max_usage_count','price_brutto'], 'required'], [['name', 'id_account','time_unit_count','type' ,'time_unit_type' ,'max_usage_count','max_reservation_count','price_brutto'], 'required'],
//////////////// ////////////////
//price brutto //price brutto
//////////////// ////////////////
@ -76,6 +85,10 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
//////////////// ////////////////
[['max_usage_count',], 'integer','min' => 0 , 'max' => 10000], [['max_usage_count',], 'integer','min' => 0 , 'max' => 10000],
//////////////// ////////////////
//max_reservation_count
////////////////
[['max_reservation_count',], 'integer','min' => 0 , 'max' => 10000],
////////////////
//flag_student //flag_student
//////////////// ////////////////
[['flag_student',], 'integer'], [['flag_student',], 'integer'],
@ -140,6 +153,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'), 'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'),
'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'), 'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'),
'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'), 'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'),
'max_reservation_count' => Yii::t('common/ticket_type', 'Max Reservation Count'),
]; ];
} }
@ -169,7 +183,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
} }
public function getTimeUnitHuman() { public function getTimeUnitHuman() {
$result = null; $result = null;
$s = self::timeUnitTypes ( $this->time_unit_type ); $s = self::timeUnitTypes( );
if (array_key_exists ( $this->time_unit_type, $s )) { if (array_key_exists ( $this->time_unit_type, $s )) {
$result = $s [$this->time_unit_type]; $result = $s [$this->time_unit_type];
} }
@ -210,7 +224,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
} }
public function validateIdAccount($attribute,$params){ public function validateIdAccount($attribute){
$account = null; $account = null;
if ( !$this->hasErrors("id_account")){ if ( !$this->hasErrors("id_account")){
$account = Account::findOne($this->$attribute); $account = Account::findOne($this->$attribute);
@ -233,9 +247,12 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
} }
} }
/** /**
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive * $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
* */ * @param null $forceIncludeObjectWithId
* @param null $account
* @return array|\yii\db\ActiveRecord[]|null
*/
public static function read($forceIncludeObjectWithId = null, $account = null){ public static function read($forceIncludeObjectWithId = null, $account = null){
$ticketTypes = null; $ticketTypes = null;

94
common/models/Trainer.php Normal file
View File

@ -0,0 +1,94 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "trainer".
*
* @property integer $id
* @property string $name
* @property string $phone
* @property string $email
* @property string $password
* @property integer $active
* @property string $created_at
* @property string $updated_at
*/
class Trainer extends \yii\db\ActiveRecord
{
const ACTIVE_ON = 1;
const ACTIVE_OFF = 0;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'trainer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['active'], 'integer'],
[['name', 'email'], 'string', 'max' => 255],
[['phone'], 'string', 'max' => 20],
[['name','phone','email'] , 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('trainer', 'ID'),
'name' => Yii::t('trainer', 'Name'),
'phone' => Yii::t('trainer', 'Phone'),
'email' => Yii::t('trainer', 'Email'),
'password' => Yii::t('trainer', 'Password'),
'active' => Yii::t('trainer', 'Active'),
'created_at' => Yii::t('trainer', 'Created At'),
'updated_at' => Yii::t('trainer', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public static function prettyPrintActive($active){
if ( $active == Trainer::ACTIVE_ON ){
return \Yii::t("trainer",'active_on');
}
return \Yii::t("trainer",'active_off');
}
public static function trainerOptions($all = false, $emptyString = false){
$items = ArrayHelper::map(Trainer::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('trainer','All')];
}
if ( $emptyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}

View File

@ -3,11 +3,8 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use yii\base\Object;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use common\components\AccountAwareBehavior;
use common\components\UserAwareBehavior;
use common\components\DiscountAwareBehavior; use common\components\DiscountAwareBehavior;
use common\components\CustomerAwareBehavior; use common\components\CustomerAwareBehavior;
use yii\db\Query; use yii\db\Query;
@ -604,12 +601,17 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
} }
return $status; return $status;
} }
public function beforeDelete() {
/**
* @return bool
* @throws \yii\db\StaleObjectException
*/
public function beforeDelete() {
parent::beforeDelete (); parent::beforeDelete ();
if ($this->type == Transfer::TYPE_TICKET) { if ($this->type == Transfer::TYPE_TICKET) {
$ticket = $this->ticket; $ticket = $this->ticket;
if ($ticket != null) { if ($ticket != null) {
$ticket->delete (); $ticket->delete();
} }
} else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) { } else if ($this->type == Transfer::TYPE_MONEY_MOVEMENT_OUT) {
/** @noinspection PhpUndefinedFieldInspection */ /** @noinspection PhpUndefinedFieldInspection */
@ -816,11 +818,10 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
* an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ] * an array, wchic contains items. each item has to key - value pairs: [ id_account => 0, money => 0 ]
* *
* @param $accounts * @param $accounts
* @param $accountMap
* @param $idAccount * @param $idAccount
* @return array * @return array
*/ */
public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $accountMap, $idAccount) { public static function mkTotalsResultWithAllAvailableAccount($queryResult, $accounts, $idAccount) {
$totals = [ ]; $totals = [ ];
$totals ['total'] = 0; $totals ['total'] = 0;
@ -867,6 +868,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
* @param $types * @param $types
* @param $idAccount * @param $idAccount
* @return array * @return array
* @throws \yii\db\Exception
*/ */
public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) { public static function exTotalQuery($mode, $start, $end, $idUser, $types, $idAccount) {
$query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount ); $query = self::mkTotalQuery ( $mode, $start, $end, $idUser, $types, $idAccount );
@ -885,45 +887,56 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
* @param $accounts * @param $accounts
* @param $accountMap * @param $accountMap
* @return array * @return array
* @throws \yii\db\Exception
*/ */
public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) { public static function mkPaidAtTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$result = [ ]; $result = [ ];
$queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery ( 'paid_at', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount ); $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
return $result; return $result;
} }
/** /**
* find all transfers in the period ( doesn't matter if paid or not ) * find all transfers in the period ( doesn't matter if paid or not )
*/ * @throws \yii\db\Exception
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) { */
public static function mkCreatedAtTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$result = [ ]; $result = [ ];
$queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery ( 'created_at', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount ); $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
return $result; return $result;
} }
/** /**
* find transfers which were created but not paid in the period * find transfers which were created but not paid in the period
*/ * @throws \yii\db\Exception
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) { */
public static function mkCreatedAtNotPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$result = [ ]; $result = [ ];
$queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery ( 'created_at_not_paid', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount ); $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
return $result; return $result;
} }
/** /**
* find transfers which were created and paid in the period * find transfers which were created and paid in the period
*/ * @param $start
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) { * @param $end
* @param $idUser
* @param $types
* @param $idAccount
* @param $accounts
* @return array
* @throws \yii\db\Exception
*/
public static function mkCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$result = [ ]; $result = [ ];
$queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery ( 'created_at_paid', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount ); $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
return $result; return $result;
} }
@ -937,22 +950,35 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
* @param $accounts * @param $accounts
* @param $accountMap * @param $accountMap
* @return array * @return array
* @throws \yii\db\Exception
*/ */
public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) { public static function mkPaidAtNotCreatedAtPaidTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
/** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpUnusedLocalVariableInspection */
$result = [ ]; $result = [ ];
$queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount ); $queryResult = self::exTotalQuery ( 'paid_at_not_created_at', $start, $end, $idUser, $types, $idAccount );
$result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $accountMap, $idAccount ); $result = self::mkTotalsResultWithAllAvailableAccount ( $queryResult, $accounts, $idAccount );
return $result; return $result;
} }
public static function mkTotals($start, $end, $idUser, $types, $idAccount, $accounts, $accountMap) {
/**
* @param $start
* @param $end
* @param $idUser
* @param $types
* @param $idAccount
* @param $accounts
* @param $accountMap
* @return array
* @throws \yii\db\Exception
*/
public static function mkTotals($start, $end, $idUser, $types, $idAccount, $accounts) {
$result = [ ]; $result = [ ];
$result ['paid_at'] = self::mkPaidAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ); $result ['paid_at'] = self::mkPaidAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
$result ['created_at'] = self::mkCreatedAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ); $result ['created_at'] = self::mkCreatedAtTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
$result ['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ); $result ['created_at_not_paid'] = self::mkCreatedAtNotPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
$result ['created_at_paid'] = self::mkCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ); $result ['created_at_paid'] = self::mkCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
$result ['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts, $accountMap ); $result ['paid_at_not_created_at'] = self::mkPaidAtNotCreatedAtPaidTotals ( $start, $end, $idUser, $types, $idAccount, $accounts );
return $result; return $result;
} }
@ -1220,6 +1246,7 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
$ticket->id_discount = null; // contract.id_discount $ticket->id_discount = null; // contract.id_discount
$ticket->start = $request->request_target_time_at; $ticket->start = $request->request_target_time_at;
$ticket->end = date ( 'Y-m-d', strtotime ( $request->request_target_time_at . " +1 month -1 day" ) ); $ticket->end = date ( 'Y-m-d', strtotime ( $request->request_target_time_at . " +1 month -1 day" ) );
$ticket->max_reservation_count = $ticketType->max_reservation_count;
$ticket->max_usage_count = $ticketType->max_usage_count; $ticket->max_usage_count = $ticketType->max_usage_count;
$ticket->usage_count = 0; $ticket->usage_count = 0;
$ticket->status = Ticket::STATUS_INACTIVE; $ticket->status = Ticket::STATUS_INACTIVE;

View File

@ -161,6 +161,8 @@ class User extends ActiveRecord implements IdentityInterface
* Generates password hash from password and sets it to the model * Generates password hash from password and sets it to the model
* *
* @param string $password * @param string $password
* @throws \yii\base\Exception
* @throws \yii\base\InvalidConfigException
*/ */
public function setPassword($password) public function setPassword($password)
{ {

View File

@ -0,0 +1,16 @@
<?php
namespace common\modules\event;
class EventModule extends \yii\base\Module
{
public $controllerNamespace = 'common\modules\event\controllers';
public $mode;
public function init()
{
parent::init();
// custom initialization code goes here
}
}

View File

@ -0,0 +1,13 @@
<?php
namespace common\modules\event\controllers;
use yii\web\Controller;
class DefaultController extends Controller
{
public function actionIndex()
{
return $this->render('index');
}
}

View File

@ -0,0 +1,354 @@
<?php
namespace common\modules\event\controllers;
use common\manager\EventRegistrationManager;
use common\models\CardEventRegistrationForm;
use common\models\EventEquipmentType;
use common\models\EventEquipmentTypeAssignment;
use common\models\EventRegistrationEquipmentTypeAssignment;
use common\modules\event\EventModule;
use common\modules\event\models\copy\ClearWeekForm;
use common\modules\event\models\copy\CopyWeekSearch;
use common\modules\event\models\EventEquipmentTypeForm;
use common\modules\event\models\EventPermissions;
use common\modules\event\models\timetable\TimeTableSearch;
use DateTime;
use Exception;
use Throwable;
use Yii;
use common\models\Event;
use common\modules\event\models\EventSearch;
use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\web\Response;
/** @noinspection PhpUnused */
/**
* EventController implements the CRUD actions for Event model.
*/
class EventController extends Controller
{
public function behaviors()
{
$behaviors = [
'verbs' => [
'class' => VerbFilter::class,
'actions' => [
'delete' => ['post'],
],
],
];
$module = EventModule::getInstance();
assert(isset($module), 'event module not set');
$allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable', 'copy-week','clear-week',];
if ($module->mode === 'backend') {
$allowedActions[] = 'create';
$allowedActions[] = 'update';
$allowedActions[] = 'delete';
$allowedActions[] = 'equipment-types-assignment';
}
$behaviors['access'] = [
'class' => AccessControl::class,
'rules' => [
// allow authenticated users
[
'actions' => $allowedActions,
'allow' => true,
'roles' => ['@'],
],
// everything else is denied
],
];
return $behaviors;
}
/**
* Lists all Event models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new EventSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$permissions = new EventPermissions();
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'permissions' => $permissions
]);
}
/**
* 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),
]
);
$equipmentAssignmentDataProvider = new ActiveDataProvider([
'query' => EventEquipmentTypeAssignment::find()->andWhere(['id_event' => $id]),
]
);
return $this->render('view', [
'model' => $this->findModel($id),
'dataProvider' => $dataProvider,
'equipmentAssignmentDataProvider' => $equipmentAssignmentDataProvider,
'permissions' => new EventPermissions()
]);
}
/**
* Creates a new Event model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Event();
/** @noinspection NotOptimalIfConditionsInspection */
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
]);
}
/**
* Updates an existing Event model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
/** @noinspection NotOptimalIfConditionsInspection */
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
]);
}
/**
* Deletes an existing Event model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
* @throws Throwable
*/
public function actionDelete($id)
{
$manager = new EventRegistrationManager();
$manager->deleteEvent($this->findModel($id));
return $this->redirect(['index']);
}/** @noinspection PhpUnused */
/**
* @param $id
* @return Response
* @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;
}
}/** @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 string|Response
* @throws NotFoundHttpException
* @throws Exception
*/
public function actionReserveCard($id)
{
$event = $this->findModel($id);
$model = new CardEventRegistrationForm();
$model->event_id = $id;
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
$manager = new EventRegistrationManager();
try {
$manager->registerCard($model);
} /** @noinspection PhpRedundantCatchClauseInspection */ 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,
]);
}
return $this->redirect(['view', 'id' => $id]);
}
return $this->render('register_card', [
'model' => $model,
'event' => $event,
]);
}
/** @noinspection PhpUnused */
/**
* @return string
* @throws Exception
*/
public function actionTimetable()
{
$search = new TimeTableSearch();
$search->startDateString = (new DateTime())->format('Y.m.d');
$dataProvider = $search->search(Yii::$app->request->get());
return $this->render('timetable', array(
'model' => $search,
'dataProvider' => $dataProvider
));
}
/** @noinspection PhpUnused */
/**
* @return string
* @throws Exception
*/
public function actionCopyWeek()
{
$model = new CopyWeekSearch();
$model->sourceDateString = date('Y.m.d');
$model->targetDateString = date('Y.m.d', strtotime('+1 week'));
if (Yii::$app->request->isPost) {
$model->search(Yii::$app->request->post());
if (count($model->getErrors()) === 0) {
$model->save();
$this->redirect(['copy-week', $model->formName() . '[sourceDateString]'=> $model->sourceDateString, $model->formName() . '[targetDateString]' =>$model->targetDateString ]);
}
} else {
$model->search(Yii::$app->request->get());
}
return $this->render('copy_week', ['model' => $model]);
}/** @noinspection PhpUnused */
/**
* @return Response
* @throws Throwable
*/
public function actionClearWeek(){
$clearWeekForm = new ClearWeekForm();
$clearWeekForm->clear(Yii::$app->request->get());
return $this->redirect(['timetable', []]);
}
/**
* @param $id the id
* @return string
* @throws NotFoundHttpException
*/
public function actionEquipmentTypesAssignment($id)
{
// $event = $this->findModel($id);
$formModel = new EventEquipmentTypeForm(
['idEvent' => $id]
);
$formModel->loadEvent();
$formModel->loadAssignedEquipment();
if (Yii::$app->request->isPost) {
if ($formModel->load(Yii::$app->request->post()) && $formModel->save()) {
$this->redirect(['view','id' => $formModel->event->id]);
}
}else{
if ( !isset($formModel->event) ){
throw new NotFoundHttpException('The requested page does not exist.');
}
}
$formModel->equipmentTypeList = EventEquipmentType::find()->orderBy(['name' => SORT_ASC])->all();
return $this->render('equipment-types-assignment', [
'formModel' => $formModel
]);
}
/**
* Finds the Event model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Event the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Event::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException('The requested page does not exist.');
}
}

View File

@ -0,0 +1,165 @@
<?php
namespace common\modules\event\manager;
use common\models\Event;
use common\modules\event\models\timetable\TimeTableMonth;
use common\modules\event\models\timetable\TimeTableMonthDay;
use common\modules\event\models\timetable\TimeTableMonthWeek;
use customerapi\models\available\EventInterval;
use DateTime;
use Exception;
use yii\db\Query;
use yii\db\StaleObjectException;
class EventManager
{
/** @noinspection PhpUnused */
/**
* Delete or mark deleted an event
* @param $id
* @throws Throwable
* @throws \yii\base\Exception on any error
* @throws StaleObjectException
*/
public function deleteEvent($id){
$event = Event::findOne($id);
if ( !isset($event)){
throw new \yii\base\Exception("Event $id not found");
}
$registrations = $event->eventRegistrations;
if ( !isset($registrations) || count($registrations) === 0 ){
$event->delete();
} else {
$event->deleted_at = time();
$event->save(false);
}
}
/**
* @param EventInterval $interval
* @return TimeTableMonth
* @throws Exception
*/
public function loadTimeTable($interval , $activeOrDisplayInterval = "active" )
{
$timeTable = new TimeTableMonth();
$timeTable->interval = $interval;
/** @var DateTime[] $displayDates */
$displayDates = $interval->getAllDisplayDates();
$timeTable->weeks = [];
/** @var DateTime $displayDate */
foreach ($displayDates as $displayDate) {
$timeTableMonthDay = new TimeTableMonthDay();
$timeTableMonthDay->date = $displayDate;
$timeTableMonthDay->active = $interval->isActive($displayDate);
$timeTable->days[] = $timeTableMonthDay;
$weekNumber = $displayDate->format('W');
if (!isset($timeTable->weeks[$weekNumber])) {
$week = new TimeTableMonthWeek();
$week->weekNumber = $weekNumber;
$timeTable->weeks[$weekNumber] = $week;
}
$weekDayName = strtolower($displayDate->format('l'));
$timeTable->weeks[$weekNumber]->$weekDayName = $timeTableMonthDay;
}
if ( $activeOrDisplayInterval == "active"){
$dateTimeFrom = $interval->firstActiveDate;
$dateTimeTo = (clone $interval->lastActiveDate)->modify('+1 day');
}else{
// active
$dateTimeFrom = $interval->firstDisplayDate;
$dateTimeTo = (clone $interval->lastDisplayDate)->modify('+1 day');
}
// get events between active dates
$events =$this->getEvents($dateTimeFrom,$dateTimeTo);
// set events per day
/** @var Event $event */
foreach ($events as $event) {
foreach ($timeTable->days as $date) {
$eventDay = new DateTime();
$eventDay->setTimestamp($event->start);
/** @noinspection PhpUndefinedMethodInspection */
$eventDay->setTimezone($date->date->getTimezone());
$eventDay->setTime(0, 0);
if ($date->date == $eventDay) {
$date->events[] = $event;
break;
}
}
}
return $timeTable;
}
/**
* Get all active events between the to dates
* @param DateTime $fromInc from date inclusive (>=)
* @param DateTime $toExcl to date exclusive (<)
* @return Event[]
*/
public function getEvents($fromInc, $toExcl)
{
$query = Event::find();
$query = $query
->innerJoinWith('trainer')
->innerJoinWith('eventType')
->innerJoinWith('room')
->joinWith('activeEventRegistrations')
->andWhere(['>=', 'event.start', $fromInc->getTimestamp()])
->andWhere(['<', 'event.start', $toExcl->getTimestamp()])
->orderBy([
'event.start' => SORT_ASC
]);
$query = $this->withEventConditions($query);
return $query
->all();
}
/**
* Get conditions to retrieve all valid active events
* @param Query $query
* @return Query
*/
public function withEventConditions($query)
{
$query = $query->andWhere(['event.active' => '1'])
->andWhere(['event.deleted_at' => null]);
return $query;
}/** @noinspection PhpUnused */
/**
* @param DateTime $date
* @return Event[]
*/
public function getEventsForDay($date)
{
$start = clone $date;
$start->setTime(0,0);
$to = clone $start;
$to->modify('+1 day');
return $this->getEvents($start,$to);
}
public function getEvent($id){
return Event::findOne($id);
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace common\modules\event\models;
use common\models\Event;
use common\models\EventEquipmentType;
use common\models\EventEquipmentTypeAssignment;
use common\modules\event\manager\EventManager;
use common\modules\event\models\timetable\TimeTableMonth;
use common\modules\event\models\timetable\TimeTableMonthDay;
use customerapi\models\available\EventInterval;
use DateTime;
use Exception;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
/**
* @property string $sourceDateString
*/
class EventEquipmentTypeForm extends Model
{
public $equipmentTypeList = [];
public $idEquipmentType;
public $idEvent;
public $count = null;
public $event = null;
public $assignedEquipmentTypes;
private $equipmentType = null;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['count','idEvent','idEquipmentType'],'required'],
['count','integer'],
[['idEvent',], 'validateIdEvent'],
[['idEquipmentType',], 'validateEquipment'],
];
}
public function validateEquipment(){
$this->equipmentType = EventEquipmentType::find()->andWhere(['id'=> $this->idEquipmentType])->one();
if ( !isset($this->equipmentType)){
$this->addError("idEquipmentType","Hibás Felszerelés típus");
}
}
public function validateIdEvent(){
$this->loadEvent();
if ( !isset($this->event)){
$this->addError("idEvent","Esemény nem található");
}
}
public function loadEvent(){
$this->event = Event::find()->andWhere(['id'=> $this->idEvent])->one();
}
public function loadAssignedEquipment(){
$this->assignedEquipmentTypes = new ActiveDataProvider(
[
'query' => EventEquipmentTypeAssignment::find()->andWhere(['id_event' => $this->event->id]),
'pagination' => false,
// 'sort' => [
// 'defaultOrder' => [
// 'created_at' => SORT_DESC,
// 'title' => SORT_ASC,
// ]
// ],
]
);
}
/**
* @throws Exception
*/
public function save(){
$result = $this->validate();
if ( $result === false ){
return false;
}
// delete assignments with the same type
EventEquipmentTypeAssignment::deleteAll(
[
'id_event' => $this->event->id,
'id_event_equipment_type' => $this->equipmentType->id
]
);
if ( $this->count > 0 ){
$assignment = new EventEquipmentTypeAssignment();
$assignment->id_event = $this->event->id;
$assignment->id_event_equipment_type = $this->equipmentType->id;
$assignment->count = $this->count;
$assignment->save(false);
}
return true;
}
public function attributeLabels(){
return [
"count" => "Mennyiség"
];
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2019.01.15.
* Time: 8:29
*/
namespace common\modules\event\models;
use common\modules\event\EventModule;
/**
* Class EventPermissions
* @package common\modules\event\models
*
* @property boolean $allowCreate
* @property boolean $allowDelete
* @property boolean $allowEdit
*/
class EventPermissions
{
public $allowCreate = false;
public $allowDelete = false;
public $allowEdit = false;
public $allowIndexCreatedAt = false;
public function __construct()
{
$moduleMode = EventModule::getInstance()->mode;
if ( $moduleMode == 'backend'){
$this->allowCreate = true;
$this->allowDelete = true;
$this->allowEdit = true;
$this->allowIndexCreatedAt = true;
}
}
}

Some files were not shown because too many files have changed in this diff Show More