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 $created_at
|
||||
* @property integer $updated_at
|
||||
* @property integer $key_listener_enabled
|
||||
* @property string $password write-only password
|
||||
*/
|
||||
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
|
||||
namespace frontend\components;
|
||||
|
||||
use common\models\User;
|
||||
use yii\base\Widget;
|
||||
|
||||
class ReceptionWidget extends Widget{
|
||||
@ -13,14 +14,22 @@ class ReceptionWidget extends Widget{
|
||||
|
||||
public $viewFile = '//common/_reception';
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
public $user ;
|
||||
|
||||
public function init(){
|
||||
parent::init();
|
||||
$this->user = User::findOne(\Yii::$app->user->id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
use backend\models\CustomerActivateForm;
|
||||
use common\models\User;
|
||||
use frontend\models\SingleCustomerActivateForm;
|
||||
use common\components\Helper;
|
||||
use frontend\components\HtmlHelper;
|
||||
@ -83,6 +84,10 @@ class CustomerController extends Controller
|
||||
$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() ){
|
||||
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->key_listener_enabled = 0;
|
||||
$user->save();
|
||||
|
||||
$model->customer = $receptionForm->customer;
|
||||
$model->id_user = \Yii::$app->user->id;
|
||||
|
||||
@ -132,6 +135,8 @@ class TicketController extends FrontendController
|
||||
$model->userCart = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
|
||||
$model->customerCart = Transfer::modelsToArray( Transfer::readCustomerCart( $receptionForm->customer ) );
|
||||
|
||||
|
||||
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
'discounts' => $discounts,
|
||||
|
||||
@ -163,6 +163,11 @@ class TicketCreate extends Ticket{
|
||||
$original_end = Helper::getTicketExpirationDate($start, $ticketType);
|
||||
$this->original_end = DateUtil::formatDateUtc($original_end);
|
||||
$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;
|
||||
}
|
||||
|
||||
|
||||
if ( Helper::isTicketCreatePriceEditable() ){
|
||||
$transfer->money = $this->price_brutto;
|
||||
} else {
|
||||
$transfer->money = $transfer->item_price;
|
||||
}
|
||||
|
||||
$transfer->id_account = $this->_account->id_account;
|
||||
|
||||
|
||||
@ -10,6 +10,7 @@ use yii\widgets\ActiveForm;
|
||||
use yii\helpers\Html;
|
||||
|
||||
/** @var $model frontend\models\ReceptionForm */
|
||||
/** @var $user_key_listener_enabled number */
|
||||
?>
|
||||
<?php
|
||||
$alertClass = "info";
|
||||
@ -22,6 +23,9 @@ use yii\helpers\Html;
|
||||
$cassaMessage = "Nincs kassza kiválasztva";
|
||||
}
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var userKeyListenerEnabled = <?= $user_key_listener_enabled ?>;
|
||||
</script>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<div class="alert alert-<?php echo $alertClass;?>">
|
||||
|
||||
@ -43,6 +43,21 @@ if ( isset($model->card)){
|
||||
</div>
|
||||
</div>
|
||||
<?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>
|
||||
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ var seq = '';
|
||||
var socket;
|
||||
$(document).ready(
|
||||
function(){
|
||||
|
||||
$("input[name='number']").on('focus', function (e) {
|
||||
$(this)
|
||||
.one('mouseup', function () {
|
||||
@ -43,16 +42,8 @@ function addDocumentKeypressedListener(){
|
||||
console.info("word typed",word);
|
||||
console.info("isWordTypedListenerAllowedOnlyForEmptyCustomer",isWordTypedListenerAllowedOnlyForEmptyCustomer);
|
||||
if ( word && word.length > 0){
|
||||
var redirectAllowed = true;
|
||||
if ( isWordTypedListenerAllowedOnlyForEmptyCustomer ){
|
||||
let params = new URLSearchParams(location.search)
|
||||
let cardNumber = params.get("number");
|
||||
var redirectAllowed = userKeyListenerEnabled == 1;
|
||||
|
||||
if ( cardNumber && cardNumber.length > 0){
|
||||
redirectAllowed = false;
|
||||
console.info("redirect disabled! number param exists", word, cardNumber );
|
||||
}
|
||||
}
|
||||
if ( redirectAllowed){
|
||||
location.href= reception_card_url +'&number=' + word;
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ function Customer(o){
|
||||
init();
|
||||
|
||||
function init(){
|
||||
|
||||
defaults = $.extend(defaults,o);
|
||||
var url = location.href;
|
||||
// var initCamera;
|
||||
|
||||
@ -73,6 +73,7 @@ class ApiManager
|
||||
'name' => $ticket->ticketType->name,
|
||||
],
|
||||
'usageCount' => $ticket->usage_count,
|
||||
'maxUsageCount' => $ticket->max_usage_count,
|
||||
'start' => DateUtil::parseDateTime($ticket->start)->getTimestamp(),
|
||||
'end' => DateUtil::parseDateTime($ticket->end)->getTimestamp()
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user