add fingerpint frontend gui
This commit is contained in:
parent
c3fd9ff58a
commit
c92166e11d
@ -23,7 +23,9 @@ class Fingerprint extends ActiveRecord
|
||||
return ArrayHelper::merge([
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); },
|
||||
'value' => static function () {
|
||||
return date('Y-m-d H:i:s');
|
||||
},
|
||||
'updatedAtAttribute' => false,
|
||||
]
|
||||
], parent::behaviors());
|
||||
@ -59,7 +61,7 @@ class Fingerprint extends ActiveRecord
|
||||
return [
|
||||
'id_fingerprint' => Yii::t('common/fingerprint', 'Id Fingerprint'),
|
||||
'id_customer' => Yii::t('common/fingerprint', 'Id Customer'),
|
||||
'fingerprint' => Yii::t('common/fingerprint', 'Fingerprint'),
|
||||
'fingerprint' => Yii::t('common/fingerprint', 'Ujjlenyomat'),
|
||||
'created_at' => Yii::t('common/fingerprint', 'Created At'),
|
||||
'updated_at' => Yii::t('common/fingerprint', 'Updated At'),
|
||||
];
|
||||
|
||||
126
frontend/controllers/FingerprintController.php
Normal file
126
frontend/controllers/FingerprintController.php
Normal file
@ -0,0 +1,126 @@
|
||||
<?php /** @noinspection PhpUnused */
|
||||
|
||||
|
||||
namespace frontend\controllers;
|
||||
|
||||
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Fingerprint;
|
||||
use frontend\models\FingerprintCreate;
|
||||
use frontend\models\FingerprintSearch;
|
||||
use Throwable;
|
||||
use Yii;
|
||||
use yii\db\StaleObjectException;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\web\Response;
|
||||
|
||||
class FingerprintController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'only' => ['index'],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
// everything else is denied
|
||||
],
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new FingerprintSearch();
|
||||
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'card' => $searchModel->card,
|
||||
'customer' => $searchModel->customer,
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $id_card
|
||||
* @return string|Response
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function actionCreate($id_card)
|
||||
{
|
||||
|
||||
/** @var Card $card */
|
||||
$card = Card::findOne($id_card);
|
||||
|
||||
if (!isset($card)) {
|
||||
throw new NotFoundHttpException('Card not found:' . $id_card);
|
||||
}
|
||||
|
||||
$customer = Customer::findOne($card->customer);
|
||||
|
||||
if (!isset($customer)) {
|
||||
throw new NotFoundHttpException('Customer not found');
|
||||
}
|
||||
|
||||
|
||||
$model = new FingerprintCreate();
|
||||
$model->id_customer = $customer->id_customer;
|
||||
|
||||
/** @noinspection NotOptimalIfConditionsInspection */
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['index', 'FingerprintSearch[id_card]' => $card->id_card]);
|
||||
}
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $id
|
||||
* @return Response
|
||||
* @throws NotFoundHttpException
|
||||
* @throws Throwable
|
||||
* @throws StaleObjectException
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
|
||||
$model = Fingerprint::findOne($id);
|
||||
|
||||
if (!isset($model)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
|
||||
/** @var Customer $customer */
|
||||
$customer = Customer::findOne($model->id_customer);
|
||||
|
||||
$model->delete();
|
||||
|
||||
return $this->redirect([
|
||||
'index',
|
||||
'FingerprintSearch[id_card]' => $customer->id_customer_card
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
21
frontend/models/FingerprintCreate.php
Normal file
21
frontend/models/FingerprintCreate.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use common\models\Fingerprint;
|
||||
|
||||
class FingerprintCreate extends Fingerprint
|
||||
{
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['fingerprint'], 'string'],
|
||||
[['fingerprint' ], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
68
frontend/models/FingerprintSearch.php
Normal file
68
frontend/models/FingerprintSearch.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Fingerprint;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class FingerprintSearch extends Fingerprint
|
||||
{
|
||||
|
||||
public $id_card;
|
||||
|
||||
public $customer;
|
||||
public $card;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[[ 'id_card'], 'integer'],
|
||||
[[ 'id_card'], 'required']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @return ActiveDataProvider
|
||||
* @throws NotFoundHttpException
|
||||
*/
|
||||
public function search($params){
|
||||
|
||||
$this->load($params);
|
||||
$this->validate();
|
||||
|
||||
|
||||
$query = Fingerprint::find();
|
||||
|
||||
/** @var Card $card */
|
||||
$card = Card::findOne($this->id_card);
|
||||
|
||||
if ( !isset($card)){
|
||||
throw new NotFoundHttpException('Card not found:' . $this->id_card);
|
||||
}
|
||||
$this->card = $card;
|
||||
|
||||
$customer = Customer::findOne($card->customer);
|
||||
|
||||
if ( !isset($customer)){
|
||||
throw new NotFoundHttpException('Customer not found');
|
||||
}
|
||||
|
||||
|
||||
$this->customer = $customer;
|
||||
|
||||
$query->andWhere(['id_customer' => $customer->id_customer]);
|
||||
return new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,8 +5,9 @@ use yii\helpers\Url;
|
||||
<?php
|
||||
|
||||
|
||||
$route = \Yii::$app->controller->id .'/'. \Yii::$app->controller->action->id;
|
||||
$route = Yii::$app->controller->id .'/'. Yii::$app->controller->action->id;
|
||||
|
||||
/** @noinspection PhpUnhandledExceptionInspection */
|
||||
$todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
|
||||
|
||||
|
||||
@ -23,6 +24,7 @@ $items = [
|
||||
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
|
||||
[ 'Kártya', ['card/info', 'id_card' => $card->id_card ]],
|
||||
[ 'Törölköző Bérlés', ['log/towel', 'id_card' => $card->id_card , 'LogSearch[start]' => $todayDateTime ]],
|
||||
[ 'Ujjlenyomat', ['fingerprint/index', 'FingerprintSearch[id_card]' => $card->id_card ]],
|
||||
];
|
||||
|
||||
|
||||
|
||||
35
frontend/views/fingerprint/create.php
Normal file
35
frontend/views/fingerprint/create.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Fingerprint */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
|
||||
|
||||
$this->title = 'Ujjlenyomat hozzáadása';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Ujjlenyomatok', 'url' => ['index', 'id_customer' => $model->id_customer]];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="fingerprint-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<div class="fingerprint-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'fingerprint')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
|
||||
<?= $form->field($model, 'id_customer')->hiddenInput(['maxlength' => true])->label(false) ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton('Mentés', ['class' => 'btn btn-success']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
37
frontend/views/fingerprint/index.php
Normal file
37
frontend/views/fingerprint/index.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\helpers\Html;
|
||||
|
||||
?>
|
||||
<h1>Ujjlenyomatok</h1>
|
||||
|
||||
|
||||
<p>
|
||||
<?php
|
||||
echo Html::a("Ujjlenyomat hozzáadása", ['create', 'id_card' => $card->id_card], ['class' => 'btn btn-success']);
|
||||
?>
|
||||
</p>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
echo GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' => 'fingerprint',
|
||||
'label' => "Ujjlenyomat"
|
||||
],
|
||||
[
|
||||
'attribute' => 'created_at',
|
||||
'label' => "Létrehozva",
|
||||
'format' => 'datetime'
|
||||
],
|
||||
['class' => 'yii\grid\ActionColumn',
|
||||
'template' => '{delete}',
|
||||
]
|
||||
]
|
||||
]);
|
||||
?>
|
||||
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
<?php /** @noinspection PhpUnused */
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: rocho
|
||||
@ -9,18 +10,21 @@
|
||||
namespace rest\controllers;
|
||||
|
||||
|
||||
use common\components\Helper;
|
||||
use common\models\Card;
|
||||
use common\models\Customer;
|
||||
use common\models\Fingerprint;
|
||||
use common\models\Ticket;
|
||||
use Yii;
|
||||
use yii\web\BadRequestHttpException;
|
||||
use yii\web\HttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class FingerprintController extends RestController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $idCustomer
|
||||
* @param $fingerPrint
|
||||
* @throws HttpException
|
||||
*/
|
||||
public function actionAdd($idCustomer,$fingerPrint)
|
||||
{
|
||||
$customer = Customer::findOne($idCustomer);
|
||||
@ -29,8 +33,6 @@ class FingerprintController extends RestController
|
||||
throw new HttpException(404, 'Not Found');
|
||||
}
|
||||
|
||||
// Fingerprint::deleteAll(['id_customer' =>$idCustomer]);
|
||||
|
||||
$fingerPrintModel = new Fingerprint();
|
||||
$fingerPrintModel->id_customer = $customer->id_customer;
|
||||
$fingerPrintModel->fingerprint = $fingerPrint;
|
||||
@ -45,6 +47,9 @@ class FingerprintController extends RestController
|
||||
public function actionEnter($fingerPrint)
|
||||
{
|
||||
|
||||
if ( !Yii::$app->request->isPost){
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
/** @var Fingerprint $fingerPrint */
|
||||
$fingerPrint = Fingerprint::find()->andWhere(['fingerPrint' => $fingerPrint])->one();
|
||||
@ -60,8 +65,20 @@ class FingerprintController extends RestController
|
||||
throw new HttpException(404, 'Not Found');
|
||||
}
|
||||
|
||||
$card = $customer->card;
|
||||
|
||||
$tickets = Ticket::readActive($card);
|
||||
|
||||
$id_ticket = null;
|
||||
if ( isset($tickets) && count($tickets) > 0){
|
||||
$ticket = $tickets[0];
|
||||
$id_ticket = $ticket->id_ticket;
|
||||
}
|
||||
|
||||
return
|
||||
[
|
||||
'id_card' => $card->id_card,
|
||||
'id_ticket' => $id_ticket,
|
||||
'id_customer' => $customer->id_customer
|
||||
];
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user