85 lines
2.3 KiB
PHP
85 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace common\models;
|
|
|
|
use Yii;
|
|
use common\components\Helper;
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\helpers\ArrayHelper;
|
|
|
|
/**
|
|
* This is the model class for table "door_manager_log".
|
|
*
|
|
* @property string $request_id
|
|
* @property string $identifier
|
|
* @property string $device
|
|
* @property string $direction
|
|
* @property string $original_direction
|
|
* @property bool $verify_only
|
|
* @property datetime $created_at
|
|
* @property integer $card_id_card
|
|
* @property string $card_number
|
|
* @property integer $virtual_key_id
|
|
* @property integer $key_id_key
|
|
* @property string $key_number
|
|
* @property string $customer_id_customer
|
|
* @property string $customer_name
|
|
* @property string $customer_email
|
|
* @property string $ticket_id_ticket
|
|
* @property string $ticket_usage_count
|
|
* @property string $ticket_usage
|
|
* @property string $ticket_type_name
|
|
* @property string $validation_kind
|
|
* @property bool $error
|
|
* @property string $error_code
|
|
* @property string $error_message
|
|
*
|
|
*/
|
|
class DoorManagerLog extends \yii\db\ActiveRecord
|
|
{
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public static function tableName()
|
|
{
|
|
return 'door_manager_log';
|
|
}
|
|
|
|
public function behaviors()
|
|
{
|
|
return ArrayHelper::merge([
|
|
[
|
|
'class' => TimestampBehavior::className(),
|
|
'value' => function ($event) {
|
|
if ( isset($event->sender->created_at) ){
|
|
return $event->sender->created_at;
|
|
}
|
|
return date('Y-m-d H:i:s');
|
|
},
|
|
'updatedAtAttribute' => false,
|
|
]
|
|
], parent::behaviors());
|
|
}
|
|
|
|
|
|
static function findFirstForCardFromTime($idCard,$datetime){
|
|
return DoorManagerLog::find()
|
|
->andWhere(['id_card' =>$idCard])
|
|
->andWhere(['verify_only' => false])
|
|
->andWhere(['>=' ,'created_at', $datetime])
|
|
->one();
|
|
}
|
|
|
|
|
|
static function findAllEntryForTicketFromTime($idTicket, $datetime = null){
|
|
return DoorManagerLog::find()
|
|
->andWhere(['id_ticket' =>$idTicket])
|
|
->andWhere(['verify_only' => false])
|
|
->andWhere(['direction' => 'IN'])
|
|
->andWhere(['>=' ,'created_at', isset( $datetime ) ? $datetime : date('Y-m-d H:i:s')])
|
|
->all();
|
|
}
|
|
|
|
}
|