add reception changes
This commit is contained in:
@@ -12,6 +12,7 @@ use yii\filters\VerbFilter;
|
||||
use yii\base\Object;
|
||||
use common\models\Card;
|
||||
use frontend\models\CustomerUpdate;
|
||||
use frontend\models\CustomerCreate;
|
||||
|
||||
/**
|
||||
* CustomerController implements the CRUD actions for Customer model.
|
||||
@@ -78,12 +79,21 @@ class CustomerController extends Controller
|
||||
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||
* @return mixed
|
||||
*/
|
||||
public function actionCreate()
|
||||
public function actionCreate($number = null)
|
||||
{
|
||||
$model = new Customer();
|
||||
$model = new CustomerCreate();
|
||||
|
||||
$model->country = "Magyarország";
|
||||
$model->id_user = Yii::$app->user->id;
|
||||
|
||||
|
||||
if ( isset($number)){
|
||||
$model->cardNumber = $number;
|
||||
}
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['view', 'id' => $model->id_customer]);
|
||||
\Yii::$app->session->setFlash( 'success','Vendég létrehozva!' );
|
||||
return $this->redirect(['update', 'number' => $model->cardNumber]);
|
||||
} else {
|
||||
return $this->render('create', [
|
||||
'model' => $model,
|
||||
@@ -104,7 +114,7 @@ class CustomerController extends Controller
|
||||
if ( $number != null ){
|
||||
$card = Card::readCard($number);
|
||||
if ( $card != null ){
|
||||
$model = CustomerUpdate::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->one();
|
||||
$model = CustomerUpdate::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->andWhere( [ 'customer.id_customer_card' => $card->id_card ])->one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,9 +123,17 @@ class CustomerController extends Controller
|
||||
}
|
||||
|
||||
|
||||
$model->birthdate= isset($model->birthdate ) ? Yii::$app->formatter->asDate($model->birthdate) :'';
|
||||
|
||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||
return $this->redirect(['update', 'number' => $card->number]);
|
||||
|
||||
\Yii::$app->session->setFlash( 'success','Vendég módosításai elmentve' );
|
||||
|
||||
return $this->redirect(['update', 'number' => $card->number]);
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
return $this->render('update', [
|
||||
'model' => $model,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user