Merge branch 'release/v0.1.20'

This commit is contained in:
Roland Schneider 2020-01-06 11:10:23 +01:00
commit 26d1a4af8e
16 changed files with 647 additions and 1 deletions

7
.gitignore vendored
View File

@ -48,3 +48,10 @@ phpunit.phar
/rest/web/assets/** /rest/web/assets/**
!/rest/web/assets/.gitkeep !/rest/web/assets/.gitkeep
/customerapi/config/*-local.php
/customerapi/runtime/logs/**
!/customerapi/runtime/.gitkeep
/customerapi/web/assets/**
!/customerapi/assets/.gitkeep

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

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

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

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

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

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

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

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

View File

@ -1,3 +1,5 @@
-0.1.20
- add fingerprint basics
-0.1.19 -0.1.19
- add payed_at/ bought at filters for transfer index and list - add payed_at/ bought at filters for transfer index and list
-0.1.18 -0.1.18

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.19', 'version' => 'v0.1.20',
'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

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

View 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;
}
*/
}

View 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;
}
*/
}

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

View File

@ -0,0 +1,19 @@
<?php
use yii\base\Model;
class FingerPrintEnterForm extends Model
{
public $fingerPrint;
public function enterDoor()
{
}
}