Finish version/v.0.0.54

This commit is contained in:
Roland Schneider 2016-03-20 15:44:04 +01:00
commit 44185047f3
31 changed files with 1089 additions and 19 deletions

View File

@ -80,6 +80,7 @@ class AdminMenuStructure{
$items[] = ['label' => 'Statisztika', 'url' => ['/ticket/statistics' , 'TicketSearchStatisitcs[start]' =>$today,'TicketSearchStatisitcs[end]' => $tomorrow ] ]; $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 létrehozás', 'url' => ['/card-package/index' , ] ];
$items[] = ['label' => 'Kártya csomag RFId hozzárendelés', 'url' => ['/card-package/import' , ] ]; $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, $this->menuItems[] = ['label' => 'Bérletek/Vendégek', 'url' => $this->emptyUrl,
'items' => $items 'items' => $items
]; ];
@ -133,6 +134,7 @@ class AdminMenuStructure{
///////////////////////////// /////////////////////////////
$items = []; $items = [];
$items[] = ['label' => 'Kártya események', 'url' => ['/door-log/index' , 'DoorLogSearch[start]' =>$todayDatetime,'DoorLogSearch[end]' => $tomorrowDatetime ] ]; $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' => 'Részletek aktiválása', 'url' => ['/ugiro/parts' ] ];
// $items[] = ['label' => 'Bevétel', 'url' => ['/transfer/summary' , 'TransferSummarySearch[start]' =>$today,'TransferSummarySearch[end]' => $tomorrow ] ]; // $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 ] ]; // $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

@ -9,6 +9,7 @@ use yii\filters\VerbFilter;
use backend\models\UploadForm; use backend\models\UploadForm;
use common\components\Helper; use common\components\Helper;
use common\models\User; use common\models\User;
use common\models\Log;
/** /**
* Site controller * Site controller
@ -74,6 +75,16 @@ class SiteController extends Controller
]; ];
if ($model->load(Yii::$app->request->post()) && $model->login()) { if ($model->load(Yii::$app->request->post()) && $model->login()) {
$geoip = Helper::getGeoIp();
$user = User::findOne(\Yii::$app->user->id);
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
Log::log([
'type' =>Log::$TYPE_LOGIN,
'message' => $message
]);
$this->sendLoginMail(); $this->sendLoginMail();
return $this->goBack(); return $this->goBack();

View File

@ -142,11 +142,7 @@ class GiroKotegForm extends Model{
public static function transliterate($string) public static function transliterate($string)
{ {
// if (static::hasIntl()) {
// return transliterator_transliterate(BaseInflector::$transliterator, $string);
// } else {
return str_replace(array_keys(BaseInflector::$transliteration), BaseInflector::$transliteration, $string); return str_replace(array_keys(BaseInflector::$transliteration), BaseInflector::$transliteration, $string);
// }
} }
/** /**

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>

View File

@ -1,3 +1,7 @@
-0.0.54
- add ticket usage count increment trigger
- add log
- fix card flag update query
-0.0.53 -0.0.53
- inventory changes - inventory changes
- add id_ticket_current to card and ticket table - add id_ticket_current to card and ticket table

View File

@ -363,7 +363,11 @@ class Helper {
public static function mkYiiSortItems($config){ public static function mkYiiSortItems($config){
$result = []; $result = [];
foreach ($config as $col ){ 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; return $result;
} }

View File

@ -24,7 +24,7 @@ class GiroBase {
$data = substr($data, 0, $hossz ); $data = substr($data, 0, $hossz );
} }
$data = str_pad($data, $hossz, $pad_string, STR_PAD_RIGHT); $data = str_pad($data, $hossz, $pad_string, STR_PAD_RIGHT);
echo $data; //echo $data;
// echo strlen($data); // echo strlen($data);
return $data; return $data;
} }

View File

@ -71,7 +71,7 @@ class GiroBeszed extends GiroBase {
$tetel->szamlaTulajdonosNeve = $customer->name; $tetel->szamlaTulajdonosNeve = $customer->name;
$tetel->kozlemeny = "Fitness berlet. Megbizas azon: " . $request->id_ticket_installment_request; $tetel->kozlemeny = "Fitness berlet. Megbizas azon: " . $request->id_ticket_installment_request;
return $tetel->toString(); return $tetel->toString();
} }
public static function createLab($requests) { public static function createLab($requests) {

View File

@ -2,6 +2,7 @@
namespace common\components\giro; namespace common\components\giro;
use common\components\giro\GiroBase; use common\components\giro\GiroBase;
use yii\helpers\VarDumper;
/** /**
* @property common\components\giro\GiroUzenetsorszam $uzenetSorszam * @property common\components\giro\GiroUzenetsorszam $uzenetSorszam
* @property common\components\giro\GiroBankszamla $kotelezettBankszamla * @property common\components\giro\GiroBankszamla $kotelezettBankszamla

View File

@ -4,7 +4,7 @@ return [
'supportEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu', 'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.0.53', 'version' => 'v0.0.54',
'company' => 'movar',//gyor 'company' => 'movar',//gyor
'company_name' => "Freimann Kft.", 'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global 'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@ -3,6 +3,7 @@
namespace common\models; namespace common\models;
use Yii; use Yii;
use common\models\BaseFitnessActiveRecord;
/** /**
* This is the model class for table "customer". * This is the model class for table "customer".
@ -29,7 +30,7 @@ use Yii;
* @property string $created_at * @property string $created_at
* @property string $updated_at * @property string $updated_at
*/ */
class Customer extends \yii\db\ActiveRecord class Customer extends BaseFitnessActiveRecord
{ {
const STATUS_DELETED = 0; const STATUS_DELETED = 0;
@ -49,6 +50,7 @@ class Customer extends \yii\db\ActiveRecord
{ {
return 'customer'; return 'customer';
} }
/** /**
* @inheritdoc * @inheritdoc
@ -184,6 +186,12 @@ class Customer extends \yii\db\ActiveRecord
} }
public function afterSave($insert, $changedAttributes){
if ( !$insert ){
Card::updateCardFlagTicket($this->id_customer_card);
}
}
} }

View File

@ -138,6 +138,9 @@ class DoorLog extends \yii\db\ActiveRecord
17 => "Bérlet érvényességi időn kívüli KI olvastatás (nem enged)", 17 => "Bérlet érvényességi időn kívüli KI olvastatás (nem enged)",
19 => "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)", 19 => "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)",
128 => "Vésznyitás",
256 => "Kártya tiltva -> információ mező",
]; ];
} }

101
common/models/Log.php Normal file
View File

@ -0,0 +1,101 @@
<?php
namespace common\models;
use Yii;
use yii\helpers\Url;
use yii\helpers\VarDumper;
use common\models\BaseFitnessActiveRecord;
/**
* This is the model class for table "log".
*
* @property integer $id_log
* @property integer $type
* @property string $message
* @property string $url
* @property string $app
* @property integer $id_user
* @property integer $id_transfer
* @property integer $id_money_movement
* @property integer $id_ticket
* @property integer $id_sale
* @property integer $id_customer
* @property integer $id_account
* @property integer $id_account_state
* @property integer $id_key
* @property integer $id_product
* @property integer $id_door_log
* @property string $created_at
* @property string $updated_at
*/
class Log extends BaseFitnessActiveRecord
{
public static $TYPE_INFO = 10;
public static $TYPE_ERR = 20;
public static $TYPE_TICKET_USAGE_FIRST = 30;
public static $TYPE_TICKET_USAGE_MULTIPLE = 40;
public static $TYPE_LOGIN = 50;
public static $TYPE_DEFAULT_ACCOUNT= 60;
public static $TYPE_CREATE_CUSTOMER= 70;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'log';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'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', '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', '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'
];
}
public static function info($message ){
self::log(['type' =>self::$TYPE_INFO, 'message' => $message]);
}
public static function log( $config ){
\Yii::info( "Log :" . VarDumper::dump( $config) ) ;
$model = new Log($config);
$model->app = \Yii::$app->name;
$model->url = Url::canonical();
$model->id_user = \Yii::$app->user->id;
$model->save();
}
}

View File

@ -37,18 +37,35 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
const STATUS_INACTIVE = 20; const STATUS_INACTIVE = 20;
public static $SQL_UPDATE = "UPDATE card as c1 public static $SQL_UPDATE = "UPDATE card as c1
left JOIN ( select distinct ticket.id_card as id_card from ticket left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t from ticket
on t.id_card = c1.id_card where ticket.start <= CURDATE()
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end and ticket.end >= curdate()
WHERE c1.type <> 50"; and ticket.status = 10
and ticket.usage_count < ticket.max_usage_count
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 public static $SQL_UPDATE_CARD = "UPDATE card as c1
left JOIN ( select distinct ticket.id_card as id_card from ticket left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t from ticket
on t.id_card = c1.id_card where ticket.start <= CURDATE()
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end and ticket.end >= curdate()
WHERE c1.type <> 50 and c1.id_card = :id"; and ticket.status = 10
and ticket.usage_count < ticket.max_usage_count
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
WHERE c1.type <> 50 and c1.id_card = :id";
/** /**

View File

@ -0,0 +1,75 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m160316_063618_create__table__log extends Migration
{
public function up()
{
/*
* log
id_log
type
message
url
app
id_user
id_transfer
id_money_movement
id_ticket
id_sale
id_customer
id_card
id_account
id_account_state
id_key
id_product
id_door_log
* */
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable( '{{%log}}', [
'id_log' => $this->primaryKey(),
'type' => $this->integer(11),
'message' => $this->string(),
'url' => $this->text(),
'app' => $this->string(50),
'id_user' => $this->integer(11),
'id_transfer' => $this->integer(11),
'id_money_movement' => $this->integer(11),
'id_ticket' => $this->integer(11),
'id_sale' => $this->integer(11),
'id_customer' => $this->integer(11),
'id_account' => $this->integer(11),
'id_account_state' => $this->integer(11),
'id_key' => $this->integer(11),
'id_product' => $this->integer(11),
'id_door_log' => $this->integer(11),
'created_at' => $this->dateTime()->notNull(),
'updated_at' => $this->dateTime()->notNull(),
], $tableOptions );
}
public function down()
{
$this->dropTable("{{%log}}");
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -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()
{
}
*/
}

View 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()
{
}
*/
}

View File

@ -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()
{
}
*/
}

