add mover cutler door

This commit is contained in:
Roland Schneider 2017-06-17 22:01:11 +02:00
parent b9399acc2e
commit f538a82def
13 changed files with 175 additions and 44 deletions

View File

@ -405,6 +405,18 @@ class CardController extends \backend\controllers\BackendController {
$result = $command->execute();
\Yii::info("Clearing flag key ready: " . $result );
}
if ( Helper::isTicketTypeDoorAllowedCheckOn()){
\Yii::info ( "updating door allowed flag" );
$command = $connection->createCommand ( Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() );
$result = $command->execute ();
\Yii::info ( "Door allowed flag updated: ". $result );
}else{
\Yii::info ( "clearing door allowed flag" );
$command = $connection->createCommand ( Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() );
$result = $command->execute ();
\Yii::info ( "Door allowed flag cleared: ". $result );
}
}
return $this->render("recalculate");
}

View File

@ -56,13 +56,17 @@ use yii\helpers\ArrayHelper;
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/ticket_type', "Active") ]) ?>
<?= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Student") ]) ?>
<?= mkTitle("Csoportos beszedés")?>
<?= $form->field($model, 'installment_enabled')->checkbox( ['value' => 1, 'label' => Yii::t('common/ticket_type', "Csoportos beszedéses a bruttó áron felül") ]) ?>
<p>A részletek havonta kerülnek beszedésre</p>
<?= $form->field($model, 'installment_money')->textInput() ?>
<?= $form->field($model, 'installment_count')->textInput() ?>
<?php // if ( \common\components\Helper::isTicketTypeDoorAllowedCheckOn()){ ?>
<?= $form->field($model, 'door_allowed')->checkbox( ['value' => 1, 'label' => 'Forgóvilla engedi' ]) ?>
<?php //}?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket_type', 'Create') : Yii::t('common/ticket_type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>

View File

@ -21,42 +21,54 @@ $this->params['breadcrumbs'][] = $this->title;
</p>
<?php }?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
<?php
$columns = [
'name',
'price_brutto',
'max_usage_count',
'time_unit_count',
[
'attribute' =>'time_unit_type',
'value' =>'timeUnitHuman',
],
[
'attribute' => 'id_account',
'value' => 'accountName',
],
[
'attribute' =>'flag_student',
'value' =>function($model, $key, $index, $column){
return $model->isStudent() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
},
],
[
'attribute' =>'status',
'value' =>'statusHuman',
],
'attribute' =>'time_unit_type',
'value' =>'timeUnitHuman',
],
[
'attribute' => 'id_account',
'value' => 'accountName',
],
[
'attribute' =>'flag_student',
'value' =>function($model, $key, $index, $column){
return $model->isStudent() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
},
],
[
'attribute' =>'door_allowed',
'value' =>function($model, $key, $index, $column){
return $model->isDoor() ? Yii::t('common', "Yes") : Yii::t('common', "No") ;
},
'visible' => \common\components\Helper::isTicketTypeDoorAllowedCheckOn()
],
[
'attribute' =>'status',
'value' =>'statusHuman',
],
'created_at:datetime',
'updated_at:datetime',
[
'class' => 'yii\grid\ActionColumn',
'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']),
],
],
'class' => 'yii\grid\ActionColumn',
'template' => RoleDefinition::getRoleTemplate( ['admin' => '{view} {update}','employee' => '{view}' , 'reception' => '{view}']),
],
];
?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => $columns
]); ?>
</div>

View File

