cutler movar doormove
This commit is contained in:
@@ -63,5 +63,22 @@ class DoorManagerLog extends \yii\db\ActiveRecord
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\components\DateUtil;
|
||||
use common\components\Helper;
|
||||
use common\helpers\AppDateTimeHelper;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\helpers\ArrayHelper;
|
||||
@@ -62,10 +65,27 @@ class VirtualKey extends \yii\db\ActiveRecord
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function () {
|
||||
return date('Y-m-d H:i:s');
|
||||
return DateUtil::formatDateTimeUtc(DateUtil::utcDateTime() );
|
||||
}
|
||||
]
|
||||
],
|
||||
parent::behaviors());
|
||||
}
|
||||
|
||||
public static function readNotInCreatedInTheLastXMinutesByIdCard($idCard,$minutes){
|
||||
|
||||
$date = DateUtil::utcDateTime();
|
||||
$date = DateUtil::minusMinutes($date,$minutes );
|
||||
$dateStr = DateUtil::formatDateTimeUtc($date);
|
||||
|
||||
$virtualKeysNotInCreatedInTheLastXMinuteForCard = VirtualKey::find()
|
||||
->andWhere(['id_card' => $idCard])
|
||||
->andWhere([">=" ,'created_at',$dateStr])
|
||||
->andWhere(['direction_in_at' => null])
|
||||
->orderBy(['created_at' => SORT_DESC])
|
||||
->all();
|
||||
return $virtualKeysNotInCreatedInTheLastXMinuteForCard;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user