Merge branch 'feature/fingerprint' into develop
This commit is contained in:
commit
d95abc0cb9
121
backend/controllers/FingerprintController.php
Normal file
121
backend/controllers/FingerprintController.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use common\models\Fingerprint;
|
||||
use backend\models\FingerprintSearch;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
|
||||
/**
|
||||
* FingerprintController implements the CRUD actions for Fingerprint model.
|
||||
*/
|
||||
class FingerprintController extends Controller
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'delete' => ['post'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all Fingerprint models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$searchModel = new FingerprintSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a single Fingerprint model.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionView($id)
|
||||
{
|
||||
return $this->render('view', [
|
||||
'model' => $this->findModel($id),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Fingerprint model.
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
{
|
||||
$model = new Fingerprint();
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_fingerprint]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing Fingerprint model.
|
||||
* If update is successful, the browser will be redirected to the 'view' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionUpdate($id)
|
||||
{
|
||||
$model = $this->findModel($id);
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_fingerprint]);
|
||||
} else {
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Fingerprint model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
* @param integer $id
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionDelete($id)
|
||||
{
|
||||
$this->findModel($id)->delete();
|
||||
|
||||
return $this->redirect(['index']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the Fingerprint model based on its primary key value.
|
||||
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||
* @param integer $id
|
||||
* @return Fingerprint the loaded model
|
||||
* @throws NotFoundHttpException if the model cannot be found
|
||||
*/
|
||||
protected function findModel($id)
|
||||
{
|
||||
if (($model = Fingerprint::findOne($id)) !== null) {
|
||||
return $model;
|
||||
} else {
|
||||
throw new NotFoundHttpException('The requested page does not exist.');
|
||||
}
|
||||
}
|
||||
}
|
||||
69
backend/models/FingerprintSearch.php
Normal file
69
backend/models/FingerprintSearch.php
Normal file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Fingerprint;
|
||||
|
||||
/**
|
||||
* FingerprintSearch represents the model behind the search form about `common\models\Fingerprint`.
|
||||
*/
|
||||
class FingerprintSearch extends Fingerprint
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_fingerprint', 'id_customer'], 'integer'],
|
||||
[['fingerprint', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Fingerprint::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_fingerprint' => $this->id_fingerprint,
|
||||
'id_customer' => $this->id_customer,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'fingerprint', $this->fingerprint]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
29
backend/views/fingerprint/_form.php
Normal file
29
backend/views/fingerprint/_form.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Fingerprint */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="fingerprint-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'id_customer')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'fingerprint')->textarea(['rows' => 6]) ?>
|
||||
|
||||
<?= $form->field($model, 'created_at')->textInput() ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at')->textInput() ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/fingerprint', 'Create') : Yii::t('common/fingerprint', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
35
backend/views/fingerprint/_search.php
Normal file
35
backend/views/fingerprint/_search.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\FingerprintSearch */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
?>
|
||||
|
||||
<div class="fingerprint-search">
|
||||
|
||||
<?php $form = ActiveForm::begin([
|
||||
'action' => ['index'],
|
||||
'method' => 'get',
|
||||
]); ?>
|
||||
|
||||
<?= $form->field($model, 'id_fingerprint') ?>
|
||||
|
||||
<?= $form->field($model, 'id_customer') ?>
|
||||
|
||||
<?= $form->field($model, 'fingerprint') ?>
|
||||
|
||||
<?= $form->field($model, 'created_at') ?>
|
||||
|
||||
<?= $form->field($model, 'updated_at') ?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton(Yii::t('common/fingerprint', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::resetButton(Yii::t('common/fingerprint', 'Reset'), ['class' => 'btn btn-default']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
21
backend/views/fingerprint/create.php
Normal file
21
backend/views/fingerprint/create.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Fingerprint */
|
||||
|
||||
$this->title = Yii::t('common/fingerprint', 'Create Fingerprint');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="fingerprint-create">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
38
backend/views/fingerprint/index.php
Normal file
38
backend/views/fingerprint/index.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $searchModel backend\models\FingerprintSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = Yii::t('common/fingerprint', 'Fingerprints');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="fingerprint-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/fingerprint', 'Create Fingerprint'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
|
||||
'id_fingerprint',
|
||||
'id_customer',
|
||||
'fingerprint:ntext',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
|
||||
</div>
|
||||
23
backend/views/fingerprint/update.php
Normal file
23
backend/views/fingerprint/update.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Fingerprint */
|
||||
|
||||
$this->title = Yii::t('common/fingerprint', 'Update {modelClass}: ', [
|
||||
'modelClass' => 'Fingerprint',
|
||||
]) . ' ' . $model->id_fingerprint;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = ['label' => $model->id_fingerprint, 'url' => ['view', 'id' => $model->id_fingerprint]];
|
||||
$this->params['breadcrumbs'][] = Yii::t('common/fingerprint', 'Update');
|
||||
?>
|
||||
<div class="fingerprint-update">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
39
backend/views/fingerprint/view.php
Normal file
39
backend/views/fingerprint/view.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\DetailView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model common\models\Fingerprint */
|
||||
|
||||
$this->title = $model->id_fingerprint;
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/fingerprint', 'Fingerprints'), 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="fingerprint-view">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a(Yii::t('common/fingerprint', 'Update'), ['update', 'id' => $model->id_fingerprint], ['class' => 'btn btn-primary']) ?>
|
||||
<?= Html::a(Yii::t('common/fingerprint', 'Delete'), ['delete', 'id' => $model->id_fingerprint], [
|
||||
'class' => 'btn btn-danger',
|
||||
'data' => [
|
||||
'confirm' => Yii::t('common/fingerprint', 'Are you sure you want to delete this item?'),
|
||||
'method' => 'post',
|
||||
],
|
||||
]) ?>
|
||||
</p>
|
||||
|
||||
<?= DetailView::widget([
|
||||
'model' => $model,
|
||||
'attributes' => [
|
||||
'id_fingerprint',
|
||||
'id_customer',
|
||||
'fingerprint:ntext',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
],
|
||||
]) ?>
|
||||
|
||||
</div>
|
||||
67
common/models/Fingerprint.php
Normal file
67
common/models/Fingerprint.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\helpers\ArrayHelper;
|
||||
|
||||
/**
|
||||
* This is the model class for table "fingerprint".
|
||||
*
|
||||
* @property integer $id_fingerprint
|
||||
* @property integer $id_customer
|
||||
* @property string $fingerprint
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Fingerprint extends ActiveRecord
|
||||
{
|
||||
public function behaviors()
|
||||
{
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); },
|
||||
'updatedAtAttribute' => false,
|
||||
]
|
||||
], parent::behaviors());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'fingerprint';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_customer'], 'integer'],
|
||||
[['fingerprint'], 'string'],
|
||||
[['created_at', 'updated_at'], 'required'],
|
||||
[['created_at', 'updated_at'], 'safe']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_fingerprint' => Yii::t('common/fingerprint', 'Id Fingerprint'),
|
||||
'id_customer' => Yii::t('common/fingerprint', 'Id Customer'),
|
||||
'fingerprint' => Yii::t('common/fingerprint', 'Fingerprint'),
|
||||
'created_at' => Yii::t('common/fingerprint', 'Created At'),
|
||||
'updated_at' => Yii::t('common/fingerprint', 'Updated At'),
|
||||
];
|
||||
}
|
||||
}
|
||||
54
console/migrations/m200103_104020_add_table_fingerprint.php
Normal file
54
console/migrations/m200103_104020_add_table_fingerprint.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m200103_104020_add_table_fingerprint
|
||||
*/
|
||||
class m200103_104020_add_table_fingerprint extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('{{%fingerprint}}', [
|
||||
'id_fingerprint' => $this->primaryKey(),
|
||||
'id_customer' => $this->integer(11),
|
||||
'fingerprint' => $this->text(),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
echo "m200103_104020_add_table_fingerprint cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m200103_104020_add_table_fingerprint cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
52
console/migrations/m200106_093107_add_user_fingerprint.php
Normal file
52
console/migrations/m200106_093107_add_user_fingerprint.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
use common\models\User;
|
||||
use yii\db\Migration;
|
||||
|
||||
/**
|
||||
* Class m200106_093107_add_user_fingerprint
|
||||
*/
|
||||
class m200106_093107_add_user_fingerprint extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeUp()
|
||||
{
|
||||
$user = new User();
|
||||
$user->username = 'fingerprint_system';
|
||||
$user->email = 'fingerprint_system@rocho-net.hu';
|
||||
$user->setPassword('Vn?y0c?DI|Ar6Kfvmf?$');
|
||||
$user->generateAuthKey();
|
||||
$user->save();
|
||||
|
||||
$role = Yii::$app->authManager->createRole('fingerprint_system');
|
||||
Yii::$app->authManager->add($role);
|
||||
Yii::$app->authManager->assign($role, $user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function safeDown()
|
||||
{
|
||||
echo "m200106_093107_add_user_fingerprint cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use up()/down() to run migration code without a transaction.
|
||||
public function up()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m200106_093107_add_user_fingerprint cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
70
rest/controllers/FingerprintController.php
Normal file
70
rest/controllers/FingerprintController.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: rocho
|
||||
* Date: 2018.08.29.
|
||||
* Time: 21:58
|
||||
*/
|
||||
|
||||
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\web\BadRequestHttpException;
|
||||
use yii\web\HttpException;
|
||||
use yii\web\NotFoundHttpException;
|
||||
|
||||
class FingerprintController extends RestController
|
||||
{
|
||||
|
||||
public function actionAdd($idCustomer,$fingerPrint)
|
||||
{
|
||||
$customer = Customer::findOne($idCustomer);
|
||||
|
||||
if ( null === $customer) {
|
||||
throw new HttpException(404, 'Not Found');
|
||||
}
|
||||
|
||||
// Fingerprint::deleteAll(['id_customer' =>$idCustomer]);
|
||||
|
||||
$fingerPrintModel = new Fingerprint();
|
||||
$fingerPrintModel->id_customer = $customer->id_customer;
|
||||
$fingerPrintModel->fingerprint = $fingerPrint;
|
||||
$fingerPrintModel->save(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string the sha string of the fingerprint $fingerPrint
|
||||
* @return array the response
|
||||
* @throws HttpException on any error
|
||||
*/
|
||||
public function actionEnter($fingerPrint)
|
||||
{
|
||||
|
||||
|
||||
/** @var Fingerprint $fingerPrint */
|
||||
$fingerPrint = Fingerprint::find()->andWhere(['fingerPrint' => $fingerPrint])->one();
|
||||
|
||||
if ( null === $fingerPrint) {
|
||||
throw new HttpException(404, 'Not Found');
|
||||
}
|
||||
|
||||
$customer = Customer::findOne($fingerPrint->id_customer);
|
||||
|
||||
|
||||
if ( null === $customer) {
|
||||
throw new HttpException(404, 'Not Found');
|
||||
}
|
||||
|
||||
return
|
||||
[
|
||||
'id_customer' => $customer->id_customer
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
19
rest/models/FingerPrintEnterForm.php
Normal file
19
rest/models/FingerPrintEnterForm.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
use yii\base\Model;
|
||||
|
||||
class FingerPrintEnterForm extends Model
|
||||
{
|
||||
|
||||
public $fingerPrint;
|
||||
|
||||
|
||||
|
||||
public function enterDoor()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user