fix move out , if usage count reached max usage count
fix gui: card number will be loaded only if form is empty
This commit is contained in:
parent
3d8516c50f
commit
cb1b2e2d13
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
FITNESS_WORD_TYPED_LISTENER_ALLOWED_ONLY_FOR_EMPTY_CUSTOMER=1
|
||||
@ -26,7 +26,7 @@ AppAsset::register($this);
|
||||
<title><?= Html::encode($this->title) ?></title>
|
||||
<script>
|
||||
var reception_card_url = '<?php echo Url::toRoute('customer/reception');?>';
|
||||
var isWordTypedListenerAllowedOnlyForEmptyCustomer = <?= \common\components\Helper::isWordTypedListenerAllowedOnlyForEmptyCustomer() ? 'true' : 'false' ?>
|
||||
var isWordTypedListenerAllowedOnlyForEmptyCustomer = <?= \common\components\Helper::isWordTypedListenerAllowedOnlyForEmptyCustomer() ? 'true' : 'false' ?>;
|
||||
</script>
|
||||
<?php $this->head() ?>
|
||||
</head>
|
||||
|
||||
@ -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){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user