restore flag_out logic, toggleKey logic
This commit is contained in:
@@ -5,6 +5,8 @@ namespace common\models;
|
||||
use Yii;
|
||||
use common\components\Helper;
|
||||
|
||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||
|
||||
/**
|
||||
* This is the model class for table "card".
|
||||
*
|
||||
@@ -17,6 +19,7 @@ use common\components\Helper;
|
||||
* @property string $updated_at
|
||||
* @property int flag_out
|
||||
* @property \common\models\Customer $customer relation
|
||||
* @property mixed validity
|
||||
*/
|
||||
class Card extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
@@ -86,6 +89,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
'id_card' => Yii::t('common/card', 'Id Card'),
|
||||
'number' => Yii::t('common/card', 'Number'),
|
||||
@@ -98,15 +102,18 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
|
||||
public function validateAscii($attribute,$params){
|
||||
public function validateAscii($attribute, /** @noinspection PhpUnusedParameterInspection */
|
||||
$params){
|
||||
if ( !$this->hasErrors($this->$attribute)){
|
||||
$this->$attribute = Helper::fixAsciiChars($this->$attribute);
|
||||
Yii::info(" $attribute converted to: " . $this->$attribute);
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
Yii::info(" $attribute converted to: " . $this->$attribute);
|
||||
}
|
||||
}
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/card', 'Active'),
|
||||
self::STATUS_DELETED => Yii::t('common/card', 'Inactive'),
|
||||
];
|
||||
@@ -114,7 +121,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses($this->status);
|
||||
$s = self::statuses();
|
||||
if ( array_key_exists($this->status, $s)){
|
||||
$result = $s[$this->status];
|
||||
}
|
||||
@@ -128,7 +135,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
static function types() {
|
||||
return [
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
self::TYPE_RFID => Yii::t('common/card', 'RFID'),
|
||||
self::TYPE_QRCODE => Yii::t('common/card', 'QRCODE'),
|
||||
self::TYPE_BARCODE => Yii::t('common/card', 'BARCODE'),
|
||||
@@ -139,7 +147,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
public function getTypeHuman(){
|
||||
$result = null;
|
||||
$s = self::types($this->type);
|
||||
$s = self::types();
|
||||
if ( array_key_exists($this->type, $s)){
|
||||
$result = $s[$this->type];
|
||||
}
|
||||
@@ -182,18 +190,24 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
|
||||
public function getCustomerName(){
|
||||
$name = null;
|
||||
$customer = $this->customer;
|
||||
if ( $this->customer != null){
|
||||
$name = $this->customer->name;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
public static function addCardNumberCondition($query,$number, $field_number = "card.number",$field_rfid_key = "card.rfid_key"){
|
||||
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
|
||||
/**
|
||||
* @param \yii\db\Query $query
|
||||
* @param number $number
|
||||
* @param string $field_number
|
||||
* @param string $field_rfid_key
|
||||
*/
|
||||
public static function addCardNumberCondition($query, $number, $field_number = "card.number", $field_rfid_key = "card.rfid_key"){
|
||||
$query->andWhere(['or',
|
||||
['and',[ 'in',$field_number , [$number]],"trim(coalesce(card.number, '')) <>'' " ],
|
||||
['and', ['in',$field_rfid_key ,[ $number ] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -201,7 +215,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
if ( !isset($id)){
|
||||
return ;
|
||||
}
|
||||
$db = \Yii::$app->db;
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
$db = \Yii::$app->db;
|
||||
|
||||
$command = $db->createCommand(Ticket::$SQL_UPDATE_CARD,[':id' => $id]);
|
||||
$command->execute();
|
||||
@@ -224,11 +239,10 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
public function setFlagsHasKey($hasKey){
|
||||
|
||||
$pos = Card::$FLAG_KEY;
|
||||
// $this->flag = $hasKey ? ( $this->flag & ~(1 << $pos) ) : ( $this->flag | 1 << $pos );
|
||||
// $this->flag_out = $hasKey ? ( $this->flag_out | 1 << $pos ) : ( $this->flag_out & ~(1 << $pos) );
|
||||
// \Yii::info("flag has key: ".$this->flag .";".$this->flag_out);
|
||||
$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 */
|
||||
\Yii::info("flag has key: ".$this->flag .";".$this->flag_out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ class Log extends BaseFitnessActiveRecord
|
||||
'type' =>Log::$TYPE_LOGIN,
|
||||
'message' => $message
|
||||
]);
|
||||
* @param unknown $config
|
||||
* @param array $config
|
||||
*/
|
||||
public static function log( $config ){
|
||||
$model = new Log($config);
|
||||
|
||||
Reference in New Issue
Block a user