diff --git a/frontend/controllers/CardController.php b/frontend/controllers/CardController.php
new file mode 100644
index 0000000..b1ce3bf
--- /dev/null
+++ b/frontend/controllers/CardController.php
@@ -0,0 +1,86 @@
+ [
+ 'class' => VerbFilter::className(),
+ 'actions' => [
+ 'delete' => ['post'],
+ ],
+ ],
+ ];
+ }
+
+
+
+
+
+
+ /**
+ * Finds the Card model based on its primary key value.
+ * If the model is not found, a 404 HTTP exception will be thrown.
+ * @param integer $id
+ * @return Card the loaded model
+ * @throws NotFoundHttpException if the model cannot be found
+ */
+ protected function findModel($id)
+ {
+ if (($model = Card::findOne($id)) !== null) {
+ return $model;
+ } else {
+ throw new NotFoundHttpException('The requested page does not exist.');
+ }
+ }
+
+
+ /**
+ * Your controller action to fetch the list
+ */
+ public function actionList($search = null) {
+ $query = new Query();
+
+ $query->select ( [
+ 'card.number as number',
+ 'customer.name as name',
+ "concat( card.number , case when customer.name is null then '' else customer.name end ) as txt ",
+ ] )->from (Card::tableName() )->join("left join", Customer::tableName(), 'card.id_card = customer.id_customer_card')->where ( ' lower(number) LIKE "%' . strtolower ( $search ) . '%"' )->orderBy ( 'number' ) ;
+
+ if ( isset($_GET['onlyFree']) && $_GET['onlyFree'] == '1'){
+ $query->andWhere( 'customer.id_customer is null' );
+ }
+
+ $command = $query->createCommand ();
+ $data = $command->queryAll ();
+ $out = [ ];
+ foreach ( $data as $d ) {
+ $out [] = [
+ 'number' => $d ['number'],
+ 'name' => $d ['name'],
+ 'txt' => $d ['txt'],
+ ];
+ }
+ echo Json::encode ( $out );
+ }
+
+
+
+}
diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php
index 98e4d19..b28c568 100644
--- a/frontend/controllers/CustomerController.php
+++ b/frontend/controllers/CustomerController.php
@@ -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,
]);
diff --git a/frontend/models/CustomerUpdate.php b/frontend/models/CustomerUpdate.php
index 96e1ffc..8f1967f 100644
--- a/frontend/models/CustomerUpdate.php
+++ b/frontend/models/CustomerUpdate.php
@@ -68,7 +68,7 @@ class CustomerUpdate extends \common\models\Customer
[['email'], 'email' ],
[['email'], 'unique' ],
- [['password_plain','password_repeat'], 'string', 'max' => 32],
+// [['password_plain','password_repeat'], 'string', 'max' => 32],
[['sex'], 'integer'],
diff --git a/frontend/views/common/_menu_reception.php b/frontend/views/common/_menu_reception.php
index 5c7e3f0..52d5a70 100644
--- a/frontend/views/common/_menu_reception.php
+++ b/frontend/views/common/_menu_reception.php
@@ -2,6 +2,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;
+use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $card common\models\Card */
@@ -33,44 +34,47 @@ function mkCustomerBtn($card, $label,$route = null ){
$classes .= ' disabled';
}
if ( isset($route)){
- $url = [$route, 'number' => $card->number];
+ $url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
}
return Html::a( $label , $url, ['class' => $classes ] );
}
-?>
+function mkBtn($card, $label,$route = null ){
+
+ $url = null;
+ $classes = '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'] )?>
-
-
+ if ( isset($route)){
+ $url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )];
+ }
+
+ return Html::a( $label , $url, ['class' => $classes ] );
+}
+
+
+?>
+
+
+
+
+
+ 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?>
+
+
+
+
+
+
+
+ 'glyphicon glyphicon-plus' ] ) , 'ticket/create' , ['class' => 'btn btn-primary btn-reception'] )?>
+
+
+
+
+ 'btn btn-primary btn-reception'] )?>
+
+
+
diff --git a/frontend/views/customer/_form_create.php b/frontend/views/customer/_form_create.php
new file mode 100644
index 0000000..036d453
--- /dev/null
+++ b/frontend/views/customer/_form_create.php
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+ field($model, 'cardNumber')->widget(CardNumberTypeahead::className(),[]) ?>
+
+
+ = $form->field($model, 'partnerCardNumber')->textInput() ?>
+
+
+
+
+
+
+ = $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
+
+
+
+
+ = $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
+
+
+
+
+
+
+
+ = $form->field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?>
+
+
+ = $form->field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?>
+
+
+
+
+
+ = $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
+
+
+ = $form->field($model, 'birthdate')->widget(DatePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd'
+ ]
+ ]) ?>
+
+
+
+
+
+ = $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
+
+
+ = $form->field($model, 'date_stundent_card_expire')->widget(DatePicker::classname(), [
+ 'pluginOptions' => [
+ 'autoclose'=>true,
+ 'format' => 'yyyy.mm.dd'
+ ]
+ ]) ?>
+
+
+
+
+
+ = $form->field($model, 'description')->textarea(['maxlength' => true]) ?>
+
+
+
+
+
+ = $form->field($model, 'tax_number')->textInput(['maxlength' => true]) ?>
+
+
+
+
+ = $form->field($model, 'country')->textInput(['maxlength' => true]) ?>
+
+
+
+
+ = $form->field($model, 'zip')->widget(CityZipTypeahead::className(),[
+ 'pluginEvents' =>[
+ "typeahead:select" => "function(a,b) {
+ $('#customercreate-city').typeahead( 'val', b.name );
+ }",]
+ ])?>
+
+
+ field($model, 'city')->widget(CityNameTypeahead::className(),[
+ 'pluginEvents' =>[
+ "typeahead:select" => "function(a,b) {
+ $('#customercreate-zip').typeahead( 'val', b.zip );
+ }",]
+
+ ])?>
+
+
+
+
+
+
+ = $form->field($model, 'address')->textInput(['maxlength' => true]) ?>
+
+
+ = Html::submitButton($model->isNewRecord ? Yii::t('common/customer', 'Create') : Yii::t('common/customer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
+
+
+
+
+
diff --git a/frontend/views/customer/_form_reception.php b/frontend/views/customer/_form_reception.php
deleted file mode 100644
index d4f01d7..0000000
--- a/frontend/views/customer/_form_reception.php
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-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 ] );
-}
-
-?>
-
-
diff --git a/frontend/views/customer/_form_update.php b/frontend/views/customer/_form_update.php
index b42be88..0823749 100644
--- a/frontend/views/customer/_form_update.php
+++ b/frontend/views/customer/_form_update.php
@@ -44,31 +44,19 @@ use yii\base\Widget;
-
-
-
-
- = $form->field($model, 'password_plain')->passwordInput(['maxlength' => true]) ?>
-
-
- = $form->field($model, 'password_repeat')->passwordInput(['maxlength' => true]) ?>
-
-
-
= $form->field($model, 'sex')->dropDownList(Customer::sexes()) ?>
- field($model, 'birthdate',[ ] )->widget(DatePicker::classname(), [
- 'value' => Yii::$app->formatter->asDate($model->birthdate),
+ field($model, 'birthdate',[ ] )->widget(DatePicker::classname(), [
'pluginOptions' => [
'autoclose'=>true,
'format' => 'yyyy.mm.dd'
]
- ]) */?>
+ ]) ?>
'CustomerUpdate[birthdate]',
'value' => Yii::$app->formatter->asDate($model->birthdate),
@@ -77,7 +65,8 @@ use yii\base\Widget;
'format' => 'yyyy.mm.dd'
]
]
- )
+ );
+ */
?>
diff --git a/frontend/views/customer/create.php b/frontend/views/customer/create.php
index a9e04e8..9bc033f 100644
--- a/frontend/views/customer/create.php
+++ b/frontend/views/customer/create.php
@@ -1,20 +1,38 @@
title = Yii::t('frontend/customer', 'Create Customer');
-$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/customer', 'Customers'), 'url' => ['index']];
+$this->title = Yii::t('common/customer', 'Create Customer');
+$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
+
+
+$customer = $model;
+$card = $customer->card;
+
?>
+
+
+ $customer, 'card' => $card] ) ?>
+
+
+ $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
+
+
+
+
+
= Html::encode($this->title) ?>
- = $this->render('_form', [
+ = $this->render('_form_create', [
'model' => $model,
]) ?>
diff --git a/frontend/views/customer/update.php b/frontend/views/customer/update.php
index 05727b3..debcd50 100644
--- a/frontend/views/customer/update.php
+++ b/frontend/views/customer/update.php
@@ -7,9 +7,7 @@ use frontend\components\ReceptionCardNumberWidget;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
-$this->title = Yii::t('common/customer', 'Update {modelClass}: ', [
- 'modelClass' => 'Customer',
-]) . ' ' . $model->name;
+$this->title = Yii::t('common/customer', 'Update customer:' ) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/customer', 'Customers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_customer]];
$this->params['breadcrumbs'][] = Yii::t('common/customer', 'Update');
@@ -20,7 +18,6 @@ $card = $customer->card;
?>
-
= Html::encode($this->title) ?>
@@ -33,6 +30,7 @@ $card = $customer->card;
+
= Html::encode($this->title) ?>
= $this->render('_form_update', [
'model' => $model,
]) ?>
diff --git a/frontend/views/layouts/main.php b/frontend/views/layouts/main.php
index ba9afeb..993db33 100644
--- a/frontend/views/layouts/main.php
+++ b/frontend/views/layouts/main.php
@@ -11,6 +11,7 @@ use frontend\assets\AppAsset;
use common\widgets\Alert;
use common\components\FrotnendMenuStructure;
use frontend\components\FrontendMenuStructure;
+use kartik\widgets\AlertBlock;
AppAsset::register($this);
?>
@@ -30,6 +31,13 @@ AppAsset::register($this);
true,
+ 'type' => AlertBlock::TYPE_GROWL,
+ 'delay' => '3000'
+ ]);
+
$menuStruct = new FrontendMenuStructure();
$items = $menuStruct->run();
diff --git a/frontend/views/product/index.php b/frontend/views/product/index.php
index 7b36ca2..9185b8a 100644
--- a/frontend/views/product/index.php
+++ b/frontend/views/product/index.php
@@ -21,9 +21,7 @@ $this->params['breadcrumbs'][] = $this->title;
= GridView::widget([
'dataProvider' => $dataProvider,
- 'filterModel' => $searchModel,
'columns' => [
- ['class' => 'yii\grid\SerialColumn'],
'id_product',
'id_product_category',