cutler movar doormove reception ui changes
This commit is contained in:
parent
30dca92465
commit
beb3c3944e
29
common/manager/VirtualKeyManager.php
Normal file
29
common/manager/VirtualKeyManager.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace common\manager;
|
||||
|
||||
use common\components\DateUtil;
|
||||
use common\components\Helper;
|
||||
use common\models\VirtualKey;
|
||||
use yii\base\BaseObject;
|
||||
|
||||
class VirtualKeyManager extends BaseObject
|
||||
{
|
||||
|
||||
public function createNewVirtualKey($idCard)
|
||||
{
|
||||
$model = new VirtualKey();
|
||||
$model->id_card = $idCard;
|
||||
|
||||
$model->save(false);
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
public function getValidUntilTime($createdAtStr){
|
||||
$createdAt = DateUtil::parseDateTime($createdAtStr);
|
||||
$validUntil = DateUtil::addMinutes($createdAt,Helper::getDoorPassValidityIntervalMinutes());
|
||||
return $validUntil;
|
||||
|
||||
}
|
||||
}
|
||||
48
frontend/controllers/VirtualKeyController.php
Normal file
48
frontend/controllers/VirtualKeyController.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use common\components\DateUtil;
|
||||
use common\components\Helper;
|
||||
use common\manager\VirtualKeyManager;
|
||||
use common\models\Card;
|
||||
use common\models\VirtualKey;
|
||||
use Yii;
|
||||
use common\models\City;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* CityController implements the CRUD actions for City model.
|
||||
*/
|
||||
class VirtualKeyController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'allow-card' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function actionAllowCard($idCard)
|
||||
{
|
||||
$card = Card::findOne($idCard);
|
||||
if (!isset($card)){
|
||||
throw new BadRequestHttpException("card id not found");
|
||||
}
|
||||
|
||||
$VirtualKeyManager = new VirtualKeyManager();
|
||||
$VirtualKeyManager->createNewVirtualKey($idCard);
|
||||
|
||||
$this->redirect(['customer/reception', 'number' => $card->number]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,21 +14,25 @@ use yii\widgets\ActiveForm;
|
||||
if (! ( isset($model) && isset($model->card))){
|
||||
return;
|
||||
}
|
||||
$virtualKeysNotInCreatedInTheLastXMinuteForCard = VirtualKey::readNotInCreatedInTheLastXMinutesByIdCard($model->card->id_card,5);
|
||||
$minutes = \common\components\Helper::getDoorPassValidityIntervalMinutes();
|
||||
$virtualKeysNotInCreatedInTheLastXMinuteForCard = VirtualKey::readNotInCreatedInTheLastXMinutesByIdCard($model->card->id_card,$minutes);
|
||||
|
||||
if (count($virtualKeysNotInCreatedInTheLastXMinuteForCard) > 0){
|
||||
$activeVirtualKey = $virtualKeysNotInCreatedInTheLastXMinuteForCard[0];
|
||||
?>
|
||||
<div>
|
||||
<?php
|
||||
echo "Forgó kapun beléphet eddig: " ;
|
||||
echo "Forgó kapun beléphet: " ;
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
?>
|
||||
<div>
|
||||
<?php
|
||||
echo $activeVirtualKey->created_at ;
|
||||
echo Html::tag("div", "Tól:" .$activeVirtualKey->created_at) ;
|
||||
$manager = new \common\manager\VirtualKeyManager();
|
||||
$dateTimeUntil = \common\components\DateUtil::formatDateTimeUtc( $manager->getValidUntilTime($activeVirtualKey->created_at) );
|
||||
echo Html::tag("div", " Ig:" .$dateTimeUntil) ;
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
@ -42,7 +46,7 @@ if (! ( isset($model) && isset($model->card))){
|
||||
}
|
||||
|
||||
$form = ActiveForm::begin([
|
||||
'action' => ['door-card-pass/allow-card', 'idCard' => $model->card->id_card],
|
||||
'action' => ['virtual-key/allow-card', 'idCard' => $model->card->id_card],
|
||||
'method' => 'post',
|
||||
]); ?>
|
||||
<div class="row">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user