#1: Log Card Read In Botond

This commit is contained in:
Roland Schneider 2018-02-07 08:23:26 +01:00
parent acb5b040c5
commit cf08823d3f
13 changed files with 149 additions and 54 deletions

View File

@ -5,9 +5,7 @@ namespace backend\controllers;
use Yii;
use common\models\Account;
use backend\models\AccountSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* AccountController implements the CRUD actions for Account model.
@ -60,6 +58,7 @@ class AccountController extends \backend\controllers\BackendController
* Displays a single Account model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
*/
public function actionView($id)
{
@ -91,6 +90,7 @@ class AccountController extends \backend\controllers\BackendController
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException
*/
public function actionUpdate($id)
{

View File

@ -19,6 +19,8 @@ use common\models\Account;
<?= $form->field($model, 'type')->dropDownList(Account::types()) ?>
<?= $form->field($model, 'log_card_read_in_reception')->checkbox([], false) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/account', 'Create') : Yii::t('common/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

View File

@ -22,7 +22,9 @@ $this->params['breadcrumbs'][] = $this->title;
</p>
<?php }?>
<?= GridView::widget([
<?=
/** @noinspection PhpUnhandledExceptionInspection */
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'name',
@ -34,6 +36,10 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'type',
'value' => 'typeHuman',
],
[
'attribute' => 'log_card_read_in_reception',
'value' => function($model) { return $model->log_card_read_in_reception == '1' ? 'Igen' : 'Nem'; }
],
'created_at:datetime',
'updated_at:datetime',
@ -42,6 +48,7 @@ $this->params['breadcrumbs'][] = $this->title;
],
],
]); ?>
]);
?>
</div>

View File

