implement registration in backend
This commit is contained in:
@@ -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{
|
||||||
|
|
||||||
@@ -23,12 +20,12 @@ class AdminMenuStructure{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \yii\base\InvalidConfigException
|
||||||
|
*/
|
||||||
protected function addUserMainMenu(){
|
protected function addUserMainMenu(){
|
||||||
|
|
||||||
$userMainMenu = null;
|
$userMainMenu = null;
|
||||||
$items = [];
|
$items = [];
|
||||||
@@ -173,7 +170,6 @@ class AdminMenuStructure{
|
|||||||
$items[] = ['label' => 'Termek', 'url' => ['/room' ] ];
|
$items[] = ['label' => 'Termek', 'url' => ['/room' ] ];
|
||||||
$items[] = ['label' => 'Esemény típusok', 'url' => ['/event-type' ] ];
|
$items[] = ['label' => 'Esemény típusok', 'url' => ['/event-type' ] ];
|
||||||
$items[] = ['label' => 'Események', 'url' => ['/event' ] ];
|
$items[] = ['label' => 'Események', 'url' => ['/event' ] ];
|
||||||
$items[] = ['label' => 'Esemény regisztrációk', 'url' => ['/event-registration' ] ];
|
|
||||||
$this->menuItems[] = ['label' => 'Csoportos edzés', 'url' => $this->emptyUrl,
|
$this->menuItems[] = ['label' => 'Csoportos edzés', 'url' => $this->emptyUrl,
|
||||||
'items' => $items
|
'items' => $items
|
||||||
];
|
];
|
||||||
@@ -199,7 +195,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']
|
||||||
@@ -207,9 +204,13 @@ class AdminMenuStructure{
|
|||||||
}
|
}
|
||||||
$this->menuItems[] = $mainMenuItem;
|
$this->menuItems[] = $mainMenuItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use common\models\CardEventRegistrationForm;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use backend\models\EventSearch;
|
use backend\models\EventSearch;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
@@ -48,11 +49,20 @@ class EventController extends Controller
|
|||||||
* Displays a single Event model.
|
* Displays a single Event model.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function actionView($id)
|
public function actionView($id)
|
||||||
{
|
{
|
||||||
|
$eventRegistrationManager = new EventRegistrationManager();
|
||||||
|
|
||||||
|
|
||||||
|
$dataProvider = new ActiveDataProvider([
|
||||||
|
'query' => $eventRegistrationManager->createFindRegistrationsQuery($id),
|
||||||
|
]
|
||||||
|
);
|
||||||
return $this->render('view', [
|
return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $this->findModel($id),
|
||||||
|
'dataProvider' => $dataProvider
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,6 +89,7 @@ class EventController extends Controller
|
|||||||
* 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)
|
||||||
{
|
{
|
||||||
@@ -109,28 +120,65 @@ class EventController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function actionRegisterCard($id){
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return \yii\web\Response
|
||||||
|
* @throws \yii\db\Exception
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return string|\yii\web\Response
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
public function actionRegisterCard($id)
|
||||||
|
{
|
||||||
|
|
||||||
|
$event = $this->findModel($id);
|
||||||
|
|
||||||
$model = new CardEventRegistrationForm();
|
$model = new CardEventRegistrationForm();
|
||||||
$model->event_id = $id;
|
$model->event_id = $id;
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->validate() ) {
|
if ($model->load(Yii::$app->request->post())) {
|
||||||
$manager = new EventRegistrationManager();
|
if ($model->validate()) {
|
||||||
try {
|
$manager = new EventRegistrationManager();
|
||||||
$manager->registerCard($model);
|
try {
|
||||||
} catch (HttpException $e) {
|
$manager->registerCard($model);
|
||||||
if ( array_key_exists($e->getCode(),EventRegistrationManager::$STATES)) {
|
} catch (HttpException $e) {
|
||||||
$model->addError("id_event", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
|
if (array_key_exists($e->getCode(), EventRegistrationManager::$STATES)) {
|
||||||
} else {
|
$model->addError("card_number", Yii::t('event-registration', EventRegistrationManager::$STATES[$e->getCode()]));
|
||||||
$model->addError("id_event", Yii::t('event-registration', "Unknown Error"));
|
} else {
|
||||||
|
$model->addError("card_number", Yii::t('event-registration', "Unknown Error"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($model->hasErrors()) {
|
||||||
|
return $this->render('register_card', [
|
||||||
|
'model' => $model,
|
||||||
|
'event' => $event,
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
return $this->redirect(['view', 'id' => $id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( $model->hasErrors() ){
|
return $this->render('register_card', [
|
||||||
return $this->redirect(['view', 'id' => $model->registration->id]);
|
'model' => $model,
|
||||||
} else {
|
'event' => $event,
|
||||||
return $this->render('register_card', [
|
]);
|
||||||
'model' => $model,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -167,8 +166,6 @@ class TransferSearch extends Transfer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
['like', 'name', ['test', 'sample']]
|
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'transfer.id_account' => $this->id_account,
|
'transfer.id_account' => $this->id_account,
|
||||||
'transfer.status' => $this->status,
|
'transfer.status' => $this->status,
|
||||||
@@ -280,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*/
|
||||||
@@ -293,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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,41 +9,46 @@ use yii\widgets\ActiveForm;
|
|||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="event-form">
|
<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(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'startDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
|
<?= $form->field($model, 'startDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'autoclose'=>true,
|
'autoclose' => true,
|
||||||
'format' => 'yyyy.mm.dd hh:ii'
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
],
|
],
|
||||||
'options' => [
|
'options' => [
|
||||||
'autocomplete' => 'off'
|
'autocomplete' => 'off'
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $form->field($model, 'endDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
|
<?= $form->field($model, 'endDateString')->widget(\kartik\widgets\DateTimePicker::classname(), [
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
'autoclose'=>true,
|
'autoclose' => true,
|
||||||
'format' => 'yyyy.mm.dd hh:ii'
|
'format' => 'yyyy.mm.dd hh:ii'
|
||||||
],
|
],
|
||||||
'options' => [
|
'options' => [
|
||||||
'autocomplete' => 'off'
|
'autocomplete' => 'off'
|
||||||
]
|
]
|
||||||
])
|
])
|
||||||
?>
|
?>
|
||||||
|
<?= $form->field($model, 'seat_count')->textInput() ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_room')->dropDownList(\common\models\Room::roomOptions(false, true) ) ?>
|
<?= $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_trainer')->dropDownList(\common\models\Trainer::trainerOptions(false, true)) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_event_type')->dropDownList(\common\models\EventType::eventTypeOptions(false, true) ) ?>
|
<?= $form->field($model, 'id_event_type')->dropDownList(\common\models\EventType::eventTypeOptions(false, true)) ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<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']) ?>
|
<?= 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>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,6 +14,31 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<h2>Esemény</h2>
|
||||||
|
<?= /** @var \common\models\Event $event */
|
||||||
|
/** @noinspection PhpUnhandledExceptionInspection */
|
||||||
|
\yii\widgets\DetailView::widget([
|
||||||
|
'model' => $event,
|
||||||
|
'attributes' => [
|
||||||
|
'id',
|
||||||
|
'start:datetime',
|
||||||
|
'end:datetime',
|
||||||
|
[
|
||||||
|
'attribute' => 'room.name',
|
||||||
|
'label' => $model->getAttributeLabel('id_room')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'trainer.name',
|
||||||
|
'label' => $model->getAttributeLabel('id_trainer')
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'eventType.name',
|
||||||
|
'label' => $model->getAttributeLabel('id_event_type')
|
||||||
|
],
|
||||||
|
'seat_count',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
<?= $this->render('_form_register_card', [
|
<?= $this->render('_form_register_card', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
<?= Html::a(Yii::t('event', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
|
<?= Html::a(Yii::t('event', 'Register'), ['register-card', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::a(Yii::t('event', 'Delete'), ['delete', 'id' => $model->id], [
|
<?= Html::a(Yii::t('event', 'Delete'), ['delete', 'id' => $model->id], [
|
||||||
'class' => 'btn btn-danger',
|
'class' => 'btn btn-danger pull-right',
|
||||||
'data' => [
|
'data' => [
|
||||||
'confirm' => Yii::t('event', 'Are you sure you want to delete this item?'),
|
'confirm' => Yii::t('event', 'Are you sure you want to delete this item?'),
|
||||||
'method' => 'post',
|
'method' => 'post',
|
||||||
@@ -25,27 +26,144 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
]) ?>
|
]) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<div class="row">
|
||||||
'model' => $model,
|
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||||
'attributes' => [
|
<?php try {
|
||||||
'id',
|
echo DetailView::widget([
|
||||||
'start:datetime',
|
'model' => $model,
|
||||||
'end:datetime',
|
'attributes' => [
|
||||||
[
|
'id',
|
||||||
'attribute' => 'room.name',
|
'start:datetime',
|
||||||
'label' => $model->getAttributeLabel('id_room')
|
'end:datetime',
|
||||||
],
|
[
|
||||||
[
|
'attribute' => 'room.name',
|
||||||
'attribute' => 'trainer.name',
|
'label' => $model->getAttributeLabel('id_room')
|
||||||
'label' => $model->getAttributeLabel('id_trainer')
|
],
|
||||||
],
|
[
|
||||||
[
|
'attribute' => 'trainer.name',
|
||||||
'attribute' => 'eventType.name',
|
'label' => $model->getAttributeLabel('id_trainer')
|
||||||
'label' => $model->getAttributeLabel('id_event_type')
|
],
|
||||||
],
|
],
|
||||||
'created_at:datetime',
|
]);
|
||||||
'updated_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')
|
||||||
|
],
|
||||||
|
'seat_count',
|
||||||
|
'created_at:datetime',
|
||||||
|
'updated_at:datetime',
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Failed to render view";
|
||||||
|
} ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<h2>Regisztrációk</h2>
|
||||||
|
|
||||||
|
<?php try {
|
||||||
|
echo \yii\grid\GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'card_number',
|
||||||
|
'label' => \Yii::t('event', 'Card Number'),
|
||||||
|
'contentOptions' => function ($model ) {
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (isset($model['event_registration_canceled_at'])) {
|
||||||
|
$options['style'] = 'text-decoration: line-through;';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'customer_name',
|
||||||
|
'label' => \Yii::t('event', 'Customer Name'),
|
||||||
|
'contentOptions' => function ($model ) {
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (isset($model['event_registration_canceled_at'])) {
|
||||||
|
$options['style'] = 'text-decoration: line-through;';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'customer_email',
|
||||||
|
'label' => \Yii::t('event', 'Customer Email'),
|
||||||
|
'contentOptions' => function ($model ) {
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (isset($model['event_registration_canceled_at'])) {
|
||||||
|
$options['style'] = 'text-decoration: line-through;';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'event_registration_created_at',
|
||||||
|
'label' => \Yii::t('event', 'Event Registration Created At'),
|
||||||
|
'contentOptions' => function ($model) {
|
||||||
|
$options = [];
|
||||||
|
|
||||||
|
if (isset($model['event_registration_canceled_at'])) {
|
||||||
|
$options['style'] = 'text-decoration: line-through;';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'event_registration_canceled_at',
|
||||||
|
'label' => \Yii::t('event', 'Canceled At'),
|
||||||
|
'contentOptions' => function () {
|
||||||
|
$options = [];
|
||||||
|
return $options;
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'class' => 'yii\grid\ActionColumn',
|
||||||
|
'template' => '{cancel-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('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-ban-circle"></span>', $url, $options);
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Failed to render registrations";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -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">
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace common\manager;
|
namespace common\manager;
|
||||||
use common\models\Card;
|
use common\models\Card;
|
||||||
|
use common\models\Customer;
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use common\models\EventRegistration;
|
use common\models\EventRegistration;
|
||||||
|
use common\models\Ticket;
|
||||||
|
use yii\db\Query;
|
||||||
use yii\web\BadRequestHttpException;
|
use yii\web\BadRequestHttpException;
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\web\ServerErrorHttpException;
|
use yii\web\ServerErrorHttpException;
|
||||||
@@ -22,6 +25,8 @@ class EventRegistrationManager extends \yii\base\Object
|
|||||||
const NO_FREE_SEATS = 4;
|
const NO_FREE_SEATS = 4;
|
||||||
const EVENT_TYPE_NOT_FOUND = 5;
|
const EVENT_TYPE_NOT_FOUND = 5;
|
||||||
const TICKET_INSUFFICIENT = 6;
|
const TICKET_INSUFFICIENT = 6;
|
||||||
|
const UNKNOWN_ERROR = 7;
|
||||||
|
const MAX_SEAT_COUNT_EXCEEDED = 8;
|
||||||
|
|
||||||
public static $STATES = [
|
public static $STATES = [
|
||||||
self::CARD_NOT_FOUND => "CARD_NOT_FOUND",
|
self::CARD_NOT_FOUND => "CARD_NOT_FOUND",
|
||||||
@@ -30,6 +35,8 @@ class EventRegistrationManager extends \yii\base\Object
|
|||||||
self::NO_FREE_SEATS => "NO_FREE_SEATS",
|
self::NO_FREE_SEATS => "NO_FREE_SEATS",
|
||||||
self::EVENT_TYPE_NOT_FOUND => "EVENT_TYPE_NOT_FOUND",
|
self::EVENT_TYPE_NOT_FOUND => "EVENT_TYPE_NOT_FOUND",
|
||||||
self::TICKET_INSUFFICIENT => "TICKET_INSUFFICIENT",
|
self::TICKET_INSUFFICIENT => "TICKET_INSUFFICIENT",
|
||||||
|
self::UNKNOWN_ERROR => "UNKNOWN_ERROR",
|
||||||
|
self::MAX_SEAT_COUNT_EXCEEDED => "MAX_SEAT_COUNT_EXCEEDED",
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -39,6 +46,7 @@ class EventRegistrationManager extends \yii\base\Object
|
|||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
* @throws BadRequestHttpException
|
* @throws BadRequestHttpException
|
||||||
* @throws ServerErrorHttpException
|
* @throws ServerErrorHttpException
|
||||||
|
* @throws \yii\web\HttpException
|
||||||
*/
|
*/
|
||||||
public function registerCard($cardEventForm){
|
public function registerCard($cardEventForm){
|
||||||
|
|
||||||
@@ -77,21 +85,85 @@ class EventRegistrationManager extends \yii\base\Object
|
|||||||
|
|
||||||
$selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
|
$selectedTicket = $eventType->findTicketAllowingEventType($activeTickets);
|
||||||
|
|
||||||
|
|
||||||
if ( !isset($selectedTicket) ){
|
if ( !isset($selectedTicket) ){
|
||||||
throw new NotFoundHttpException("Ticket not found", self::TICKET_INSUFFICIENT);
|
throw new NotFoundHttpException("Ticket not found", self::TICKET_INSUFFICIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $selectedTicket->hasOpenReservationCount() ){
|
||||||
|
$selectedTicket->consumeReservationCount(1);
|
||||||
|
}
|
||||||
|
$selectedTicket->save();
|
||||||
|
|
||||||
$registration = new EventRegistration();
|
$registration = new EventRegistration();
|
||||||
$registration->id_event = $event->id;
|
$registration->id_event = $event->id;
|
||||||
$registration->id_card = $card->id_card;
|
$registration->id_card = $card->id_card;
|
||||||
$registration->id_ticket = $selectedTicket->id_ticket;
|
$registration->id_ticket = $selectedTicket->id_ticket;
|
||||||
$registration->save(false);
|
try{
|
||||||
|
$registration->save(false);
|
||||||
|
}catch (\Throwable $exception){
|
||||||
|
throw new ServerErrorHttpException("Failed to save", self::UNKNOWN_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
$cardEventForm->registration = $registration;
|
$cardEventForm->registration = $registration;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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",
|
||||||
|
"card.number as card_number",
|
||||||
|
"card.number as card_number",
|
||||||
|
"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|\yii\db\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 \common\models\EventRegistration $registration
|
||||||
|
* @throws ServerErrorHttpException
|
||||||
|
*/
|
||||||
|
public function cancelRegistration($registration){
|
||||||
|
if ( isset($registration->canceled_at)){
|
||||||
|
throw new ServerErrorHttpException('The registration is already canceled');
|
||||||
|
}
|
||||||
|
|
||||||
|
$ticket = Ticket::findOne(['id' => $registration->id_ticket ]);
|
||||||
|
|
||||||
|
$ticket->restoreReservationCount(1);
|
||||||
|
$ticket->save(false);
|
||||||
|
|
||||||
|
$registration->canceled_at = date('Y-m-d H:i:s' );
|
||||||
|
$registration->save(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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)',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -32,5 +32,12 @@ return [
|
|||||||
'Id Room' => 'Terem',
|
'Id Room' => 'Terem',
|
||||||
'Id Trainer' => 'Edző',
|
'Id Trainer' => 'Edző',
|
||||||
'Id Event Type' => 'Esemény Típus',
|
'Id Event Type' => 'Esemény Típus',
|
||||||
'Registration Count' => 'Résztvevők'
|
'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ő',
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -18,6 +18,7 @@ class CardEventRegistrationForm extends \yii\base\Model
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
[['card_number'], 'required' ],
|
||||||
[['card_number'], 'validateFormat' ]
|
[['card_number'], 'validateFormat' ]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -29,5 +30,15 @@ class CardEventRegistrationForm extends \yii\base\Model
|
|||||||
public function getIsNewRecord(){
|
public function getIsNewRecord(){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'card_number' => \Yii::t('event', 'Card Number'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,13 +123,20 @@ class Collection extends \common\models\BaseFitnessActiveRecord
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* */
|
* @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();
|
||||||
|
|
||||||
$query->innerJoin("account",'account.id_account = collection.id_account' );
|
$query->innerJoin("account",'account.id_account = collection.id_account' );
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ use yii\helpers\ArrayHelper;
|
|||||||
* @property integer $seat_count
|
* @property integer $seat_count
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
* @property \common\models\EventType eventType
|
* @property \common\models\EventType $eventType
|
||||||
|
* @property \common\models\Trainer $trainer
|
||||||
|
* @property \common\models\Room $room
|
||||||
|
* @property \common\models\EventRegistration[] $eventRegistrations
|
||||||
*/
|
*/
|
||||||
class Event extends \yii\db\ActiveRecord
|
class Event extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
@@ -45,7 +48,8 @@ class Event extends \yii\db\ActiveRecord
|
|||||||
return [
|
return [
|
||||||
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
|
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
|
||||||
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
||||||
[['id_trainer','id_room', 'id_event_type'], 'required'],
|
[['id_trainer','id_room', 'id_event_type','seat_count'], 'required'],
|
||||||
|
[['id_trainer','id_room', 'id_event_type','seat_count'], 'integer'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,6 +76,7 @@ class Event extends \yii\db\ActiveRecord
|
|||||||
'startDateString' => Yii::t('event', 'Start'),
|
'startDateString' => Yii::t('event', 'Start'),
|
||||||
'endDateString' => Yii::t('event', 'End'),
|
'endDateString' => Yii::t('event', 'End'),
|
||||||
'status' => Yii::t('event', 'Status'),
|
'status' => Yii::t('event', 'Status'),
|
||||||
|
'seat_count' => Yii::t('event', 'Seat Count'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,13 +132,18 @@ class Event extends \yii\db\ActiveRecord
|
|||||||
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
* @return \common\models\EventRegistration[]|\yii\db\ActiveQuery
|
||||||
*/
|
*/
|
||||||
public function getEventRegistrationCount(){
|
public function getEventRegistrationCount(){
|
||||||
return sizeof($this->getEventRegistrations());
|
return sizeof($this->eventRegistrations);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasFreeSeats(){
|
public function hasFreeSeats(){
|
||||||
$registrationCount = $this->getEventRegistrations() ;
|
$registrationCount = sizeof($this->eventRegistrations) ;
|
||||||
|
|
||||||
return $registrationCount < $this->seat_count ;
|
$seatCount = $this->seat_count;
|
||||||
|
if ( !isset($seatCount ) || $seatCount == 0){
|
||||||
|
$seatCount = PHP_INT_MAX;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $registrationCount < $seatCount ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace common\models;
|
namespace common\models;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
|
use yii\behaviors\TimestampBehavior;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the model class for table "event_registration".
|
* This is the model class for table "event_registration".
|
||||||
@@ -50,4 +52,15 @@ class EventRegistration extends \yii\db\ActiveRecord
|
|||||||
'canceled_at' => Yii::t('event-registration', 'Canceled At'),
|
'canceled_at' => Yii::t('event-registration', 'Canceled At'),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return ArrayHelper::merge( [
|
||||||
|
[
|
||||||
|
'class' => TimestampBehavior::className(),
|
||||||
|
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
||||||
|
]
|
||||||
|
],
|
||||||
|
parent::behaviors());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,7 +89,19 @@ class EventType extends \yii\db\ActiveRecord
|
|||||||
if ( sizeof($tickets) == 0 ){
|
if ( sizeof($tickets) == 0 ){
|
||||||
return null;
|
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
|
// TODO: implement bossiness logic to select ticket
|
||||||
return $tickets[0];
|
return $possibleTickets[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -441,7 +445,31 @@ 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(406,"Max ticket seat count exceeded",EventRegistrationManager::MAX_SEAT_COUNT_EXCEEDED);
|
||||||
|
}
|
||||||
|
$this->reservation_count = $newReservationCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function restoreReservationCount($usagesToRestore){
|
||||||
|
$this->reservation_count = $this->reservation_count - $usagesToRestore;
|
||||||
|
if ( $this->usage_count < 0 ){
|
||||||
|
$this->usage_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function afterSave($insert, $changedAttributes) {
|
public function afterSave($insert, $changedAttributes) {
|
||||||
Card::updateCardFlagTicket($this->id_card);;
|
Card::updateCardFlagTicket($this->id_card);;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m181227_210620_alter_table_event_registration_cancaled_at_allow_null extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->execute("alter table event_registration modify canceled_at datetime null;");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m181227_210620_alter_table_event_registration_cancaled_at_allow_null cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m181227_215706_fix_trigger_event_seat_count_check extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->execute("DROP TRIGGER IF EXISTS event_seat_count_check;");
|
||||||
|
$this->execute("CREATE TRIGGER event_seat_count_check
|
||||||
|
AFTER INSERT ON event_registration FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
IF (SELECT coalesce(COUNT(id),0) FROM event_registration
|
||||||
|
WHERE canceled_at is null AND id_event = NEW.id_event)
|
||||||
|
>
|
||||||
|
(SELECT coalesce(seat_count,0) from event where id = NEW.id_event)
|
||||||
|
THEN
|
||||||
|
SIGNAL SQLSTATE '45000'
|
||||||
|
SET MESSAGE_TEXT = 'MAX_SEAT_COUNT_EXCEEDED';
|
||||||
|
END IF;
|
||||||
|
END;
|
||||||
|
");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m181227_215706_fix_trigger_event_seat_count_check cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m181229_121344_alter_table_ticket_add_seat_count extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("ticket","reservation_count","int default 0");
|
||||||
|
$this->addColumn("ticket","max_reservation_count","int default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m181229_121344_alter_table_ticket_add_seat_count cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m181230_100000_alter_table_ticket_type_add_reservation_count extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn("ticket_type","max_reservation_count","int default 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m181230_100000_alter_table_ticket_type_add_reservation_count cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@@ -66,7 +66,7 @@ class CollectionController extends Controller
|
|||||||
$accounts = Account::read();
|
$accounts = Account::read();
|
||||||
$accountMap = Account::toAccaountMap($accounts);
|
$accountMap = Account::toAccaountMap($accounts);
|
||||||
|
|
||||||
$totals = Transfer::mkTotals($model->start, $model->end, $model->id_user, null, $model->id_account, $accounts, $accountMap);
|
$totals = Transfer::mkTotals($model->start, $model->end, $model->id_user, null, $model->id_account, $accounts);
|
||||||
|
|
||||||
return $this->render('view', [
|
return $this->render('view', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
@@ -106,7 +106,7 @@ class CollectionController extends Controller
|
|||||||
if ( $model->load(Yii::$app->request->post()) && $model->save() ) {
|
if ( $model->load(Yii::$app->request->post()) && $model->save() ) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_collection]);
|
return $this->redirect(['view', 'id' => $model->id_collection]);
|
||||||
} else {
|
} else {
|
||||||
$model->totals = Transfer::mkTotals($model->timestampStart, $model->timestampEnd, $model->user->id, null, $model->account->id_account, $model->accounts, $model->accountMap);
|
$model->totals = Transfer::mkTotals($model->timestampStart, $model->timestampEnd, $model->user->id, null, $model->account->id_account, $model->accounts );
|
||||||
return $this->render('create', [
|
return $this->render('create', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ class TicketController extends FrontendController
|
|||||||
$model->usage_count = 0;
|
$model->usage_count = 0;
|
||||||
$model->id_card = $receptionForm->card->id_card;
|
$model->id_card = $receptionForm->card->id_card;
|
||||||
$model->id_account = Account::readDefault();
|
$model->id_account = Account::readDefault();
|
||||||
|
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
|
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
|
||||||
@@ -139,7 +140,12 @@ class TicketController extends FrontendController
|
|||||||
'receptionForm' => $receptionForm,
|
'receptionForm' => $receptionForm,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $id
|
||||||
|
* @return string|\yii\web\Response
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
public function actionUpdate($id){
|
public function actionUpdate($id){
|
||||||
|
|
||||||
/** @var \frontend\models\TicketUpdate $model */
|
/** @var \frontend\models\TicketUpdate $model */
|
||||||
@@ -156,12 +162,14 @@ class TicketController extends FrontendController
|
|||||||
return $this->render('update',['model' => $model]);
|
return $this->render('update',['model' => $model]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an existing Transfer model.
|
* Deletes an existing Transfer model.
|
||||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||||
* @param integer $id
|
* @param integer $id
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
* @throws \yii\db\Exception
|
||||||
*/
|
*/
|
||||||
public function actionDelete($id)
|
public function actionDelete($id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ use common\models\Discount;
|
|||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
use common\models\UserSoldItem;
|
use common\models\UserSoldItem;
|
||||||
use common\models\ShoppingCart;
|
use common\models\ShoppingCart;
|
||||||
use yii\base\Object;
|
|
||||||
use common\models\TicketInstallmentRequest;
|
use common\models\TicketInstallmentRequest;
|
||||||
use common\models\Contract;
|
use common\models\Contract;
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
@@ -20,7 +19,7 @@ use common\models\Card;
|
|||||||
* @property $userCart common\models\Transfer[] items in user cart
|
* @property $userCart common\models\Transfer[] items in user cart
|
||||||
* @property $customerCart common\models\Transfer[] items in customer cart
|
* @property $customerCart common\models\Transfer[] items in customer cart
|
||||||
* @property $customer common\models\Customer selected customer
|
* @property $customer common\models\Customer selected customer
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
class TicketCreate extends Ticket{
|
class TicketCreate extends Ticket{
|
||||||
|
|
||||||
@@ -93,11 +92,11 @@ class TicketCreate extends Ticket{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function validateTicketType($attribute,$params){
|
public function validateTicketType($attribute){
|
||||||
$type = TicketType::findOne($this->id_ticket_type);
|
$type = TicketType::findOne($this->id_ticket_type);
|
||||||
$this->_ticketType = $type;
|
$this->_ticketType = $type;
|
||||||
if ( !isset($type)) {
|
if ( !isset($type)) {
|
||||||
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid ticket type' ));
|
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid ticket type' ));
|
||||||
}else{
|
}else{
|
||||||
if ( $type->isInstallment()){
|
if ( $type->isInstallment()){
|
||||||
$bankAccount = trim($this->customer->bank_account);
|
$bankAccount = trim($this->customer->bank_account);
|
||||||
@@ -124,17 +123,17 @@ class TicketCreate extends Ticket{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateAccount($attribute,$params){
|
public function validateAccount($attribute){
|
||||||
$this->_account = Account::findOne($this->id_account);
|
$this->_account = Account::findOne($this->id_account);
|
||||||
if ( !isset($this->_account )) {
|
if ( !isset($this->_account )) {
|
||||||
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid transfer' ));
|
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid transfer' ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validateDiscount($attribute,$params){
|
public function validateDiscount($attribute){
|
||||||
$this->_discount = Discount::findOne($this->id_discount);
|
$this->_discount = Discount::findOne($this->id_discount);
|
||||||
if ( !isset($this->_discount)) {
|
if ( !isset($this->_discount)) {
|
||||||
$this->addError($attribute,Yii::t('frontend/ticket' , 'Invalid discount' ));
|
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid discount' ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,13 +162,19 @@ class TicketCreate extends Ticket{
|
|||||||
$start = DateUtil::parseDate($this->start);
|
$start = DateUtil::parseDate($this->start);
|
||||||
$original_end = Helper::getTicketExpirationDate($start,$ticketType);
|
$original_end = Helper::getTicketExpirationDate($start,$ticketType);
|
||||||
$this->original_end = DateUtil::formatDateUtc($original_end);
|
$this->original_end = DateUtil::formatDateUtc($original_end);
|
||||||
|
$this->max_reservation_count = $ticketType->max_reservation_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterSave($insert, $changedAttributes){
|
/**
|
||||||
|
* @param $insert
|
||||||
|
* @param $changedAttributes
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public function afterSave($insert, $changedAttributes){
|
||||||
$this->addTransfer();
|
$this->addTransfer();
|
||||||
$this->appendToUserCart();
|
$this->appendToUserCart();
|
||||||
$this->appendToCustomerCart();
|
$this->appendToCustomerCart();
|
||||||
@@ -208,7 +213,10 @@ class TicketCreate extends Ticket{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function addTransfer(){
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
protected function addTransfer(){
|
||||||
//$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
|
//$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
|
||||||
|
|
||||||
|
|
||||||
@@ -230,16 +238,13 @@ class TicketCreate extends Ticket{
|
|||||||
$transfer->money = $this->price_brutto;
|
$transfer->money = $this->price_brutto;
|
||||||
|
|
||||||
$transfer->id_account = $this->_account->id_account;
|
$transfer->id_account = $this->_account->id_account;
|
||||||
|
|
||||||
$status = Transfer::STATUS_PAID;
|
|
||||||
|
|
||||||
if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){
|
if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){
|
||||||
$status = Transfer::STATUS_NOT_PAID;
|
$status = Transfer::STATUS_NOT_PAID;
|
||||||
}else if ( $this->isAppendToUserCart() ){
|
}else if ( $this->isAppendToUserCart() ){
|
||||||
$status = Transfer::STATUS_NOT_PAID;
|
$status = Transfer::STATUS_NOT_PAID;
|
||||||
}else if ( $this->isAppendToCustomerCart() ){
|
}else if ( $this->isAppendToCustomerCart() ){
|
||||||
$status = Transfer::STATUS_NOT_PAID;
|
$status = Transfer::STATUS_NOT_PAID;
|
||||||
$customer = $this->customer;
|
|
||||||
}else {
|
}else {
|
||||||
$status = Transfer::STATUS_PAID;
|
$status = Transfer::STATUS_PAID;
|
||||||
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
$transfer->paid_at = date('Y-m-d H:i:s' ) ;
|
||||||
@@ -260,18 +265,6 @@ class TicketCreate extends Ticket{
|
|||||||
$this->_transfer = $transfer;
|
$this->_transfer = $transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function addToCart(){
|
|
||||||
if ( $this->isAddToCart()){
|
|
||||||
$item = new UserSoldItem();
|
|
||||||
$item->id_transfer = $this->_transfer->id_transfer;
|
|
||||||
$item->id_user = \Yii::$app->user->id;
|
|
||||||
$item->save(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function isAppendToUserCart(){
|
public function isAppendToUserCart(){
|
||||||
$result = false;
|
$result = false;
|
||||||
if ( isset( $this->cart ) && $this->cart == 'user' ){
|
if ( isset( $this->cart ) && $this->cart == 'user' ){
|
||||||
@@ -287,8 +280,11 @@ class TicketCreate extends Ticket{
|
|||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function appendToUserCart(){
|
public function appendToUserCart(){
|
||||||
if ( $this->isAppendToUserCart() ){
|
if ( $this->isAppendToUserCart() ){
|
||||||
$item = new UserSoldItem();
|
$item = new UserSoldItem();
|
||||||
@@ -300,7 +296,10 @@ class TicketCreate extends Ticket{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
public function appendToCustomerCart(){
|
public function appendToCustomerCart(){
|
||||||
if ( Transfer::canBeAddedToCart($this->payment_method)){
|
if ( Transfer::canBeAddedToCart($this->payment_method)){
|
||||||
if ( $this->isAppendToCustomerCart() && isset($this->customer) ){
|
if ( $this->isAppendToCustomerCart() && isset($this->customer) ){
|
||||||
|
|||||||
@@ -3,15 +3,10 @@
|
|||||||
namespace frontend\models;
|
namespace frontend\models;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
use yii\base\Object;
|
|
||||||
use yii\db\Query;
|
|
||||||
use yii\db\Expression;
|
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
use common\components\Helper;
|
use common\components\Helper;
|
||||||
/**
|
/**
|
||||||
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
|
||||||
@@ -96,23 +91,14 @@ class TransferSearch extends Transfer
|
|||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function totalsTransfers($params){
|
/**
|
||||||
$accountTotals = [];
|
* @throws \yii\db\Exception
|
||||||
$fullTotal = [
|
*/
|
||||||
'label' => Yii::t('common/transfer', 'Total'),
|
public function totalsTransfers(){
|
||||||
'money' => 0
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$accounts = Account::find()->orderBy("name asc")->all();
|
$accounts = Account::find()->orderBy("name asc")->all();
|
||||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
|
||||||
$idUser = Yii::$app->user->id;
|
$idUser = Yii::$app->user->id;
|
||||||
|
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts);
|
||||||
|
|
||||||
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,9 @@ namespace frontend\models;
|
|||||||
|
|
||||||
use common\components\DateUtil;
|
use common\components\DateUtil;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
|
||||||
use yii\data\ActiveDataProvider;
|
use yii\data\ActiveDataProvider;
|
||||||
use common\models\Transfer;
|
use common\models\Transfer;
|
||||||
use yii\base\Object;
|
|
||||||
use yii\db\Query;
|
|
||||||
use yii\db\Expression;
|
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
|
||||||
use yii\helpers\ArrayHelper;
|
|
||||||
use common\components\Helper;
|
|
||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -95,23 +88,14 @@ class TransferSearchToday extends Transfer
|
|||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function totalsTransfers($params){
|
/**
|
||||||
$accountTotals = [];
|
* @throws \yii\db\Exception
|
||||||
$fullTotal = [
|
*/
|
||||||
'label' => Yii::t('common/transfer', 'Total'),
|
public function totalsTransfers(){
|
||||||
'money' => 0
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
$accounts = Account::find()->orderBy("name asc")->all();
|
$accounts = Account::find()->orderBy("name asc")->all();
|
||||||
$accountMap = ArrayHelper::map( $accounts ,'id_account','name' );
|
|
||||||
$idUser = Yii::$app->user->id;
|
$idUser = Yii::$app->user->id;
|
||||||
|
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts);
|
||||||
|
|
||||||
$this->totals = Transfer::mkTotals($this->timestampStart, $this->timestampEnd, $idUser, $this->types, $this->id_account, $accounts, $accountMap);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user