add display money to account state close, delete ticket on customer tickets

This commit is contained in:
2016-01-10 15:25:25 +01:00
parent 5a98d128bc
commit 7c584a0779
21 changed files with 291 additions and 19 deletions

View File

@@ -126,5 +126,54 @@ class TicketController extends FrontendController
'receptionForm' => $receptionForm,
]);
}
/**
* Deletes an existing Transfer model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$ticket = $this->findModel($id);
$transfer = Transfer::find()->andWhere(['transfer.type' => Transfer::TYPE_TICKET])
->andWhere(['transfer.id_object' => $ticket->id_ticket])
->one();
$connection = \Yii::$app->db;
$transaction = $connection->beginTransaction();
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");
}
} 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.
* @param integer $id
* @return Ticket the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Ticket::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}