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

@@ -0,0 +1,172 @@
<?php
namespace frontend\controllers;
use Yii;
use common\models\City;
use backend\models\CitySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
use yii\db\Query;
use yii\helpers\Json;
/**
* CityController implements the CRUD actions for City model.
*/
class CityController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all City models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CitySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single City model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new City model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
public function actionCreate()
{
$model = new City();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_city]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
*/
/**
* Updates an existing City model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_city]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
*/
/**
* Deletes an existing City model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
*/
/**
* Finds the City model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return City the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = City::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
/**
* Your controller action to fetch the list
*/
public function actionNameList($search = null) {
$query = new Query();
$query->select ( [
'name',
'min(zip) as zip',
'concat( zip, \' \', name) as fullname'
] )->from (City::tableName() )->where ( ' lower(name) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20);
$command = $query->createCommand ();
$data = $command->queryAll ();
$out = [ ];
foreach ( $data as $d ) {
$out [] = [
'name' => $d ['name'],
'zip' => $d ['zip'],
'fullname' => $d ['fullname'],
];
}
echo Json::encode ( $out );
}
/**
* Your controller action to fetch the list
*/
public function actionZipList($search = null) {
$query = new Query();
$query->select ( [
'name',
'min(zip) as zip',
'concat( zip, \' \', name) as fullname'
] )->from (City::tableName() )->where ( ' lower(zip) LIKE "' . strtolower ( $search ) . '%"' )->orderBy ( 'name' )->groupBy('name')->limit(20);
$command = $query->createCommand ();
$data = $command->queryAll ();
$out = [ ];
foreach ( $data as $d ) {
$out [] = [
'name' => $d ['name'],
'zip' => $d ['zip'],
'fullname' => $d ['fullname'],
];
}
echo Json::encode ( $out );
}
}

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.

View File

@@ -0,0 +1,121 @@
<?php
namespace frontend\controllers;
use Yii;
use common\models\Product;
use frontend\models\ProductSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ProductController implements the CRUD actions for Product model.
*/
class ProductController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Product models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new ProductSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Product model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Product model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Product();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_product]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Product model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_product]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Product model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
*/
public function actionDelete($id)
{
$this->findModel($id)->delete();
return $this->redirect(['index']);
}
/**
* Finds the Product model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Product the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Product::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}