add reception changes

This commit is contained in:
2015-09-29 17:27:31 +02:00
parent 8e235a8d3c
commit 2b57f95b1e
4 changed files with 71 additions and 29 deletions

View File

@@ -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();
}

View File

@@ -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;
}
}
}

View File

@@ -17,46 +17,77 @@ use yii\widgets\ActiveForm;
</style>
<?php
$card = $model->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 ] );
}
?>
<div class="reception-form">
<?php $form = ActiveForm::begin(); ?>
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => false,
'method' => 'get'
]); ?>
<div class="row">
<div class='col-md-3'>
<div class='row'>
<div class='col-md-8'>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Adatlap') , null, ['class' => 'btn btn-primary btn-reception'] )?>
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') ); ?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
<div class='row'>
<div class='col-md-8'>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Befizetések') ,null,['class' => 'btn btn-primary btn-reception'] )?>
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') ); ?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , null, ['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Jelentkezések') , null,['class' => 'btn btn-primary btn-reception'] )?>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Jelentkezések') , null,['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Egyenleg') , null,['class' => 'btn btn-primary btn-reception'] )?>
<?php echo mkCustomerBtn( $card, Yii::t( 'frontend/customer' , 'Egyenleg') ); ?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Termékeladás') , null,['class' => 'btn btn-primary btn-reception'] )?>
<?php echo Html::a(Yii::t( 'frontend/customer', 'Termékeladás') , null,['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
</div>
<div class='col-md-2'>
<?php echo $form->field($model, 'number')->textInput()?>
<div class="row" >
<div class='col-md-12'>
<?php echo $form->field($model, 'number')->textInput()?>
</div>
<div class='col-md-12'>
<?php echo $customername; ?>
</div>
</div>
</div>
</div>