From 01da3c470c5b919d5031ade8784f9e2ae31da46b Mon Sep 17 00:00:00 2001 From: rocho Date: Mon, 26 Oct 2015 07:49:10 +0100 Subject: [PATCH] add default account to frontend --- common/models/Account.php | 11 ++ common/models/ShoppingCart.php | 2 +- common/models/Ticket.php | 3 +- ...228_alter__table__add__column__paid_at.php | 30 ++++ frontend/components/FrontendMenuStructure.php | 3 +- frontend/components/HtmlHelper.php | 22 ++- .../components/ReceptionCardNumberWidget.php | 8 +- .../components/ReceptionCustomerWidget.php | 22 +++ frontend/components/ReceptionMenuWidget.php | 5 +- frontend/components/ReceptionTicketWidget.php | 22 +++ frontend/components/ReceptionWidget.php | 11 +- frontend/controllers/AccountController.php | 145 ++++++++++++++++++ frontend/controllers/CustomerController.php | 19 +++ .../controllers/MoneyMovementController.php | 1 + frontend/controllers/ProductController.php | 13 +- frontend/controllers/TicketController.php | 3 +- frontend/models/AccountSearch.php | 70 +++++++++ frontend/models/AccountSelect.php | 42 +++++ frontend/models/CustomerCreate.php | 24 ++- frontend/models/CustomerUpdate.php | 19 +++ frontend/models/ReceptionForm.php | 35 +++++ frontend/views/account/_form.php | 27 ++++ frontend/views/account/_search.php | 37 +++++ frontend/views/account/create.php | 21 +++ frontend/views/account/index.php | 39 +++++ frontend/views/account/select.php | 24 +++ frontend/views/account/update.php | 23 +++ frontend/views/account/view.php | 40 +++++ frontend/views/common/_form_card_number.php | 42 ----- frontend/views/common/_menu_reception.php | 80 ---------- frontend/views/common/_reception.php | 13 +- frontend/views/common/_reception_customer.php | 45 ++++++ .../common/_reception_form_card_number.php | 50 ++++++ frontend/views/common/_reception_menu.php | 59 +++++++ frontend/views/common/_reception_ticket.php | 60 ++++++++ frontend/views/customer/create.php | 12 +- frontend/views/customer/reception.php | 19 +-- frontend/views/customer/update.php | 13 +- frontend/views/product/_sale_form.php | 8 +- frontend/views/product/_user_cart.php | 6 +- frontend/views/product/sale.php | 18 +-- frontend/views/ticket/_form.php | 4 + frontend/views/ticket/create.php | 13 +- frontend/web/js/product.sell.js | 3 +- frontend/web/js/ticket.sell.js | 2 +- 45 files changed, 948 insertions(+), 220 deletions(-) create mode 100644 console/migrations/m151025_152228_alter__table__add__column__paid_at.php create mode 100644 frontend/components/ReceptionCustomerWidget.php create mode 100644 frontend/components/ReceptionTicketWidget.php create mode 100644 frontend/controllers/AccountController.php create mode 100644 frontend/models/AccountSearch.php create mode 100644 frontend/models/AccountSelect.php create mode 100644 frontend/views/account/_form.php create mode 100644 frontend/views/account/_search.php create mode 100644 frontend/views/account/create.php create mode 100644 frontend/views/account/index.php create mode 100644 frontend/views/account/select.php create mode 100644 frontend/views/account/update.php create mode 100644 frontend/views/account/view.php delete mode 100644 frontend/views/common/_form_card_number.php delete mode 100644 frontend/views/common/_menu_reception.php create mode 100644 frontend/views/common/_reception_customer.php create mode 100644 frontend/views/common/_reception_form_card_number.php create mode 100644 frontend/views/common/_reception_menu.php create mode 100644 frontend/views/common/_reception_ticket.php diff --git a/common/models/Account.php b/common/models/Account.php index 6633ca0..df458f6 100644 --- a/common/models/Account.php +++ b/common/models/Account.php @@ -143,6 +143,17 @@ class Account extends \yii\db\ActiveRecord return $accounts; } + public static function writeDefault($account){ + $session = Yii::$app->session; + $session->set('id_account', $account->id_account); + + } + public static function readDefault( ){ + $session = Yii::$app->session; + $result = $session->get('id_account'); + return $result; + + } } diff --git a/common/models/ShoppingCart.php b/common/models/ShoppingCart.php index 5349e7d..a955c0b 100644 --- a/common/models/ShoppingCart.php +++ b/common/models/ShoppingCart.php @@ -68,7 +68,7 @@ class ShoppingCart extends \yii\db\ActiveRecord //delete cart $sql = "UPDATE transfer AS t INNER JOIN shopping_cart AS s ON t.id_transfer = s.id_transfer - SET t.status = " . Transfer::STATUS_PAID + SET t.status = " . Transfer::STATUS_PAID . " t.paid_at = " . date('Y-m-d H:i:s' ) . " WHERE t.status = " . Transfer::STATUS_NOT_PAID; $q1 = Yii::$app->db->createCommand($sql); diff --git a/common/models/Ticket.php b/common/models/Ticket.php index 86bbf24..1f1152b 100644 --- a/common/models/Ticket.php +++ b/common/models/Ticket.php @@ -3,6 +3,7 @@ namespace common\models; use Yii; +use yii\db\ActiveRecord; /** * This is the model class for table "ticket". @@ -140,7 +141,7 @@ class Ticket extends \common\models\BaseFitnessActiveRecord $query->andWhere(['id_card' => $card->id_card]); $query->andWhere( 'start <= :today' ,[ 'today' => $today] ); $query->andWhere( 'end >= :today' ,[ 'today' => $today] ); - + $query->orderBy([ "created_at" =>SORT_DESC] ); $result = $query->all(); return $result; diff --git a/console/migrations/m151025_152228_alter__table__add__column__paid_at.php b/console/migrations/m151025_152228_alter__table__add__column__paid_at.php new file mode 100644 index 0000000..4bf5888 --- /dev/null +++ b/console/migrations/m151025_152228_alter__table__add__column__paid_at.php @@ -0,0 +1,30 @@ +addColumn("transfer", "paid_at", "datetime"); + } + + public function down() + { + echo "m151025_152228_alter__table__add__column__paid_at cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/frontend/components/FrontendMenuStructure.php b/frontend/components/FrontendMenuStructure.php index 505d3d5..6e61ed1 100644 --- a/frontend/components/FrontendMenuStructure.php +++ b/frontend/components/FrontendMenuStructure.php @@ -28,7 +28,7 @@ class FrontendMenuStructure{ if ( $this->isLogged() ){ $lastAccountState = AccountState::find()->andWhere(['id_user' => Yii::$app->user->id])->orderBy(['account_state.created_at' => SORT_DESC])->limit(1)->one(); if ( isset($lastAccountState) ){ - $this->start = strtotime( $lastAccountState->created_at . ' UTC' ); + $this->start = Yii::$app->formatter->asDatetime(strtotime( $lastAccountState->created_at . ' UTC' )); } } @@ -60,6 +60,7 @@ class FrontendMenuStructure{ $this->menuItems[] = ['label' => 'Pénzmozgások', 'url' => [ '/money-movement/index', 'MoneyMovementSearch[start]' => $this->start, 'MoneyMovementSearch[end]' => $this->tomorrow ] ]; $this->menuItems[] = ['label' => 'Kassza', 'items' => [ + ['label' => Yii::t('frontend/account-state','Default account'), 'url' => ['/account/select'] ], ['label' => Yii::t('frontend/account-state', 'Account states'), 'url' => ['/account-state/index'] ], ['label' => Yii::t('frontend/account-state','Open account state'), 'url' => ['/account-state/open'] ], ['label' => Yii::t('frontend/account-state','Close account state'), 'url' => ['/account-state/close'] ], diff --git a/frontend/components/HtmlHelper.php b/frontend/components/HtmlHelper.php index e399098..af28f4a 100644 --- a/frontend/components/HtmlHelper.php +++ b/frontend/components/HtmlHelper.php @@ -17,9 +17,10 @@ class HtmlHelper{ * @see ReceptionCardNumberWidget * @see ReceptionMenuWidget * */ - public static function mkReceptionCardBtn($card, $label,$route = null ){ + public static function mkReceptionCardBtn($recptionForm, $label,$route = null ){ $url = null; + $card = $recptionForm->card; $classes = 'btn btn-primary btn-reception'; if ( $card == null ){ $classes .= ' disabled'; @@ -29,10 +30,25 @@ class HtmlHelper{ } return Html::a( $label , $url, ['class' => $classes ] ); } - - public static function mkReceptionBtn($card, $label,$route = null ){ + public static function mkReceptionCustomerBtn($recptionForm, $label,$route = null ){ $url = null; + $card = $recptionForm->card; + $customer = $recptionForm->customer; + $classes = 'btn btn-primary btn-reception'; + if ( $card == null || $customer == null){ + $classes .= ' disabled'; + } + if ( isset($route)){ + $url = [$route, 'number' => ( isset( $card ) ? $card->number : '' )]; + } + return Html::a( $label , $url, ['class' => $classes ] ); + } + + public static function mkReceptionBtn($recptionForm, $label,$route = null ){ + + $url = null; + $card = $recptionForm->card; $classes = 'btn btn-primary btn-reception'; if ( isset($route)){ diff --git a/frontend/components/ReceptionCardNumberWidget.php b/frontend/components/ReceptionCardNumberWidget.php index 983b6c1..5741966 100644 --- a/frontend/components/ReceptionCardNumberWidget.php +++ b/frontend/components/ReceptionCardNumberWidget.php @@ -8,14 +8,12 @@ class ReceptionCardNumberWidget extends Widget{ public $number; public $route; - public $customer; - public $card; - - public $viewFile = '//common/_form_card_number'; + public $model; + public $viewFile = '//common/_reception_form_card_number'; public function run(){ - echo $this->render($this->viewFile,['card' => $this->card, 'customer' =>$this->customer , 'route' => $this->route ]); + echo $this->render($this->viewFile,['model' => $this->model, 'route' => $this->route ]); } diff --git a/frontend/components/ReceptionCustomerWidget.php b/frontend/components/ReceptionCustomerWidget.php new file mode 100644 index 0000000..96255e2 --- /dev/null +++ b/frontend/components/ReceptionCustomerWidget.php @@ -0,0 +1,22 @@ +render($this->viewFile,[ 'model' => $this->model ]); + } + + +} \ No newline at end of file diff --git a/frontend/components/ReceptionMenuWidget.php b/frontend/components/ReceptionMenuWidget.php index a1cd23d..656cb4b 100644 --- a/frontend/components/ReceptionMenuWidget.php +++ b/frontend/components/ReceptionMenuWidget.php @@ -11,11 +11,12 @@ class ReceptionMenuWidget extends Widget{ public $customer; public $card; - public $viewFile = '//common/_menu_reception'; + public $viewFile = '//common/_reception_menu'; + public $model; public function run(){ - echo $this->render($this->viewFile,['card' => $this->card, 'customer' =>$this->customer ]); + echo $this->render($this->viewFile,[ 'model' => $this->model ]); } diff --git a/frontend/components/ReceptionTicketWidget.php b/frontend/components/ReceptionTicketWidget.php new file mode 100644 index 0000000..bb10d71 --- /dev/null +++ b/frontend/components/ReceptionTicketWidget.php @@ -0,0 +1,22 @@ +render($this->viewFile,[ 'model' => $this->model ]); + } + + +} \ No newline at end of file diff --git a/frontend/components/ReceptionWidget.php b/frontend/components/ReceptionWidget.php index d7fbce4..f83e227 100644 --- a/frontend/components/ReceptionWidget.php +++ b/frontend/components/ReceptionWidget.php @@ -10,26 +10,17 @@ class ReceptionWidget extends Widget{ public $number; public $route; - public $customer; - public $card; - - public $tickets; public $viewFile = '//common/_reception'; public function init(){ parent::init(); - if ( isset($this->form)){ - $this->card = $this->form->card; - $this->customer = $this->form->customer; - $this->tickets = $this->form->tickets; - } } public function run(){ - echo $this->render($this->viewFile,['card' => $this->card, 'customer' =>$this->customer, 'tickets' => $this->tickets ]); + echo $this->render($this->viewFile,[ 'model' => $this->form ]); } diff --git a/frontend/controllers/AccountController.php b/frontend/controllers/AccountController.php new file mode 100644 index 0000000..febe2ea --- /dev/null +++ b/frontend/controllers/AccountController.php @@ -0,0 +1,145 @@ + [ + 'class' => VerbFilter::className(), + 'actions' => [ + 'delete' => ['post'], + ], + ], + ]; + } + + + /** + * Lists all Account models. + * @return mixed + */ + public function actionSelect() + { + $model = new AccountSelect(); + + $model->id_account = Account::readDefault(); + + $accounts = Account::read(); + + if ($model->load(Yii::$app->request->post()) && $model->writeToSession()) { + Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Default session is set!') ); + } + return $this->render('select', [ + 'model' => $model, + 'accounts' => $accounts + ]); + } + + /** + * Lists all Account models. + * @return mixed + */ + public function actionIndex() + { + $searchModel = new AccountSearch(); + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); + + return $this->render('index', [ + 'searchModel' => $searchModel, + 'dataProvider' => $dataProvider, + ]); + } + + /** + * Displays a single Account model. + * @param integer $id + * @return mixed + */ + public function actionView($id) + { + return $this->render('view', [ + 'model' => $this->findModel($id), + ]); + } + + /** + * Creates a new Account model. + * If creation is successful, the browser will be redirected to the 'view' page. + * @return mixed + */ + public function actionCreate() + { + $model = new Account(); + + if ($model->load(Yii::$app->request->post()) && $model->save()) { + return $this->redirect(['view', 'id' => $model->id_account]); + } else { + return $this->render('create', [ + 'model' => $model, + ]); + } + } + + /** + * Updates an existing Account 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_account]); + } else { + return $this->render('update', [ + 'model' => $model, + ]); + } + } + + /** + * Deletes an existing Account 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 Account model based on its primary key value. + * If the model is not found, a 404 HTTP exception will be thrown. + * @param integer $id + * @return Account the loaded model + * @throws NotFoundHttpException if the model cannot be found + */ + protected function findModel($id) + { + if (($model = Account::findOne($id)) !== null) { + return $model; + } else { + throw new NotFoundHttpException('The requested page does not exist.'); + } + } +} diff --git a/frontend/controllers/CustomerController.php b/frontend/controllers/CustomerController.php index 2cf5187..4024fcf 100644 --- a/frontend/controllers/CustomerController.php +++ b/frontend/controllers/CustomerController.php @@ -55,6 +55,14 @@ class CustomerController extends Controller $model->readCard(); + if ( $model->isFreeCard() ){ + return $this->redirect([ 'create', 'number' => $model->card->number ]); + }else if ( $model->isCustomerWithTicket()){ + return $this->redirect([ 'product/sale', 'number' => $model->card->number ]); + }else if ( $model->isCardWithCustomer() ){ + return $this->redirect([ 'ticket/create', 'number' => $model->card->number ]); + } + return $this->render('reception',['model' => $model]); } @@ -102,6 +110,10 @@ class CustomerController extends Controller $model->id_user = Yii::$app->user->id; + $receptionForm = new ReceptionForm(); + $receptionForm->number = $number; + $receptionForm->readCard(); + if ( isset($number)){ $model->cardNumber = $number; } @@ -112,6 +124,7 @@ class CustomerController extends Controller } else { return $this->render('create', [ 'model' => $model, + 'receptionForm' => $receptionForm ]); } } @@ -126,6 +139,11 @@ class CustomerController extends Controller { $card = null; $model = null; + + $receptionForm = new ReceptionForm(); + $receptionForm->number = $number; + $receptionForm->readCard(); + if ( $number != null ){ $card = Card::readCard($number); if ( $card != null ){ @@ -151,6 +169,7 @@ class CustomerController extends Controller return $this->render('update', [ 'model' => $model, + 'receptionForm' => $receptionForm ]); } } diff --git a/frontend/controllers/MoneyMovementController.php b/frontend/controllers/MoneyMovementController.php index ec5ebba..40fb172 100644 --- a/frontend/controllers/MoneyMovementController.php +++ b/frontend/controllers/MoneyMovementController.php @@ -65,6 +65,7 @@ class MoneyMovementController extends Controller $model->id_user = Yii::$app->user->id; $model->type = MoneyMovement::TYPE_OUT; + $model->id_account = Account::readDefault(); $accounts = Account::read(); diff --git a/frontend/controllers/ProductController.php b/frontend/controllers/ProductController.php index c135d35..77299a0 100644 --- a/frontend/controllers/ProductController.php +++ b/frontend/controllers/ProductController.php @@ -21,7 +21,7 @@ use common\models\Transfer; use common\models\User; use common\models\UserSoldItem; use common\models\ShoppingCart; - +use frontend\models\ReceptionForm; /** * ProductController implements the CRUD actions for Product model. */ @@ -58,7 +58,14 @@ class ProductController extends Controller public function actionSale( $number = null){ - $this->findByNumber($number); +// $this->findByNumber($number); + + $receptionForm = new ReceptionForm() ; + $receptionForm->number = $number; + $receptionForm->readCard(); + + $this->card = $receptionForm->card; + $this->customer = $receptionForm->customer; $model = new ProductSaleForm(); @@ -83,6 +90,7 @@ class ProductController extends Controller $model->accounts = $accounts; $model->discounts = $discounts; + $model->id_account = Account::readDefault(); $result = []; $result['code'] = 'unknown'; @@ -120,6 +128,7 @@ class ProductController extends Controller 'accounts' => $accounts, 'discounts' => $discounts, 'userTransfers' => $userTransfers, + 'receptionForm' => $receptionForm, ]); } diff --git a/frontend/controllers/TicketController.php b/frontend/controllers/TicketController.php index f8dd1d8..890af5e 100644 --- a/frontend/controllers/TicketController.php +++ b/frontend/controllers/TicketController.php @@ -80,9 +80,7 @@ class TicketController extends Controller { $receptionForm = new ReceptionForm(); - $receptionForm->number = $number; - $receptionForm->readCard(); if ( !isset($receptionForm->card ) ){ @@ -104,6 +102,7 @@ class TicketController extends Controller $model->status = Ticket::STATUS_ACTIVE; $model->usage_count = 0; $model->id_card = $receptionForm->card->id_card; + $model->id_account = Account::readDefault(); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', Yii::t('frontend/ticket', 'Ticket added to customer') ); diff --git a/frontend/models/AccountSearch.php b/frontend/models/AccountSearch.php new file mode 100644 index 0000000..750469d --- /dev/null +++ b/frontend/models/AccountSearch.php @@ -0,0 +1,70 @@ + $query, + ]); + + $this->load($params); + + if (!$this->validate()) { + // uncomment the following line if you do not want to return any records when validation fails + // $query->where('0=1'); + return $dataProvider; + } + + $query->andFilterWhere([ + 'id_account' => $this->id_account, + 'status' => $this->status, + 'type' => $this->type, + 'created_at' => $this->created_at, + 'updated_at' => $this->updated_at, + ]); + + $query->andFilterWhere(['like', 'name', $this->name]); + + return $dataProvider; + } +} diff --git a/frontend/models/AccountSelect.php b/frontend/models/AccountSelect.php new file mode 100644 index 0000000..49ada27 --- /dev/null +++ b/frontend/models/AccountSelect.php @@ -0,0 +1,42 @@ +id_account); + Account::writeDefault($account); + return true; + } + +} diff --git a/frontend/models/CustomerCreate.php b/frontend/models/CustomerCreate.php index 41f47eb..7b88074 100644 --- a/frontend/models/CustomerCreate.php +++ b/frontend/models/CustomerCreate.php @@ -68,6 +68,15 @@ class CustomerCreate extends \common\models\Customer [['email'], 'string', 'max' => 255], [['email'], 'email' ], [['email'], 'unique' ], + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , +// 'enableClientValidation' => false, + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/frontend','E-mail or phone number required!') + ], [['password_plain','password_repeat'], 'string', 'max' => 32], @@ -80,13 +89,24 @@ class CustomerCreate extends \common\models\Customer [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , +// 'enableClientValidation' => false, + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/frontend','E-mail or phone number required!') + ], + [['zip'], 'string', 'max' => 8], - [['city'], 'string', 'max' => 30] + [['city'], 'string', 'max' => 30], + +// [['email','phone'], 'validateEmailOrPhoneRequired' ], ]; } - public function validateCustomerCard($a,$p){ $card = null; diff --git a/frontend/models/CustomerUpdate.php b/frontend/models/CustomerUpdate.php index 8f1967f..dab17eb 100644 --- a/frontend/models/CustomerUpdate.php +++ b/frontend/models/CustomerUpdate.php @@ -68,6 +68,16 @@ class CustomerUpdate extends \common\models\Customer [['email'], 'email' ], [['email'], 'unique' ], + [['email'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty($model->phone) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/frontend','E-mail or phone number required!') + ], + + // [['password_plain','password_repeat'], 'string', 'max' => 32], [['sex'], 'integer'], @@ -79,6 +89,15 @@ class CustomerUpdate extends \common\models\Customer [['phone', 'tax_number', 'country'], 'string', 'max' => 20], + [['phone'], 'required', 'when' => function($model) { + return !isset( $model->email ) || empty( $model->email ) ; + } , + 'whenClient' => "function (attribute, value) { + return false; + }", + 'message' => Yii::t('customer/frontend','E-mail or phone number required!') + ], + [['zip'], 'string', 'max' => 8], [['city'], 'string', 'max' => 30] diff --git a/frontend/models/ReceptionForm.php b/frontend/models/ReceptionForm.php index 372314f..83be5df 100644 --- a/frontend/models/ReceptionForm.php +++ b/frontend/models/ReceptionForm.php @@ -53,6 +53,41 @@ class ReceptionForm extends Model $this->tickets = Ticket::readActive($this->card); } + /** + * @return true , if card found without customer + * */ + public function isFreeCard(){ + $result = isset($this->card) && !isset($this->customer); + return $result; + } + /** + * @return true , if card found with customer + * */ + public function isCardWithCustomer(){ + $result = isset($this->card) && isset($this->customer); + return $result; + } + + /** + * @return true , if card and customer found with at least one valid tickets + * */ + public function isCustomerWithTicket(){ + $result = false; + if ( isset($this->card) && isset($this->customer) ){ + if ( isset($this->tickets) && count($this->tickets) > 0 ){ + $result = true; + } + } + return $result; + } + + /** + * @return true, if no card and customer found + * */ + public function isInvalidNumber(){ + $result = !isset($this->card) && !isset($this->customer); + return $result; + } } diff --git a/frontend/views/account/_form.php b/frontend/views/account/_form.php new file mode 100644 index 0000000..cf488db --- /dev/null +++ b/frontend/views/account/_form.php @@ -0,0 +1,27 @@ + + +
+ + + + field($model, 'name')->textInput(['maxlength' => true]) ?> + + field($model, 'status')->textInput() ?> + + field($model, 'type')->textInput() ?> + +
+ isNewRecord ? Yii::t('frontend/account', 'Create') : Yii::t('frontend/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/account/_search.php b/frontend/views/account/_search.php new file mode 100644 index 0000000..337bb59 --- /dev/null +++ b/frontend/views/account/_search.php @@ -0,0 +1,37 @@ + + + diff --git a/frontend/views/account/create.php b/frontend/views/account/create.php new file mode 100644 index 0000000..d6cd64e --- /dev/null +++ b/frontend/views/account/create.php @@ -0,0 +1,21 @@ +title = Yii::t('frontend/account', 'Create Account'); +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/account/index.php b/frontend/views/account/index.php new file mode 100644 index 0000000..0a24e42 --- /dev/null +++ b/frontend/views/account/index.php @@ -0,0 +1,39 @@ +title = Yii::t('frontend/account', 'Accounts'); +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ render('_search', ['model' => $searchModel]); ?> + +

+ 'btn btn-success']) ?> +