@ -50,6 +50,11 @@ $this->params['breadcrumbs'][] = $this->title;
'attribute' => 'status',
'value' => $model->statusHuman
],
[
'attribute' => 'door_allowed',
'value' => ( $model->isDoor() ? Yii::t('common', 'Yes' ) : Yii::t('common', 'No' ) ),
//'visible' => \common\components\Helper::isTicketTypeDoorAllowedCheckOn()
],
'created_at:datetime',
'updated_at:datetime',
[

View File

@ -348,6 +348,10 @@ class Helper {
public static function isKeyRequired() {
return \Yii::$app->params ['key_required'] == true;
}
public static function isTicketTypeDoorAllowedCheckOn() {
return \Yii::$app->params ['ticket_type_door_allowed_check_on'] == true;
}
public static function getProductSaleDefaultFocus() {
return \Yii::$app->params ['product_sale_default_focus'] ;

View File

@ -60,5 +60,6 @@ return [
*/
'key_toggle_door_log_enabled' => false,
//if key required for entry trough the door
'key_required' => true
'key_required' => true,
'ticket_type_door_allowed_check_on' => false
];

View File

@ -34,10 +34,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
const TYPE_EMPLOYEE = 50;
public static $FLAG_TICKET = 0;
public static $FLAG_DOOR = 1;
public static $FLAG_KEY = 2;
public static $FLAG_STATUS = 3;
public static $FLAG_TICKET = 0; //has valid ticket
public static $FLAG_DOOR = 1; //door in/out order
public static $FLAG_KEY = 2; //key status
public static $FLAG_STATUS = 3; //allowed/disabled
public static $FLAG_DOOR_ALLOWED = 4; //ticket type allows door
/**
* This script is used in daily scripts, to clear the flag door log status
@ -65,6 +66,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
UPDATE card set flag = ( flag & ~(1 << 1 ) ) WHERE card.type <> 50 and card.id_card = :id
";
public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG(){
return "UPDATE card set flag = ( flag & ~(1 << " . Card::$FLAG_DOOR_ALLOWED. " ) ) WHERE card.type <> 50 ";
}
public static function SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(){
return Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() . " and card.id_card = :id ";
}
/**
* @inheritdoc
*/
@ -227,6 +237,15 @@ class Card extends \common\models\BaseFitnessActiveRecord
$command = $db->createCommand(Card::$SQL_CLEARS_STATUS_DOOR_IN,[':id' => $id]);
$command->execute();
if ( Helper::isTicketTypeDoorAllowedCheckOn()) {
$command = $db->createCommand(Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
$command->execute();
}else{
$command = $db->createCommand(Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG_FOR_CARD(), [':id' => $id]);
$command->execute();
}
}
public function beforeSave($insert) {
@ -279,6 +298,11 @@ class Card extends \common\models\BaseFitnessActiveRecord
return Helper::isBitOn($this->flag_out,Card::$FLAG_KEY);
}
/**
* if flag is on, door entry is not allowed.
*/
public function isFlagDoorAllowed(){
return Helper::isBitOn($this->flag,Card::$FLAG_DOOR_ALLOWED);
}
}

View File

@ -73,8 +73,25 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
,c1.flag = case when t.id_card is null then ( c1.flag | 1 << 0 ) else ( c1.flag & ~(1 << 0) ) end
, c1.id_ticket_current = case when t.id_ticket is null then null else t.id_ticket end
WHERE c1.type <> 50 and c1.id_card = :id";
public static function SQL_UPDATE_DOOR_ALLOWED_FLAG(){
return "
UPDATE card c
LEFT JOIN ticket t on c.id_ticket_current = t.id_ticket
LEFT JOIN ticket_type tt on t.id_ticket_type = tt.id_ticket_type
set
c.flag = case when tt.door_allowed <> 1 then ( c.flag | 1 << 4 ) else ( c.flag & ~(1 << 4) ) end
WHERE c.type <> 50
";
}
public static function SQL_UPDATE_DOOR_ALLOWED_FLAG_FOR_CARD(){
return Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() . " and c.id_card = :id";
}
/**
* @inheritdoc
*/
@ -395,6 +412,4 @@ class Ticket extends \common\models\BaseFitnessActiveRecord
Card::updateCardFlagTicket($this->id_card);;
}
}

View File

