add mover cutler door

This commit is contained in:
2017-06-17 22:01:11 +02:00
parent b9399acc2e
commit f538a82def
13 changed files with 175 additions and 44 deletions

View File

@@ -348,6 +348,10 @@ class Helper {
public static function isKeyRequired() {
return \Yii::$app->params ['key_required'] == true;
}
public static function isTicketTypeDoorAllowedCheckOn() {
return \Yii::$app->params ['ticket_type_door_allowed_check_on'] == true;
}
public static function getProductSaleDefaultFocus() {
return \Yii::$app->params ['product_sale_default_focus'] ;

View File

@@ -60,5 +60,6 @@ return [
*/
'key_toggle_door_log_enabled' => false,
//if key required for entry trough the door
'key_required' => true
'key_required' => true,
'ticket_type_door_allowed_check_on' => false
];

View File

@@ -34,10 +34,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
const TYPE_EMPLOYEE = 50;
public static $FLAG_TICKET = 0;
public static $FLAG_DOOR = 1;
public static $FLAG_KEY = 2;
public static $FLAG_STATUS = 3;
public static $FLAG_TICKET = 0; //has valid ticket
public static $FLAG_DOOR = 1; //door in/out order
public static $FLAG_KEY = 2; //key status
public static $FLAG_STATUS = 3; //allowed/disabled
public static $FLAG_DOOR_ALLOWED = 4; //ticket type allows door
/**
* This script is used in daily scripts, to clear the flag door log status
@@ -65,6 +66,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
UPDATE card set flag = ( flag & ~(1 << 1 ) ) WHERE card.type <> 50 and card.id_card = :id
";
public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG(){
return "UPDATE card set flag = ( flag & ~(1 << " . Card::$FLAG_DOOR_ALLOWED. " ) ) WHERE card.type <> 50 ";
}
public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(){
return Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() . " and card.id_card = :id ";
}
/**
* @inheritdoc
*/
@@ -227,6 +237,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
$command = $db->createCommand(Card::$SQL_CLEARS_STATUS_DOOR_IN,[':id' => $id]);
$command->execute();
if ( Helper::isTicketTypeDoorAllowedCheckOn()) {
$command = $db->createCommand(Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
$command->execute();
}else{
$command = $db->createCommand(Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
$command->execute();
}
}
public function beforeSave($insert) {
@@ -279,6 +298,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
return Helper::isBitOn($this->flag_out,Card::$FLAG_KEY);
}
/**
* if flag is on, door entry is not allowed.
*/
public function isFlagDoorAllowed(){
return Helper::isBitOn($this->flag,Card::$FLAG_DOOR_ALLOWED);
}
}

View File

@@ -73,8 +73,25 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
,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";
public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){
return "
UPDATE card c
LEFT JOIN ticket t on c.id_ticket_current = t.id_ticket
LEFT JOIN ticket_type tt on t.id_ticket_type = tt.id_ticket_type
set
c.flag = case when tt.door_allowed <> 1 then ( c.flag | 1 << 4 ) else ( c.flag & ~(1 << 4) ) end
WHERE c.type <> 50
";
}
public static function SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(){
return Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() . " and c.id_card = :id";
}
/**
* @inheritdoc
*/
@@ -395,6 +412,4 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
Card::updateCardFlagTicket($this->id_card);;
}
}

View File

@@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
* @property integer installment_enabled
* @property integer installment_count
* @property integer installment_money
* @property integer door_allowed
* @property string $created_at
* @property string $updated_at
*/
@@ -38,6 +39,9 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
const INSTALLMENT_OFF = 0;
const INSTALLMENT_ON = 1;
const FLAG_DOOR_ALLOWED_OFF = 0;
const FLAG_DOOR_ALLOWED_ON = 1;
/**
* @inheritdoc
@@ -104,6 +108,13 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
[['installment_money',], 'integer'],
[['installment_count',], 'integer'],
////////////////
//door_allowed
////////////////
[['door_allowed',], 'integer'],
[['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
];
}
@@ -128,6 +139,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
'installment_enabled' => Yii::t('common/ticket_type', 'Részlet fizetés a brutto áron felül'),
'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'),
'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'),
'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'),
];
}
@@ -188,6 +200,11 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
public function isStudent(){
return $this->flag_student == ( self::FLAG_STUDENT_ON);
}
public function isDoor(){
return $this->door_allowed == ( self::FLAG_STUDENT_ON);
}
public function isInstallment(){
return $this->installment_enabled == ( self::INSTALLMENT_ON);
}