add ticket usage count increment trigger, add log, fix card flag update query, fix customer card move update
This commit is contained in:
parent
1d5a5be5bf
commit
7db129de92
@ -80,6 +80,7 @@ class AdminMenuStructure{
|
||||
$items[] = ['label' => 'Statisztika', 'url' => ['/ticket/statistics' , 'TicketSearchStatisitcs[start]' =>$today,'TicketSearchStatisitcs[end]' => $tomorrow ] ];
|
||||
$items[] = ['label' => 'Kártya létrehozás', 'url' => ['/card-package/index' , ] ];
|
||||
$items[] = ['label' => 'Kártya csomag RFId hozzárendelés', 'url' => ['/card-package/import' , ] ];
|
||||
$items[] = ['label' => 'Érvényességek újraszámolása', 'url' => ['/card/recalculate' , ] ];
|
||||
$this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl,
|
||||
'items' => $items
|
||||
];
|
||||
@ -133,6 +134,7 @@ class AdminMenuStructure{
|
||||
/////////////////////////////
|
||||
$items = [];
|
||||
$items[] = ['label' => 'Kártya események', 'url' => ['/door-log/index' , 'DoorLogSearch[start]' =>$todayDatetime,'DoorLogSearch[end]' => $tomorrowDatetime ] ];
|
||||
$items[] = ['label' => 'Esemény napló', 'url' => ['/log/index' , 'LogSearch[start]' =>$todayDatetime,'LogSearch[end]' => $tomorrowDatetime ] ];
|
||||
// $items[] = ['label' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
|
||||
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ];
|
||||
// $items[] = ['label' => 'Napi bevételek', 'url' => ['/transfer/list', 'TransferListSearch[start]' =>$todayDatetime,'TransferListSearch[end]' => $tomorrowDatetime ] ];
|
||||
|
||||
127
backend/controllers/LogController.php
Normal file
127
backend/controllers/LogController.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\Log;
|
||||
use backend\models\LogSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* LogController implements the CRUD actions for Log model.
|
||||
*/
|
||||
class LogController extends \backend\controllers\BackendController
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'actions' => [ 'index' ],
|
||||
'allow' => true,
|
||||
'roles' => ['admin','employee','reception'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Log models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new LogSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Log model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Log model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Log();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_log]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Log model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_log]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Log model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Log model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Log the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Log::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
122
backend/models/LogSearch.php
Normal file
122
backend/models/LogSearch.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Log;
|
||||
use yii\db\Query;
|
||||
use common\components\Helper;
|
||||
|
||||
/**
|
||||
* LogSearch represents the model behind the search form about `common\models\Log`.
|
||||
*/
|
||||
class LogSearch extends Log
|
||||
{
|
||||
|
||||
public $start;
|
||||
public $end;
|
||||
public $timestampStart;
|
||||
public $timestampEnd;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_log', 'type', 'id_user', 'id_transfer', 'id_money_movement', 'id_ticket', 'id_sale', 'id_customer', 'id_account', 'id_account_state', 'id_key', 'id_product', 'id_door_log'], 'integer'],
|
||||
[['message', 'url', 'app', 'created_at', 'updated_at'], 'safe'],
|
||||
[[ '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' ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = new Query();
|
||||
$query->select([
|
||||
'log.id_log as log_id_log',
|
||||
'log.created_at as log_created_at',
|
||||
'log.message as log_message',
|
||||
'log.app as log_app',
|
||||
'log.type as log_type',
|
||||
'user.username as user_username',
|
||||
'customer.name as customer_name',
|
||||
|
||||
]);
|
||||
$query->from("log");
|
||||
$query->leftJoin("user"," user.id = log.id_user");
|
||||
$query->leftJoin("customer"," customer.id_customer = log.id_customer");
|
||||
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' =>[
|
||||
'defaultOrder' => [ 'log_created_at' => SORT_DESC],
|
||||
'attributes' => Helper::mkYiiSortItems([
|
||||
['log_id_log'],
|
||||
['log_created_at'],
|
||||
['log_message'],
|
||||
['log_app'],
|
||||
['log_app'],
|
||||
['user_username'],
|
||||
['customer_name'],
|
||||
|
||||
])
|
||||
|
||||
]
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere(['>=', 'log.created_at', $this->timestampStart]);
|
||||
$query->andFilterWhere(['<', 'log.created_at', $this->timestampEnd]);
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_log' => $this->id_log,
|
||||
'type' => $this->type,
|
||||
'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,
|
||||
'id_account' => $this->id_account,
|
||||
'id_account_state' => $this->id_account_state,
|
||||
'id_key' => $this->id_key,
|
||||
'id_product' => $this->id_product,
|
||||
'id_door_log' => $this->id_door_log,
|
||||
'created_at' => $this->created_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'message', $this->message])
|
||||
->andFilterWhere(['like', 'url', $this->url])
|
||||
->andFilterWhere(['like', 'app', $this->app]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
57
backend/views/log/_form.php
Normal file
57
backend/views/log/_form.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Log */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="log-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'id_log')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'type')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'message')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'url')->textarea(['rows' => 6]) ?>
|
||||
|
||||
<?= $form->field($model, 'app')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'id_user')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_transfer')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_money_movement')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_ticket')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_sale')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_customer')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_account')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_account_state')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_key')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_product')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'id_door_log')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at')->textInput() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/log', 'Create') : Yii::t('common/log', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
50
backend/views/log/_search.php
Normal file
50
backend/views/log/_search.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use kartik\widgets\DateTimePicker;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\LogSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="log-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
|
||||
<?= $form->field($model, 'start')->widget(DateTimePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd hh:ii'
|
||||
]
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<?= $form->field($model, 'end') ->widget(DateTimePicker::classname(), [
|
||||
'pluginOptions' => [
|
||||
'autoclose'=>true,
|
||||
'format' => 'yyyy.mm.dd hh:ii'
|
||||
]
|
||||
]) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('common/log', 'Keresés'), ['class' => 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
21
backend/views/log/create.php
Normal file
21
backend/views/log/create.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Log */
|
||||
|
||||
$this->title = Yii::t('common/log', 'Create Log');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/log', 'Logs'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="log-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
60
backend/views/log/index.php
Normal file
60
backend/views/log/index.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\LogSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('common/log', 'Logok');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="log-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
|
||||
[
|
||||
'attribute' => "log_id_log",
|
||||
'label' => "Log azonosító",
|
||||
],
|
||||
[
|
||||
'attribute' => "log_created_at",
|
||||
'label' => "Dátum idő",
|
||||
],
|
||||
[
|
||||
'attribute' => "log_message",
|
||||
'label' => "Üzenet",
|
||||
],
|
||||
[
|
||||
'attribute' => "log_app",
|
||||
'label' => "Alkalmazás",
|
||||
],
|
||||
[
|
||||
'attribute' => "user_username",
|
||||
'label' => "Felhasználó",
|
||||
],
|
||||
// 'id_user',
|
||||
// 'id_transfer',
|
||||
// 'id_money_movement',
|
||||
// 'id_ticket',
|
||||
// 'id_sale',
|
||||
// 'id_customer',
|
||||
// 'id_account',
|
||||
// 'id_account_state',
|
||||
// 'id_key',
|
||||
// 'id_product',
|
||||
// 'id_door_log',
|
||||
// 'updated_at',
|
||||
|
||||
// ['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
23
backend/views/log/update.php
Normal file
23
backend/views/log/update.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Log */
|
||||
|
||||
$this->title = Yii::t('common/log', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Log',
|
||||
]) . ' ' . $model->id_log;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/log', 'Logs'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id_log, 'url' => ['view', 'id' => $model->id_log]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/log', 'Update');
|
||||
?>
|
||||
<div class="log-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
52
backend/views/log/view.php
Normal file
52
backend/views/log/view.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Log */
|
||||
|
||||
$this->title = $model->id_log;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/log', 'Logs'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="log-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= 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',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_log',
|
||||
'type',
|
||||
'message',
|
||||
'url:ntext',
|
||||
'app',
|
||||
'id_user',
|
||||
'id_transfer',
|
||||
'id_money_movement',
|
||||
'id_ticket',
|
||||
'id_sale',
|
||||
'id_customer',
|
||||
'id_account',
|
||||
'id_account_state',
|
||||
'id_key',
|
||||
'id_product',
|
||||
'id_door_log',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
@ -1,3 +1,7 @@
|
||||
-0.0.54
|
||||
- add ticket usage count increment trigger
|
||||
- add log
|
||||
- fix card flag update query
|
||||
-0.0.53
|
||||
- inventory changes
|
||||
- add id_ticket_current to card and ticket table
|
||||
|
||||
@ -363,7 +363,11 @@ class Helper {
|
||||
public static function mkYiiSortItems($config){
|
||||
$result = [];
|
||||
foreach ($config as $col ){
|
||||
$result = $result + Helper::mkYiiSortItem($col[0] ,$col[1]);
|
||||
if ( count($col) == 1){
|
||||
$result = $result + Helper::mkYiiSortItem($col[0] ,$col[0]);
|
||||
}else{
|
||||
$result = $result + Helper::mkYiiSortItem($col[0] ,$col[1]);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'supportEmail' => 'rocho02@gmail.com',
|
||||
'infoEmail' => 'info@rocho-net.hu',
|
||||
'user.passwordResetTokenExpire' => 3600,
|
||||
'version' => 'v0.0.53',
|
||||
'version' => 'v0.0.54',
|
||||
'company' => 'movar',//gyor
|
||||
'company_name' => "Freimann Kft.",
|
||||
'product_visiblity' => 'account',// on reception which products to display. account or global
|
||||
|
||||
@ -62,24 +62,26 @@ class Log extends BaseFitnessActiveRecord
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_log' => Yii::t('common/log', 'Id Log'),
|
||||
'type' => Yii::t('common/log', 'Type'),
|
||||
'message' => Yii::t('common/log', 'Message'),
|
||||
'id_log' => Yii::t('common/log', 'Azonosító'),
|
||||
'type' => Yii::t('common/log', 'Típus'),
|
||||
'message' => Yii::t('common/log', 'Üzenet'),
|
||||
'url' => Yii::t('common/log', 'Url'),
|
||||
'app' => Yii::t('common/log', 'App'),
|
||||
'id_user' => Yii::t('common/log', 'Id User'),
|
||||
'id_transfer' => Yii::t('common/log', 'Id Transfer'),
|
||||
'id_money_movement' => Yii::t('common/log', 'Id Money Movement'),
|
||||
'id_ticket' => Yii::t('common/log', 'Id Ticket'),
|
||||
'id_sale' => Yii::t('common/log', 'Id Sale'),
|
||||
'id_customer' => Yii::t('common/log', 'Id Customer'),
|
||||
'id_account' => Yii::t('common/log', 'Id Account'),
|
||||
'app' => Yii::t('common/log', 'Alkalmazás'),
|
||||
'id_user' => Yii::t('common/log', 'Felhasználó'),
|
||||
'id_transfer' => Yii::t('common/log', 'Tranzakció'),
|
||||
'id_money_movement' => Yii::t('common/log', 'Pénzmozgás'),
|
||||
'id_ticket' => Yii::t('common/log', 'Bérlet'),
|
||||
'id_sale' => Yii::t('common/log', 'Termékeladás'),
|
||||
'id_customer' => Yii::t('common/log', 'Vendég'),
|
||||
'id_account' => Yii::t('common/log', 'Kassza'),
|
||||
'id_account_state' => Yii::t('common/log', 'Id Account State'),
|
||||
'id_key' => Yii::t('common/log', 'Id Key'),
|
||||
'id_product' => Yii::t('common/log', 'Id Product'),
|
||||
'id_door_log' => Yii::t('common/log', 'Id Door Log'),
|
||||
'created_at' => Yii::t('common/log', 'Created At'),
|
||||
'updated_at' => Yii::t('common/log', 'Updated At'),
|
||||
'id_key' => Yii::t('common/log', 'Kulcs'),
|
||||
'id_product' => Yii::t('common/log', 'Termék'),
|
||||
'id_door_log' => Yii::t('common/log', 'Kapu log'),
|
||||
'created_at' => Yii::t('common/log', 'Dátum idő'),
|
||||
'updated_at' => Yii::t('common/log', 'Módosítás'),
|
||||
'start' => 'Időszak kezdete',
|
||||
'end' => 'Időszak vége'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -37,22 +37,31 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
const STATUS_INACTIVE = 20;
|
||||
|
||||
public static $SQL_UPDATE = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card ,ticket.id_ticket as id_ticket from ticket
|
||||
left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
|
||||
from ticket
|
||||
where ticket.start <= CURDATE()
|
||||
and ticket.end >= curdate() and ticket.status = 10
|
||||
and ticket.end >= curdate()
|
||||
and ticket.status = 10
|
||||
and ticket.usage_count < ticket.max_usage_count
|
||||
order by id_ticket desc limit 1 ) as t
|
||||
group by id_card
|
||||
order by id_card desc
|
||||
) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET 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";
|
||||
|
||||
public static $SQL_UPDATE_CARD = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card ,ticket.id_ticket as id_ticket from ticket
|
||||
left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
|
||||
from ticket
|
||||
where ticket.start <= CURDATE()
|
||||
and ticket.end >= curdate() and ticket.status = 10
|
||||
and ticket.end >= curdate()
|
||||
and ticket.status = 10
|
||||
and ticket.usage_count < ticket.max_usage_count
|
||||
order by id_ticket desc limit 1 ) as t
|
||||
and ticket.id_card = :id
|
||||
group by id_card
|
||||
order by id_card desc
|
||||
) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET 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
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160318_201703_add__trigger__inc_ticket_usage_count extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->execute("
|
||||
|
||||
DROP TRIGGER IF EXISTS trigger_inc_ticket_usage_count;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trigger_inc_ticket_usage_count
|
||||
AFTER INSERT ON `door_log` FOR EACH ROW
|
||||
begin
|
||||
/*DECLARE p_usage_count Integer;*/
|
||||
DECLARE p_count_all Integer;
|
||||
DECLARE p_count_all_2 Integer;
|
||||
DECLARE p_from DATETIME;
|
||||
DECLARE p_usage_count Integer;
|
||||
DECLARE p_max_usage_count Integer;
|
||||
|
||||
-- delete from devlog;
|
||||
/** van vendég*/
|
||||
IF NEW.id_customer is not null
|
||||
/*van kártya*/
|
||||
and NEW.id_card is not null
|
||||
/**van bérlet*/
|
||||
and NEW.id_ticket_current is not null
|
||||
/**bemozgás volt*/
|
||||
and NEW.direction = 7
|
||||
then
|
||||
insert into devlog ( msg) values('conditions ok');
|
||||
select count(*) into @p_count_all from door_log where created_at >= CURDATE() and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
IF @p_count_all = 1
|
||||
THEN
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = NEW.id_ticket_current;
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
30, concat('Bérlet használat (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
else
|
||||
/**
|
||||
Innentől kezdve biztos, hogy nem ez az első belépés az aktuális napon.
|
||||
Ki kell számolnunk hányadik 3 órás intervallumban vagyunk az első belépéstől számítva.
|
||||
Pl. ha 06:00 kor volt az első belépés, akkor 07: 30 még nem von le újabb használatot,
|
||||
de a 09:00 már igen
|
||||
*/
|
||||
|
||||
select min(created_at) + INTERVAL (3 * FLOOR( ( ( HOUR(TIMEDIFF(min(created_at) , now() )) /3 ) ) ) ) hour as last_date
|
||||
into @p_from
|
||||
from door_log
|
||||
where created_at > CURDATE() and id_customer is not null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
-- select count(*) into @p_count_all_2 from door_log where created_at >= p_from and id_ticket_current ;
|
||||
select count(*) into @p_count_all_2 from door_log where created_at >= @p_from and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
-- insert into devlog ( msg) values(CONCAT( 'ticket count since last period begin: ', @p_count_all_2) );
|
||||
/**
|
||||
Ha az első belépéstől számítot aktuális 3 órás intervallumban ez az elős belépés, akkor növeljük a használatot
|
||||
*/
|
||||
IF @p_count_all_2 = 1
|
||||
THEN
|
||||
-- insert into devlog ( msg) values( 'need to increase usage count multiple intervals ' );
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = New.id_ticket_current;
|
||||
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
40, concat('Bérlet használat/egy nap tobbszori (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
|
||||
END IF; -- end @p_count_all_2 = 1
|
||||
|
||||
END IF;
|
||||
|
||||
/**
|
||||
Van e érvényes bérlet státusz frissítése a bérletkártyán
|
||||
update card.flag and card.id_ticket_current
|
||||
|
||||
*/
|
||||
-- insert into devlog ( msg) values( 'updateing card state' );
|
||||
UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card ,ticket.id_ticket as id_ticket from ticket
|
||||
where ticket.start <= CURDATE()
|
||||
and ticket.end >= curdate() and ticket.status = 10
|
||||
and ticket.usage_count < ticket.max_usage_count
|
||||
order by id_ticket desc limit 1 ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET 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 = New.id_card;
|
||||
|
||||
|
||||
END IF;
|
||||
|
||||
END;
|
||||
$$
|
||||
DELIMITER ;
|
||||
");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160318_201703_add__trigger__inc_ticket_usage_count cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
32
console/migrations/m160319_180510_update_ticket_count.php
Normal file
32
console/migrations/m160319_180510_update_ticket_count.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160319_180510_update_ticket_count extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->execute("update ticket_type set max_usage_count = 10000;");
|
||||
|
||||
$this->execute( "update ticket set max_usage_count = 10000 , usage_count = 0" );
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160319_180510_update_ticket_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,128 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160320_094046_change_auto_inc_ticket_usage_trigger extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$this->execute("
|
||||
DROP TRIGGER IF EXISTS trigger_inc_ticket_usage_count;
|
||||
DELIMITER $$
|
||||
CREATE TRIGGER trigger_inc_ticket_usage_count
|
||||
AFTER INSERT ON `door_log` FOR EACH ROW
|
||||
begin
|
||||
/*DECLARE p_usage_count Integer;*/
|
||||
DECLARE p_count_all Integer;
|
||||
DECLARE p_count_all_2 Integer;
|
||||
DECLARE p_from DATETIME;
|
||||
DECLARE p_usage_count Integer;
|
||||
DECLARE p_max_usage_count Integer;
|
||||
|
||||
-- delete from devlog;
|
||||
/** van vendég*/
|
||||
IF NEW.id_customer is not null
|
||||
/*van kártya*/
|
||||
and NEW.id_card is not null
|
||||
/**van bérlet*/
|
||||
and NEW.id_ticket_current is not null
|
||||
/**bemozgás volt*/
|
||||
and NEW.direction = 7
|
||||
then
|
||||
insert into devlog ( msg) values('conditions ok');
|
||||
select count(*) into @p_count_all from door_log where created_at >= CURDATE() and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
IF @p_count_all = 1
|
||||
THEN
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = NEW.id_ticket_current;
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
30, concat('Bérlet használat (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
else
|
||||
/**
|
||||
Innentől kezdve biztos, hogy nem ez az első belépés az aktuális napon.
|
||||
Ki kell számolnunk hányadik 3 órás intervallumban vagyunk az első belépéstől számítva.
|
||||
Pl. ha 06:00 kor volt az első belépés, akkor 07: 30 még nem von le újabb használatot,
|
||||
de a 09:00 már igen
|
||||
*/
|
||||
|
||||
select min(created_at) + INTERVAL (3 * FLOOR( ( ( HOUR(TIMEDIFF(min(created_at) , now() )) /3 ) ) ) ) hour as last_date
|
||||
into @p_from
|
||||
from door_log
|
||||
where created_at > CURDATE() and id_customer is not null;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
-- select count(*) into @p_count_all_2 from door_log where created_at >= p_from and id_ticket_current ;
|
||||
select count(*) into @p_count_all_2 from door_log where created_at >= @p_from and id_ticket_current = New.id_ticket_current and direction = 7;
|
||||
|
||||
-- insert into devlog ( msg) values(CONCAT( 'ticket count since last period begin: ', @p_count_all_2) );
|
||||
/**
|
||||
Ha az első belépéstől számítot aktuális 3 órás intervallumban ez az elős belépés, akkor növeljük a használatot
|
||||
*/
|
||||
IF @p_count_all_2 = 1
|
||||
THEN
|
||||
-- insert into devlog ( msg) values( 'need to increase usage count multiple intervals ' );
|
||||
select usage_count, max_usage_count into @p_usage_count ,@p_max_usage_count from ticket where id_ticket = NEW.id_ticket_current;
|
||||
update ticket set usage_count = usage_count +1 where id_ticket = New.id_ticket_current;
|
||||
|
||||
insert into log (type,message, app, id_ticket, id_door_log,created_at, updated_at)
|
||||
values(
|
||||
40, concat('Bérlet használat/egy nap tobbszori (elotte: ',@p_usage_count, ' > utana: ' , @p_usage_count +1 , ' max: ', @p_max_usage_count, ')' ), ' trigger_inc_ticket',New.id_ticket_current, New.id_door_log,now(),now());
|
||||
|
||||
END IF; -- end @p_count_all_2 = 1
|
||||
|
||||
END IF;
|
||||
|
||||
/**
|
||||
Van e érvényes bérlet státusz frissítése a bérletkártyán
|
||||
update card.flag and card.id_ticket_current
|
||||
|
||||
*/
|
||||
-- insert into devlog ( msg) values( 'updateing card state' );
|
||||
UPDATE card as c1
|
||||
left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
|
||||
from ticket
|
||||
where ticket.start <= CURDATE()
|
||||
and ticket.end >= curdate()
|
||||
and ticket.status = 10
|
||||
and ticket.usage_count < ticket.max_usage_count
|
||||
and ticket.id_card = New.id_card
|
||||
group by id_card
|
||||
order by id_card desc ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET 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 = New.id_card;
|
||||
|
||||
|
||||
END IF;
|
||||
|
||||
END;
|
||||
$$
|
||||
DELIMITER ;
|
||||
");
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160320_094046_change_auto_inc_ticket_usage_trigger cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -164,6 +164,9 @@ class CustomerUpdate extends \common\models\Customer
|
||||
if ( isset($this->replacementCard)){
|
||||
Ticket::updateAll( ['id_card' => $this->replacementCard->id_card ], ['id_card' => $this->originalCard->id_card] );
|
||||
}
|
||||
if ( !$insert ){
|
||||
Card::updateCardFlagTicket($this->id_customer_card);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user