add default account to frontend

This commit is contained in:
rocho 2015-10-26 07:49:10 +01:00
parent 0c92fdf167
commit 01da3c470c
45 changed files with 948 additions and 220 deletions

View File

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

View File

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

View File

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

View File

@ -0,0 +1,30 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m151025_152228_alter__table__add__column__paid_at extends Migration
{
public function up()
{
$this->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()
{
}
*/
}

View File

@ -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'] ],

View File

@ -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)){

View File

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

View File

@ -0,0 +1,22 @@
<?php
namespace frontend\components;
use yii\base\Widget;
/**
* This is the model class for table "customer".
*
* @property string $viewFile
* @property common\models\ReceptionForm $model
* */
class ReceptionCustomerWidget extends Widget{
public $viewFile = '//common/_reception_customer';
public $model;
public function run(){
echo $this->render($this->viewFile,[ 'model' => $this->model ]);
}
}

View File

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

View File

@ -0,0 +1,22 @@
<?php
namespace frontend\components;
use yii\base\Widget;
/**
* This is the model class for table "customer".
*
* @property string $viewFile
* @property common\models\ReceptionForm $model
* */
class ReceptionTicketWidget extends Widget{
public $viewFile = '//common/_reception_ticket';
public $model;
public function run(){
echo $this->render($this->viewFile,[ 'model' => $this->model ]);
}
}

View File

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

View File

@ -0,0 +1,145 @@
<?php
namespace frontend\controllers;
use Yii;
use common\models\Account;
use frontend\models\AccountSearch;
use frontend\models\AccountSelect;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
use yii\base\Object;
/**
* AccountController implements the CRUD actions for Account model.
*/
class AccountController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'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.');
}
}
}

View File

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

View File

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

View File

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

View File

@ -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') );

View File

@ -0,0 +1,70 @@
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Account;
/**
* AccountSearch represents the model behind the search form about `common\models\Account`.
*/
class AccountSearch extends Account
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_account', 'status', 'type'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Account::find();
$dataProvider = new ActiveDataProvider([
'query' => $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;
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use common\models\Account;
/**
* AccountSearch represents the model behind the search form about `common\models\Account`.
*/
class AccountSelect extends Model
{
public $id_account;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_account', 'type'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
public function writeToSession(){
$account = Account::findOne($this->id_account);
Account::writeDefault($account);
return true;
}
}

View File

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

View File

@ -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]

View File

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

View File

@ -0,0 +1,27 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'status')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/account', 'Create') : Yii::t('frontend/account', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model frontend\models\AccountSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_account') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'status') ?>
<?= $form->field($model, 'type') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/account', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('frontend/account', 'Reset'), ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,21 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->title = Yii::t('frontend/account', 'Create Account');
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account', 'Accounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,39 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel frontend\models\AccountSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('frontend/account', 'Accounts');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('frontend/account', 'Create Account'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_account',
'name',
'status',
'type',
'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,24 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\components\HtmlHelper;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="account-form">
<?php $form = ActiveForm::begin(); ?>
<?php echo $form->field($model, 'id_account')->dropDownList(HtmlHelper::mkAccountOptions($accounts)) ?>
<div class="form-group">
<?= Html::submitButton( Yii::t('frontend/account', 'Update'), ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->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');
?>
<div class="account-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,40 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Account */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/account', 'Accounts'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('frontend/account', 'Update'), ['update', 'id' => $model->id_account], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('frontend/account', 'Delete'), ['delete', 'id' => $model->id_account], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('frontend/account', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_account',
'name',
'status',
'type',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -1,42 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<?php
$customername = "";
$number = "";
if ( isset($card)){
$number = $card->number;
}
if ( isset($customer) ){
$customername = $customer->name;
}
?>
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => false,
'method' => 'get',
'action' => $route
]); ?>
<div class="row" >
<div class='col-md-12'>
<?php echo Html::textInput("number", $number )?>
</div>
<div class='col-md-12'>
<?php echo $customername; ?>
</div>
<div class='col-md-12'>
<?php echo Html::submitButton( Yii::t('frontend/card', "Search"),[ 'class' => 'btn btn-primary']); ?>
</div>
</div>
<?php ActiveForm::end(); ?>

