add feature word_typed_listener_allowed_only_for_empty_customerf

This commit is contained in:
Schneider Roland 2023-03-24 17:08:51 +01:00
parent beb3c3944e
commit 89fe6a37c1
4 changed files with 35 additions and 17 deletions

View File

@ -552,4 +552,11 @@ class Helper {
return Helper::getArrayValue(\Yii::$app->params ,'door_pass_validity_interval_minutes','10'); return Helper::getArrayValue(\Yii::$app->params ,'door_pass_validity_interval_minutes','10');
} }
public static function isWordTypedListenerAllowedOnlyForEmptyCustomer(){
$key = "word_typed_listener_allowed_only_for_empty_customer";
// return Helper::getArrayValue(\Yii::$app->params ,$key,'0') === '1';
return true;
}
} }

View File

@ -1,5 +1,6 @@
<?php <?php
$REST_ALLOW_VERIFY_ONLY=getenv('FITNESS_REST_ALLOW_VERIFY_ONLY'); $REST_ALLOW_VERIFY_ONLY=getenv('FITNESS_REST_ALLOW_VERIFY_ONLY');
$FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER=getenv('FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER');
return [ return [
'user.passwordResetTokenExpire' => 3600, 'user.passwordResetTokenExpire' => 3600,
@ -23,5 +24,6 @@ return [
'reception_show_stock' => false, 'reception_show_stock' => false,
'login_admin_email' => false, 'login_admin_email' => false,
'warn_ticket_expire_in_usage_count' => 10, 'warn_ticket_expire_in_usage_count' => 10,
'rest_allow_verify_only' => $REST_ALLOW_VERIFY_ONLY === 'true' 'rest_allow_verify_only' => $REST_ALLOW_VERIFY_ONLY === 'true',
'word_typed_listener_allowed_only_for_empty_customer' => $FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER,
]; ];

View File

@ -26,6 +26,7 @@ AppAsset::register($this);
<title><?= Html::encode($this->title) ?></title> <title><?= Html::encode($this->title) ?></title>
<script> <script>
var reception_card_url = '<?php echo Url::toRoute('customer/reception');?>'; var reception_card_url = '<?php echo Url::toRoute('customer/reception');?>';
var isWordTypedListenerAllowedOnlyForEmptyCustomer = <?= \common\components\Helper::isWordTypedListenerAllowedOnlyForEmptyCustomer() ? 'true' : 'false' ?>
</script> </script>
<?php $this->head() ?> <?php $this->head() ?>
</head> </head>
@ -34,17 +35,17 @@ AppAsset::register($this);
<div class="wrap"> <div class="wrap">
<?php <?php
// with growl // with growl
echo AlertBlock::widget([ echo AlertBlock::widget([
'useSessionFlash' => true, 'useSessionFlash' => true,
'type' => AlertBlock::TYPE_GROWL, 'type' => AlertBlock::TYPE_GROWL,
'delay' => '1' 'delay' => '1'
]); ]);
$menuStruct = new FrontendMenuStructure(); $menuStruct = new FrontendMenuStructure();
$items = $menuStruct->run(); $items = $menuStruct->run();
NavBar::begin([ NavBar::begin([
'brandLabel' => 'Web Recepció', 'brandLabel' => 'Web Recepció',
'brandUrl' => Yii::$app->homeUrl, 'brandUrl' => Yii::$app->homeUrl,

View File

@ -4,7 +4,7 @@ var seq = '';
var socket; var socket;
$(document).ready( $(document).ready(
function(){ function(){
$("input[name='number']").on('focus', function (e) { $("input[name='number']").on('focus', function (e) {
$(this) $(this)
.one('mouseup', function () { .one('mouseup', function () {
@ -13,7 +13,7 @@ $(document).ready(
}) })
.select(); .select();
}); });
addDocumentKeypressedListener(); addDocumentKeypressedListener();
} }
); );
@ -23,9 +23,9 @@ function addDocumentKeypressedListener(){
$( document ).keypress(function( event ) { $( document ).keypress(function( event ) {
var tag = event.target.tagName.toLowerCase(); var tag = event.target.tagName.toLowerCase();
if ( tag != 'input' && tag != 'textarea' && tag != 'select') { if ( tag != 'input' && tag != 'textarea' && tag != 'select') {
resetSequenceIfToMuchTimePassedOrEnterWasPressed(event); resetSequenceIfToMuchTimePassedOrEnterWasPressed(event);
if ( event.which == 13 ) { if ( event.which == 13 ) {
enterPressed = 1; enterPressed = 1;
if ( seq ){ if ( seq ){
@ -35,19 +35,27 @@ function addDocumentKeypressedListener(){
appendCharToSeq(event); appendCharToSeq(event);
} }
} }
}); });
$( document ).on( "wordtyped", function( event, data ) { $( document ).on( "wordtyped", function( event, data ) {
var word; var word;
word = data.word; word = data.word;
if ( word && word.length > 0){ if ( word && word.length > 0){
var redirectAllowed = true;
location.href= reception_card_url +'&number=' + word; if ( isWordTypedListenerAllowedOnlyForEmptyCustomer ){
if ( location.href !== reception_card_url ){
redirectAllowed = false;
console.info("disalbling customer redirect. reason: isWordTypedListenerAllowedOnlyForEmptyCustomer = true")
}
}
if ( redirectAllowed){
location.href= reception_card_url +'&number=' + word;
}
} }
}); });
function resetSequenceIfToMuchTimePassedOrEnterWasPressed(){ function resetSequenceIfToMuchTimePassedOrEnterWasPressed(){
var prevDate, timePassed; var prevDate, timePassed;
prevDate= keyDate; prevDate= keyDate;
@ -58,7 +66,7 @@ function addDocumentKeypressedListener(){
enterPressed = 0; enterPressed = 0;
} }
} }
function appendCharToSeq(event){ function appendCharToSeq(event){
var code,s; var code,s;
code = event.which; code = event.which;
@ -68,7 +76,7 @@ function addDocumentKeypressedListener(){
seq += s; seq += s;
} }
} }
} }