add ticket installment
This commit is contained in:
@@ -21,6 +21,7 @@ use common\models\UserSoldItem;
|
||||
use frontend\components\FrontendController;
|
||||
use frontend\components\DefaultAccountBehavior;
|
||||
use frontend\components\CassaOpenBehavior;
|
||||
use frontend\models\TicketUpdate;
|
||||
|
||||
/**
|
||||
* TicketController implements the CRUD actions for Ticket model.
|
||||
@@ -38,7 +39,7 @@ class TicketController extends FrontendController
|
||||
],
|
||||
'access' => [
|
||||
'class' => \yii\filters\AccessControl::className(),
|
||||
'only' => ['create', 'index' ],
|
||||
'only' => ['create', 'index','update' ],
|
||||
'rules' => [
|
||||
// allow authenticated users
|
||||
[
|
||||
@@ -135,6 +136,21 @@ class TicketController extends FrontendController
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionUpdate($id){
|
||||
$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]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an existing Transfer model.
|
||||
* If deletion is successful, the browser will be redirected to the 'index' page.
|
||||
@@ -152,12 +168,21 @@ class TicketController extends FrontendController
|
||||
try {
|
||||
ShoppingCart::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
UserSoldItem::deleteAll([ 'id_transfer' => $transfer->id_transfer]);
|
||||
if ( $transfer->delete() ){
|
||||
\Yii::$app->session->setFlash( 'success','Bérlet törölve' );
|
||||
$transaction->commit();
|
||||
}else{
|
||||
throw new \Exception("Failed to save");
|
||||
}
|
||||
// $transfer->status = Transfer::STATUS_STORNO;
|
||||
// $transfer->save(false);
|
||||
// $ticket->status = Ticket::STATUS_DELETED;
|
||||
// $ticket->save(false);
|
||||
$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' );
|
||||
// $transaction->commit();
|
||||
// }else{
|
||||
// throw new \Exception("Failed to save");
|
||||
// }
|
||||
|
||||
} catch(Exception $e) {
|
||||
$transaction->rollback();
|
||||
|
||||
Reference in New Issue
Block a user