Merge branch 'release/v.0.1.21'

This commit is contained in:
Roland Schneider 2020-01-07 20:21:31 +01:00
commit 363a40a45c
10 changed files with 323 additions and 13 deletions

View File

@ -1,3 +1,5 @@
-0.1.21
- add fingerprint frontend gui
-0.1.20 -0.1.20
- add fingerprint basics - add fingerprint basics
-0.1.19 -0.1.19

View File

@ -5,7 +5,7 @@ return [
'supportEmail' => 'rocho02@gmail.com', 'supportEmail' => 'rocho02@gmail.com',
'infoEmail' => 'info@rocho-net.hu', 'infoEmail' => 'info@rocho-net.hu',
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
'version' => 'v0.1.20', 'version' => 'v0.1.21',
'company' => 'movar',//gyor 'company' => 'movar',//gyor
'company_name' => "Freimann Kft.", 'company_name' => "Freimann Kft.",
'product_visiblity' => 'account',// on reception which products to display. account or global 'product_visiblity' => 'account',// on reception which products to display. account or global

View File

@ -23,7 +23,9 @@ class Fingerprint extends ActiveRecord
return ArrayHelper::merge([ return ArrayHelper::merge([
[ [
'class' => TimestampBehavior::className(), '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, 'updatedAtAttribute' => false,
] ]
], parent::behaviors()); ], parent::behaviors());
@ -59,7 +61,7 @@ class Fingerprint extends ActiveRecord
return [ return [
'id_fingerprint' => Yii::t('common/fingerprint', 'Id Fingerprint'), 'id_fingerprint' => Yii::t('common/fingerprint', 'Id Fingerprint'),
'id_customer' => Yii::t('common/fingerprint', 'Id Customer'), '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'), 'created_at' => Yii::t('common/fingerprint', 'Created At'),
'updated_at' => Yii::t('common/fingerprint', 'Updated At'), 'updated_at' => Yii::t('common/fingerprint', 'Updated At'),
]; ];

View 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
]);
}
}

View 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'],
];
}
}

View 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,
]);
}
}

View File

@ -5,8 +5,9 @@ use yii\helpers\Url;
<?php <?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')); $todayDateTime = Yii::$app->formatter->asDatetime(strtotime('today UTC'));
@ -23,6 +24,7 @@ $items = [
[ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]], [ 'Kosár', ['transfer/customer-cart', 'id_card' => $card->id_card ]],
[ 'Kártya', ['card/info', '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 ]], [ '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 ]],
]; ];

View 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>

View 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}',
]
]
]);
?>

View File

@ -1,4 +1,5 @@
<?php <?php /** @noinspection PhpUnused */
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
* User: rocho * User: rocho
@ -9,18 +10,21 @@
namespace rest\controllers; namespace rest\controllers;
use common\components\Helper;
use common\models\Card;
use common\models\Customer; use common\models\Customer;
use common\models\Fingerprint; use common\models\Fingerprint;
use common\models\Ticket; use common\models\Ticket;
use Yii;
use yii\web\BadRequestHttpException; use yii\web\BadRequestHttpException;
use yii\web\HttpException; use yii\web\HttpException;
use yii\web\NotFoundHttpException;
class FingerprintController extends RestController class FingerprintController extends RestController
{ {
/**
* @param $idCustomer
* @param $fingerPrint
* @throws HttpException
*/
public function actionAdd($idCustomer,$fingerPrint) public function actionAdd($idCustomer,$fingerPrint)
{ {
$customer = Customer::findOne($idCustomer); $customer = Customer::findOne($idCustomer);
@ -29,8 +33,6 @@ class FingerprintController extends RestController
throw new HttpException(404, 'Not Found'); throw new HttpException(404, 'Not Found');
} }
// Fingerprint::deleteAll(['id_customer' =>$idCustomer]);
$fingerPrintModel = new Fingerprint(); $fingerPrintModel = new Fingerprint();
$fingerPrintModel->id_customer = $customer->id_customer; $fingerPrintModel->id_customer = $customer->id_customer;
$fingerPrintModel->fingerprint = $fingerPrint; $fingerPrintModel->fingerprint = $fingerPrint;
@ -45,6 +47,9 @@ class FingerprintController extends RestController
public function actionEnter($fingerPrint) public function actionEnter($fingerPrint)
{ {
if ( !Yii::$app->request->isPost){
throw new BadRequestHttpException();
}
/** @var Fingerprint $fingerPrint */ /** @var Fingerprint $fingerPrint */
$fingerPrint = Fingerprint::find()->andWhere(['fingerPrint' => $fingerPrint])->one(); $fingerPrint = Fingerprint::find()->andWhere(['fingerPrint' => $fingerPrint])->one();
@ -60,8 +65,20 @@ class FingerprintController extends RestController
throw new HttpException(404, 'Not Found'); 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 return
[ [
'id_card' => $card->id_card,
'id_ticket' => $id_ticket,
'id_customer' => $customer->id_customer 'id_customer' => $customer->id_customer
]; ];