group training changes

This commit is contained in:
Roland Schneider 2020-10-24 16:08:33 +02:00
parent 43618764a4
commit a7147df522
27 changed files with 849 additions and 52 deletions

View File

@ -166,6 +166,7 @@ class AdminMenuStructure{
/////////////////////////////
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' ] ];

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,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,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

@ -11,7 +11,6 @@ $this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id'
$this->params['breadcrumbs'][] = Yii::t('event', 'Update');
?>
<div class="event-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [

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

@ -2,6 +2,7 @@
namespace common\models;
use customerapi\models\details\EventEquipmentTypeAssignmentView;
use DateTime;
use DateTimeZone;
use Exception;
@ -147,6 +148,14 @@ class Event extends ActiveRecord
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
@ -167,6 +176,11 @@ class Event extends ActiveRecord
return count($this->getActiveEventRegistrations()->all());
}
protected function getEquipmentTypeAssignmentsClass()
{
return EventEquipmentTypeAssignment::class;
}
/** @noinspection PhpUnused */
public function getOpenSeatCount(){
return $this->seat_count - $this->getEventRegistrationCount();

View File

@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type".
@ -31,22 +33,32 @@ class EventEquipmentType extends \yii\db\ActiveRecord
public function rules()
{
return [
[['created_at', 'updated_at'], 'required'],
[['created_at', 'updated_at'], 'safe'],
[['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', 'ID'),
'name' => Yii::t('common/event', 'Name'),
'created_at' => Yii::t('common/event', 'Created At'),
'updated_at' => Yii::t('common/event', 'Updated At'),
'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'),
];
}

View File

@ -3,6 +3,8 @@
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_equipment_type_assignment".
@ -39,6 +41,18 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
/**
* @inheritdoc
*/
@ -57,7 +71,7 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
public function getIdEvent()
public function getEvent()
{
return $this->hasOne(Event::className(), ['id' => 'id_event']);
}
@ -65,7 +79,7 @@ class EventEquipmentTypeAssignment extends \yii\db\ActiveRecord
/**
* @return \yii\db\ActiveQuery
*/
public function getIdEventEquipmentType()
public function getEventEquipmentType()
{
return $this->hasOne(EventEquipmentType::className(), ['id' => 'id_event_equipment_type']);
}

View File

@ -4,9 +4,13 @@ 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;
@ -43,11 +47,12 @@ class EventController extends Controller
$module = EventModule::getInstance();
assert(isset($module), 'event module not set');
$allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable', 'copy-week','clear-week'];
$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,
@ -93,14 +98,19 @@ class EventController extends Controller
{
$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()
]);
}
@ -295,6 +305,36 @@ class EventController extends Controller
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.

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,84 @@
<?php /** @noinspection PhpUnhandledExceptionInspection */
use common\modules\event\models\EventEquipmentTypeForm;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\widgets\DetailView;
/* @var $model EventEquipmentTypeForm */
?>
<h1>Szükséges felszerelés hozzáadása eseményhez</h1>
<div class="panel panel-default">
<div class="panel-heading">Esemény</div>
<div class="panel-body">
<?php try {
echo DetailView::widget([
'model' => $model->event,
'attributes' => [
'id',
'start:datetime',
[
'attribute' => 'eventType.name',
'label' => 'Típus'
],
[
'attribute' => 'trainer.name',
'label' => 'Edző'
]
],
]);
} catch (Exception $e) {
echo "failed to render event details ";
}
echo Html::a(Yii::t('event', 'Vissza az eseményhez'), ['view', 'id' => $model->event->id], ['class' => 'btn btn-primary']);
?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Felszerelés hozzáadása/módosítása</div>
<div class="panel-body">
<?php $form = ActiveForm::begin([]); ?>
<?= $form->field($model, 'idEvent')->hiddenInput()->label(false) ?>
<div class="form-group">
<?= $form->field($model, 'idEquipmentType')->dropDownList(ArrayHelper::map($model->equipmentTypeList, 'id', 'name'))->label("Felszerelés") ?>
</div>
<div class="form-group">
<?= $form->field($model, 'count')->textInput()->label("Mennyiség") ?>
</div>
<?= Html::submitButton( 'Hozzáad/Módosít', ['class' => 'btn btn-success' ]) ?>
<?php ActiveForm::end(); ?>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">Szükséges felszerelés</div>
<div class="panel-body">
<?php
echo GridView::widget([
'dataProvider' => $model->assignedEquipmentTypes,
'columns' => [
[
'label' => "Felszerelés",
'value' => function ($data) {
return $data->eventEquipmentType->name;
},
],
[
'label' => "Rendelkezésre álló mennyiség",
'value' => function ($data) {
return $data->count;
},
],
],
]);
?>
</div>
</div>

