add coronavirus activate/inactivate

This commit is contained in:
2020-04-20 09:10:18 +02:00
parent e7e4183221
commit 5d847e2538
13 changed files with 628 additions and 10 deletions

View File

@@ -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