add reception customer update changes

This commit is contained in:
2015-09-30 11:25:32 +02:00
parent 2b57f95b1e
commit 640d04cb76
20 changed files with 1185 additions and 15 deletions

View File

@@ -11,6 +11,7 @@ use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use common\models\Card;
use frontend\models\CustomerUpdate;
/**
* CustomerController implements the CRUD actions for Customer model.
@@ -32,12 +33,12 @@ class CustomerController extends Controller
];
}
public function actionReception(){
public function actionReception($number = ""){
$model = new ReceptionForm();
if ($model->load(Yii::$app->request->get()) && $model->validate()) {
$model->readCard();
}
$model->number = $number;
$model->readCard();
return $this->render('reception',['model' => $model]);
@@ -90,24 +91,37 @@ class CustomerController extends Controller
}
}
/**
/**
* Updates an existing Customer model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
public function actionUpdate($number = null)
{
$model = $this->findModel($id);
$card = null;
$model = null;
if ( $number != null ){
$card = Card::readCard($number);
if ( $card != null ){
$model = CustomerUpdate::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->one();
}
}
if ( $model == null) {
throw new NotFoundHttpException('The requested page does not exist.');
}
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_customer]);
return $this->redirect(['update', 'number' => $card->number]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Customer model.