door card pass: create table and create model and console controller
This commit is contained in:
76
frontend/controllers/DoorCardPassController.php
Normal file
76
frontend/controllers/DoorCardPassController.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
use common\models\Card;
|
||||
use common\models\DoorCardPass;
|
||||
use Yii;
|
||||
use common\models\City;
|
||||
use backend\models\CitySearch;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\base\BaseObject;
|
||||
use yii\db\Query;
|
||||
use yii\helpers\Json;
|
||||
|
||||
/**
|
||||
* CityController implements the CRUD actions for City model.
|
||||
*/
|
||||
class DoorCardPassController 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");
|
||||
}
|
||||
$model = new DoorCardPass();
|
||||
$model->id_card = $idCard;
|
||||
$model->save(false);
|
||||
|
||||
$this->redirect('customer/reception');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single City model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the City model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return City the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = City::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,25 +61,25 @@ $card = $model->card;
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['key/toggle', 'number' => $model->getCardNumber()],
|
||||
'method' => 'post',
|
||||
]); ?>
|
||||
<div class="row" style="margin-bottom: 6px;">
|
||||
<div class='col-md-12'>
|
||||
<?php echo Html::hiddenInput('number', $model->getCardNumber())?>
|
||||
<?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class='col-md-12'>
|
||||
<?= Html::submitButton(Yii::t('frontend/collection', 'Kulcs Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
<?php
|
||||
$doorEntryStrategy = \common\components\Helper::getDoorEntryStrategy();
|
||||
if ( $doorEntryStrategy === 'door_pass'){
|
||||
echo $this->render(
|
||||
'//common/door_entry_strategy/_strategy_door_pass',
|
||||
[
|
||||
'model' => $model
|
||||
]);
|
||||
}else {
|
||||
echo $this->render(
|
||||
'//common/door_entry_strategy/_strategy_key',
|
||||
[
|
||||
'model' => $model
|
||||
]);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php if ( isset($model->customer) ) { ?>
|
||||
<?php $form = ActiveForm::begin([
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Url;
|
||||
use frontend\components\HtmlHelper;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $card common\models\Card */
|
||||
/* @var $customer common\models\Customer */
|
||||
/* @var $model frontend\models\ReceptionForm */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['door-card-pass/allow', 'number' => $model->getCardNumber()],
|
||||
'method' => 'post',
|
||||
]); ?>
|
||||
<div class="row">
|
||||
<div class='col-md-12'>
|
||||
<?= Html::submitButton( "Kapun beléphet", ['class' => 'btn btn-primary btn-block']) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php ActiveForm::end(); ?>
|
||||
30
frontend/views/common/door_entry_strategy/_strategy_key.php
Normal file
30
frontend/views/common/door_entry_strategy/_strategy_key.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Url;
|
||||
use frontend\components\HtmlHelper;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $card common\models\Card */
|
||||
/* @var $customer common\models\Customer */
|
||||
/* @var $model frontend\models\ReceptionForm */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['key/toggle', 'number' => $model->getCardNumber()],
|
||||
'method' => 'post',
|
||||
]); ?>
|
||||
<div class="row" style="margin-bottom: 6px;">
|
||||
<div class='col-md-12'>
|
||||
<?php echo Html::hiddenInput('number', $model->getCardNumber())?>
|
||||
<?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class='col-md-12'>
|
||||
<?= Html::submitButton(Yii::t('frontend/collection', 'Kulcs Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php ActiveForm::end(); ?>
|
||||
Reference in New Issue
Block a user