add fingerpint frontend gui

This commit is contained in:
2020-01-07 20:16:10 +01:00
parent c3fd9ff58a
commit c92166e11d
8 changed files with 320 additions and 12 deletions

View File

@@ -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
];