add frontend ticket changes
This commit is contained in:
@@ -38,14 +38,24 @@ class TicketController extends Controller
|
||||
* Lists all Ticket models.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionIndex()
|
||||
public function actionIndex($number = null)
|
||||
{
|
||||
$receptionForm = new ReceptionForm();
|
||||
$receptionForm->number = $number;
|
||||
$receptionForm->readCard();
|
||||
|
||||
|
||||
if ( !isset($receptionForm->card ) ){
|
||||
throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.'));
|
||||
}
|
||||
|
||||
$searchModel = new TicketSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
$dataProvider = $searchModel->search( $receptionForm->card, Yii::$app->request->queryParams);
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
'receptionForm' => $receptionForm,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -75,6 +85,10 @@ class TicketController extends Controller
|
||||
|
||||
$receptionForm->readCard();
|
||||
|
||||
if ( !isset($receptionForm->card ) ){
|
||||
throw new NotFoundHttpException( Yii::t('frontend/ticket', 'The requested card does not exist.'));
|
||||
}
|
||||
|
||||
$model = new TicketCreate();
|
||||
|
||||
$discounts = Discount::read();
|
||||
@@ -89,9 +103,11 @@ class TicketController extends Controller
|
||||
$model->id_user = \Yii::$app->user->id;
|
||||
$model->status = Ticket::STATUS_ACTIVE;
|
||||
$model->usage_count = 0;
|
||||
$model->id_card = $receptionForm->card->id_card;
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_ticket]);
|
||||
Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') );
|
||||
return $this->redirect(['index', 'number' => $receptionForm->card->number]);
|
||||
} else {
|
||||
|
||||
$userTransfers = Transfer::modelsToArray( Transfer::readUserSoldTransfers($user) );
|
||||
|
||||
Reference in New Issue
Block a user