+ + $dataProvider, + 'filterModel' => $searchModel, + 'columns' => [ + ['class' => 'yii\grid\SerialColumn'], + + 'id_account', + 'name', + 'status', + 'type', + 'created_at', + // 'updated_at', + + ['class' => 'yii\grid\ActionColumn'], + ], + ]); ?> + +
diff --git a/frontend/views/account/select.php b/frontend/views/account/select.php new file mode 100644 index 0000000..33ac305 --- /dev/null +++ b/frontend/views/account/select.php @@ -0,0 +1,24 @@ + + +
+ + + + field($model, 'id_account')->dropDownList(HtmlHelper::mkAccountOptions($accounts)) ?> + +
+ 'btn btn-primary']) ?> +
+ + + +
diff --git a/frontend/views/account/update.php b/frontend/views/account/update.php new file mode 100644 index 0000000..267b397 --- /dev/null +++ b/frontend/views/account/update.php @@ -0,0 +1,23 @@ +title = Yii::t('frontend/account', 'Update {modelClass}: ', [ + 'modelClass' => 'Account', +]) . ' ' . $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_account]]; +$this->params['breadcrumbs'][] = Yii::t('frontend/account', 'Update'); +?> +
+ +

title) ?>

+ + render('_form', [ + 'model' => $model, + ]) ?> + +
diff --git a/frontend/views/account/view.php b/frontend/views/account/view.php new file mode 100644 index 0000000..8aa3ed7 --- /dev/null +++ b/frontend/views/account/view.php @@ -0,0 +1,40 @@ +title = $model->name; +$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account', 'Accounts'), 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ +

