add feature clear card

This commit is contained in:
2016-04-03 10:44:12 +02:00
parent ee4ae54e6f
commit 5ff974c717
12 changed files with 108 additions and 56 deletions

View File

@@ -14,6 +14,7 @@ use yii\web\UploadedFile;
use common\components\Helper;
use backend\models\CardInsertForm;
use common\models\Ticket;
use frontend\components\HtmlHelper;
/**
* CardController implements the CRUD actions for Card model.
@@ -25,6 +26,16 @@ class CardController extends \backend\controllers\BackendController {
'class' => \yii\filters\AccessControl::className (),
'rules' => [
// allow authenticated users
[
'actions' => [
'clear',
],
'allow' => true,
'roles' => [
'admin'
]
],
[
'actions' => [
'create',
@@ -40,7 +51,8 @@ class CardController extends \backend\controllers\BackendController {
'roles' => [
'@'
]
]
] ,
]
// everything else is denied
@@ -48,6 +60,23 @@ class CardController extends \backend\controllers\BackendController {
];
}
public function actionClear($id){
$model = $this->findModel ( $id );
$customer = $model->customer;
$customer->id_customer_card = null;
$customer->save(false);
Ticket::updateAll(['id_card' => null],['id_card' => $model->id_card]);
Helper::flash('success', "Vendég törölve a kártyáról");
$this->redirect(['card/update','id' =>$id]);
}
/**
* Lists all Card models.
*