View File

@ -0,0 +1,6 @@
<?php
use common\modules\event\models\EventEquipmentTypeForm;
/* @var $formModel EventEquipmentTypeForm */
echo $this->render('_equipment-types-assignment_form', ['model' => $formModel]);

View File

@ -16,6 +16,7 @@ if ( $permissions->allowCreate ){
$indexTableTemplateButtons[] = '{update}';
}
$indexTableTemplateButtons[] = '{reserve-card}';
$indexTableTemplateButtons[] = '{equipment-types-assignment}';
?>
@ -108,7 +109,7 @@ $indexTableTemplateButtons[] = '{reserve-card}';
],
[
'class' => 'yii\grid\ActionColumn',
'template' => join("",$indexTableTemplateButtons),
'template' => join(" ",$indexTableTemplateButtons),
'urlCreator' => function ($action, $model, $key, $index) {
$params = ['id' => $model['event_id']];
$params[0] = "event" . '/' . $action;
@ -148,6 +149,14 @@ $indexTableTemplateButtons[] = '{reserve-card}';
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-user"></span>', $url, $options);
},
'equipment-types-assignment' => function ($url, $model, $key) {
$options = [
'title' => Yii::t('yii', 'Equipment Types'),
'aria-label' => Yii::t('yii', 'Equipment Types'),
'data-pjax' => '0',
];
return Html::a('<span class="glyphicon glyphicon-wrench"></span>', $url, $options);
}
]

View File

@ -5,7 +5,7 @@ use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
$this->title = Yii::t('event', 'Update Event:') . ' ' . $model->id;
$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');

View File