title) ?>

+ +

+ $model->id_account], ['class' => 'btn btn-primary']) ?> + $model->id_account], [ + 'class' => 'btn btn-danger', + 'data' => [ + 'confirm' => Yii::t('frontend/account', 'Are you sure you want to delete this item?'), + 'method' => 'post', + ], + ]) ?> +

+ + $model, + 'attributes' => [ + 'id_account', + 'name', + 'status', + 'type', + 'created_at', + 'updated_at', + ], + ]) ?> + +
diff --git a/frontend/views/common/_form_card_number.php b/frontend/views/common/_form_card_number.php deleted file mode 100644 index 15ffe85..0000000 --- a/frontend/views/common/_form_card_number.php +++ /dev/null @@ -1,42 +0,0 @@ - - -number; -} -if ( isset($customer) ){ - $customername = $customer->name; -} - -?> - - false, - 'method' => 'get', - 'action' => $route - ]); ?> -
-
- -
-
- -
-
- 'btn btn-primary']); ?> -
-
- - - - diff --git a/frontend/views/common/_menu_reception.php b/frontend/views/common/_menu_reception.php deleted file mode 100644 index 64d6f9c..0000000 --- a/frontend/views/common/_menu_reception.php +++ /dev/null @@ -1,80 +0,0 @@ - - - - -name; -} - -/* -function mkCustomerBtn($card, $label,$route = null ){ - - $url = null; - $classes = 'btn btn-primary btn-reception'; - if ( $card == null ){ - $classes .= ' disabled'; - } - if ( isset($route)){ - $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'; - - 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' ); ?> -
-
-
-
- -
-
- - - diff --git a/frontend/views/common/_reception.php b/frontend/views/common/_reception.php index 3315a8f..cd5f30b 100644 --- a/frontend/views/common/_reception.php +++ b/frontend/views/common/_reception.php @@ -4,15 +4,20 @@ use frontend\components\ReceptionMenuWidget; use frontend\models\ReceptionForm; use frontend\components\ReceptionCardNumberTicketsWidget; use yii\base\Widget; +use frontend\components\ReceptionTicketWidget; +use frontend\components\ReceptionCustomerWidget; ?>
- $customer, 'card' => $card] ) ?> + $model ] ) ?> +
+
+ $model, 'route' => ['customer/reception'] ] )?>
- $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?> + $model ] ) ?>
-
- $tickets, 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] ) ?> +
+ $model ] ) ?>
\ No newline at end of file diff --git a/frontend/views/common/_reception_customer.php b/frontend/views/common/_reception_customer.php new file mode 100644 index 0000000..b79b290 --- /dev/null +++ b/frontend/views/common/_reception_customer.php @@ -0,0 +1,45 @@ + + +isCardWithCustomer() ){ +?> +
+
+ $model, + 'attributes' =>[ + [ + 'label' => 'Kártyaszám', + 'value' => $model->card->number + ], + [ + 'label' => 'Vendég', + 'value' => $model->customer->name + ], + [ + 'label' => 'E-Mail', + 'value' => $model->customer->email + ], + [ + 'label' => 'Telefon', + 'value' => $model->customer->phone + ], + ] + + ]) + ?> +
+
+ \ No newline at end of file diff --git a/frontend/views/common/_reception_form_card_number.php b/frontend/views/common/_reception_form_card_number.php new file mode 100644 index 0000000..d551fbf --- /dev/null +++ b/frontend/views/common/_reception_form_card_number.php @@ -0,0 +1,50 @@ + + + + +card)){ + $number = $model->card->number; +} + +?> + +
+ false, + 'method' => 'get', + 'action' => $route + ]); ?> +
+
+ 'form-control'])?> +
+
+
+
+ 'btn btn-primary btn-block']); ?> +
+
+ +
+ + + diff --git a/frontend/views/common/_reception_menu.php b/frontend/views/common/_reception_menu.php new file mode 100644 index 0000000..313a00c --- /dev/null +++ b/frontend/views/common/_reception_menu.php @@ -0,0 +1,59 @@ + + + + +customer ) ){ + $customername = $model->customer->name; +} + +$card = $model->card; + + + + +?> +
+
+ +
+
+ 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?> +
+
+
+
+ +
+
+ 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?> +
+
+
+
+ +
+
+ + + diff --git a/frontend/views/common/_reception_ticket.php b/frontend/views/common/_reception_ticket.php new file mode 100644 index 0000000..dfb9655 --- /dev/null +++ b/frontend/views/common/_reception_ticket.php @@ -0,0 +1,60 @@ + + +tickets) > 0 ){ + $ticket = $model->tickets[0]; +} + +if ( isset($model->card)){ + if ( isset($model->customer)){ + if ( isset($ticket)){ + echo Html::beginTag("div",['class'=>"alert alert-success" , "role"=>"alert"]); + echo Html::beginTag("strong",[ ]); + echo "Érvényes bérlet!" ; + echo Html::endTag("strong"); + echo Html::tag("br"); + echo Html::beginTag("strong",[ ]); + echo "Típus: " ; + echo Html::endTag("strong"); + echo $ticket->ticketTypeName ; + echo Html::tag("br"); + echo Html::beginTag("strong",[ ]); + echo "Érvényes: " ; + echo Html::endTag("strong"); + echo Yii::$app->formatter->asDate($ticket->start); + echo " - "; + echo Yii::$app->formatter->asDate($ticket->end); + echo Html::endTag("div"); + }else{ + echo Html::beginTag("div",['class'=>"alert alert-danger", "role"=>"alert"]); + echo Html::beginTag("strong",[ ]); + echo "Bérlet lejárt vagy nem érvényes!"; + echo Html::endTag("strong"); + echo Html::endTag("div"); + } + }else{ + echo Html::beginTag("div",['class'=>"alert alert-info" ,"role"=>"alert"]); + echo Html::beginTag("strong",[ ]); + echo "Üres bérlet!"; + echo Html::endTag("strong"); + echo Html::endTag("div"); + } +}else{ + echo Html::beginTag("div",['class'=>"alert alert-warning" ,"role"=>"alert"]); + echo Html::beginTag("strong",[ ]); + echo "Nincs bérlet megadva!"; + echo Html::endTag("strong"); + echo Html::endTag("div"); +} + +?> \ No newline at end of file diff --git a/frontend/views/customer/create.php b/frontend/views/customer/create.php index 0588016..5708176 100644 --- a/frontend/views/customer/create.php +++ b/frontend/views/customer/create.php @@ -3,6 +3,7 @@ use yii\helpers\Html; use frontend\components\ReceptionMenuWidget; use frontend\components\ReceptionCardNumberWidget; +use frontend\components\ReceptionWidget; /* @var $this yii\web\View */ @@ -18,16 +19,7 @@ $card = $customer->card; ?>
-
-
- $customer, 'card' => $card] ) ?> -
-
- $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?> -
-
-
-
+ $receptionForm, 'route' => ['customer/create'] ] )?>

