add log table
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use common\models\BaseFitnessActiveRecord;
|
||||
|
||||
/**
|
||||
* This is the model class for table "customer".
|
||||
@@ -29,7 +30,7 @@ use Yii;
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Customer extends \yii\db\ActiveRecord
|
||||
class Customer extends BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
@@ -49,6 +50,7 @@ class Customer extends \yii\db\ActiveRecord
|
||||
{
|
||||
return 'customer';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
|
||||
@@ -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)",
|
||||
|
||||
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ő",
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
98
common/models/Log.php
Normal file
98
common/models/Log.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\helpers\Url;
|
||||
use yii\helpers\VarDumper;
|
||||
|
||||
/**
|
||||
* 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 \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
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', 'Id Log'),
|
||||
'type' => Yii::t('common/log', 'Type'),
|
||||
'message' => Yii::t('common/log', 'Message'),
|
||||
'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'),
|
||||
'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'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,18 +37,26 @@ 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 from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) 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
|
||||
WHERE c1.type <> 50";
|
||||
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";
|
||||
|
||||
public static $SQL_UPDATE_CARD = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) 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
|
||||
WHERE c1.type <> 50 and c1.id_card = :id";
|
||||
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 = :id";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user