add app param 'key_required'

This commit is contained in:
2017-03-22 07:55:12 +01:00
parent 59f6b32e7c
commit 57e578540c
4 changed files with 31 additions and 13 deletions

View File

@@ -57,6 +57,10 @@ class Card extends \common\models\BaseFitnessActiveRecord
WHERE c1.type <> 50
";
public static $SQL_CLEAR_KEY_STATUS = "
UPDATE card set flag = ( flag & ~(1 << 2 ) ) WHERE card.type <> 50 and card.id_card = :id
";
public static $SQL_CLEARS_STATUS_DOOR_IN = "
UPDATE card set flag = ( flag & ~(1 << 1 ) ) WHERE card.type <> 50 and card.id_card = :id
";
@@ -239,9 +243,14 @@ class Card extends \common\models\BaseFitnessActiveRecord
}
public function setFlagsHasKey($hasKey){
$this->flag = $hasKey ? ( $this->flag & ~(1 << Card::$FLAG_KEY) ) : ( $this->flag | 1 << Card::$FLAG_KEY );
$this->flag_out = $hasKey ? ( $this->flag_out | 1 << Card::$FLAG_KEY ) : ( $this->flag_out & ~(1 << Card::$FLAG_KEY) );
/** @noinspection PhpUndefinedClassInspection */
if (Helper::isKeyRequired()){
$this->flag = $hasKey ? ( $this->flag & ~(1 << Card::$FLAG_KEY) ) : ( $this->flag | 1 << Card::$FLAG_KEY );
$this->flag_out = $hasKey ? ( $this->flag_out | 1 << Card::$FLAG_KEY ) : ( $this->flag_out & ~(1 << Card::$FLAG_KEY) );
/** @noinspection PhpUndefinedClassInspection */
}else{
$this->flag = ( $this->flag & ~(1 << Card::$FLAG_KEY) );
$this->flag_out = ( $this->flag_out & ~(1 << Card::$FLAG_KEY) );
}
\Yii::info("flag has key: ".$this->flag .";".$this->flag_out);
}