add ticket usage count increment trigger, add log, fix card flag update query, fix customer card move update

This commit is contained in:
2016-03-20 15:36:05 +01:00
parent 1d5a5be5bf
commit 7db129de92
18 changed files with 846 additions and 25 deletions

View File

@@ -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 ] ];

View 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.');
}
}
}

View 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;
}
}

View 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>

View 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>

View 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>

View 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>

View 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>

View 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>