diff --git a/common/manager/KeyDoorManager.php b/common/manager/KeyDoorManager.php index 9d4553c..009036d 100644 --- a/common/manager/KeyDoorManager.php +++ b/common/manager/KeyDoorManager.php @@ -363,25 +363,8 @@ class KeyDoorManager extends BaseObject Yii::info("$ctx->requestId: active ticket count:" . count($activeTickets)); /** @var Ticket $ticket */ $ticket = null; - if (isset($activeTickets) && count($activeTickets) > 0) { - for ( $i = 0; ($i < count($activeTickets)) && !isset($ticket); $i++){ - /**@var $currentTicket Ticket **/ - $currentTicket = $activeTickets[$i]; - if ( $currentTicket->usage_count < $currentTicket->max_usage_count){ - $ticket = $currentTicket; - } - } - } - if (!isset($ticket)) { - throw new FitnessException( - "$ctx->requestId: No active ticket found for:" . $ctx->card->number, - FitnessException::TYPE_BAD_REQUEST, - "NOT_FOUND_ACTIVE_TICKET", - $ctx - ); - } - $ctx->ticket = $ticket; - Yii::info("$ctx->requestId: ticket {$ticket->id_ticket} loaded in sec " . $stopWatch->split()); + + // load customer $customer = $ctx->card->customer; @@ -400,6 +383,27 @@ class KeyDoorManager extends BaseObject // if direction is in, check if usage count must be increased if ($ctx->direction == DoorLog::$DIRECTION_IN) { + if (isset($activeTickets) && count($activeTickets) > 0) { + for ( $i = 0; ($i < count($activeTickets)) && !isset($ticket); $i++){ + /**@var $currentTicket Ticket **/ + $currentTicket = $activeTickets[$i]; + if ( $currentTicket->usage_count < $currentTicket->max_usage_count){ + $ticket = $currentTicket; + } + } + } + + if (!isset($ticket)) { + throw new FitnessException( + "$ctx->requestId: No active ticket found for:" . $ctx->card->number, + FitnessException::TYPE_BAD_REQUEST, + "NOT_FOUND_ACTIVE_TICKET", + $ctx + ); + } + $ctx->ticket = $ticket; + Yii::info("$ctx->requestId: ticket {$ticket->id_ticket} loaded in sec " . $stopWatch->split()); + // Key required if (!isset($ctx->key)) { throw new FitnessException( @@ -544,7 +548,26 @@ class KeyDoorManager extends BaseObject $ctx->virtualKey->save(false); } - // set ticket move out counter + if (isset($activeTickets) && count($activeTickets) > 0) { + for ( $i = 0; ($i < count($activeTickets)) && !isset($ticket); $i++){ + /**@var $currentTicket Ticket **/ + $currentTicket = $activeTickets[$i]; + if ( $currentTicket->count_move_out < $currentTicket->max_usage_count && $currentTicket->count_move_out != $currentTicket->usage_count){ + $ticket = $currentTicket; + } + } + } + + if (!isset($ticket)) { + throw new FitnessException( + "$ctx->requestId: No active ticket found for:" . $ctx->card->number, + FitnessException::TYPE_BAD_REQUEST, + "NOT_FOUND_ACTIVE_TICKET", + $ctx + ); + } + $ctx->ticket = $ticket; + $ticket->count_move_out = $ticket->usage_count; if (!$ctx->verifyOnly) { $ticket->save(false); diff --git a/common/models/Ticket.php b/common/models/Ticket.php index 234a0c5..c1f6902 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -24,6 +24,7 @@ use yii\web\HttpException; * @property string $end * @property integer $max_usage_count * @property integer $usage_count + * @property integer $count_move_out * @property integer $status * @property integer $price_brutto * @property integer $part eddig a részletig kell kifizetve lenni diff --git a/docker/fitness/.env b/docker/fitness/.env index 7ea26a6..bd822b8 100644 --- a/docker/fitness/.env +++ b/docker/fitness/.env @@ -1,3 +1,3 @@ FITNESS_REST_ALLOW_VERIFY_ONLY=true #DOOR_ENTRY_STRATEGY=door_pass -FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER=0 \ No newline at end of file +FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER=1 \ No newline at end of file diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php index 78c03f3..2238170 100644 --- a/frontend/views/layouts/main.php +++ b/frontend/views/layouts/main.php @@ -26,7 +26,7 @@ AppAsset::register($this); <?= Html::encode($this->title) ?> head() ?> diff --git a/frontend/web/js/app.js b/frontend/web/js/app.js index fa2a10c..9ca3a10 100644 --- a/frontend/web/js/app.js +++ b/frontend/web/js/app.js @@ -40,12 +40,17 @@ function addDocumentKeypressedListener(){ $( document ).on( "wordtyped", function( event, data ) { var word; word = data.word; + console.info("word typed",word); + console.info("isWordTypedListenerAllowedOnlyForEmptyCustomer",isWordTypedListenerAllowedOnlyForEmptyCustomer); if ( word && word.length > 0){ var redirectAllowed = true; if ( isWordTypedListenerAllowedOnlyForEmptyCustomer ){ - if ( location.href !== reception_card_url ){ + let params = new URLSearchParams(location.search) + let cardNumber = params.get("number"); + + if ( cardNumber && cardNumber.length > 0){ redirectAllowed = false; - console.info("disalbling customer redirect. reason: isWordTypedListenerAllowedOnlyForEmptyCustomer = true") + console.info("redirect disabled! number param exists", word, cardNumber ); } } if ( redirectAllowed){