title) ?>

diff --git a/frontend/views/customer/reception.php b/frontend/views/customer/reception.php index fefac02..2f9a03b 100644 --- a/frontend/views/customer/reception.php +++ b/frontend/views/customer/reception.php @@ -2,23 +2,8 @@ use frontend\components\ReceptionMenuWidget; use frontend\components\ReceptionCardNumberWidget; use yii\base\Widget; - - - +use frontend\components\ReceptionWidget; ?>

Recepció

- -render('_form_reception', [ 'model' => $model ]); ?> -
-
- $model->customer, 'card' =>$model->card ] ) ?> -
-
- $model->customer, 'card' =>$model->card, 'route' => ['customer/reception'] ] )?> -
-
-
-
\ No newline at end of file + $model, 'route' => ['customer/reception'] ] )?> diff --git a/frontend/views/customer/update.php b/frontend/views/customer/update.php index debcd50..5a7175a 100644 --- a/frontend/views/customer/update.php +++ b/frontend/views/customer/update.php @@ -3,6 +3,7 @@ use yii\helpers\Html; use frontend\components\ReceptionMenuWidget; use frontend\components\ReceptionCardNumberWidget; +use frontend\components\ReceptionWidget; /* @var $this yii\web\View */ /* @var $model common\models\Customer */ @@ -19,16 +20,8 @@ $card = $customer->card;
-
-
- $customer, 'card' => $card] ) ?> -
-
- $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?> -
-
-
-
+ $receptionForm, 'route' => ['customer/reception'] ] )?> +

