add event module

This commit is contained in:
Roland Schneider
2019-01-16 17:34:58 +01:00
parent 8decd1bc79
commit 8967445a28
18 changed files with 1151 additions and 2 deletions

View File

@@ -0,0 +1,12 @@
<div class="event-default-index">
<h1><?= $this->context->action->uniqueId ?></h1>
<p>
This is the view content for action "<?= $this->context->action->id ?>".
The action belongs to the controller "<?= get_class($this->context) ?>"
in the "<?= $this->context->module->id ?>" module.
</p>
<p>
You may customize this page by editing the following file:<br>
<code><?= __FILE__ ?></code>
</p>
</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,73 @@
<?php
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,162 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\modules\event\models\EventSearch */
/* @var $permissions common\modules\event\models\EventPermissions */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('event', 'Events');
$this->params['breadcrumbs'][] = $this->title;
$indexTableTemplateButtons = ['{view}']; // '{view} {update} {reserve-card}';
if ( $permissions->allowCreate ){
$indexTableTemplateButtons[] = '{update}';
}
$indexTableTemplateButtons[] = '{reserve-card}';
?>
<div class="event-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?php
if ( $permissions->allowCreate ){
echo Html::a(Yii::t('event', 'Create Event'), ['create'], ['class' => 'btn btn-success']);
}
?>
</p>
<?php
/**
* Filter array of menu config by the 'allowed' property.
* If property not set , it means it is allowed ( allowed boolean default true)
* @param $array array of menu configs
* @return array the filtered array of menu configs
*/
function buildColumns($array){
$result = [];
foreach ($array as $item){
$allow = true;
if ( isset($item['allow'])){
$allow = $item['allow'];
}
if ( $allow ){
$result[] = $item;
}
}
return $result;
}
$columns = buildColumns([
[
'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',
'allow' => $permissions->allowIndexCreatedAt
],
[
'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' => join("",$indexTableTemplateButtons),
'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);
}
]
],
]);
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $columns
]); ?>
</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,21 @@
<?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,187 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Event */
/* @var $permissions common\modules\event\models\EventPermissions */
$this->title = \Yii::t('event', 'Event Details');
$this->params['breadcrumbs'][] = ['label' => Yii::t('event', 'Events'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
/**
* @var \common\modules\event\EventModule
*/
$module = \common\modules\event\EventModule::getInstance();
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>
<?php
if ($permissions->allowEdit) {
echo Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
if ($model->canReserve()) {
echo Html::a(Yii::t('event', 'Reservation'), ['reserve-card', 'id' => $model->id], ['class' => 'btn btn-primary']);
}
?>
<?php
if ($permissions->allowDelete) {
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) {
if ( \common\modules\event\EventModule::getInstance()->mode =='frontend' ){
return Html::a($model['card_number'], ['/ticket/create', 'number' => $model['card_number']]);
}else{
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) {
if ( \common\modules\event\EventModule::getInstance()->mode =='frontend' ) {
return Html::a($model['customer_name'], ['/ticket/create', 'number' => $model['card_number']]);
}else{
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>