user auto disable word listening
improve card creation mobileapi - add ticket usage count
This commit is contained in:
parent
d3e4009f3e
commit
9809731933
@ -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
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<?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{
|
||||||
@ -13,14 +14,22 @@ class ReceptionWidget extends Widget{
|
|||||||
|
|
||||||
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 ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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 ]);
|
||||||
|
|||||||
@ -115,6 +115,9 @@ class TicketController extends FrontendController
|
|||||||
|
|
||||||
$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;
|
||||||
|
|
||||||
@ -132,6 +135,8 @@ class TicketController extends FrontendController
|
|||||||
$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,
|
||||||
|
|||||||
@ -163,6 +163,11 @@ class TicketCreate extends Ticket{
|
|||||||
$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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -234,8 +239,11 @@ class TicketCreate extends Ticket{
|
|||||||
$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;
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ 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";
|
||||||
@ -22,6 +23,9 @@ 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;?>">
|
||||||
|
|||||||
@ -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>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ function Customer(o){
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
function init(){
|
function init(){
|
||||||
|
|
||||||
defaults = $.extend(defaults,o);
|
defaults = $.extend(defaults,o);
|
||||||
var url = location.href;
|
var url = location.href;
|
||||||
// var initCamera;
|
// var initCamera;
|
||||||
|
|||||||
@ -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()
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user