title) ?>

render('_form_update', [ diff --git a/frontend/views/product/_sale_form.php b/frontend/views/product/_sale_form.php index ebd9850..2e3069d 100644 --- a/frontend/views/product/_sale_form.php +++ b/frontend/views/product/_sale_form.php @@ -99,15 +99,15 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
- 'btn btn-success', 'id' => 'btn_sell'] );?> + 'btn btn-success btn-block', 'id' => 'btn_sell'] );?>
- 'btn btn-success', 'id' => 'btn_sell_append'] );?> + 'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
card) ){ - echo Html::a(Yii::t("frontend/product","Write up"),null,['class' => 'btn btn-success', 'id' => 'btn_add_to_customer_cart'] ); + if ( $receptionForm->isCardWithCustomer() ){ + echo Html::a(Yii::t("frontend/product","Write up"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_add_to_customer_cart'] ); } ?>
diff --git a/frontend/views/product/_user_cart.php b/frontend/views/product/_user_cart.php index 6b095ba..1f4a1be 100644 --- a/frontend/views/product/_user_cart.php +++ b/frontend/views/product/_user_cart.php @@ -33,4 +33,8 @@ use yii\bootstrap\Html;
- 'btn_pay_user_cart', 'class' => 'btn btn-primary' ]) ?> \ No newline at end of file +
+
+ 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' ]) ?> +
+
\ No newline at end of file diff --git a/frontend/views/product/sale.php b/frontend/views/product/sale.php index 66476a4..d4347a4 100644 --- a/frontend/views/product/sale.php +++ b/frontend/views/product/sale.php @@ -9,6 +9,8 @@ use yii\helpers\Url; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Discount; +use frontend\components\ReceptionWidget; +use common\models\Account; /* @var $this yii\web\View */ /* @var $form yii\bootstrap\ActiveForm */ @@ -26,7 +28,7 @@ if ( isset($model->card) ){ $options['customer_cart'] = $model->customerCart; } $options['discounts'] = Discount::modelsToArray($discounts); - +$options['id_account'] = Account::readDefault(); $this->registerJs ( 'new ProductSell( '. json_encode($options).');' ); @@ -67,21 +69,15 @@ $this->registerJs ( 'new ProductSell( '. json_encode($options).');' ); -
-
- $customer, 'card' => $card] ) ?> -
-
- $customer, 'card' =>$card, 'route' => ['product/sale'] ] )?> -
-
+ $receptionForm, 'route' => ['customer/reception'] ] )?> +

