status flag
This commit is contained in:
@@ -12,6 +12,7 @@ use common\components\Helper;
|
||||
* @property string $number
|
||||
* @property integer $status
|
||||
* @property integer $type
|
||||
* @property integer $flag
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
@@ -27,6 +28,9 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
const TYPE_OLD = 40;
|
||||
const TYPE_EMPLOYEE = 50;
|
||||
|
||||
|
||||
public static $FLAG_TICKET = 0;
|
||||
public static $FLAG_STATUS = 1;
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -172,4 +176,17 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
$command->execute();
|
||||
}
|
||||
|
||||
public function beforeSave($insert) {
|
||||
if (parent::beforeSave($insert)){
|
||||
$this->flag = Helper::setBit($this->flag, Card::$FLAG_STATUS, ( $this->status != Card::STATUS_ACTIVE));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function getFlagText(){
|
||||
return Helper::getArrayValue(DoorLog::getCardFlagTexts(), $this->flag, "Ismeretlen");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -143,8 +143,10 @@ class DoorLog extends \yii\db\ActiveRecord
|
||||
|
||||
public static function getCardFlagTexts( ){
|
||||
return [
|
||||
0 => "Kártya ok",
|
||||
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",
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
@@ -40,14 +40,15 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
left JOIN ( select distinct ticket.id_card as id_card from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end";
|
||||
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
|
||||
WHERE c1.type <> 50";
|
||||
|
||||
public static $SQL_UPDATE_CARD = "UPDATE card as c1
|
||||
left JOIN ( select distinct ticket.id_card as id_card from ticket
|
||||
where ticket.start <= CURDATE() and ticket.end >= curdate() and ticket.status = 10 ) as t
|
||||
on t.id_card = c1.id_card
|
||||
SET c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
|
||||
WHERE c1.id_card = :id";
|
||||
WHERE c1.type <> 50 and c1.id_card = :id";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user