implement registration
This commit is contained in:
@@ -24,7 +24,7 @@ use common\components\Helper;
|
||||
*/
|
||||
class Card extends \common\models\BaseFitnessActiveRecord
|
||||
{
|
||||
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
const STATUS_INACTIVE = 20;
|
||||
@@ -34,8 +34,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
const TYPE_BARCODE = 30;
|
||||
const TYPE_OLD = 40;
|
||||
const TYPE_EMPLOYEE = 50;
|
||||
|
||||
|
||||
|
||||
|
||||
public static $FLAG_TICKET = 0; //has valid ticket
|
||||
public static $FLAG_DOOR = 1; //door in/out order
|
||||
public static $FLAG_KEY = 2; //key status
|
||||
@@ -121,8 +121,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
'updated_at' => Yii::t('common/card', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function validateAscii($attribute, /** @noinspection PhpUnusedParameterInspection */
|
||||
$params){
|
||||
if ( !$this->hasErrors($this->$attribute)){
|
||||
@@ -131,7 +131,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
Yii::info(" $attribute converted to: " . $this->$attribute);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static function statuses() {
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
@@ -140,7 +140,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
self::STATUS_INACTIVE => 'Inaktív',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses();
|
||||
@@ -155,7 +155,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
public static function toTypeName($type , $def = ""){
|
||||
return Helper::getArrayValue(self::types(), $type, $def);
|
||||
}
|
||||
|
||||
|
||||
static function types() {
|
||||
/** @noinspection PhpUndefinedClassInspection */
|
||||
return [
|
||||
@@ -166,7 +166,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
self::TYPE_EMPLOYEE => Yii::t('common/card', 'Munkatárs'),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function getTypeHuman(){
|
||||
$result = null;
|
||||
$s = self::types();
|
||||
@@ -175,20 +175,24 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
public function isInactive(){
|
||||
return $this->status == self::STATUS_DELETED;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load card from the DB , where the number equals with card number or RFID number
|
||||
* @param number|string $number the card number or the RFID number
|
||||
* @param null|boolean $free optional. if set, append free or not free condition.
|
||||
* @return \common\models\Card|null the card or null, if not found with given conditions
|
||||
*/
|
||||
public static function readCard($number,$free = null){
|
||||
$card = null;
|
||||
$query = Card::find()
|
||||
->leftJoin(Customer::tableName(), 'card.id_card = customer.id_customer_card ' );
|
||||
// ->andWhere(['number'=>$number ]);
|
||||
|
||||
|
||||
Card::addCardNumberCondition($query, $number);
|
||||
|
||||
|
||||
|
||||
if ( isset($free) ){
|
||||
if ( $free == true){
|
||||
$query->andWhere('customer.id_customer is null');
|
||||
@@ -196,20 +200,20 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
$query->andWhere('customer.id_customer is not null');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$cards = $query->all();
|
||||
|
||||
|
||||
if ( count($cards) == 1){
|
||||
$card = $cards[0];
|
||||
}
|
||||
return $card;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getCustomer(){
|
||||
return $this->hasOne(Customer::className(), ['id_customer_card' => 'id_card']);
|
||||
}
|
||||
|
||||
|
||||
public function getCustomerName(){
|
||||
$name = null;
|
||||
if ( $this->customer != null){
|
||||
@@ -232,7 +236,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
['and', ['in',$field_rfid_key ,[ $number ] ],"trim(coalesce(card.rfid_key, '')) <>'' "],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public static function updateCardFlagTicket($id){
|
||||
if ( !isset($id)){
|
||||
return ;
|
||||
@@ -255,7 +259,7 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function beforeSave($insert) {
|
||||
if (parent::beforeSave($insert)){
|
||||
$this->flag = Helper::setBit( $this->flag , Card::$FLAG_STATUS, ( $this->status != Card::STATUS_ACTIVE ) );
|
||||
@@ -263,8 +267,8 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function getFlagText(){
|
||||
return Helper::getArrayValue(DoorLog::getCardFlagTexts(), $this->validity, "Ismeretlen");
|
||||
}
|
||||
@@ -317,4 +321,12 @@ class Card extends \common\models\BaseFitnessActiveRecord
|
||||
\Yii::$app->db->createCommand(self::$SQL_UPDATE_FLAG_STATUS_ACTIVE)->execute();
|
||||
}
|
||||
|
||||
public function isFree(){
|
||||
return !isset($this->customer);
|
||||
}
|
||||
|
||||
public function getActiveTickets(){
|
||||
return Ticket::readActive($this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user