diff --git a/common/components/Helper.php b/common/components/Helper.php index 9160de0..f3d70be 100644 --- a/common/components/Helper.php +++ b/common/components/Helper.php @@ -552,4 +552,11 @@ class Helper { 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; + } + + } diff --git a/environments/cutlergyor/apache2/config/common/config/params-local.php b/environments/cutlergyor/apache2/config/common/config/params-local.php index 20c48c3..e629142 100644 --- a/environments/cutlergyor/apache2/config/common/config/params-local.php +++ b/environments/cutlergyor/apache2/config/common/config/params-local.php @@ -1,5 +1,6 @@ 3600, @@ -23,5 +24,6 @@ return [ 'reception_show_stock' => false, 'login_admin_email' => false, '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, ]; diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index c2ae89f..78c03f3 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -26,6 +26,7 @@ AppAsset::register($this); <?= Html::encode($this->title) ?> head() ?> @@ -34,17 +35,17 @@ AppAsset::register($this);
true, 'type' => AlertBlock::TYPE_GROWL, 'delay' => '1' ]); - + $menuStruct = new FrontendMenuStructure(); $items = $menuStruct->run(); - + NavBar::begin([ 'brandLabel' => 'Web Recepció', 'brandUrl' => Yii::$app->homeUrl, diff --git a/frontend/web/js/app.js b/frontend/web/js/app.js index 213a416..fa2a10c 100644 --- a/frontend/web/js/app.js +++ b/frontend/web/js/app.js @@ -4,7 +4,7 @@ var seq = ''; var socket; $(document).ready( function(){ - + $("input[name='number']").on('focus', function (e) { $(this) .one('mouseup', function () { @@ -13,7 +13,7 @@ $(document).ready( }) .select(); }); - + addDocumentKeypressedListener(); } ); @@ -23,9 +23,9 @@ function addDocumentKeypressedListener(){ $( document ).keypress(function( event ) { var tag = event.target.tagName.toLowerCase(); if ( tag != 'input' && tag != 'textarea' && tag != 'select') { - + resetSequenceIfToMuchTimePassedOrEnterWasPressed(event); - + if ( event.which == 13 ) { enterPressed = 1; if ( seq ){ @@ -35,19 +35,27 @@ function addDocumentKeypressedListener(){ appendCharToSeq(event); } } - }); - + }); + $( document ).on( "wordtyped", function( event, data ) { var word; word = data.word; if ( word && word.length > 0){ - - location.href= reception_card_url +'&number=' + word; - - + var redirectAllowed = true; + 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(){ var prevDate, timePassed; prevDate= keyDate; @@ -58,7 +66,7 @@ function addDocumentKeypressedListener(){ enterPressed = 0; } } - + function appendCharToSeq(event){ var code,s; code = event.which; @@ -68,7 +76,7 @@ function addDocumentKeypressedListener(){ seq += s; } } - + }