diff --git a/backend/controllers/CardController.php b/backend/controllers/CardController.php
index 717359b..3fa1b25 100644
--- a/backend/controllers/CardController.php
+++ b/backend/controllers/CardController.php
@@ -405,6 +405,18 @@ class CardController extends \backend\controllers\BackendController {
$result = $command->execute();
\Yii::info("Clearing flag key ready: " . $result );
}
+
+ if ( Helper::isTicketTypeDoorAllowedCheckOn()){
+ \Yii::info ( "updating door allowed flag" );
+ $command = $connection->createCommand ( Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() );
+ $result = $command->execute ();
+ \Yii::info ( "Door allowed flag updated: ". $result );
+ }else{
+ \Yii::info ( "clearing door allowed flag" );
+ $command = $connection->createCommand ( Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() );
+ $result = $command->execute ();
+ \Yii::info ( "Door allowed flag cleared: ". $result );
+ }
}
return $this->render("recalculate");
}
diff --git a/backend/controllers/LogController.php b/backend/controllers/LogController.php
index d0a873c..eeab0c4 100644
--- a/backend/controllers/LogController.php
+++ b/backend/controllers/LogController.php
@@ -22,7 +22,7 @@ class LogController extends \backend\controllers\BackendController
'rules' => [
// allow authenticated users
[
- 'actions' => [ 'index' ],
+ 'actions' => [ 'index','view' ],
'allow' => true,
'roles' => ['admin','employee','reception'],
],
diff --git a/backend/controllers/TicketController.php b/backend/controllers/TicketController.php
index f69b8ac..57eeabe 100644
--- a/backend/controllers/TicketController.php
+++ b/backend/controllers/TicketController.php
@@ -2,6 +2,7 @@
namespace backend\controllers;
+use common\models\Log;
use common\models\Transfer;
use Yii;
use common\models\Ticket;
@@ -458,7 +459,14 @@ class TicketController extends \backend\controllers\BackendController {
if ($model->load ( Yii::$app->request->post () ) && $model->save ()) {
-
+
+
+ Log::log([
+ 'type' =>Log::$TYPE_TICKET_UPDATED_BY_ADMIN,
+ 'id_ticket' => $model->id_ticket,
+ 'message' => 'Bérlet módosítva'
+ ]);
+
Helper::flash("success", "Bérlet sikeresen módosítva");
$url = Url::previous("ticket_index_customer");
diff --git a/backend/models/LogSearch.php b/backend/models/LogSearch.php
index 5087cd3..c64bd98 100644
--- a/backend/models/LogSearch.php
+++ b/backend/models/LogSearch.php
@@ -20,6 +20,7 @@ class LogSearch extends Log
public $timestampStart;
public $timestampEnd;
+
/**
* @inheritdoc
*/
@@ -99,12 +100,12 @@ class LogSearch extends Log
$query->andFilterWhere([
'id_log' => $this->id_log,
'type' => $this->type,
- 'id_user' => $this->id_user,
+ 'log.id_user' => $this->id_user,
'id_transfer' => $this->id_transfer,
'id_money_movement' => $this->id_money_movement,
'id_ticket' => $this->id_ticket,
'id_sale' => $this->id_sale,
- 'id_customer' => $this->id_customer,
+ 'log.id_customer' => $this->id_customer,
'id_account' => $this->id_account,
'id_account_state' => $this->id_account_state,
'id_key' => $this->id_key,
diff --git a/backend/models/TicketSearch.php b/backend/models/TicketSearch.php
index df61d06..6ee9583 100644
--- a/backend/models/TicketSearch.php
+++ b/backend/models/TicketSearch.php
@@ -41,6 +41,8 @@ class TicketSearch extends Ticket
public $customer_name;
public $card_number;
+ public $modified;
+
/**
* @inheritdoc
@@ -48,13 +50,13 @@ class TicketSearch extends Ticket
public function rules()
{
return [
- [['id_ticket', 'id_user', 'id_ticket_type', 'id_account', 'status', 'id_customer'], 'integer'],
+ [['id_ticket', 'id_user', 'id_ticket_type', 'id_account', 'status', 'id_customer', 'modified'], 'integer'],
// [[ 'start', ], 'date' , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
// [[ 'end' , ], 'date' , 'timestampAttribute' => 'timestampEnd' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ],
[['start',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'timestampStart', 'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm', 'timeZone' => 'UTC'],
[['end',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'timestampEnd', 'timestampAttributeFormat' => 'yyyy-MM-dd HH:mm', 'timeZone' => 'UTC'],
[['valid_in_interval', 'created_in_interval', 'expire_in_interval', 'paid_in_interval'], 'boolean'],
- [['output', 'customer_name','card_number'], 'safe']
+ [['output', 'customer_name', 'card_number'], 'safe']
];
}
@@ -77,6 +79,7 @@ class TicketSearch extends Ticket
'created_in_interval' => Yii::t('backend/ticket', 'Created in interval'),
'expire_in_interval' => Yii::t('backend/ticket', 'Expire in interval'),
'paid_in_interval' => "Fizetve az időszakban",
+ 'modified' => "Módosított",
]);
}
@@ -192,6 +195,19 @@ class TicketSearch extends Ticket
'card.number' => $this->card_number
]);
+ if ($this->modified == 1) {
+ $query->andWhere(
+ [
+ 'or',
+ ['and', ['not', ['ticket.original_price' => null]], ['<>', 'ticket.original_price', 'ticket.price_brutto']],
+ ['and', ['not', ['ticket.original_end' => null]], ['<>', 'ticket.original_end', 'ticket.end']],
+
+ ]
+ );
+// $query->andWhere('ticket.original_price is not null and ticket.original_price <> ticket.price_brutto');
+// $query->andWhere('ticket.original_end is not null and ticket.original_end <> ticket.end');
+ }
+
$query->andFilterWhere(['like', new Expression('LOWER(customer.name)'), strtolower($this->customer_name)]);
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) && !($this->paid_in_interval))
@@ -232,7 +248,8 @@ class TicketSearch extends Ticket
}
- public function isAllDateConditionOn(){
+ public function isAllDateConditionOn()
+ {
$all = (!($this->valid_in_interval) && !($this->expire_in_interval) && !($this->created_in_interval) && !($this->paid_in_interval))
||
($this->valid_in_interval == true && $this->expire_in_interval == true && $this->created_in_interval && $this->paid_in_interval);
diff --git a/backend/views/card/view.php b/backend/views/card/view.php
index a6977f2..fbfe73f 100644
--- a/backend/views/card/view.php
+++ b/backend/views/card/view.php
@@ -30,4 +30,23 @@ $this->params['breadcrumbs'][] = $this->title;
],
]) ?>
+ customer;
+ if (isset($customer)) {
+ ?>
+ = DetailView::widget(
+ ['model' => $customer,
+ 'attributes' => [
+ [
+ 'attribute' => 'id_customer',
+ 'format' => 'raw',
+ 'value' => Html::a($customer->name, ['customer/view', 'id' => $customer->id_customer]),
+ 'label' => 'Vendég'
+
+ ]
+ ]]) ?>
+
+
diff --git a/backend/views/log/_search.php b/backend/views/log/_search.php
index 3d9f237..e29ad89 100644
--- a/backend/views/log/_search.php
+++ b/backend/views/log/_search.php
@@ -7,6 +7,8 @@ use kartik\widgets\DateTimePicker;
/* @var $this yii\web\View */
/* @var $model backend\models\LogSearch */
/* @var $form yii\widgets\ActiveForm */
+
+$userOptions = ['' => 'Mind'] + \yii\helpers\ArrayHelper::map(\common\models\User::read (), 'id', 'username');
?>
@@ -38,6 +40,18 @@ use kartik\widgets\DateTimePicker;
+
+
+
+
+ = $form->field($model, 'type')->dropDownList( ["" =>"Mind"] + \common\models\Log::getTypes()) ?>
+
+
+
+ = $form->field($model, 'id_user')->dropDownList( $userOptions ) ?>
+
+
+
diff --git a/backend/views/log/index.php b/backend/views/log/index.php
index ea39a3c..07af952 100644
--- a/backend/views/log/index.php
+++ b/backend/views/log/index.php
@@ -53,7 +53,19 @@ $this->params['breadcrumbs'][] = $this->title;
// 'id_door_log',
// 'updated_at',
-// ['class' => 'yii\grid\ActionColumn'],
+ [
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => '{view}',
+ 'urlCreator' => function($action, $model, $key, $index){
+ $result = "";
+
+ if ( $action == 'view'){
+ $result = \yii\helpers\Url::toRoute(['log/view','id' => $model['log_id_log']]);
+ }
+
+ return $result;
+ }
+ ],
],
]); ?>
diff --git a/backend/views/log/view.php b/backend/views/log/view.php
index 967b04f..315ccbe 100644
--- a/backend/views/log/view.php
+++ b/backend/views/log/view.php
@@ -13,32 +13,43 @@ $this->params['breadcrumbs'][] = $this->title;
= Html::encode($this->title) ?>
-
-
- = Html::a(Yii::t('common/log', 'Update'), ['update', 'id' => $model->id_log], ['class' => 'btn btn-primary']) ?>
- = Html::a(Yii::t('common/log', 'Delete'), ['delete', 'id' => $model->id_log], [
- 'class' => 'btn btn-danger',
- 'data' => [
- 'confirm' => Yii::t('common/log', 'Are you sure you want to delete this item?'),
- 'method' => 'post',
- ],
- ]) ?>
-
-
= DetailView::widget([
'model' => $model,
'attributes' => [
'id_log',
- 'type',
+ [
+ 'attribute' => 'type',
+// 'format' => 'raw',
+ 'value' =>$model->typeName,
+ 'label' => 'Típus'
+
+ ],
'message',
'url:ntext',
'app',
- 'id_user',
+ [
+ 'attribute' => 'id_user',
+ 'format' => 'raw',
+ 'value' => Html::a($model->userName, ['user/view', 'id' => $model->id_user]),
+
+ ],
+ [
+ 'attribute' => 'id_ticket',
+ 'format' => 'raw',
+ 'value' => Html::a($model->ticketName, ['ticket/view', 'id' => $model->id_ticket]),
+
+ ],
+ [
+ 'attribute' => 'id_customer',
+ 'format' => 'raw',
+ 'value' => Html::a($model->customerName, ['customer/view', 'id' => $model->id_customer]),
+
+ ],
'id_transfer',
'id_money_movement',
- 'id_ticket',
+
+
'id_sale',
- 'id_customer',
'id_account',
'id_account_state',
'id_key',
diff --git a/backend/views/ticket-type/_form.php b/backend/views/ticket-type/_form.php
index 3c3ff86..ea80d2d 100644
--- a/backend/views/ticket-type/_form.php
+++ b/backend/views/ticket-type/_form.php
@@ -56,13 +56,17 @@ use yii\helpers\ArrayHelper;
= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?>
= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?>
-
+
= mkTitle("Csoportos beszedés")?>
= $form->field($model, 'installment_enabled')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Csoportos beszedéses a bruttó áron felül") ]) ?>
A részletek havonta kerülnek beszedésre
= $form->field($model, 'installment_money')->textInput() ?>
= $form->field($model, 'installment_count')->textInput() ?>
+
+ = $form->field($model, 'door_allowed')->checkbox( ['value' => 1, 'label' => 'Forgóvilla engedi' ]) ?>
+
+
= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket_type', 'Create') : Yii::t('common/ticket_type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
diff --git a/backend/views/ticket-type/index.php b/backend/views/ticket-type/index.php
index 96abced..382ebc2 100644
--- a/backend/views/ticket-type/index.php
+++ b/backend/views/ticket-type/index.php
@@ -21,42 +21,54 @@ $this->params['breadcrumbs'][] = $this->title;
- = GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
+
+ 'time_unit_type',
- 'value' =>'timeUnitHuman',
- ],
[
- 'attribute' => 'id_account',
- 'value' => 'accountName',
- ],
- [
- 'attribute' =>'flag_student',
- 'value' =>function($model, $key, $index, $column){
- return $model->isStudent() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
- },
- ],
- [
- 'attribute' =>'status',
- 'value' =>'statusHuman',
- ],
+ 'attribute' =>'time_unit_type',
+ 'value' =>'timeUnitHuman',
+ ],
+ [
+ 'attribute' => 'id_account',
+ 'value' => 'accountName',
+ ],
+ [
+ 'attribute' =>'flag_student',
+ 'value' =>function($model, $key, $index, $column){
+ return $model->isStudent() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
+ },
+
+ ],
+ [
+ 'attribute' =>'door_allowed',
+ 'value' =>function($model, $key, $index, $column){
+ return $model->isDoor() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
+ },
+ 'visible' => \common\components\Helper::isTicketTypeDoorAllowedCheckOn()
+
+ ],
+ [
+ 'attribute' =>'status',
+ 'value' =>'statusHuman',
+ ],
'created_at:datetime',
'updated_at:datetime',
[
- 'class' => 'yii\grid\ActionColumn',
- 'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']),
-
- ],
- ],
+ 'class' => 'yii\grid\ActionColumn',
+ 'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']),
+
+ ],
+ ];
+ ?>
+ = GridView::widget([
+ 'dataProvider' => $dataProvider,
+ 'columns' => $columns
]); ?>
diff --git a/backend/views/ticket-type/view.php b/backend/views/ticket-type/view.php
index 3396d34..02fc174 100644
--- a/backend/views/ticket-type/view.php
+++ b/backend/views/ticket-type/view.php
@@ -50,6 +50,11 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'status',
'value' => $model->statusHuman
],
+ [
+ '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',
[
diff --git a/backend/views/ticket/_search.php b/backend/views/ticket/_search.php
index 53d218c..42d7ad5 100644
--- a/backend/views/ticket/_search.php
+++ b/backend/views/ticket/_search.php
@@ -57,6 +57,7 @@ $userOptions = ['' => 'Mind'] + ArrayHelper::map($model->users, 'id', 'userna
= $form->field($model, 'card_number')->textInput()->label("Kártyaszám") ?>
+ = $form->field($model, 'modified')->dropDownList( ["" =>"Mind", '1' => 'Módosított'] ) ?>
diff --git a/backend/views/ticket/view.php b/backend/views/ticket/view.php
index 97bf41c..e3c1e28 100644
--- a/backend/views/ticket/view.php
+++ b/backend/views/ticket/view.php
@@ -11,7 +11,7 @@ $this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket', 'Tickets'),
$this->params['breadcrumbs'][] = $this->title;
?>
-
= Html::encode($this->title) ?>
+ Bérlet információ: #= Html::encode($this->title) ?>
= DetailView::widget([
'model' => $model,
'attributes' => [
@@ -23,12 +23,14 @@ $this->params['breadcrumbs'][] = $this->title;
],
[
'attribute' => 'id_ticket_type',
- 'value' => $model->ticketTypeName,
+ 'format' => 'raw',
+ 'value' => Html::a($model->ticketTypeName, ['ticket-type/view', 'id' => $model->id_ticket_type]),
],
[
'attribute' => 'id_account',
- 'value' => $model->accountName,
+ 'format' => 'raw',
+ 'value' => Html::a($model->accountName, ['account/view', 'id' => $model->id_account]),
],
[
@@ -45,9 +47,75 @@ $this->params['breadcrumbs'][] = $this->title;
'value' => $model->statusName
],
'price_brutto',
+ [
+ 'attribute' => 'price_brutto',
+ 'format' => 'raw',
+ 'value' => Html::a($model->price_brutto, ['transfer/view', 'id' => $model->transfer->id_transfer]),
+
+ ],
'comment:raw',
'created_at:datetime',
'updated_at:datetime',
+ 'original_end:date',
+ 'original_price',
],
]) ?>
+
+
+ Bérletkártya
+ $model->card,
+ 'attributes' => [
+ [
+ 'attribute' => 'number',
+ 'format' => 'raw',
+ 'value' => Html::a($model->card->number, ['card/view', 'id' => $model->card->id_card]),
+ ]
+ ]]);
+
+ ?>
+
+ Vendég
+ $model->customer,
+ 'attributes' => [
+ [
+ 'attribute' => 'name',
+ 'format' => 'raw',
+ 'value' => Html::a($model->customer->name, ['customer/view', 'id' => $model->customer->id_customer]),
+ ]
+
+ ]]);
+
+ ?>
+
+ contract;
+ if (isset($contract)) {
+ ?>
+ Szerződés
+ $contract,
+ 'attributes' => [
+ [
+ 'attribute' => 'id_contract',
+ 'format' => 'raw',
+ 'value' => Html::a($contract->id_contract, ['contract/details', 'id' => $contract->id_contract]),
+ ]
+
+ ]]);
+
+ ?>
+
+
+
+
diff --git a/backend/views/transfer/view.php b/backend/views/transfer/view.php
index d3c1abf..ea9efca 100644
--- a/backend/views/transfer/view.php
+++ b/backend/views/transfer/view.php
@@ -1,4 +1,5 @@
title = $model->id_transfer;
-$this->params ['breadcrumbs'] [] = [
- 'label' => Yii::t ( 'frontend/transfer', 'Transfers' ),
- 'url' => [
- 'index'
- ]
+$this->params ['breadcrumbs'] [] = [
+ 'label' => Yii::t('frontend/transfer', 'Transfers'),
+ 'url' => [
+ 'index'
+ ]
];
$this->params ['breadcrumbs'] [] = $this->title;
?>
-
= Html::encode($this->title) ?>
-
-
- =DetailView::widget (
- [ 'model' => $model,
- 'attributes' => [
- [ 'attribute' => 'id_transfer' ],
- [ 'attribute' => 'id_account','value' => $model->accountName ],
- [ 'attribute' => 'type','value' => $model->transferTypeName ],
- [ 'attribute' => 'id_object','value' => $model->objectName ],
- [ 'attribute' => 'id_user','value' => $model->userName ],
- [ 'attribute' => 'id_discount','value' => $model->discountName ],
- [ 'attribute' => 'payment_method','value' => $model->paymentMethodName ],
- [ 'attribute' => 'status','value' => $model->statusName ],
- 'item_price',
- 'count',
- 'money',
- 'comment',
- 'created_at',
- 'paid_at' ] ] )?>
-
-
+
= Html::encode($this->title) ?>
+
+
+ = DetailView::widget(
+ ['model' => $model,
+ 'attributes' => [
+ ['attribute' => 'id_transfer'],
+ ['attribute' => 'id_account', 'value' => $model->accountName],
+ ['attribute' => 'type', 'value' => $model->transferTypeName],
+ ['attribute' => 'id_object', 'value' => $model->objectName],
+ ['attribute' => 'id_user', 'value' => $model->userName],
+ ['attribute' => 'id_discount', 'value' => $model->discountName],
+ ['attribute' => 'payment_method', 'value' => $model->paymentMethodName],
+ ['attribute' => 'status', 'value' => $model->statusName],
+ 'item_price',
+ 'count',
+ 'money',
+ 'comment',
+ 'created_at',
+ 'paid_at']]) ?>
+
+
+ type == Transfer::TYPE_TICKET) {
+ $ticket = $model->ticket;
+ ?>
+ = DetailView::widget(
+ ['model' => $ticket,
+ 'attributes' => [
+ [
+ 'attribute' => 'id_ticket_type',
+ 'format' => 'raw',
+ 'value' => Html::a($ticket->ticketTypeName, ['ticket/view', 'id' => $ticket->id_ticket]),
+ 'label' => 'Bérlet'
+
+ ]
+ ]]) ?>
+
+
+ customer;
+ if (isset($customer)) {
+ ?>
+ = DetailView::widget(
+ ['model' => $customer,
+ 'attributes' => [
+ [
+ 'attribute' => 'id_customer',
+ 'format' => 'raw',
+ 'value' => Html::a($customer->name, ['customer/view', 'id' => $customer->id_customer]),
+ 'label' => 'Vendég'
+
+ ]
+ ]]) ?>
+
+
+
+
type == Transfer::TYPE_TICKET) {
+
+ if ($model->status == Transfer::STATUS_STORNO || $model->status == Transfer::STATUS_PAID) {
+
+ ?>
+ Sztornózott vagy fizetett bérlet fizetettlenre állítása:
+
+ - A tranzakció státusza fizetetlen lesz
+ - A bérlet státusza inaktív lesz ( a bérlettel nem lehet bemenni a forgó kapun)
+ - A bérlet a vásárló kosarába kerül
+
+ $model->id_transfer
+ ], [
+ 'class' => 'btn btn-danger',
+ 'data-confirm' => "Figyelem, a bérlet fizetetlennek lesz jelölve !!",
+ 'data-method' => 'post'
+ ]);
+ }
+ }
+
- if ( $model->type == Transfer::TYPE_TICKET ){
-
- if ($model->status == Transfer::STATUS_STORNO || $model->status == Transfer::STATUS_PAID ) {
-
- ?>
- Sztornózott vagy fizetett bérlet fizetettlenre állítása:
-
- - A tranzakció státusza fizetetlen lesz
- - A bérlet státusza inaktív lesz ( a bérlettel nem lehet bemenni a forgó kapun)
- - A bérlet a vásárló kosarába kerül
-
- $model->id_transfer
- ], [
- 'class' => 'btn btn-danger',
- 'data-confirm' => "Figyelem, a bérlet fizetetlennek lesz jelölve !!",
- 'data-method' => 'post'
- ] );
- }
- }
-
-
}
?>
diff --git a/changelog.txt b/changelog.txt
index 17fef38..3f829f1 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,3 +1,6 @@
+-0.1.08
+ - add feature cutler door
+ - add admin object links
-0.1.07
- fix frontend ticket/sell displayed accounts
-0.1.06
diff --git a/common/components/DateUtil.php b/common/components/DateUtil.php
index 4e05d84..eb9437e 100644
--- a/common/components/DateUtil.php
+++ b/common/components/DateUtil.php
@@ -101,4 +101,11 @@ class DateUtil
return $formatter->asDatetime($dateTimeObject);
}
+ public static function parseDate($dateString){
+
+ $date = \DateTime::createFromFormat("Y.m.d", $dateString, new \DateTimeZone( 'UTC'));
+ $date->setTime(0, 0, 0);
+ return $date;
+ }
+
}
\ No newline at end of file
diff --git a/common/components/Helper.php b/common/components/Helper.php
index 54fc469..74939f5 100644
--- a/common/components/Helper.php
+++ b/common/components/Helper.php
@@ -2,6 +2,7 @@
namespace common\components;
+use common\models\TicketType;
use common\models\Transfer;
use \Yii;
@@ -348,6 +349,10 @@ class Helper {
public static function isKeyRequired() {
return \Yii::$app->params ['key_required'] == true;
}
+
+ public static function isTicketTypeDoorAllowedCheckOn() {
+ return \Yii::$app->params ['ticket_type_door_allowed_check_on'] == true;
+ }
public static function getProductSaleDefaultFocus() {
return \Yii::$app->params ['product_sale_default_focus'] ;
@@ -489,5 +494,40 @@ class Helper {
}
}
}
+
+ /**
+ * @param $start \DateTime datetime
+ * @param $ticketType \common\models\TicketType the ticket type
+ */
+ public static function getTicketExpirationDate($start,$ticketType){
+ $result = new \DateTime();
+ $result->setTimezone(new \DateTimeZone("UTC") );
+ $result->setTimestamp($start->getTimestamp());
+
+
+ $unitCount = $ticketType->time_unit_count;
+ $unitType = $ticketType->time_unit_type;
+
+ switch ($unitType){
+ case TicketType::TIME_UNIT_DAY:
+ $result->add(new \DateInterval("P".$unitCount."D"));
+ $result->sub(new \DateInterval("P1D"));
+ break;
+ case TicketType::TIME_UNIT_MONTH:
+ $result->add(new \DateInterval("P".$unitCount."M"));
+ $result->sub(new \DateInterval("P1D"));
+ break;
+ case TicketType::TIME_UNIT_MONTH_REFERENCE:
+ if ( $unitCount > 1 ){
+ $result->add(new \DateInterval("P". ($unitCount -1 )."M"));
+ }
+ $result->sub(new \DateInterval("P1D"));
+ break;
+ }
+
+ $result->setTime(0, 0, 0);
+
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/common/config/params.php b/common/config/params.php
index 574ad51..5b77f5d 100644
--- a/common/config/params.php
+++ b/common/config/params.php
@@ -5,7 +5,7 @@ return [
'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600,
- 'version' => 'v0.1.07',
+ 'version' => 'v0.1.08',
'company' => 'movar',//gyor
'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global
@@ -60,5 +60,6 @@ return [
*/
'key_toggle_door_log_enabled' => false,
//if key required for entry trough the door
- 'key_required' => true
+ 'key_required' => true,
+ 'ticket_type_door_allowed_check_on' => false
];
diff --git a/common/models/Card.php b/common/models/Card.php
index 9bf27f5..9484821 100644
--- a/common/models/Card.php
+++ b/common/models/Card.php
@@ -34,10 +34,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
const TYPE_EMPLOYEE = 50;
- public static $FLAG_TICKET = 0;
- public static $FLAG_DOOR = 1;
- public static $FLAG_KEY = 2;
- public static $FLAG_STATUS = 3;
+ public static $FLAG_TICKET = 0; //has valid ticket
+ public static $FLAG_DOOR = 1; //door in/out order
+ public static $FLAG_KEY = 2; //key status
+ public static $FLAG_STATUS = 3; //allowed/disabled
+ public static $FLAG_DOOR_ALLOWED = 4; //ticket type allows door
/**
* This script is used in daily scripts, to clear the flag door log status
@@ -65,6 +66,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
UPDATE card set flag = ( flag & ~(1 << 1 ) ) WHERE card.type <> 50 and card.id_card = :id
";
+ public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG(){
+ return "UPDATE card set flag = ( flag & ~(1 << " . Card::$FLAG_DOOR_ALLOWED. " ) ) WHERE card.type <> 50 ";
+ }
+
+ public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(){
+ return Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() . " and card.id_card = :id ";
+ }
+
+
/**
* @inheritdoc
*/
@@ -227,6 +237,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
$command = $db->createCommand(Card::$SQL_CLEARS_STATUS_DOOR_IN,[':id' => $id]);
$command->execute();
+
+ if ( Helper::isTicketTypeDoorAllowedCheckOn()) {
+ $command = $db->createCommand(Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
+ $command->execute();
+ }else{
+ $command = $db->createCommand(Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
+ $command->execute();
+ }
+
}
public function beforeSave($insert) {
@@ -279,6 +298,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
return Helper::isBitOn($this->flag_out,Card::$FLAG_KEY);
}
-
+ /**
+ * if flag is on, door entry is not allowed.
+ */
+ public function isFlagDoorAllowed(){
+ return Helper::isBitOn($this->flag,Card::$FLAG_DOOR_ALLOWED);
+ }
}
diff --git a/common/models/Log.php b/common/models/Log.php
index 8131116..1f4d21c 100644
--- a/common/models/Log.php
+++ b/common/models/Log.php
@@ -2,6 +2,7 @@
namespace common\models;
+use common\components\Helper;
use Yii;
use yii\helpers\Url;
use yii\helpers\VarDumper;
@@ -54,6 +55,43 @@ class Log extends BaseFitnessActiveRecord
public static $TYPE_TOWEL_IN = 190;
public static $TYPE_TOWEL_OUT = 200;
public static $TYPE_CRUD = 210;
+ public static $TYPE_TICKET_UPDATED_BY_ADMIN = 220;
+
+
+ public static function getTypes(){
+ return [
+
+ Log::$TYPE_INFO => "Info",
+ Log::$TYPE_ERR => "Hiba",
+ Log::$TYPE_TICKET_USAGE_FIRST => "Bérlet használat",
+ Log::$TYPE_TICKET_USAGE_MULTIPLE => "Többszöri bérlet használat",
+ Log::$TYPE_LOGIN => "Bejelentkezés",
+ Log::$TYPE_DEFAULT_ACCOUNT=> "Alapértelmezett kassza",
+ Log::$TYPE_CREATE_CUSTOMER=> "Új vendég",
+ Log::$TYPE_PROCUREMENT_UPDATE => "Beszerzés módosítás",
+ Log::$TYPE_TICKET_COUNT_MOVE_OUT => "Ki mozgás",
+ Log::$TYPE_WASTE => "Selejt",
+ Log::$TYPE_NEWSLETTER_SUBSCRIBE => "Feliratkozás hirlevélre",
+ Log::$TYPE_NEWSLETTER_UNSUBSCRIBE => "Leiratkozás hírlevélről",
+ Log::$TYPE_NEWSLETTER_SENT => "Hirlevél elküldve",
+ Log::$TYPE_TICKET_EXPIRE_SENT => "Bérlet lejáart figyelmeztetés elküldve",
+ Log::$TYPE_NEWSLETTER_SEND_START => "Hirlevél küldés start",
+ Log::$TYPE_NEWSLETTER_SEND_END => "Hirlevél küldés vége",
+ Log::$TYPE_KEY_ASSIGN => "Kulcs kiadás",
+ Log::$TYPE_KEY_UNASSIGN => "Kulcs visszaadás",
+ Log::$TYPE_TOWEL_IN => "Törölköző ki",
+ Log::$TYPE_TOWEL_OUT => "Törölköző vissza",
+ Log::$TYPE_CRUD => "CRUD",
+ Log::$TYPE_TICKET_UPDATED_BY_ADMIN => "Bérlet módosítás"
+
+ ];
+}
+
+
+ public function getTypeName(){
+ $types = Log::getTypes();
+ return Helper::getArrayValue($types,$this->type,null);
+ }
/**
* @inheritdoc
@@ -132,5 +170,47 @@ class Log extends BaseFitnessActiveRecord
$model->id_user = 1;
$model->save(false);
}
-
+
+ public function getUser(){
+ return $this->hasOne( User::className(), ["id" =>"id_user" ] );
+ }
+
+ public function getTicket(){
+ return $this->hasOne( Ticket::className(), ["id_ticket" =>"id_ticket" ] );
+ }
+
+ public function getCustomer(){
+ return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
+ }
+
+ public function getMoneyMovement(){
+ return $this->hasOne( MoneyMovement::className(), ["id_money_movement" =>"id_money_movement" ] );
+ }
+
+
+ public function getUserName(){
+ $user = $this->user;
+ if ( isset($user)){
+ return $user->username;
+ }
+ return null;
+ }
+
+ public function getCustomerName(){
+ $customer = $this->customer;
+ if ( isset($customer)){
+ return $customer->name;
+ }
+ return null;
+ }
+
+ public function getTicketName(){
+ $ticket = $this->ticket;
+ if ( isset($ticket)){
+ return $ticket->ticketTypeName;
+ }
+ return null;
+ }
+
+
}
diff --git a/common/models/Ticket.php b/common/models/Ticket.php
index 19a8f0c..1b742d6 100644
--- a/common/models/Ticket.php
+++ b/common/models/Ticket.php
@@ -32,6 +32,8 @@ use common\components\Helper;
* @property string $created_at
* @property string $updated_at
* @property int id_contract
+ * @property integer $original_price
+ * @property string $original_end;
*
* @property \common\models\Card card
*/
@@ -73,8 +75,25 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
,c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
, c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end
WHERE c1.type <> 50 and c1.id_card = :id";
-
-
+
+
+
+ public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){
+ return "
+ UPDATE card c
+ LEFT JOIN ticket t on c.id_ticket_current = t.id_ticket
+ LEFT JOIN ticket_type tt on t.id_ticket_type = tt.id_ticket_type
+ set
+ c.flag = case when tt.door_allowed <> 1 then ( c.flag | 1 << 4 ) else ( c.flag & ~(1 << 4) ) end
+ WHERE c.type <> 50
+ ";
+ }
+
+ public static function SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(){
+ return Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() . " and c.id_card = :id";
+ }
+
+
/**
* @inheritdoc
*/
@@ -124,6 +143,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
'id_card' => Yii::t('backend/ticket','Card'),
'id_customer' => Yii::t('backend/ticket','Customer'),
'payment_method' => Yii::t('common/transfer', 'Fizetési mód'),
+ 'original_price' => Yii::t('common/transfer', 'Eredeti ár'),
+ 'original_end' => Yii::t('common/transfer', 'Eredeti érvényesség vége'),
];
}
@@ -135,6 +156,10 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
public function getContract(){
return $this->hasOne( Contract::className(), ["id_contract" =>"id_contract" ] );
}
+
+ public function getTransfer(){
+ return $this->hasOne( Transfer::className(), ["id_object" =>"id_ticket"] )->andWhere(['transfer.type' => Transfer::TYPE_TICKET]);
+ }
public function getCardNumber(){
$result = "";
@@ -395,6 +420,4 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
Card::updateCardFlagTicket($this->id_card);;
}
-
-
}
diff --git a/common/models/TicketType.php b/common/models/TicketType.php
index 2a03a4c..a424676 100644
--- a/common/models/TicketType.php
+++ b/common/models/TicketType.php
@@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
* @property integer installment_enabled
* @property integer installment_count
* @property integer installment_money
+ * @property integer door_allowed
* @property string $created_at
* @property string $updated_at
*/
@@ -38,6 +39,9 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
const INSTALLMENT_OFF = 0;
const INSTALLMENT_ON = 1;
+
+ const FLAG_DOOR_ALLOWED_OFF = 0;
+ const FLAG_DOOR_ALLOWED_ON = 1;
/**
* @inheritdoc
@@ -104,6 +108,13 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
[['installment_money',], 'integer'],
[['installment_count',], 'integer'],
+
+ ////////////////
+ //door_allowed
+ ////////////////
+ [['door_allowed',], 'integer'],
+ [['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
+
];
}
@@ -128,6 +139,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
'installment_enabled' => Yii::t('common/ticket_type', 'Részlet fizetés a brutto áron felül'),
'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'),
'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'),
+ 'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'),
];
}
@@ -188,6 +200,11 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
public function isStudent(){
return $this->flag_student == ( self::FLAG_STUDENT_ON);
}
+
+ public function isDoor(){
+ return $this->door_allowed == ( self::FLAG_STUDENT_ON);
+ }
+
public function isInstallment(){
return $this->installment_enabled == ( self::INSTALLMENT_ON);
}
diff --git a/common/models/Transfer.php b/common/models/Transfer.php
index 86c5351..f3548e1 100644
--- a/common/models/Transfer.php
+++ b/common/models/Transfer.php
@@ -197,6 +197,13 @@ class Transfer extends \common\models\BaseFitnessActiveRecord {
"id_transfer" => "id_transfer"
] );
}
+
+ public function getCustomer(){
+ return $this->hasOne ( Customer::className (), [
+ "id_customer" => "id_customer"
+ ] );
+ }
+
public function getSale() {
return $this->hasOne ( Sale::className (), [
"id_sale" => "id_object"
diff --git a/console/controllers/TicketController.php b/console/controllers/TicketController.php
index cfe81ec..dc60595 100644
--- a/console/controllers/TicketController.php
+++ b/console/controllers/TicketController.php
@@ -40,6 +40,18 @@ class TicketController extends Controller {
$result = $command->execute ();
\Yii::info ( "Clearing key status updated: ". $result );
}
+
+ if ( Helper::isTicketTypeDoorAllowedCheckOn()){
+ \Yii::info ( "updating door allowed flag" );
+ $command = $connection->createCommand ( Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() );
+ $result = $command->execute ();
+ \Yii::info ( "Door allowed flag updated: ". $result );
+ }else{
+ \Yii::info ( "clearing door allowed flag" );
+ $command = $connection->createCommand ( Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() );
+ $result = $command->execute ();
+ \Yii::info ( "Door allowed flag cleared: ". $result );
+ }
}
/**
diff --git a/console/migrations/m170612_054003_add_ticket_type_door_alowed.php b/console/migrations/m170612_054003_add_ticket_type_door_alowed.php
new file mode 100644
index 0000000..bcfa275
--- /dev/null
+++ b/console/migrations/m170612_054003_add_ticket_type_door_alowed.php
@@ -0,0 +1,30 @@
+.addColumn("ticket_type", "door_allowed", "int default 0");
+ }
+
+ public function down()
+ {
+ echo "m170612_054003_add_ticket_type_door_alowed cannot be reverted.\n";
+
+ return false;
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/console/migrations/m170902_211224_add_column_original_expiration_date_and_price.php b/console/migrations/m170902_211224_add_column_original_expiration_date_and_price.php
new file mode 100644
index 0000000..9818203
--- /dev/null
+++ b/console/migrations/m170902_211224_add_column_original_expiration_date_and_price.php
@@ -0,0 +1,29 @@
+addColumn("ticket", "original_end","datetime DEFAULT NULL");
+ }
+
+ public function down()
+ {
+ echo "m170902_211224_add_column_original_expiration_date_and_price cannot be reverted.\n";
+
+ }
+
+ /*
+ // Use safeUp/safeDown to run migration code within a transaction
+ public function safeUp()
+ {
+ }
+
+ public function safeDown()
+ {
+ }
+ */
+}
diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php
index 9d79307..d08e277 100644
--- a/frontend/models/ReceptionForm.php
+++ b/frontend/models/ReceptionForm.php
@@ -19,6 +19,8 @@ use common\models\DoorLog;
/**
* ContactForm is the model behind the contact form.
+ *
+ * @property \common\models\Card $card
*/
class ReceptionForm extends Model
{
diff --git a/frontend/models/TicketCreate.php b/frontend/models/TicketCreate.php
index aa7f754..a588ae7 100644
--- a/frontend/models/TicketCreate.php
+++ b/frontend/models/TicketCreate.php
@@ -1,6 +1,7 @@
part_count = 0;
}
+
+ if ( isset($ticketType )){
+ $this->original_price = $ticketType->price_brutto;
+ $start = DateUtil::parseDate($this->start);
+ $original_end = Helper::getTicketExpirationDate($start,$ticketType);
+ $this->original_end = DateUtil::formatDateUtc($original_end);
+ }
}
}
return $result;
diff --git a/frontend/views/card/info.php b/frontend/views/card/info.php
index 94b39ef..edc2ead 100644
--- a/frontend/views/card/info.php
+++ b/frontend/views/card/info.php
@@ -48,6 +48,19 @@ $this->params['breadcrumbs'][] = $this->title;
echo Html::tag("span", "Kártya nincs tiltva - OK", ['class' => 'text-success']);
} ?>
+
+ Bérlet beléphet a forgókapun:
+ isFlagDoorAllowed()) {
+ echo Html::tag("span", "Beléphet - Nem", ['class' => 'text-danger']);
+ } else {
+ echo Html::tag("span", "Beléphet - Igen", ['class' => 'text-success']);
+ } ?>
+
+
Kilépés jelző
diff --git a/frontend/views/common/_reception_ticket.php b/frontend/views/common/_reception_ticket.php
index d60a594..70fd006 100644
--- a/frontend/views/common/_reception_ticket.php
+++ b/frontend/views/common/_reception_ticket.php
@@ -1,13 +1,8 @@
card)){
echo " - ";
echo Yii::$app->formatter->asDate($ticket->end);
echo Html::endTag("div");
+
+
}else{
echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
@@ -72,6 +69,19 @@ if ( isset($model->card)){
echo Html::endTag("div");
}
+if (Helper::isTicketTypeDoorAllowedCheckOn()) {
+ if (isset($model->card) && isset($ticket) ) {
+ $alert = "alert " . ($model->card->isFlagDoorAllowed() ? "alert-warning" : "alert-success");
+ $text = "Kapun beléphet: " .($model->card->isFlagDoorAllowed() ? "nem" : "igen");
+
+ echo Html::beginTag("div",['class' => $alert ,"role"=>"alert"]);
+ echo Html::beginTag("strong",[ ]);
+ echo $text;
+ echo Html::endTag("strong");
+ echo Html::endTag("div");
+
+ }
+}
if ( isset($model->contract)){
/** @var common\models\Contract $contract*/
diff --git a/frontend/views/site/about.php b/frontend/views/site/about.php
index 8eb0764..7b840af 100644
--- a/frontend/views/site/about.php
+++ b/frontend/views/site/about.php
@@ -13,4 +13,37 @@ $this->params['breadcrumbs'][] = $this->title;
This is the About page. You may modify the following file to customize its content:
= __FILE__ ?>
+
+
+ setTimezone(new DateTimeZone('UTC'));
+
+ $dt->sub( new DateInterval( 'P2D') );
+
+
+ echo \common\components\DateUtil::formatUtc($dt);
+
+ echo " - ";
+
+ $ticketType = new \common\models\TicketType();
+ $ticketType->time_unit_type = \common\models\TicketType::TIME_UNIT_DAY;
+ $ticketType->time_unit_count = 3;
+
+ $dt2 = \common\components\Helper::getTicketExpirationDate($dt, $ticketType);
+ echo \common\components\DateUtil::formatUtc($dt2);
+
+// $dt2 = \common\components\Helper::getTicketExpirationDate($dt, $ticketType);
+// echo \common\components\DateUtil::formatUtc($dt2);
+
+
+ // $dt = \common\components\DateUtil::addMonth($dt,1);
+ // echo \common\components\DateUtil::formatUtc($dt);
+ // $dt = \common\components\DateUtil::addMonth($dt,1);
+ // echo \common\components\DateUtil::formatUtc($dt);
+
+ ?>
+