@ -21,6 +21,7 @@ use yii\helpers\ArrayHelper;
* @property integer installment_enabled
* @property integer installment_count
* @property integer installment_money
* @property integer door_allowed
* @property string $created_at
* @property string $updated_at
*/
@ -38,6 +39,9 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
const INSTALLMENT_OFF = 0;
const INSTALLMENT_ON = 1;
const FLAG_DOOR_ALLOWED_OFF = 0;
const FLAG_DOOR_ALLOWED_ON = 1;
/**
* @inheritdoc
@ -104,6 +108,13 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
[['installment_money',], 'integer'],
[['installment_count',], 'integer'],
////////////////
//door_allowed
////////////////
[['door_allowed',], 'integer'],
[['door_allowed',], 'in', 'range' => [ self::FLAG_DOOR_ALLOWED_OFF, self::FLAG_DOOR_ALLOWED_ON ]],
];
}
@ -128,6 +139,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
'installment_enabled' => Yii::t('common/ticket_type', 'Részlet fizetés a brutto áron felül'),
'installment_count' => Yii::t('common/ticket_type', 'Havi részletek száma'),
'installment_money' => Yii::t('common/ticket_type', 'Havi részlet összege'),
'door_allowed' => Yii::t('common/ticket_type', 'Forgóvilla'),
];
}
@ -188,6 +200,11 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
public function isStudent(){
return $this->flag_student == ( self::FLAG_STUDENT_ON);
}
public function isDoor(){
return $this->door_allowed == ( self::FLAG_STUDENT_ON);
}
public function isInstallment(){
return $this->installment_enabled == ( self::INSTALLMENT_ON);
}

View File

@ -40,6 +40,18 @@ class TicketController extends Controller {
$result = $command->execute ();
\Yii::info ( "Clearing key status updated: ". $result );
}
if ( Helper::isTicketTypeDoorAllowedCheckOn()){
\Yii::info ( "updating door allowed flag" );
$command = $connection->createCommand ( Ticket::SQL_UPDATE_DOOR_ALLOWED_FLAG() );
$result = $command->execute ();
\Yii::info ( "Door allowed flag updated: ". $result );
}else{
\Yii::info ( "clearing door allowed flag" );
$command = $connection->createCommand ( Card::SQL_CLEAR_STATUS_DOOR_ALLOWED_FLAG() );
$result = $command->execute ();
\Yii::info ( "Door allowed flag cleared: ". $result );
}
}
/**

View File

@ -19,6 +19,8 @@ use common\models\DoorLog;
/**
* ContactForm is the model behind the contact form.
*
* @property \common\models\Card $card
*/
class ReceptionForm extends Model
{

View File

@ -48,6 +48,19 @@ $this->params['breadcrumbs'][] = $this->title;
echo Html::tag("span", "Kártya nincs tiltva - OK", ['class' => 'text-success']);
} ?>
</li>
<?php
if ( \common\components\Helper::isTicketTypeDoorAllowedCheckOn()){
?>
<li>Bérlet beléphet a forgókapun:
<?php if ($card->isFlagDoorAllowed()) {
echo Html::tag("span", "Beléphet - Nem", ['class' => 'text-danger']);
} else {
echo Html::tag("span", "Beléphet - Igen", ['class' => 'text-success']);
} ?>
</li>
<?php
}
?>
</ul>
<h2>Kilépés jelző</h2>

View File

@ -1,13 +1,8 @@
<?php
use yii\base\Object;
use common\models\Ticket;
use \frontend\models\ReceptionForm;
use common\components\Helper;
use common\models\DoorLog;
use yii\helpers\Html;
use yii\helpers\Url;
use common\models\Contract;
use common\components\Helper;
use common\models\Card;
use common\models\DoorLog;
/* @var $this yii\web\View */
/* @var $model \frontend\models\ReceptionForm */
@ -41,6 +36,8 @@ if ( isset($model->card)){
echo "&nbsp;-&nbsp;";
echo Yii::$app->formatter->asDate($ticket->end);
echo Html::endTag("div");
}else{
echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
@ -72,6 +69,19 @@ if ( isset($model->card)){
echo Html::endTag("div");
}
if (Helper::isTicketTypeDoorAllowedCheckOn()) {
if (isset($model->card) && isset($ticket) ) {
$alert = "alert " . ($model->card->isFlagDoorAllowed() ? "alert-warning" : "alert-success");
$text = "Kapun beléphet: " .($model->card->isFlagDoorAllowed() ? "nem" : "igen");
echo Html::beginTag("div",['class' => $alert ,"role"=>"alert"]);
echo Html::beginTag("strong",[ ]);
echo $text;
echo Html::endTag("strong");
echo Html::endTag("div");
}
}
if ( isset($model->contract)){
/** @var common\models\Contract $contract*/