diff --git a/composer.lock b/composer.lock index 162ede7..c44bc26 100644 --- a/composer.lock +++ b/composer.lock @@ -318,16 +318,16 @@ }, { "name": "kartik-v/bootstrap-fileinput", - "version": "v4.2.6", + "version": "v4.2.7", "source": { "type": "git", "url": "https://github.com/kartik-v/bootstrap-fileinput.git", - "reference": "e4906dd5ee852a5333d3ce4d19f69ee855efe844" + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/e4906dd5ee852a5333d3ce4d19f69ee855efe844", - "reference": "e4906dd5ee852a5333d3ce4d19f69ee855efe844", + "url": "https://api.github.com/repos/kartik-v/bootstrap-fileinput/zipball/0468bbba9c28c1250aca83eba9b33e32ec135f78", + "reference": "0468bbba9c28c1250aca83eba9b33e32ec135f78", "shasum": "" }, "type": "library", @@ -362,20 +362,20 @@ "progress", "upload" ], - "time": "2015-08-26 18:42:44" + "time": "2015-09-13 17:39:44" }, { "name": "kartik-v/bootstrap-star-rating", - "version": "v3.5.3", + "version": "v3.5.4", "source": { "type": "git", "url": "https://github.com/kartik-v/bootstrap-star-rating.git", - "reference": "bd9c52db6ac71cb270620c1aee601d142ab2cc00" + "reference": "987777ee21a599bebbc545c743063fcee9833842" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/bootstrap-star-rating/zipball/bd9c52db6ac71cb270620c1aee601d142ab2cc00", - "reference": "bd9c52db6ac71cb270620c1aee601d142ab2cc00", + "url": "https://api.github.com/repos/kartik-v/bootstrap-star-rating/zipball/987777ee21a599bebbc545c743063fcee9833842", + "reference": "987777ee21a599bebbc545c743063fcee9833842", "shasum": "" }, "type": "library", @@ -403,7 +403,7 @@ "jquery", "star" ], - "time": "2015-06-18 14:42:46" + "time": "2015-09-21 09:06:33" }, { "name": "kartik-v/dependent-dropdown", @@ -1036,16 +1036,16 @@ }, { "name": "kartik-v/yii2-widget-select2", - "version": "v2.0.2", + "version": "v2.0.3", "source": { "type": "git", "url": "https://github.com/kartik-v/yii2-widget-select2.git", - "reference": "585e8797d7982e0c9d09370b98b451a028a59439" + "reference": "e72880e7e8dfc845c112ed7df275bf1c929be6db" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/585e8797d7982e0c9d09370b98b451a028a59439", - "reference": "585e8797d7982e0c9d09370b98b451a028a59439", + "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/e72880e7e8dfc845c112ed7df275bf1c929be6db", + "reference": "e72880e7e8dfc845c112ed7df275bf1c929be6db", "shasum": "" }, "require": { @@ -1080,7 +1080,7 @@ "widget", "yii2" ], - "time": "2015-07-01 15:20:59" + "time": "2015-09-12 19:56:48" }, { "name": "kartik-v/yii2-widget-sidenav", diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php index e013318..232314a 100644 --- a/frontend/controllers/CustomerController.php +++ b/frontend/controllers/CustomerController.php @@ -10,6 +10,7 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii\base\Object; +use common\models\Card; /** * CustomerController implements the CRUD actions for Customer model. @@ -32,12 +33,10 @@ class CustomerController extends Controller } public function actionReception(){ - $model = new ReceptionForm(); - if ($model->load(Yii::$app->request->post()) && $model->validate()) { - -// return $this->redirect(['view', 'id' => $model->id_customer]); + if ($model->load(Yii::$app->request->get()) && $model->validate()) { + $model->readCard(); } diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php index 47b14f9..d8f224c 100644 --- a/frontend/models/ReceptionForm.php +++ b/frontend/models/ReceptionForm.php @@ -4,6 +4,8 @@ namespace frontend\models; use Yii; use yii\base\Model; +use common\models\Card; +use common\models\Customer; /** * ContactForm is the model behind the contact form. @@ -11,8 +13,10 @@ use yii\base\Model; class ReceptionForm extends Model { public $number; + public $card; + public $customer; + - /** * @inheritdoc */ @@ -23,6 +27,7 @@ class ReceptionForm extends Model ]; } + /** * @inheritdoc */ @@ -32,5 +37,12 @@ class ReceptionForm extends Model 'verifyCode' => 'Verification Code', ]; } + + public function readCard(){ + $this->card = Card::findOne(['number' => $this->number]); + if ( $this->card != null ){ + $this->customer = $this->card->customer; + } + } } diff --git a/frontend/views/customer/_form_reception.php b/frontend/views/customer/_form_reception.php index 524904b..d4f01d7 100644 --- a/frontend/views/customer/_form_reception.php +++ b/frontend/views/customer/_form_reception.php @@ -17,46 +17,77 @@ use yii\widgets\ActiveForm; +card; +$customer = $model->customer; +$customername = ""; +if ( $customer != null ){ + $customername = $customer->name; +} + + +function mkCustomerBtn($card, $label,$url = null ){ + + $classes = 'btn btn-primary btn-reception'; + if ( $card == null ){ + $classes .= ' disabled'; + } + + return Html::a( $label , null, ['class' => $classes ] ); +} + +?> +
- + false, + 'method' => 'get' + ]); ?>
- 'btn btn-primary btn-reception'] )?> +
- 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?> + 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
- 'btn btn-primary btn-reception'] )?> +
- 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?> + 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
- 'btn btn-primary btn-reception'] )?> + 'btn btn-primary btn-reception'] )?>
- 'btn btn-primary btn-reception'] )?> +
- 'btn btn-primary btn-reception'] )?> + 'btn btn-primary btn-reception'] )?>
- field($model, 'number')->textInput()?> +
+
+ field($model, 'number')->textInput()?> +
+
+ +
+