add feature clear card
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user