View File

@ -1,80 +0,0 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
use frontend\components\HtmlHelper;
/* @var $this yii\web\View */
/* @var $card common\models\Card */
/* @var $customer common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<style >
.btn.btn-reception{
width:100%;
margin-top: 6px;
margin-bottom: 6px;
}
</style>
<?php
$customername = "";
if ( isset($customer ) ){
$customername = $customer->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 ] );
}
*/
?>
<div class='row'>
<div class='col-md-8'>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
<div class='row'>
<div class='col-md-8'>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
</div>
<div class='col-md-4'>
<?php echo HtmlHelper::mkReceptionCardBtn( $card, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo HtmlHelper::mkReceptionBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
</div>
</div>

View File

@ -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;
?>
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
<?php echo ReceptionMenuWidget::widget( [ 'model' => $model ] ) ?>
</div>
<div class='col-md-2'>
<?php echo ReceptionCardNumberWidget::widget( [ 'model' => $model, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
<?php echo ReceptionCustomerWidget::widget([ 'model' => $model ] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberTicketsWidget::widget([ 'tickets' => $tickets, 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] ) ?>
<div class='col-md-3'>
<?php echo ReceptionTicketWidget::widget([ 'model' => $model ] ) ?>
</div>
</div>

View File

@ -0,0 +1,45 @@
<?php
use common\models\Ticket;
use frontend\model\ReceptionForm;
use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\base\Widget;
/* @var $this yii\web\View */
/* @var $model frontend\model\ReceptionForm */
?>
<?php
if ( $model->isCardWithCustomer() ){
?>
<div class="row">
<div class="col-md-12">
<?php
echo DetailView::widget([
'model' => $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
],
]
])
?>
</div>
</div>
<?php
}
?>

View File

@ -0,0 +1,50 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Customer */
/* @var $form yii\widgets\ActiveForm */
?>
<style>
.form-card-number input, .form-card-number button{
margin-top: 6px;
margin-bottom: 6px;
}
</style>
<?php
$number = "";
if ( isset($model->card)){
$number = $model->card->number;
}
?>
<div class="form-card-number">
<?php $form = ActiveForm::begin([
'enableAjaxValidation' => false,
'method' => 'get',
'action' => $route
]); ?>
<div class="row" >
<div class='col-md-12'>
<?php echo Html::textInput("number", $number ,['class' => 'form-control'])?>
</div>
</div>
<div class="row" >
<div class='col-md-12'>
<?php echo Html::submitButton( Yii::t('frontend/card', "Search"),[ 'class' => 'btn btn-primary btn-block']); ?>
</div>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,59 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;
use frontend\components\HtmlHelper;
/* @var $this yii\web\View */
/* @var $card common\models\Card */
/* @var $customer common\models\Customer */
/* @var $model frontend\models\ReceptionForm */
/* @var $form yii\widgets\ActiveForm */
?>
<style >
.btn.btn-reception{
width:100%;
margin-top: 6px;
margin-bottom: 6px;
}
</style>
<?php
$customername = "";
if ( isset($model->customer ) ){
$customername = $model->customer->name;
}
$card = $model->card;
?>
<div class='row'>
<div class='col-md-8'>
<?php echo HtmlHelper::mkReceptionCustomerBtn( $model, Yii::t( 'frontend/customer' , 'Adatlap') , 'customer/update' ); ?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , Url::toRoute('customer/create') , ['class' => 'btn btn-primary btn-reception'] )?>
</div>
</div>
<div class='row'>
<div class='col-md-8'>
<?php echo HtmlHelper::mkReceptionCustomerBtn( $model, Yii::t( 'frontend/customer' , 'Befizetések') , 'ticket/index'); ?>
</div>
<div class='col-md-4'>
<?php echo HtmlHelper::mkReceptionCustomerBtn( $model, Html::tag("i","", [ 'class' => 'glyphicon glyphicon-plus' ] ) , 'ticket/create' ); ?>
</div>
</div>
<div class='row'>
<div class='col-md-12'>
<?php echo HtmlHelper::mkReceptionBtn($model, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
</div>
</div>

View File

@ -0,0 +1,60 @@
<?php
use yii\base\Object;
use common\models\Ticket;
use frontend\model\ReceptionForm;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model frontend\model\ReceptionForm */
?>
<style>
</style>
<?php
$ticket = null;
if ( count($model->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 "&nbsp;-&nbsp;";
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");
}
?>

View File

@ -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;
?>
<div class="customer-create">
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/create'] ] )?>
<h1><?= Html::encode($this->title) ?></h1>

View File

@ -2,23 +2,8 @@
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use yii\base\Widget;
use frontend\components\ReceptionWidget;
?>
<h1>Recepció</h1>
<?php
?>
<?php // echo $this->render('_form_reception', [ 'model' => $model ]); ?>
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $model->customer, 'card' =>$model->card ] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget([ 'customer' => $model->customer, 'card' =>$model->card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $model, 'route' => ['customer/reception'] ] )?>

View File

@ -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;
<div class="customer-update">
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form_update', [

View File

@ -99,15 +99,15 @@ $discountOptions = mkOptions( ArrayHelper::map($discounts, 'id_discount', 'name'
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/product","Sell product"),null,['class' => 'btn btn-success', 'id' => 'btn_sell'] );?>
<?php echo Html::a(Yii::t("frontend/product","Sell product"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_sell'] );?>
</div>
<div class='col-md-4'>
<?php echo Html::a(Yii::t("frontend/product","To cart"),null,['class' => 'btn btn-success', 'id' => 'btn_sell_append'] );?>
<?php echo Html::a(Yii::t("frontend/product","To cart"),null,['class' => 'btn btn-success btn-block', 'id' => 'btn_sell_append'] );?>
</div>
<div class='col-md-4'>
<?php
if ( isset($model->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'] );
}
?>
</div>

View File

@ -33,4 +33,8 @@ use yii\bootstrap\Html;
</div>
</div>
</div>
<?php echo Html::a(Yii::t('frontend/product', "Paid"),null,[ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary' ]) ?>
<div class='row' >
<div class='col-md-3'>
<?php echo Html::a(Yii::t('frontend/product', "Paid"),null,[ 'id' => 'btn_pay_user_cart', 'class' => 'btn btn-primary btn-block' ]) ?>
</div>
</div>

View File

@ -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).');' );
</style>
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['product/sale'] ] )?>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<div class='row '>
<div class='col-md-6 product-form'>
<h1><?php echo Yii::t('frontend/product','Sell product')?></h1>
<?php echo $this->render('_sale_form' ,['model' =>$model , 'lookupModel' =>$lookupModel, 'currencies' => $currencies, 'accounts' => $accounts,'discounts' => $discounts ]) ?>
<?php echo $this->render('_sale_form' ,[ 'receptionForm' => $receptionForm, 'model' =>$model , 'lookupModel' =>$lookupModel, 'currencies' => $currencies, 'accounts' => $accounts,'discounts' => $discounts ]) ?>
</div>
<div class='col-md-6'>
<?php if ( isset($card) ){ ?>
<?php if ( $receptionForm->isCardWithCustomer() ){ ?>
<?php echo $this->render('_customer_cart' ) ?>
<?php }?>
<?php echo $this->render('_user_cart' ) ?>

View File

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

View File

@ -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).');' );
?>
<div class="ticket-create">
<div class='row'>
<div class='col-md-3'>
<?php echo ReceptionMenuWidget::widget( [ 'customer' => $customer, 'card' => $card] ) ?>
</div>
<div class='col-md-4'>
<?php echo ReceptionCardNumberWidget::widget( [ 'customer' => $customer, 'card' =>$card, 'route' => ['customer/reception'] ] )?>
</div>
<div class='col-md-4'>
</div>
</div>
<?php echo ReceptionWidget::widget( ['form' => $receptionForm, 'route' => ['customer/reception'] ] )?>
<div class="row">

View File

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

View File

@ -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(){