View File

@ -10,6 +10,8 @@ use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\base\Object; use yii\base\Object;
use common\models\Log;
use common\models\User;
/** /**
* AccountController implements the CRUD actions for Account model. * AccountController implements the CRUD actions for Account model.
@ -43,6 +45,12 @@ class AccountController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) { if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default account is set!') ); Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default account is set!') );
$user = User::findOne(\Yii::$app->user->id);
Log::log([ 'type' => Log::$TYPE_DEFAULT_ACCOUNT,
'message' => "Alapértelmezett kassza - Felhasználó: " . $user->username . " - Kassza: " . Account::readDefaultObject()->name,
'id_account' => Account::readDefault(),
]);
return $this->redirect(['product/sale']); return $this->redirect(['product/sale']);
} }
return $this->render('select', [ return $this->render('select', [

View File

@ -16,6 +16,7 @@ use frontend\models\CustomerCreate;
use common\models\Image; use common\models\Image;
use frontend\models\ContractForm; use frontend\models\ContractForm;
use yii\base\Exception; use yii\base\Exception;
use common\models\Log;
/** /**
* CustomerController implements the CRUD actions for Customer model. * CustomerController implements the CRUD actions for Customer model.
@ -127,6 +128,13 @@ class CustomerController extends Controller
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
$this->saveBinaryImage($model); $this->saveBinaryImage($model);
\Yii::$app->session->setFlash( 'success','Vendég létrehozva!' ); \Yii::$app->session->setFlash( 'success','Vendég létrehozva!' );
Log::log([
'type' =>Log::$TYPE_CREATE_CUSTOMER,
'message' => 'Új vendég:' .$model->name,
'id_customer' => $model->id_customer
]);
return $this->redirect(['update', 'number' => $model->cardNumber]); return $this->redirect(['update', 'number' => $model->cardNumber]);
} else { } else {
return $this->render('create', [ return $this->render('create', [

View File

@ -14,6 +14,7 @@ use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use common\models\User; use common\models\User;
use common\components\Helper; use common\components\Helper;
use common\models\Log;
/** /**
* Site controller * Site controller
@ -90,6 +91,17 @@ class SiteController extends Controller
$model = new LoginForm(); $model = new LoginForm();
if ($model->load(Yii::$app->request->post()) && $model->login()) { if ($model->load(Yii::$app->request->post()) && $model->login()) {
$geoip = Helper::getGeoIp();
$user = User::findOne(\Yii::$app->user->id);
$message = "Bejelentkezés: " .$user->username. " Ip cím:". $geoip->ip . " Város: " . $geoip->city;
Log::log([
'type' =>Log::$TYPE_LOGIN,
'message' => $message
]);
$this->sendLoginIp(); $this->sendLoginIp();
// return $this->goBack(); // return $this->goBack();

View File

@ -90,6 +90,12 @@ class ContractForm extends Model {
'string', 'string',
'max' => 24 'max' => 24
], ],
[
[
'bank_account'
],
'validateBankAccount',
],
[ [
[ [
'bank_name' 'bank_name'
@ -132,6 +138,18 @@ class ContractForm extends Model {
[[ 'started_at', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ], [[ 'started_at', ], 'date', 'format' =>Yii::$app->formatter->dateFormat , 'timestampAttribute' => 'timestampStart' ,'timestampAttributeFormat' => 'yyyy-MM-dd' ,'timeZone' => 'UTC' ],
]; ];
} }
public function validateBankAccount($attribute, $params) {
if ( !is_numeric($this->bank_account)){
$this->addError( $attribute, "A bankszámlaszám csak számokat tartalmazhat!");
}else{
if ( !( strlen($this->bank_account) == 16 || strlen($this->bank_account) == 24 ) ){
$this->addError($attribute,"Bankszámlaszám 16 vagy 24 hosszú!");
}
}
}
public function validateTicketType($attribute, $params) { public function validateTicketType($attribute, $params) {
$this->ticketType = TicketType::findOne ( $this->ticket_type ); $this->ticketType = TicketType::findOne ( $this->ticket_type );
if (! isset ( $this->ticketType )) { if (! isset ( $this->ticketType )) {

View File

@ -164,6 +164,9 @@ class CustomerUpdate extends \common\models\Customer
if ( isset($this->replacementCard)){ if ( isset($this->replacementCard)){
Ticket::updateAll( ['id_card' => $this->replacementCard->id_card ], ['id_card' => $this->originalCard->id_card] ); Ticket::updateAll( ['id_card' => $this->replacementCard->id_card ], ['id_card' => $this->originalCard->id_card] );
} }
if ( !$insert ){
Card::updateCardFlagTicket($this->id_customer_card);
}
} }

View File

@ -9,6 +9,7 @@ use kartik\widgets\DatePicker;
use common\models\Transfer; use common\models\Transfer;
use common\models\Discount; use common\models\Discount;
use frontend\assets\ContractMakeAsset; use frontend\assets\ContractMakeAsset;
use yii\helpers\VarDumper;
/* @var $this yii\web\View */ /* @var $this yii\web\View */
/* @var $model common\models\Contract */ /* @var $model common\models\Contract */
@ -38,6 +39,7 @@ use frontend\assets\ContractMakeAsset;
$this->registerJs(' contract_make.init( '. json_encode($options) .' );'); $this->registerJs(' contract_make.init( '. json_encode($options) .' );');
?> ?>
<h1>Szerződés létrehozása</h1> <h1>Szerződés létrehozása</h1>
<div class="contract-form"> <div class="contract-form">