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

@@ -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);
}
}