door card pass: create table and create model and console controller
This commit is contained in:
@@ -42,6 +42,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
public static $FLAG_KEY = 2; //key status
|
||||
public static $FLAG_STATUS = 3; //allowed/disabled
|
||||
public static $FLAG_DOOR_ALLOWED = 4; //ticket type allows door
|
||||
public static $FLAG_DOOR_PASS_ALLOWED = 5; // door pass
|
||||
|
||||
/**
|
||||
* This script is used in daily scripts, to clear the flag door log status
|
||||
@@ -77,6 +78,22 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
return Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() . " and card.id_card = :id ";
|
||||
}
|
||||
|
||||
public static function SQL_DENY_DOOR_CARD_PASS() {
|
||||
return "update card set flag = flag | (1 << " . Card::$FLAG_DOOR_PASS_ALLOWED . ") ";
|
||||
}
|
||||
|
||||
public static function SQL_ALLOW_DOOR_CARD_PASS() {
|
||||
return "update card set flag = flag | (1 << " . Card::$FLAG_DOOR_PASS_ALLOWED . ") ";
|
||||
}
|
||||
|
||||
public static function SQL_DENY_DOOR_CARD_PASS_EXPIRED( ){
|
||||
return "update card ca "
|
||||
. "inner join door_card_pass dcp on ca.id_card = dcp.id_card "
|
||||
. "set ca.flag = ca.flag | (1 << " . Card::$FLAG_DOOR_PASS_ALLOWED . ") , dcp.updated_at = now()"
|
||||
. " WHERE "
|
||||
. " dcp.updated_at <> dcp.created_at and dcp.created_at <= :datetime ";
|
||||
}
|
||||
|
||||
|
||||
public static $SQL_UPDATE_FLAG_STATUS_ACTIVE = '
|
||||
update card set flag = CASE WHEN status = 20 then (flag | 1 << 3) else ( flag & ~(1 << 3 ) ) end
|
||||
|
||||
50
common/models/DoorCardPass.php
Normal file
50
common/models/DoorCardPass.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "door_card_pass".
|
||||
*
|
||||
*
|
||||
* 'id_door_card_pass'=> $this->primaryKey(),
|
||||
'id_card' => $this->integer(11),
|
||||
'id_user' => $this->integer(11),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $
|
||||
* @property integer $id_door_card_pass
|
||||
* @property integer $id_card
|
||||
* @property integer $id_user
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*
|
||||
*/
|
||||
class DoorCardPass extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'door_card_pass';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user