door manager
This commit is contained in:
@@ -25,9 +25,25 @@ use yii\helpers\ArrayHelper;
|
||||
*/
|
||||
class DoorLog extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
public static $SOURCE_APP_FORGO_VILLA = "forgo_villa";
|
||||
public static $SOURCE_APP_FITNESS_ADMIN = "fitness_admin";
|
||||
|
||||
public static $SOURCE_APP_FORGO_VILLA = "forgo_villa";
|
||||
public static $SOURCE_APP_FITNESS_ADMIN = "fitness_admin";
|
||||
|
||||
|
||||
public static $DIRECTION_OUT_MANUAL_READ_KEY_ASSIGNED = -2; // "Kézi olvasás/Kulcs ki",
|
||||
public static $DIRECTION_IN_MANUAL_READ_KEY_UNASSIGNED = -1; // "Kézi olvasás/Kulcs vissza",
|
||||
public static $DIRECTION_ALL_MANUAL_READ = 0; // "Kézi olvasás",
|
||||
public static $DIRECTION_OUT_WITHOUT_MOVE = 1; // "KI olvastatás mozgás nélkül",
|
||||
public static $DIRECTION_IN_WITHOUT_MOVE = 3; // "BE olvastatás mozgás nélkül",
|
||||
public static $DIRECTION_OUT_ = 5; // "KI mozgás",
|
||||
public static $DIRECTION_IN = 7; // "BE mozgás",
|
||||
public static $DIRECTION_OUT_ERROR_KEY_ASSIGNED = 9; // "KI olvastatás, van érvényes öltöző kulcs (nem enged)",
|
||||
public static $DIRECTION_IN_ERROR_KEY_MISSING = 11; // "BE olvastatás, nincs érvényes öltöző kulcs (nem enged)",
|
||||
public static $DIRECTION_OUT_NO_TICKET = 17; // "Bérlet érvényességi időn kívüli KI olvastatás (nem enged)",
|
||||
public static $DIRECTION_IN_NO_TICKET = 19; // "Bérlet érvényességi időn kívüli BE olvastatás (nem enged)",
|
||||
public static $DIRECTION_ALL_EMERGENCY = 128; // "Vésznyitás",
|
||||
public static $DIRECTION_ALL_CARD_BLOCKED = 256; // "Kártya tiltva -> információ mező",
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -35,16 +51,21 @@ class DoorLog extends \yii\db\ActiveRecord
|
||||
{
|
||||
return 'door_log';
|
||||
}
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); },
|
||||
'updatedAtAttribute' => false,
|
||||
]
|
||||
], parent::behaviors());
|
||||
return ArrayHelper::merge([
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function ($event) {
|
||||
if ( isset($event->sender->created_at) ){
|
||||
return $event->sender->created_at;
|
||||
}
|
||||
return date('Y-m-d H:i:s');
|
||||
},
|
||||
'updatedAtAttribute' => false,
|
||||
]
|
||||
], parent::behaviors());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,133 +96,147 @@ class DoorLog extends \yii\db\ActiveRecord
|
||||
'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 [
|
||||
-2 => "Kézi olvasás/Kulcs ki",
|
||||
-1 => "Kézi olvasás/Kulcs vissza",
|
||||
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)",
|
||||
|
||||
128 => "Vésznyitás",
|
||||
256 => "Kártya tiltva -> információ mező",
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCardFlagTexts( ){
|
||||
return [
|
||||
0 => "Kártya érvényes bérlettel",
|
||||
1 => "Nincs érvényes bérlet",
|
||||
2 => "Kártya inaktív/Érvényes bérlet",
|
||||
3 => "Kártya inaktív/Nincs érvényes bérlet"
|
||||
|
||||
];
|
||||
}
|
||||
public function getCustomer()
|
||||
{
|
||||
return $this->hasOne(Customer::className(), ["id_customer" => "id_customer"]);
|
||||
}
|
||||
|
||||
public static function mkDoorLog($direction,$card,$customer = null,$key = null){
|
||||
public function getCustomerName()
|
||||
{
|
||||
$result = "";
|
||||
if (isset($this->customer)) {
|
||||
$result = $this->customer->name;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ( !Helper::isKeyToggleDoorLogEnabled() ){
|
||||
return;
|
||||
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 [
|
||||
-2 => "Kézi olvasás/Kulcs ki",
|
||||
-1 => "Kézi olvasás/Kulcs vissza",
|
||||
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)",
|
||||
|
||||
128 => "Vésznyitás",
|
||||
256 => "Kártya tiltva -> információ mező",
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCardFlagTexts()
|
||||
{
|
||||
return [
|
||||
0 => "Kártya érvényes bérlettel",
|
||||
1 => "Nincs érvényes bérlet",
|
||||
2 => "Kártya inaktív/Érvényes bérlet",
|
||||
3 => "Kártya inaktív/Nincs érvényes bérlet"
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public static function mkDoorLog($direction, $card, $customer = null, $key = null)
|
||||
{
|
||||
|
||||
if (!Helper::isKeyToggleDoorLogEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$dlog = new DoorLog();
|
||||
$dlog->id_card = $card->id_card;
|
||||
$dlog = new DoorLog();
|
||||
$dlog->id_card = $card->id_card;
|
||||
|
||||
if ( isset($customer)){
|
||||
$dlog->id_customer = $customer->id_customer;
|
||||
}
|
||||
if (isset($customer)) {
|
||||
$dlog->id_customer = $customer->id_customer;
|
||||
}
|
||||
|
||||
if ( isset($key)){
|
||||
$dlog->id_key = $key->id_key;
|
||||
}
|
||||
$dlog->direction = $direction;
|
||||
$dlog->type = $card->type;
|
||||
$dlog->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
|
||||
if (isset($key)) {
|
||||
$dlog->id_key = $key->id_key;
|
||||
}
|
||||
$dlog->direction = $direction;
|
||||
$dlog->type = $card->type;
|
||||
$dlog->source_app = DoorLog::$SOURCE_APP_FITNESS_ADMIN;
|
||||
|
||||
$dlog->id_account = Account::readDefault();
|
||||
$dlog->id_account = Account::readDefault();
|
||||
|
||||
if ( $dlog->direction == 0){
|
||||
$dlog->card_flag = $card->validity;
|
||||
}else{
|
||||
$dlog->card_flag = -1;
|
||||
}
|
||||
if ($dlog->direction == 0) {
|
||||
$dlog->card_flag = $card->validity;
|
||||
} else {
|
||||
$dlog->card_flag = -1;
|
||||
}
|
||||
|
||||
$dlog->created_at = date('Y-m-d H:i:s');
|
||||
$dlog->save(false);
|
||||
}
|
||||
|
||||
$dlog->created_at = date('Y-m-d H:i:s');
|
||||
$dlog->save(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
49
common/models/DoorLogForTest.php
Normal file
49
common/models/DoorLogForTest.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use common\components\Helper;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @property integer id_ticket_current
|
||||
* @property integer card_flag
|
||||
* @property integer flag_out
|
||||
*/
|
||||
class DoorLogForTest extends DoorLog
|
||||
{
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[
|
||||
['id_card', 'id_customer', 'id_key', 'direction', 'type', 'id_ticket_current'], 'integer'
|
||||
],
|
||||
|
||||
[['created_at'], 'string'],
|
||||
[['created_at'], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,7 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
{
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
|
||||
const ROLE_RECEPTION = 'receptionist';
|
||||
|
||||
/**
|
||||
@@ -192,18 +192,18 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
{
|
||||
$this->password_reset_token = null;
|
||||
}
|
||||
|
||||
|
||||
public function getUserAccountAssignments(){
|
||||
return $this->hasMany(UserAccountAssignment::className(), ['id_user' =>'id']);
|
||||
}
|
||||
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('app', 'Aktív'),
|
||||
self::STATUS_DELETED => Yii::t('app', 'Inaktív'),
|
||||
] ;
|
||||
}
|
||||
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses($this->status);
|
||||
@@ -212,8 +212,8 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function attributeLabels(){
|
||||
return [
|
||||
'status' => 'Státusz',
|
||||
@@ -224,14 +224,14 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
'statusHuman' => Yii::t('backend/user', 'Status'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @return \yii\rbac\Role[]*/
|
||||
public function getRoles(){
|
||||
$roles = \Yii::$app->authManager->getRolesByUser($this->id );
|
||||
return $roles;
|
||||
return $roles;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,28 +239,28 @@ class User extends ActiveRecord implements IdentityInterface
|
||||
* */
|
||||
public function getRoleString(){
|
||||
$roles = \Yii::$app->authManager->getRolesByUser($this->id );
|
||||
|
||||
|
||||
return implode(', ', array_map(function ($role) { return sprintf("%s", RoleDefinition::getRoleLabel($role->name)); }, $roles ));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* $param int $forceIncludeAccount id warehouse, that should be included in list, even if it is inactive
|
||||
* */
|
||||
public static function read($forceIncludeObjectWithId = null){
|
||||
$users = null;
|
||||
$query = User::find();
|
||||
|
||||
|
||||
if ( RoleDefinition::isReception()){
|
||||
$query->andWhere(['id' => Yii::$app->user->id ]);
|
||||
}
|
||||
|
||||
|
||||
if ( $forceIncludeObjectWithId == null){
|
||||
$users = $query->andWhere(['status' => User::STATUS_ACTIVE])->all();
|
||||
}else{
|
||||
$users = $query->andWhere( ['or', ['status' => User::STATUS_ACTIVE], ['id' => $forceIncludeObjectWithId ] ])->all();
|
||||
}
|
||||
|
||||
|
||||
return $users;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user