user auto disable word listening

improve card creation
mobileapi - add ticket usage count
This commit is contained in:
Schneider Roland 2023-07-04 16:40:20 +02:00
parent d3e4009f3e
commit 9809731933
11 changed files with 196 additions and 112 deletions

View File

@ -20,6 +20,7 @@ use common\components\RoleDefinition;
* @property integer $status * @property integer $status
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
* @property integer $key_listener_enabled
* @property string $password write-only password * @property string $password write-only password
*/ */
class User extends ActiveRecord implements IdentityInterface class User extends ActiveRecord implements IdentityInterface

View File

@ -0,0 +1,46 @@
<?php
use yii\db\Migration;
/**
* Class m230626_205132_alter_table_user_add_column_key_listener_enabled
*/
class m230626_205132_alter_table_user_add_column_key_listener_enabled extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn(
"user",
"key_listener_enabled",
$this->integer()->null()->defaultValue(1)
);
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
echo "m230626_205132_alter_table_user_add_column_key_listener_enabled cannot be reverted.\n";
return false;
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m230626_205132_alter_table_user_add_column_key_listener_enabled cannot be reverted.\n";
return false;
}
*/
}

View File

@ -1,27 +1,36 @@
<?php <?php
namespace frontend\components; namespace frontend\components;
use common\models\User;
use yii\base\Widget; use yii\base\Widget;
class ReceptionWidget extends Widget{ class ReceptionWidget extends Widget{
public $form; public $form;
public $number; public $number;
public $route; public $route;
public $viewFile = '//common/_reception'; public $viewFile = '//common/_reception';
/**
* @var User
*/
public $user ;
public function init(){ public function init(){
parent::init(); parent::init();
$this->user = User::findOne(\Yii::$app->user->id);
} }
public function run(){ public function run(){
echo $this->render($this->viewFile,[ 'model' => $this->form ]);
echo $this->render($this->viewFile,[ 'model' => $this->form,
"user_key_listener_enabled" => $this->user->key_listener_enabled ]);
} }
} }

View File

