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