add coronavirus activate/inactivate
This commit is contained in:
@@ -20,13 +20,15 @@ use common\components\Helper;
|
||||
* @property int flag_out
|
||||
* @property \common\models\Customer $customer relation
|
||||
* @property mixed validity
|
||||
* @property string inactivated_at
|
||||
*/
|
||||
class Card extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
const STATUS_INACTIVE = 20;
|
||||
|
||||
const TYPE_RFID = 10;
|
||||
const TYPE_QRCODE = 20;
|
||||
const TYPE_BARCODE = 30;
|
||||
@@ -75,6 +77,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
|
||||
public static $SQL_UPDATE_FLAG_STATUS_ACTIVE = '
|
||||
update card set flag = CASE WHEN status = 20 then (flag | 1 << 3) else ( flag & ~(1 << 3 ) ) end
|
||||
';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -128,8 +135,9 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
static function statuses() {
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/card', 'Active'),
|
||||
self::STATUS_DELETED => Yii::t('common/card', 'Inactive'),
|
||||
self::STATUS_ACTIVE => 'Aktív',
|
||||
self::STATUS_DELETED => 'Törölve',
|
||||
self::STATUS_INACTIVE => 'Inaktív',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -305,4 +313,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
return Helper::isBitOn($this->flag,Card::$FLAG_DOOR_ALLOWED);
|
||||
}
|
||||
|
||||
public static function updateFlagStatus(){
|
||||
\Yii::$app->db->createCommand(self::$SQL_UPDATE_FLAG_STATUS_ACTIVE)->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,8 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
-- first bit is 0 when there is a ticket or 'employee' card 0000 0000
|
||||
-- first bit is 1 when there is no ticket and card type is not 'employee'
|
||||
, c1.flag = case when c1.type = 50 then ( c1.flag & ~(1 << 0) ) 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";
|
||||
, c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end
|
||||
where c1.status = 10";
|
||||
|
||||
public static $SQL_UPDATE_CARD = "UPDATE card as c1
|
||||
left JOIN ( select ticket.id_card as id_card , max(ticket.id_ticket) as id_ticket
|
||||
@@ -79,10 +80,18 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
|
||||
SET c1.validity = case when c1.type = 50 then ( c1.validity & ~(1 << 0) ) when t.id_card is null then ( c1.validity | 1 << 0 ) else ( c1.validity & ~(1 << 0) ) end
|
||||
,c1.flag = case when c1.type = 50 then ( c1.flag & ~(1 << 0) ) 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.id_card = :id";
|
||||
WHERE c1.status = 10 and c1.id_card = :id";
|
||||
|
||||
|
||||
|
||||
public static $SQL_UPDATE_TICKETS_END_DATE_ON_CARD_ACTIVATION = "UPDATE ticket t
|
||||
inner join card c on t.id_card = c.id_card
|
||||
SET end = date_add( end, INTERVAL datediff(current_date, c.inactivated_at) DAY )
|
||||
where
|
||||
c.status = 20
|
||||
and c.inactivated_at is not null
|
||||
and ((t.start <= c.inactivated_at and t.end >= c.inactivated_at) or (t.start >= c.inactivated_at)) ;";
|
||||
|
||||
public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){
|
||||
return "
|
||||
UPDATE card c
|
||||
|
||||
Reference in New Issue
Block a user