@ -3,6 +3,7 @@
namespace frontend\controllers; namespace frontend\controllers;
use backend\models\CustomerActivateForm; use backend\models\CustomerActivateForm;
use common\models\User;
use frontend\models\SingleCustomerActivateForm; use frontend\models\SingleCustomerActivateForm;
use common\components\Helper; use common\components\Helper;
use frontend\components\HtmlHelper; use frontend\components\HtmlHelper;
@ -83,6 +84,10 @@ class CustomerController extends Controller
$model->mkDoorLog(); $model->mkDoorLog();
} }
if ( \Yii::$app->request->isPost){
User::updateAll(['key_listener_enabled' =>1 ],['id' => \Yii::$app->user->id]);
// return $this->redirect([ 'customer/reception']);
}
if ( $model->isFreeCard() ){ if ( $model->isFreeCard() ){
return $this->redirect([ 'create', 'number' => $model->card->number ]); return $this->redirect([ 'create', 'number' => $model->card->number ]);

View File

@ -66,12 +66,12 @@ class TicketController extends FrontendController
public function actionIndex($number = null) public function actionIndex($number = null)
{ {
$receptionForm = $this->mkReceptionForm($number); $receptionForm = $this->mkReceptionForm($number);
if ( !isset($receptionForm->card ) ){ if ( !isset($receptionForm->card ) ){
throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.')); throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.'));
} }
$searchModel = new TicketSearch(); $searchModel = new TicketSearch();
$dataProvider = $searchModel->search( $receptionForm->card, Yii::$app->request->queryParams); $dataProvider = $searchModel->search( $receptionForm->card, Yii::$app->request->queryParams);
@ -91,47 +91,52 @@ class TicketController extends FrontendController
*/ */
public function actionCreate($number = null) public function actionCreate($number = null)
{ {
$receptionForm =$this->mkReceptionForm($number); $receptionForm =$this->mkReceptionForm($number);
if ( !isset($receptionForm->card ) ){ if ( !isset($receptionForm->card ) ){
throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.')); throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.'));
} }
if ( isset($_POST['payout_customer_cart']) && $this->payoutCustomerCart($receptionForm) ){ if ( isset($_POST['payout_customer_cart']) && $this->payoutCustomerCart($receptionForm) ){
return $this->redirect(['customer/reception' ]); return $this->redirect(['customer/reception' ]);
}else if ( isset($_POST['payout_user_cart']) && $this->payoutUserCart($receptionForm)){ }else if ( isset($_POST['payout_user_cart']) && $this->payoutUserCart($receptionForm)){
return $this->redirect(['customer/reception' ]); return $this->redirect(['customer/reception' ]);
} }
$model = new TicketCreate(); $model = new TicketCreate();
$discounts = Discount::readTicketDiscounts(); $discounts = Discount::readTicketDiscounts();
$ticketTypes = TicketType::read(null, null); $ticketTypes = TicketType::read(null, null);
$accounts = Account::read(); $accounts = Account::read();
$user = User::findOne( [ 'id' => Yii::$app->user->id ] ); $user = User::findOne( [ 'id' => Yii::$app->user->id ] );
$user->key_listener_enabled = 0;
$user->save();
$model->customer = $receptionForm->customer; $model->customer = $receptionForm->customer;
$model->id_user = \Yii::$app->user->id; $model->id_user = \Yii::$app->user->id;
$model->usage_count = 0; $model->usage_count = 0;
$model->id_card = $receptionForm->card->id_card; $model->id_card = $receptionForm->card->id_card;
$model->id_account = Account::readDefault(); $model->id_account = Account::readDefault();
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') ); Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
return $this->redirect(['product/sale', 'number' => $receptionForm->card->number]); return $this->redirect(['product/sale', 'number' => $receptionForm->card->number]);
} }
$model->userCart = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) ); $model->userCart = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
$model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $receptionForm->customer ) ); $model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $receptionForm->customer ) );
return $this->render('create', [ return $this->render('create', [
'model' => $model, 'model' => $model,
'discounts' => $discounts, 'discounts' => $discounts,
@ -150,17 +155,17 @@ class TicketController extends FrontendController
/** @var \frontend\models\TicketUpdate $model */ /** @var \frontend\models\TicketUpdate $model */
$model = TicketUpdate::findOne($id); $model = TicketUpdate::findOne($id);
if ( !isset($model)){ if ( !isset($model)){
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['index', 'number' => $model->card->number]); return $this->redirect(['index', 'number' => $model->card->number]);
} }
return $this->render('update',['model' => $model]); return $this->render('update',['model' => $model]);
} }
/** /**
@ -191,7 +196,7 @@ class TicketController extends FrontendController
$transfer->storno(); $transfer->storno();
$transaction->commit(); $transaction->commit();
\Yii::$app->session->setFlash( 'success','Bérlet törölve' ); \Yii::$app->session->setFlash( 'success','Bérlet törölve' );
// $transaction->commit(); // $transaction->commit();
// if ( $transfer->delete() ){ // if ( $transfer->delete() ){
// \Yii::$app->session->setFlash( 'success','Bérlet törölve' ); // \Yii::$app->session->setFlash( 'success','Bérlet törölve' );
@ -199,16 +204,16 @@ class TicketController extends FrontendController
// }else{ // }else{
// throw new \Exception("Failed to save"); // throw new \Exception("Failed to save");
// } // }
} catch(Exception $e) { } catch(Exception $e) {
$transaction->rollback(); $transaction->rollback();
\Yii::$app->session->setFlash( 'danger','Bérlet törlése nem sikerült' ); \Yii::$app->session->setFlash( 'danger','Bérlet törlése nem sikerült' );
} }
return $this->redirect(Yii::$app->request->referrer); return $this->redirect(Yii::$app->request->referrer);
} }
/** /**
* Finds the Ticket model based on its primary key value. * Finds the Ticket model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown. * If the model is not found, a 404 HTTP exception will be thrown.
@ -224,5 +229,5 @@ class TicketController extends FrontendController
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }
} }

View File

@ -28,17 +28,17 @@ class TicketCreate extends Ticket{
public $_discount; public $_discount;
public $_transfer; public $_transfer;
public $_ticketType; public $_ticketType;
public $customer; public $customer;
public $userCart; public $userCart;
public $customerCart; public $customerCart;
public $cart; public $cart;
public $payment_method; public $payment_method;
public function rules() public function rules()
{ {
return [ return [
@ -75,7 +75,7 @@ class TicketCreate extends Ticket{
[[ 'max_usage_count'], 'required'], [[ 'max_usage_count'], 'required'],
[[ 'max_usage_count'], 'integer'], [[ 'max_usage_count'], 'integer'],
///////////////////// /////////////////////
//price //price
///////////////////// /////////////////////
[[ 'price_brutto'], 'required'], [[ 'price_brutto'], 'required'],
[[ 'price_brutto'], 'integer'], [[ 'price_brutto'], 'integer'],
@ -87,11 +87,11 @@ class TicketCreate extends Ticket{
//cart //cart
///////////////////// /////////////////////
[['cart'], 'string', 'max' => 10] [['cart'], 'string', 'max' => 10]
]; ];
} }
public function validateTicketType($attribute){ public function validateTicketType($attribute){
$type = TicketType::findOne($this->id_ticket_type); $type = TicketType::findOne($this->id_ticket_type);
$this->_ticketType = $type; $this->_ticketType = $type;
@ -114,40 +114,40 @@ class TicketCreate extends Ticket{
$query->andWhere( [ '>', 'expired_at' , Helper::getDateTimeString() ]); $query->andWhere( [ '>', 'expired_at' , Helper::getDateTimeString() ]);
$query->andWhere( [ 'not in', 'flag', [Contract::$FLAG_DELETED ] ]); $query->andWhere( [ 'not in', 'flag', [Contract::$FLAG_DELETED ] ]);
$contracts = $query->all(); $contracts = $query->all();
if ( count($contracts) > 0 ){ if ( count($contracts) > 0 ){
$this->addError($attribute,"A vendégnek már van érvényes vagy felbontott szerződése!"); $this->addError($attribute,"A vendégnek már van érvényes vagy felbontott szerződése!");
} }
} }
} }
} }
public function validateAccount($attribute){ public function validateAccount($attribute){
$this->_account = Account::findOne($this->id_account); $this->_account = Account::findOne($this->id_account);
if ( !isset($this->_account )) { if ( !isset($this->_account )) {
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid transfer' )); $this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid transfer' ));
} }
} }
public function validateDiscount($attribute){ public function validateDiscount($attribute){
$this->_discount = Discount::findOne($this->id_discount); $this->_discount = Discount::findOne($this->id_discount);
if ( !isset($this->_discount)) { if ( !isset($this->_discount)) {
$this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid discount' )); $this->addError($attribute,\Yii::t('frontend/ticket' , 'Invalid discount' ));
} }
} }
public function beforeSave($insert){ public function beforeSave($insert){
$result = parent::beforeSave($insert); $result = parent::beforeSave($insert);
if ( $result ){ if ( $result ){
if ($insert){ if ($insert){
if ( $this->isAppendToCustomerCart() || $this->isAppendToUserCart()){ if ( $this->isAppendToCustomerCart() || $this->isAppendToUserCart()){
$this->status = Ticket::STATUS_INACTIVE; $this->status = Ticket::STATUS_INACTIVE;
}else{ }else{
$this->status = Ticket::STATUS_ACTIVE; $this->status = Ticket::STATUS_ACTIVE;
} }
$ticketType = TicketType::findOne($this->id_ticket_type); $ticketType = TicketType::findOne($this->id_ticket_type);
if ( isset($ticketType) && $ticketType->isInstallment() ){ if ( isset($ticketType) && $ticketType->isInstallment() ){
$this->part = 0; $this->part = 0;
@ -157,12 +157,17 @@ class TicketCreate extends Ticket{
$this->part_count = 0; $this->part_count = 0;
} }
if ( isset($ticketType )){ if (isset($ticketType)) {
$this->original_price = $ticketType->price_brutto; $this->original_price = $ticketType->price_brutto;
$start = DateUtil::parseDate($this->start); $start = DateUtil::parseDate($this->start);
$original_end = Helper::getTicketExpirationDate($start,$ticketType); $original_end = Helper::getTicketExpirationDate($start, $ticketType);
$this->original_end = DateUtil::formatDateUtc($original_end); $this->original_end = DateUtil::formatDateUtc($original_end);
$this->max_reservation_count = $ticketType->max_reservation_count; $this->max_reservation_count = $ticketType->max_reservation_count;
if (!Helper::isTicketCreatePriceEditable()) {
$this->price_brutto = $ticketType->price_brutto;
}
} }
} }
} }
@ -180,18 +185,18 @@ class TicketCreate extends Ticket{
$this->appendToCustomerCart(); $this->appendToCustomerCart();
$this->addContract($insert); $this->addContract($insert);
$this->updateCardFlag(); $this->updateCardFlag();
} }
protected function updateCardFlag(){ protected function updateCardFlag(){
Card::updateCardFlagTicket($this->id_card); Card::updateCardFlagTicket($this->id_card);
} }
public function addContract($insert){ public function addContract($insert){
if ($insert){ if ($insert){
$ticketType = TicketType::findOne($this->id_ticket_type); $ticketType = TicketType::findOne($this->id_ticket_type);
if ( isset($ticketType) && $ticketType->isInstallment() ){ if ( isset($ticketType) && $ticketType->isInstallment() ){
$contract = new Contract(); $contract = new Contract();
$contract->id_customer = $this->customer->id_customer; $contract->id_customer = $this->customer->id_customer;
$contract->id_user = \Yii::$app->user->id; $contract->id_user = \Yii::$app->user->id;
@ -204,7 +209,7 @@ class TicketCreate extends Ticket{
$contract->id_ticket_type = $this->id_ticket_type; $contract->id_ticket_type = $this->id_ticket_type;
$contract->id_discount = $this->id_discount; $contract->id_discount = $this->id_discount;
$contract->save(); $contract->save();
$requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract); $requests = TicketInstallmentRequest::createInstallments($this, $ticketType, $this->customer,$contract);
foreach ($requests as $request){ foreach ($requests as $request){
$request->save(false); $request->save(false);
@ -219,24 +224,27 @@ class TicketCreate extends Ticket{
protected function addTransfer(){ protected function addTransfer(){
//$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this); //$transfer = Transfer::createTicketTransfer($this->_account, $this->_discount, null, 1, $this);
$transfer = new Transfer(); $transfer = new Transfer();
$transfer->type = Transfer::TYPE_TICKET; $transfer->type = Transfer::TYPE_TICKET;
$transfer->direction = Transfer::DIRECTION_IN; $transfer->direction = Transfer::DIRECTION_IN;
$transfer->id_object = $this->id_ticket; $transfer->id_object = $this->id_ticket;
$transfer->item_price = $this->_ticketType->price_brutto; $transfer->item_price = $this->_ticketType->price_brutto;
$transfer->count = 1; $transfer->count = 1;
if (isset ( $this->_discount )) { if (isset ( $this->_discount )) {
$transfer->id_discount = $this->_discount->id_discount; $transfer->id_discount = $this->_discount->id_discount;
} }
if ( Helper::isTicketCreatePriceEditable() ){
$transfer->money = $this->price_brutto; $transfer->money = $this->price_brutto;
} else {
$transfer->money = $transfer->item_price;
}
$transfer->id_account = $this->_account->id_account; $transfer->id_account = $this->_account->id_account;
if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){ if ( !Transfer::canMarkPaidByReception( $this->payment_method ) ){
@ -252,7 +260,7 @@ class TicketCreate extends Ticket{
} }
$transfer->status = $status; $transfer->status = $status;
$transfer->payment_method = $this->payment_method; $transfer->payment_method = $this->payment_method;
if ( isset($this->comment)){ if ( isset($this->comment)){
$transfer->comment = $this->comment; $transfer->comment = $this->comment;
} }
@ -264,7 +272,7 @@ class TicketCreate extends Ticket{
} }
$this->_transfer = $transfer; $this->_transfer = $transfer;
} }
public function isAppendToUserCart(){ public function isAppendToUserCart(){
$result = false; $result = false;
if ( isset( $this->cart ) && $this->cart == 'user' ){ if ( isset( $this->cart ) && $this->cart == 'user' ){
@ -272,7 +280,7 @@ class TicketCreate extends Ticket{
} }
return $result; return $result;
} }
public function isAppendToCustomerCart(){ public function isAppendToCustomerCart(){
$result = false; $result = false;
if ( isset( $this->cart ) && $this->cart == 'customer' ){ if ( isset( $this->cart ) && $this->cart == 'customer' ){
@ -310,11 +318,11 @@ class TicketCreate extends Ticket{
\Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!"); \Yii::error("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!"); throw new \Exception("Nem sikerült menteni a bérletet! Vendég kosár hozzárendelés sikertelen!");
} }
} }
} }
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php
use frontend\components\ReceptionCardNumberWidget; use frontend\components\ReceptionCardNumberWidget;
use frontend\components\ReceptionMenuWidget; use frontend\components\ReceptionMenuWidget;
use frontend\models\ReceptionForm; use frontend\models\ReceptionForm;
@ -10,8 +10,9 @@ use yii\widgets\ActiveForm;
use yii\helpers\Html; use yii\helpers\Html;
/** @var $model frontend\models\ReceptionForm */ /** @var $model frontend\models\ReceptionForm */
/** @var $user_key_listener_enabled number */
?> ?>
<?php <?php
$alertClass = "info"; $alertClass = "info";
$cassaMessage = "Nyitva"; $cassaMessage = "Nyitva";
if ( $model->isCassaClose() ){ if ( $model->isCassaClose() ){
@ -22,10 +23,13 @@ use yii\helpers\Html;
$cassaMessage = "Nincs kassza kiválasztva"; $cassaMessage = "Nincs kassza kiválasztva";
} }
?> ?>
<script type="text/javascript">
var userKeyListenerEnabled = <?= $user_key_listener_enabled ?>;
</script>
<div class='row'> <div class='row'>
<div class='col-md-4'> <div class='col-md-4'>
<div class="alert alert-<?php echo $alertClass;?>"> <div class="alert alert-<?php echo $alertClass;?>">
Aktuális kassza: <?php echo $model->getDefaultAccountName();?> - Aktuális kassza: <?php echo $model->getDefaultAccountName();?> -
<?php echo $cassaMessage;?> <?php echo $cassaMessage;?>
</div> </div>
</div> </div>
@ -35,17 +39,17 @@ use yii\helpers\Html;
]); ?> ]); ?>
<div class='col-md-3'> <div class='col-md-3'>
<?php echo Html::textInput('CardSearch[customerName]','',['class'=>"form-control", 'placeholder' =>'Vendég neve']) ?> <?php echo Html::textInput('CardSearch[customerName]','',['class'=>"form-control", 'placeholder' =>'Vendég neve']) ?>
</div> </div>
<div class='col-md-2'> <div class='col-md-2'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary btn-block']) ?> <?= Html::submitButton(Yii::t('frontend/collection', 'Search'), ['class' => 'btn btn-primary btn-block']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
<?php /* ?> <?php /* ?>
<div class="row" style="margin-bottom: 6px;"> <div class="row" style="margin-bottom: 6px;">
<div class='col-md-4'> <div class='col-md-4'>
</div> </div>
<?php $form = ActiveForm::begin([ <?php $form = ActiveForm::begin([
'action' => ['key/toggle', 'number' => $model->getCardNumber()], 'action' => ['key/toggle', 'number' => $model->getCardNumber()],
'method' => 'post', 'method' => 'post',
@ -53,13 +57,13 @@ use yii\helpers\Html;
<div class='col-md-3'> <div class='col-md-3'>
<?php echo Html::hiddenInput('number', $model->getCardNumber())?> <?php echo Html::hiddenInput('number', $model->getCardNumber())?>
<?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?> <?php echo Html::textInput('KeyToggleForm[key]','',['class'=>"form-control", 'placeholder' =>'Kulcs']) ?>
</div> </div>
<div class='col-md-2'> <div class='col-md-2'>
<?= Html::submitButton(Yii::t('frontend/collection', 'Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?> <?= Html::submitButton(Yii::t('frontend/collection', 'Ki/Be'), ['class' => 'btn btn-primary btn-block']) ?>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
</div> </div>
<?php */ ?> <?php */ ?>
<div class='row'> <div class='row'>