@ -1,5 +1,6 @@
<?php
use yii\grid\GridView;
use yii\helpers\Html;
use yii\widgets\DetailView;
@ -42,8 +43,11 @@ function getCommonColumnsHtmlOptions($model)
<?php
if ($permissions->allowEdit) {
echo Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
echo "&nbsp";
echo Html::a("Felszerelés", ['equipment-types-assignment', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
if ($model->canReserve()) {
echo "&nbsp";
echo Html::a(Yii::t('event', 'Reservation'), ['reserve-card', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
?>
@ -65,13 +69,38 @@ function getCommonColumnsHtmlOptions($model)
<?php echo $this->render('_view', ['model' => $model]); ?>
<div class="panel panel-default">
<div class="panel-heading">Szükséges felszerelés</div>
<div class="panel-body">
<?php
echo GridView::widget([
'dataProvider' => $equipmentAssignmentDataProvider,
'columns' => [
[
'label' => "Felszerelés",
'value' => function ($data) {
return $data->eventEquipmentType->name;
},
],
[
'label' => "Rendelkezésre álló mennyiség",
'value' => function ($data) {
return $data->count;
},
],
],
]);
?>
</div>
</div>
<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([
echo GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
[

View File

@ -64,7 +64,8 @@
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
"browserTarget": "app:build",
"port": 4260
},
"configurations": {
"production": {

View File

@ -1,5 +1,6 @@
<div class="container" *ngIf="event">
<h1>Jelentkezés</h1>
<form [formGroup]="eventForm">
<div class="row">
<div class="col-lg-3 col-sm-12"><span class="title">Edzés típusa</span></div>
<div class="col-lg-9 col-sm-12"><span>{{event.eventType.name}}</span></div>
@ -24,6 +25,43 @@
<div class="col-lg-3 col-sm-12"><span class="title">Terem</span></div>
<div class="col-lg-9 col-sm-12"><span>{{event?.room?.name }}</span></div>
</div>
<h2 *ngIf="event.equipmentTypeAssignments.length > 0">
Szükséges eszközök
</h2>
<ng-container *ngFor="let equipment of event.equipmentTypeAssignments; let i = index; ">
<h3>{{equipment?.equipmentType?.name }}</h3>
<div class="row">
<div class="col-lg-12 col-sm-12">
<div class="form-check">
<input
class="form-check-input"
type="radio"
name="{{'equipment'+equipment.id}}"
formControlName="{{'equipment'+equipment.id}}"
autocomplete="off"
id="equipment_{{equipment.id}}_1"
value="1"
>
<label class="form-check-label" for="equipment_{{equipment.id}}_1">
Szeretném a terem saját eszközét használni
</label>
</div>
<div class="form-check">
<input class="form-check-input"
type="radio"
name="{{'equipment'+equipment.id}}"
formControlName="{{'equipment'+equipment.id}}"
autocomplete="off"
id="equipment_{{equipment.id}}_0"
value="0"
>
<label class="form-check-label" for="equipment_{{equipment.id}}_0">
A saját eszközömet használom
</label>
</div>
</div>
</div>
</ng-container>
<div class="row">
<div class="col-lg-9 col-sm-12 pt-2">
<a *ngIf="mayRegister(event)" class="btn btn-primary " (click)="register(event)">Foglalás</a>
@ -34,4 +72,5 @@
<a class="btn btn-primary " (click)="goBack(event)">Vissza</a>
</div>
</div>
</form>
</div>

View File

@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import {Event, EventService} from "../../services/event.service";
import {Event, EventService, RegisterEventRequest} from "../../services/event.service";
import {ActivatedRoute} from "@angular/router";
import {NavigationService} from "../../services/navigation.service";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
@Component({
selector: 'app-event-details',
@ -12,16 +13,31 @@ export class EventDetailsComponent implements OnInit {
event: Event;
eventForm: FormGroup;
formControls: any;
constructor(
private fb: FormBuilder,
private eventService: EventService,
private route: ActivatedRoute,
private navigationService: NavigationService
) { }
ngOnInit() {
this.formControls = {
idEvent: ["", [Validators.required ]],
}
let idEvent = +this.route.snapshot.paramMap.get('idEvent');
this.eventService.findEvent(idEvent).subscribe(
value => this.event = value
value => {
this.event = value;
this.event.equipmentTypeAssignments.forEach((assignment,index) =>{
this.formControls['equipment'+assignment.id] = ["", [Validators.required ]]
})
this.eventForm = this.fb.group(this.formControls);
this.eventForm.patchValue({"idEvent": this.event.id})
}
);
}
@ -44,7 +60,24 @@ export class EventDetailsComponent implements OnInit {
register(event: Event) {
console.info("register", event);
this.eventService.register(event.id)
console.info(this.eventForm.value);
let request :RegisterEventRequest= {
idEvent: this.eventForm.value.idEvent,
equipment: []
};
this.event.equipmentTypeAssignments.forEach((value, index) => {
if ( this.eventForm.value.hasOwnProperty('equipment'+value.id) ){
if ( this.eventForm.value['equipment'+value.id] === "1"){
request.equipment.push(value.id);
}
}
});
console.info(request);
this.eventService.register(request)
.subscribe(
value => {},
value => {},

View File

@ -23,8 +23,8 @@ export class EventService {
return this.http.get(Endpoints.GET_EVENT( idEvent )) as Observable<Event>;
}
register(idEvent: number ): Observable<Event> {
return this.http.post(Endpoints.POST_EVENT_REGISTRATIONS_REGISTER( idEvent ),{}) as Observable<Event>;
register(registerEventRequest: RegisterEventRequest ): Observable<Event> {
return this.http.post(Endpoints.POST_EVENT_REGISTRATIONS_REGISTER( registerEventRequest.idEvent ),registerEventRequest) as Observable<Event>;
}
findRegistrations(): Observable<Registration[]> {
@ -65,6 +65,20 @@ export interface Event {
eventType: EventType;
reservedAt: number;
room: Room;
equipmentTypeAssignments?: EquipmentTypeAssignment[];
}
export interface EquipmentTypeAssignment {
id: number;
count: number;
equipmentType: EquipmentType;
}
export interface EquipmentType {
id: number;
name: string;
}
export interface Room {
@ -93,3 +107,8 @@ export interface Registration {
created_at: number;
event: Event
}
export interface RegisterEventRequest{
idEvent: number;
equipment: number[];
}

View File

@ -32,6 +32,12 @@ class EventDetailsView extends Event
return RoomDetailsView::class;
}
protected function getEquipmentTypeAssignmentsClass()
{
return EventEquipmentTypeAssignmentView::class;
}
/**
* @Override
* @return array|false
@ -50,6 +56,7 @@ class EventDetailsView extends Event
$fields['trainer'] = 'trainer';
$fields['eventType'] = 'eventType';
$fields['room'] = 'room';
$fields['equipmentTypeAssignments'] = 'equipmentTypeAssignments';
return $fields;
}

View File

@ -0,0 +1,24 @@
<?php
namespace customerapi\models\details;
use common\models\EventEquipmentTypeAssignment;
class EventEquipmentTypeAssignmentView extends EventEquipmentTypeAssignment
{
public function fields()
{
$fields = [
"id" => "id",
"count" => "count",
];
$fields['equipmentType'] = 'eventEquipmentType';
return $fields;
}
}