- render('_sale_form' ,['model' =>$model , 'lookupModel' =>$lookupModel, 'currencies' => $currencies, 'accounts' => $accounts,'discounts' => $discounts ]) ?> + render('_sale_form' ,[ 'receptionForm' => $receptionForm, 'model' =>$model , 'lookupModel' =>$lookupModel, 'currencies' => $currencies, 'accounts' => $accounts,'discounts' => $discounts ]) ?>
- + isCardWithCustomer() ){ ?> render('_customer_cart' ) ?> render('_user_cart' ) ?> diff --git a/frontend/views/ticket/_form.php b/frontend/views/ticket/_form.php index 83892b2..3813fdc 100644 --- a/frontend/views/ticket/_form.php +++ b/frontend/views/ticket/_form.php @@ -4,6 +4,7 @@ use yii\helpers\Html; use yii\widgets\ActiveForm; use frontend\components\HtmlHelper; use kartik\widgets\DatePicker; +use common\models\Account; /* @var $this yii\web\View */ /* @var $model common\models\Ticket */ @@ -22,6 +23,9 @@ use kartik\widgets\DatePicker; $accountOptions = HtmlHelper::mkAccountOptions($accounts); $discountOptions = ['' => ''] + HtmlHelper::mkDiscountOptions($discounts, [ 'emptyOption' => true] ); $ticketTypeOptions = HtmlHelper::mkTicketTypeOptions($ticketTypes); + +// echo "default kassza: " . Account::readDefault(); +// echo " kassza: " . $model->id_account; ?> diff --git a/frontend/views/ticket/create.php b/frontend/views/ticket/create.php index 5739af6..31369d1 100644 --- a/frontend/views/ticket/create.php +++ b/frontend/views/ticket/create.php @@ -6,6 +6,7 @@ use frontend\components\ReceptionCardNumberWidget; use frontend\assets\TicketSellAsset; use common\models\TicketType; use yii\helpers\Url; +use frontend\components\ReceptionWidget; /* @var $this yii\web\View */ @@ -34,16 +35,8 @@ $this->registerJs ( 'new TicketSell( '. json_encode($options).');' ); ?>
-
-
- $customer, 'card' => $card] ) ?> -
-
- $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?> -
-
-
-
+ $receptionForm, 'route' => ['customer/reception'] ] )?> +
diff --git a/frontend/web/js/product.sell.js b/frontend/web/js/product.sell.js index c7f5055..157ea1d 100644 --- a/frontend/web/js/product.sell.js +++ b/frontend/web/js/product.sell.js @@ -27,6 +27,7 @@ function ProductSell(o){ user_cart: [], discounts: [], customer_cart: [], + id_account: null, }; @@ -275,7 +276,7 @@ function ProductSell(o){ table.find('.product-price').html('-'); table.find('.product-sale-price').html('-'); $('#productsaleform-id_product').val(''); - $('#productsaleform-id_account').val(''); + $('#productsaleform-id_account').val( app.defaults.id_account ? app.defaults.id_account : ''); $("#productsaleform-count").val(1); } diff --git a/frontend/web/js/ticket.sell.js b/frontend/web/js/ticket.sell.js index 2c342b7..0790e6b 100644 --- a/frontend/web/js/ticket.sell.js +++ b/frontend/web/js/ticket.sell.js @@ -162,7 +162,7 @@ function TicketSell(o){ app.defaults.price = app.defaults.ticket_type.price_brutto; } function validateAccount(){ - app.defaults.id_account = app.defaults.ticket_type.id_account; + app.defaults.id_account = $('#ticketcreate-id_account').val(); } function refresh(){