View File

@ -19,7 +19,7 @@ use yii\widgets\ActiveForm;
</style> </style>
<?php <?php
$number = ""; $number = "";
if ( isset($model->card)){ if ( isset($model->card)){
$number = $model->card->number; $number = $model->card->number;
@ -43,6 +43,21 @@ if ( isset($model->card)){
</div> </div>
</div> </div>
<?php ActiveForm::end(); ?> <?php ActiveForm::end(); ?>
<?php
$user = \common\models\User::findOne(\Yii::$app->user->id);
if ( $user->key_listener_enabled == 0){
?>
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => false,
'method' => 'post',
'action' => ['customer/reception']
]); ?>
<?php echo Html::hiddenInput("key_listener_enabled", "1" ,['class' => 'form-control', ])?>
<?php echo Html::submitButton( "Kártyafigyelés be ",[ 'class' => 'btn btn-success btn-block']); ?>
<?php ActiveForm::end(); ?>
<?php
}
?>
</div> </div>

View File

@ -4,7 +4,6 @@ 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 () {
@ -43,16 +42,8 @@ function addDocumentKeypressedListener(){
console.info("word typed",word); console.info("word typed",word);
console.info("isWordTypedListenerAllowedOnlyForEmptyCustomer",isWordTypedListenerAllowedOnlyForEmptyCustomer); console.info("isWordTypedListenerAllowedOnlyForEmptyCustomer",isWordTypedListenerAllowedOnlyForEmptyCustomer);
if ( word && word.length > 0){ if ( word && word.length > 0){
var redirectAllowed = true; var redirectAllowed = userKeyListenerEnabled == 1;
if ( isWordTypedListenerAllowedOnlyForEmptyCustomer ){
let params = new URLSearchParams(location.search)
let cardNumber = params.get("number");
if ( cardNumber && cardNumber.length > 0){
redirectAllowed = false;
console.info("redirect disabled! number param exists", word, cardNumber );
}
}
if ( redirectAllowed){ if ( redirectAllowed){
location.href= reception_card_url +'&number=' + word; location.href= reception_card_url +'&number=' + word;
} }

View File

@ -1,14 +1,13 @@
function Customer(o){ function Customer(o){
var defaults = { var defaults = {
'image_data' : 'customerupdate-photo_data' 'image_data' : 'customerupdate-photo_data'
};
init();
function init(){
};
init();
function init(){
defaults = $.extend(defaults,o); defaults = $.extend(defaults,o);
var url = location.href; var url = location.href;
// var initCamera; // var initCamera;
@ -38,7 +37,7 @@ function Customer(o){
preventSubmit( '#customerupdate-replacementcardnumber' ); preventSubmit( '#customerupdate-replacementcardnumber' );
preventSubmit( '#customercreate-cardnumber' ); preventSubmit( '#customercreate-cardnumber' );
} }
function preventSubmit($selector){ function preventSubmit($selector){
$($selector).keydown(function(e) { $($selector).keydown(function(e) {
if(e.keyCode == 13) { // enter key was pressed if(e.keyCode == 13) { // enter key was pressed
@ -68,7 +67,7 @@ function Customer(o){
} }
}); });
} }
// function snap(){ // function snap(){
// Webcam.snap( function(data_uri) { // Webcam.snap( function(data_uri) {
// document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>'; // document.getElementById('my_result').innerHTML = '<img width="160" height="120" src="'+data_uri+'"/>';

View File

@ -73,6 +73,7 @@ class ApiManager
'name' => $ticket->ticketType->name, 'name' => $ticket->ticketType->name,
], ],
'usageCount' => $ticket->usage_count, 'usageCount' => $ticket->usage_count,
'maxUsageCount' => $ticket->max_usage_count,
'start' => DateUtil::parseDateTime($ticket->start)->getTimestamp(), 'start' => DateUtil::parseDateTime($ticket->start)->getTimestamp(),
'end' => DateUtil::parseDateTime($ticket->end)->getTimestamp() 'end' => DateUtil::parseDateTime($ticket->end)->getTimestamp()
]; ];