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

@@ -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.');
}
}
}