@ -21,7 +21,8 @@ $this->params['breadcrumbs'][] = $this->title;
</p>
<?php }?>
<?= DetailView::widget([
<?= /** @noinspection PhpUnhandledExceptionInspection */
DetailView::widget([
'model' => $model,
'attributes' => [
'name',
@ -34,6 +35,10 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'type',
'value' => $model->typeHuman
],
[
'attribute' => 'log_card_read_in_reception',
'value' => $model->log_card_read_in_reception == '1' ? 'Igen' : 'Nem'
],
'created_at:datetime',
'updated_at:datetime',
],

View File

@ -35,4 +35,5 @@ return [
'Update {modelClass}: ' => '{modelClass} módosítása: ',
'Updated At' => 'Módosítás ideje',
'Visible for all' => 'Mindenkinek látható',
'Log Card Read in Reception' => 'Kártya olvasás logolása a recepción'
];

View File

@ -17,6 +17,7 @@ use yii\helpers\ArrayHelper;
* @property integer $type
* @property string $created_at
* @property string $updated_at
* @property integer $log_card_read_in_reception
*/
class Account extends \yii\db\ActiveRecord
{
@ -55,7 +56,7 @@ class Account extends \yii\db\ActiveRecord
return [
[['name', 'type'], 'required'],
[['name', ], 'unique'],
[['status', 'type'], 'integer'],
[['status', 'type','log_card_read_in_reception'], 'integer'],
[['name'], 'string', 'max' => 64]
];
}
@ -72,6 +73,7 @@ class Account extends \yii\db\ActiveRecord
'type' => Yii::t('common/account', 'Type'),
'created_at' => Yii::t('common/account', 'Created At'),
'updated_at' => Yii::t('common/account', 'Updated At'),
'log_card_read_in_reception' => Yii::t('common/account', 'Log Card Read in Reception'),
];
}
@ -115,6 +117,19 @@ class Account extends \yii\db\ActiveRecord
return $this->status == self::STATUS_DELETED;
}
/**
* When this account is the current default account,
* and this flag is turned on, then if a card will be
* read in the reception masks , than we will care a doorlog
* into the database.
* Use case is example "Botond", where there is no
* three arm gate, but we want to track the customers.
* @return bool
*/
public function isLogCardReadInReceptionOn(){
return $this->log_card_read_in_reception == 1;
}
/**
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
* @param null $forceIncludeAccount the next account should be included too, even if it is not
@ -206,4 +221,6 @@ class Account extends \yii\db\ActiveRecord
return ArrayHelper::map( $accounts,'id_account','name' );
}
}

View File

@ -11,6 +11,7 @@ use Yii;
* @property integer $id_user
* @property integer $id_partner_card
* @property integer $id_proposer
* @property integer $id_image
* @property string $name
* @property string $email
* @property string $password

View File

@ -0,0 +1,28 @@
<?php
use yii\db\Migration;
class m180206_174419_alter_table_account_add_column_log_card_read_in_reception extends Migration
{
public function up()
{
$this->addColumn(\common\models\Account::tableName(), "log_card_read_in_reception", $this->boolean() );
}
public function down()
{
$this->dropColumn(\common\models\Account::tableName(),"log_card_read_in_reception");
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -37,6 +37,8 @@ RUN a2enmod rewrite
COPY 000-default.conf /etc/apache2/sites-available/
COPY index.html /var/www/html/
# Ports
EXPOSE 80
@ -52,6 +54,7 @@ RUN FILE=/etc/php/7.0/apache2/php.ini \
&& echo "\nxdebug.remote_connect_back=1 " >> $FILE \
&& echo "\n" >> $FILE
ENV XDEBUG_CONFIG="idekey=PHPSTORM"
# Default command

View File

@ -0,0 +1,11 @@
<html>
<head>
</head>
<body>
<a href="fitness_web/backend/web/index.php">Fitness Web Backend</a>
<br>
<a href="fitness_web/frontend/web/index.php">Fitness Web Frontend</a>
</body>
</html>

View File

@ -10,7 +10,7 @@ return [
'id' => 'app-frontend',
'name' =>'Fitness recepció',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log','assetsAutoCompress'],
'bootstrap' => ['log'],
'controllerNamespace' => 'frontend\controllers',
'components' => [
'assetsAutoCompress' =>

View File

@ -6,6 +6,7 @@ use frontend\models\TowelForm;
use Yii;
use common\models\Customer;
use frontend\models\ReceptionForm;
use yii\base\InvalidConfigException;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
@ -54,7 +55,11 @@ class CustomerController extends Controller
$model->number = $number;
$model->readCard();
// $model->mkDoorLog();
if ( $model->defaultAccount && $model->defaultAccount->isLogCardReadInReceptionOn()) {
$model->mkDoorLog();
}
if ( $model->isFreeCard() ){
return $this->redirect([ 'create', 'number' => $model->card->number ]);
@ -91,7 +96,9 @@ class CustomerController extends Controller
/**
* Creates a new Customer model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @param null $number the card number literal
* @return mixed
* @throws \yii\web\HttpException
*/
public function actionCreate($number = null)
{
@ -136,10 +143,13 @@ class CustomerController extends Controller
* @return mixed
* @throws NotFoundHttpException
* @internal param int $id
* @throws \yii\web\HttpException
*/
public function actionUpdate($number = null)
{
$card = null;
/** @var \backend\models\CustomerUpdate $model */
$model = null;
$receptionForm = new ReceptionForm();
@ -160,7 +170,12 @@ class CustomerController extends Controller
}
try {
$model->birthdate = isset($model->birthdate) ? Yii::$app->formatter->asDate($model->birthdate) : '';
} catch (InvalidConfigException $e) {
\Yii::error("Failed to format date: " . $e->getMessage());
$model->birthdate = '';
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
@ -187,6 +202,11 @@ class CustomerController extends Controller
}
/**
* Save images as binary data.
* @param $model \common\models\Customer
* @throws \yii\web\HttpException
*/
protected function saveBinaryImage($model) {
if ( !empty($model->photo_data)){
$encoded_data = $model->photo_data;

View File

@ -2,10 +2,8 @@
namespace frontend\models;
use Yii;
use yii\base\Model;
use common\models\Card;
use common\models\Customer;
use common\models\Ticket;
use common\models\Account;
use common\models\CardSearch;
@ -21,6 +19,8 @@ use common\models\DoorLog;
* ContactForm is the model behind the contact form.
*
* @property \common\models\Card $card
* @property \common\models\Account $defaultAccount
* @property \common\models\AccountState $lastCassaState
*/
class ReceptionForm extends Model
{
@ -74,10 +74,6 @@ class ReceptionForm extends Model
$this->card = $query->one();
if ( $this->card == null ){
}
if ( $this->card != null ){
$this->customer = $this->card->customer;
$this->readValidTickets();
@ -85,6 +81,7 @@ class ReceptionForm extends Model
}
public function readCard(){
$this->number = Helper::fixAsciiChars( $this->number );
@ -122,8 +119,11 @@ class ReceptionForm extends Model
}
public function mkDoorLog(){
if ( !isset($this->card)){
return;
}