153 lines
3.8 KiB
PHP
153 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use Yii;
|
|
use common\components\Helper;
|
|
|
|
/**
|
|
* This is the model class for table "door_log".
|
|
*
|
|
* @property integer $id_door_log
|
|
* @property integer $id_card
|
|
* @property integer $id_customer
|
|
* @property integer $id_key
|
|
* @property integer $direction
|
|
* @property integer $type
|
|
* @property integer $id_account
|
|
* @property string $created_at
|
|
* @property string $source_app
|
|
*/
|
|
class DoorLog extends \yii\db\ActiveRecord
|
|
{
|
|
|
|
public static $SOURCE_APP_FORGO_VILLA = "forgo_villa";
|
|
public static $SOURCE_APP_FITNESS_ADMIN = "fitness_admin";
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'door_log';
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['id_card', 'id_customer', 'id_key', 'direction', 'type'], 'integer'],
|
|
[['created_at'], 'required'],
|
|
[['created_at'], 'safe']
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'id_door_log' => Yii::t('common/door_log', 'Id Door Log'),
|
|
'id_card' => Yii::t('common/door_log', 'Bérlet kártya'),
|
|
'id_customer' => Yii::t('common/door_log', 'Vendég'),
|
|
'id_key' => Yii::t('common/door_log', 'Kulcs'),
|
|
'direction' => Yii::t('common/door_log', 'Esemény'),
|
|
'type' => Yii::t('common/door_log', 'Típus'),
|
|
'created_at' => Yii::t('common/door_log', 'Időpont'),
|
|
'source_app' => Yii::t('common/door_log', 'Eszköz'),
|
|
];
|
|
}
|
|
|
|
public function getCustomer(){
|
|
return $this->hasOne( Customer::className(), ["id_customer" =>"id_customer" ] );
|
|
}
|
|
|
|
public function getCustomerName(){
|
|
$result = "";
|
|
if (isset($this->customer)){
|
|
$result = $this->customer->name;
|
|
}
|
|
return $result;
|
|
}
|
|
public function getCard(){
|
|
return $this->hasOne( Card::className(), ["id_card" =>"id_card" ] );
|
|
}
|
|
|
|
public function getCardNumber(){
|
|
$result = "";
|
|
if (isset($this->card)){
|
|
$result = $this->card->number;
|
|
}
|
|
return $result;
|
|
}
|
|
public function getKey(){
|
|
return $this->hasOne( Key::className(), ["id_key" =>"id_key" ] );
|
|
}
|
|
|
|
public function getKeyNumber(){
|
|
$result = "";
|
|
if (isset($this->key)){
|
|
$result = $this->key->number;
|
|
}
|
|
return $result;
|
|
}
|
|
public function getDirectionName(){
|
|
$result = "";
|
|
if ( $this->source_app == 'forgo_villa'){
|
|
if (isset($this->direction)){
|
|
$result = Helper::getArrayValue(self::getDirectionTypes() , $this->direction, "-");
|
|
}
|
|
}else{
|
|
$result = "Kézi olvasás";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
|
|
public static function getSourceAppName($source_app){
|
|
$result = "";
|
|
switch ($source_app){
|
|
case self::$SOURCE_APP_FITNESS_ADMIN :
|
|
$result = "Recepciós alkalmazás";
|
|
break;
|
|
case self::$SOURCE_APP_FORGO_VILLA:
|
|
$result = "Forgó villa";
|
|
break;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public static function getDirectionTypes( ){
|
|
return [
|
|
0 => "Kézi olvasás",
|
|
|
|
1 => "KI olvastatás mozgás nélkül",
|
|
|
|
3 => "BE olvastatás mozgás nélkül",
|
|
|
|
5 => "KI mozgás",
|
|
|
|
7 => "BE mozgás",
|
|
|
|
9 => "KI olvastatás, van érvényes öltöző kulcs (nem enged)",
|
|
|
|
11 => "BE olvastatás, nincs érvényes öltöző kulcs (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)",
|
|
];
|
|
}
|
|
|
|
public static function getCardFlagTexts( ){
|
|
return [
|
|
0 => "Kártya ok",
|
|
1 => "Nincs érvényes bérlet",
|
|
|
|
];
|
|
}
|
|
|
|
}
|