group training changes
This commit is contained in:
@@ -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.
|
||||
|
||||
118
common/modules/event/models/EventEquipmentTypeForm.php
Normal file
118
common/modules/event/models/EventEquipmentTypeForm.php
Normal 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"
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use common\modules\event\models\EventEquipmentTypeForm;
|
||||
|
||||
/* @var $formModel EventEquipmentTypeForm */
|
||||
echo $this->render('_equipment-types-assignment_form', ['model' => $formModel]);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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 " ";
|
||||
echo Html::a("Felszerelés", ['equipment-types-assignment', 'id' => $model->id], ['class' => 'btn btn-primary']);
|
||||
}
|
||||
if ($model->canReserve()) {
|
||||
echo " ";
|
||||
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' => [
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user