add product sale changes

This commit is contained in:
rocho 2015-10-01 09:37:34 +02:00
parent 7128cd438d
commit e3d6c0b902
34 changed files with 1801 additions and 1 deletions

View File

@ -44,6 +44,8 @@ class AdminMenuStructure{
$items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ]; $items[] = ['label' => 'Beszerzések', 'url' => ['/procurement/index'] ];
$items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ]; $items[] = ['label' => 'Vendégek', 'url' => ['/customer/index'] ];
$items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ]; $items[] = ['label' => 'Bérletkártyák', 'url' => ['/card/index'] ];
$items[] = ['label' => 'Pénznem', 'url' => ['/currency/index'] ];
$items[] = ['label' => 'Transfer', 'url' => ['/transfer/index'] ];
if ( count($items) > 0 ){ if ( count($items) > 0 ){
$userMainMenu = ['label' => 'Beállítások', 'url' => null, $userMainMenu = ['label' => 'Beállítások', 'url' => null,

View File

@ -0,0 +1,109 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Currency;
use backend\models\CurrencySearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* CurrencyController implements the CRUD actions for Currency model.
*/
class CurrencyController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Currency models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new CurrencySearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Currency model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Currency model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Currency();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_currency]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Currency 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_currency]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Finds the Currency model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Currency the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Currency::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace backend\controllers;
use Yii;
use common\models\Transfer;
use backend\models\TransferSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TransferController implements the CRUD actions for Transfer model.
*/
class TransferController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TransferSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Transfer model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Updates an existing Transfer 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_transfer]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Finds the Transfer model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Transfer the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Transfer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,70 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Currency;
/**
* CurrencySearch represents the model behind the search form about `common\models\Currency`.
*/
class CurrencySearch extends Currency
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_currency', 'rate'], 'integer'],
[['currency', '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 = Currency::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_currency' => $this->id_currency,
'rate' => $this->rate,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'currency', $this->currency])
->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSearch extends Transfer
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['comment', '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 = Transfer::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_transfer' => $this->id_transfer,
'id_discount' => $this->id_discount,
'id_currency' => $this->id_currency,
'id_object' => $this->id_object,
'status' => $this->status,
'type' => $this->type,
'item_price' => $this->item_price,
'count' => $this->count,
'money' => $this->money,
'money_currency' => $this->money_currency,
'rate' => $this->rate,
'id_user' => $this->id_user,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
}
}

View File

@ -0,0 +1,28 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="currency-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'currency')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'rate')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/currency', 'Create') : Yii::t('frontend/currency', '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 backend\models\CurrencySearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="currency-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_currency') ?>
<?= $form->field($model, 'currency') ?>
<?= $form->field($model, 'name') ?>
<?= $form->field($model, 'rate') ?>
<?= $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/currency', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('frontend/currency', '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\Currency */
$this->title = Yii::t('frontend/currency', 'Create Currency');
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,37 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\CurrencySearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('frontend/currency', 'Currencies');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('frontend/currency', 'Create Currency'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'currency',
'name',
'rate',
// 'created_at:datetime',
'updated_at:datetime:datetime',
['class' => 'yii\grid\ActionColumn',
'template' =>'{view} {update}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
$this->title = Yii::t('frontend/currency', 'Update {modelClass}: ', [
'modelClass' => 'Currency',
]) . ' ' . $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_currency]];
$this->params['breadcrumbs'][] = Yii::t('frontend/currency', 'Update');
?>
<div class="currency-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,32 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Currency */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/currency', 'Currencies'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="currency-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('frontend/currency', 'Update'), ['update', 'id' => $model->id_currency], ['class' => 'btn btn-primary']) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'currency',
'name',
'rate',
'created_at:datetime',
'updated_at:datetime',
],
]) ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="transfer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_discount')->textInput() ?>
<?= $form->field($model, 'id_currency')->textInput() ?>
<?= $form->field($model, 'id_object')->textInput() ?>
<?= $form->field($model, 'status')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<?= $form->field($model, 'item_price')->textInput() ?>
<?= $form->field($model, 'count')->textInput() ?>
<?= $form->field($model, 'money')->textInput() ?>
<?= $form->field($model, 'money_currency')->textInput() ?>
<?= $form->field($model, 'rate')->textInput() ?>
<?= $form->field($model, 'id_user')->textInput() ?>
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'created_at')->textInput() ?>
<?= $form->field($model, 'updated_at')->textInput() ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/transfer', 'Create') : Yii::t('frontend/transfer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,55 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model backend\models\TransferSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="transfer-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_transfer') ?>
<?= $form->field($model, 'id_discount') ?>
<?= $form->field($model, 'id_currency') ?>
<?= $form->field($model, 'id_object') ?>
<?= $form->field($model, 'status') ?>
<?php // echo $form->field($model, 'type') ?>
<?php // echo $form->field($model, 'item_price') ?>
<?php // echo $form->field($model, 'count') ?>
<?php // echo $form->field($model, 'money') ?>
<?php // echo $form->field($model, 'money_currency') ?>
<?php // echo $form->field($model, 'rate') ?>
<?php // echo $form->field($model, 'id_user') ?>
<?php // echo $form->field($model, 'comment') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('frontend/transfer', '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\Transfer */
$this->title = Yii::t('frontend/transfer', 'Create Transfer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,47 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\TransferSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('frontend/transfer', 'Transfers');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('frontend/transfer', 'Create Transfer'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
'id_discount',
'id_currency',
'id_object',
'status',
// 'type',
// 'item_price',
// 'count',
// 'money',
// 'money_currency',
// 'rate',
// 'id_user',
// 'comment',
'created_at:datetime',
'updated_at:datetime',
['class' => 'yii\grid\ActionColumn',
'template' => '{view}'
],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
$this->title = Yii::t('frontend/transfer', 'Update {modelClass}: ', [
'modelClass' => 'Transfer',
]) . ' ' . $model->id_transfer;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_transfer, 'url' => ['view', 'id' => $model->id_transfer]];
$this->params['breadcrumbs'][] = Yii::t('frontend/transfer', 'Update');
?>
<div class="transfer-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
$this->title = $model->id_transfer;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('frontend/transfer', 'Update'), ['update', 'id' => $model->id_transfer], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('frontend/transfer', 'Delete'), ['delete', 'id' => $model->id_transfer], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('frontend/transfer', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_transfer',
'id_discount',
'id_currency',
'id_object',
'status',
'type',
'item_price',
'count',
'money',
'money_currency',
'rate',
'id_user',
'comment',
'created_at',
'updated_at',
],
]) ?>
</div>

View File

@ -0,0 +1,54 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "currency".
*
* @property integer $id_currency
* @property string $currency
* @property string $name
* @property integer $rate
* @property string $created_at
* @property string $updated_at
*/
class Currency extends \common\models\BaseFitnessActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'currency';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['currency', 'name'], 'required'],
[['rate'], 'integer'],
[['currency'], 'string', 'max' => 10],
[['name'], 'string', 'max' => 32]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_currency' => Yii::t('common/currency', 'Id Currency'),
'currency' => Yii::t('common/currency', 'Currency'),
'name' => Yii::t('common/currency', 'Name'),
'rate' => Yii::t('common/currency', 'Rate'),
'created_at' => Yii::t('common/currency', 'Created At'),
'updated_at' => Yii::t('common/currency', 'Updated At'),
];
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "transfer".
*
* @property integer $id_transfer
* @property integer $id_discount
* @property integer $id_currency
* @property integer $id_object
* @property integer $status
* @property integer $type
* @property integer $item_price
* @property integer $count
* @property integer $money
* @property integer $money_currency
* @property integer $rate
* @property integer $id_user
* @property string $comment
* @property string $created_at
* @property string $updated_at
*/
class Transfer extends \yii\db\ActiveRecord
{
const TYPE_PRODUCT = 10;
const TYPE_TICKET = 20;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'transfer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['comment'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_transfer' => Yii::t('common/transfer', 'Id Transfer'),
'id_discount' => Yii::t('common/transfer', 'Id Discount'),
'id_currency' => Yii::t('common/transfer', 'Id Currency'),
'id_object' => Yii::t('common/transfer', 'Id Object'),
'status' => Yii::t('common/transfer', 'Status'),
'type' => Yii::t('common/transfer', 'Type'),
'item_price' => Yii::t('common/transfer', 'Item Price'),
'count' => Yii::t('common/transfer', 'Count'),
'money' => Yii::t('common/transfer', 'Money'),
'money_currency' => Yii::t('common/transfer', 'Money Currency'),
'rate' => Yii::t('common/transfer', 'Rate'),
'id_user' => Yii::t('common/transfer', 'Id User'),
'comment' => Yii::t('common/transfer', 'Comment'),
'created_at' => Yii::t('common/transfer', 'Created At'),
'updated_at' => Yii::t('common/transfer', 'Updated At'),
];
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSearch extends Transfer
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['comment', '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 = Transfer::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_transfer' => $this->id_transfer,
'id_discount' => $this->id_discount,
'id_currency' => $this->id_currency,
'id_object' => $this->id_object,
'status' => $this->status,
'type' => $this->type,
'item_price' => $this->item_price,
'count' => $this->count,
'money' => $this->money,
'money_currency' => $this->money_currency,
'rate' => $this->rate,
'id_user' => $this->id_user,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
}
}

View File

@ -0,0 +1,72 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150930_140224_add__table__transfer extends Migration
{
/*id_transfer (int)
id_account
id_discount
id_currency
id_object
status
type
item_price
count
money
money_currency
rate
id_user
comment
created_at
updated_at
*/
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%transfer}}', [
'id_transfer' => $this->primaryKey(),
'id_discount' => $this->integer(11) ,
'id_currency' => $this->integer(11) ,
'id_discount' => $this->integer(11) ,
'id_object' => $this->integer(11) ,
'status' => $this->smallInteger(),
'type' => $this->smallInteger(),
'item_price' => $this->integer(11),
'count' => $this->integer(11),
'money' => $this->integer(11),
'money_currency' => $this->integer(11),
'rate' => $this->integer(11),
'id_user' => $this->integer(11),
'comment' => $this->string(255),
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
}
public function down()
{
echo "m150930_140224_add__table__transfer cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -0,0 +1,43 @@
<?php
use yii\db\Schema;
use yii\db\Migration;
class m150930_140728_add__table__currency extends Migration
{
public function up()
{
$tableOptions = null;
if ($this->db->driverName === 'mysql') {
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
}
$this->createTable('{{%currency}}', [
'id_currency' => $this->primaryKey(),
'currency' => $this->string(10)->notNull(),
'name' => $this->string(32)->notNull(),
'rate' => $this->integer(11) ,
'created_at' => $this->timestamp()->notNull(),
'updated_at' => $this->timestamp()->notNull(),
], $tableOptions);
}
public function down()
{
echo "m150930_140728_add__table__currency cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migration code within a transaction
public function safeUp()
{
}
public function safeDown()
{
}
*/
}

View File

@ -8,12 +8,19 @@ use frontend\models\ProductSearch;
use yii\web\Controller; use yii\web\Controller;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use frontend\models\ProductSaleForm;
use common\models\Card;
use common\models\Customer;
/** /**
* ProductController implements the CRUD actions for Product model. * ProductController implements the CRUD actions for Product model.
*/ */
class ProductController extends Controller class ProductController extends Controller
{ {
protected $card;
protected $customer;
public function behaviors() public function behaviors()
{ {
return [ return [
@ -26,6 +33,21 @@ class ProductController extends Controller
]; ];
} }
public function actionSale( $number = null){
$this->findByNumber($number);
$model = new ProductSaleForm();
return $this->render("sale",[
'customer' => $this->customer,
'card' => $this->card
]);
}
/** /**
* Lists all Product models. * Lists all Product models.
* @return mixed * @return mixed
@ -118,4 +140,18 @@ class ProductController extends Controller
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }
protected function findByNumber($number){
$this->card = null;
$this->customer = null;
if ( $number != null ){
$this->card = Card::readCard($number);
if ( $this->card != null ){
$this->customer = Customer::find()->innerJoin(Card::tableName(), "customer.id_customer_card = card.id_card")->andWhere( [ 'customer.id_customer_card' => $this->card->id_card ])->one();
}
}
}
} }

View File

@ -0,0 +1,121 @@
<?php
namespace frontend\controllers;
use Yii;
use common\models\Transfer;
use frontend\models\TransferSearch;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* TransferController implements the CRUD actions for Transfer model.
*/
class TransferController extends Controller
{
public function behaviors()
{
return [
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Lists all Transfer models.
* @return mixed
*/
public function actionIndex()
{
$searchModel = new TransferSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
/**
* Displays a single Transfer model.
* @param integer $id
* @return mixed
*/
public function actionView($id)
{
return $this->render('view', [
'model' => $this->findModel($id),
]);
}
/**
* Creates a new Transfer model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Transfer();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id_transfer]);
} else {
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Transfer 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_transfer]);
} else {
return $this->render('update', [
'model' => $model,
]);
}
}
/**
* Deletes an existing Transfer 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 Transfer model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return Transfer the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = Transfer::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
}
}
}

View File

@ -0,0 +1,46 @@
<?php
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.
*/
class ProductSaleForm extends Model
{
public $productNumber;
public $productBarcode;
public $count;
public $currency;
public $account;
public $comment;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['number'], 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'verifyCode' => 'Verification Code',
];
}
}

View File

@ -0,0 +1,79 @@
<?php
namespace frontend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSearch extends Transfer
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['comment', '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 = Transfer::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_transfer' => $this->id_transfer,
'id_discount' => $this->id_discount,
'id_currency' => $this->id_currency,
'id_object' => $this->id_object,
'status' => $this->status,
'type' => $this->type,
'item_price' => $this->item_price,
'count' => $this->count,
'money' => $this->money,
'money_currency' => $this->money_currency,
'rate' => $this->rate,
'id_user' => $this->id_user,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
}
}

View File

@ -72,7 +72,7 @@ function mkBtn($card, $label,$route = null ){
<div class='row'> <div class='row'>
<div class='col-md-12'> <div class='col-md-12'>
<?php //echo Html::a(Yii::t( 'frontend/customer', 'Termékeladás') , 'product/index' , ['class' => 'btn btn-primary btn-reception'] )?> <?php //echo Html::a(Yii::t( 'frontend/customer', 'Termékeladás') , 'product/index' , ['class' => 'btn btn-primary btn-reception'] )?>
<?php echo mkBtn($card, Yii::t( 'frontend/customer', 'Termékeladás'), 'product/index')?> <?php echo mkBtn($card, Yii::t( 'frontend/transfer', 'Termékeladás'), 'product/sale')?>
</div> </div>
</div> </div>

View File

@ -0,0 +1,180 @@
<?php
use frontend\components\ReceptionMenuWidget;
use frontend\components\ReceptionCardNumberWidget;
use yii\helpers\Html;
?>
<style>
.product-form input, .product-form select, .product-form textarea{
width: 100%;
}
</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 class='col-md-4'>
</div>
</div>
<h1><?php echo Yii::t('frontend/product','Sell product')?></h1>
<div class='row'>
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Product'))?>
<?php echo Html::textInput('filter_text')?>
</div>
<div class='col-md-4'>
</div>
<div class='col-md-4'>
</div>
</div>
<div class='row product-form'>
<div class='col-md-6'>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Product name'))?>
</div>
<div class='col-md-6'>
<?php echo Html::tag('span','',[ 'class' => 'product product-name']); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Product price'))?>
</div>
<div class='col-md-6'>
<?php echo Html::tag('span','',[ 'class' => 'product product-price']); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Product number'))?>
</div>
<div class='col-md-6'>
<?php echo Html::tag('span','',[ 'class' => 'product product-number']); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Barcode'))?>
</div>
<div class='col-md-6'>
<?php echo Html::tag('span','',[ 'class' => 'product barcode']); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Count'))?>
</div>
<div class='col-md-6'>
<?php echo Html::textInput('count') ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Currency'))?>
</div>
<div class='col-md-6'>
<?php echo Html::dropDownList('currency',null,[],[]); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Account'))?>
</div>
<div class='col-md-6'>
<?php echo Html::dropDownList('account',null,[],[]); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Discount'))?>
</div>
<div class='col-md-6'>
<?php echo Html::dropDownList('discount',null,[],[]); ?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Comment'))?>
</div>
</div>
<div class="row">
<div class='col-md-10'>
<?php echo Html::textarea('comment', ''); ?>
</div>
</div>
</div>
<div class='col-md-6'>
<div class="row">
<div class='col-md-10'>
<?php echo Html::label(Yii::t('frontend/product', 'Bill'))?>
</div>
</div>
<div class="row">
<div class='col-md-4'>
<?php echo Html::label(Yii::t('frontend/product', 'Debit'))?>
</div>
<div class='col-md-6'>
<?php echo Html::tag("span",'0,00',['sale', 'sale-debit']) ?>
</div>
</div>
<div class="row">
<div class='col-md-12'>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>
<?php echo Yii::t('frontend/product', 'Product name')?>
</th>
<th>
<?php echo Yii::t('frontend/product', 'Count')?>
</th>
<th>
<?php echo Yii::t('frontend/product', 'Currency')?>
</th>
<th>
<?php echo Yii::t('frontend/product', 'Item Price')?>
</th>
<th>
<?php echo Yii::t('frontend/product', 'Total Price')?>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,45 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="transfer-form">
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'id_discount')->textInput() ?>
<?= $form->field($model, 'id_currency')->textInput() ?>
<?= $form->field($model, 'id_object')->textInput() ?>
<?= $form->field($model, 'status')->textInput() ?>
<?= $form->field($model, 'type')->textInput() ?>
<?= $form->field($model, 'item_price')->textInput() ?>
<?= $form->field($model, 'count')->textInput() ?>
<?= $form->field($model, 'money')->textInput() ?>
<?= $form->field($model, 'money_currency')->textInput() ?>
<?= $form->field($model, 'rate')->textInput() ?>
<?= $form->field($model, 'id_user')->textInput() ?>
<?= $form->field($model, 'comment')->textInput(['maxlength' => true]) ?>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('frontend/transfer', 'Create') : Yii::t('frontend/transfer', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>

View File

@ -0,0 +1,55 @@
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\TransferSearch */
/* @var $form yii\widgets\ActiveForm */
?>
<div class="transfer-search">
<?php $form = ActiveForm::begin([
'action' => ['index'],
'method' => 'get',
]); ?>
<?= $form->field($model, 'id_transfer') ?>
<?= $form->field($model, 'id_discount') ?>
<?= $form->field($model, 'id_currency') ?>
<?= $form->field($model, 'id_object') ?>
<?= $form->field($model, 'status') ?>
<?php // echo $form->field($model, 'type') ?>
<?php // echo $form->field($model, 'item_price') ?>
<?php // echo $form->field($model, 'count') ?>
<?php // echo $form->field($model, 'money') ?>
<?php // echo $form->field($model, 'money_currency') ?>
<?php // echo $form->field($model, 'rate') ?>
<?php // echo $form->field($model, 'id_user') ?>
<?php // echo $form->field($model, 'comment') ?>
<?php // echo $form->field($model, 'created_at') ?>
<?php // echo $form->field($model, 'updated_at') ?>
<div class="form-group">
<?= Html::submitButton(Yii::t('frontend/transfer', 'Search'), ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton(Yii::t('frontend/transfer', '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\Transfer */
$this->title = Yii::t('frontend/transfer', 'Create Transfer');
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-create">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,48 @@
<?php
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel common\models\TransferSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('frontend/transfer', 'Transfers');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-index">
<h1><?= Html::encode($this->title) ?></h1>
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
<p>
<?= Html::a(Yii::t('frontend/transfer', 'Create Transfer'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'id_transfer',
'id_discount',
'id_currency',
'id_object',
'status',
// 'type',
// 'item_price',
// 'count',
// 'money',
// 'money_currency',
// 'rate',
// 'id_user',
// 'comment',
// 'created_at',
// 'updated_at',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>

View File

@ -0,0 +1,23 @@
<?php
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
$this->title = Yii::t('frontend/transfer', 'Update {modelClass}: ', [
'modelClass' => 'Transfer',
]) . ' ' . $model->id_transfer;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->id_transfer, 'url' => ['view', 'id' => $model->id_transfer]];
$this->params['breadcrumbs'][] = Yii::t('frontend/transfer', 'Update');
?>
<div class="transfer-update">
<h1><?= Html::encode($this->title) ?></h1>
<?= $this->render('_form', [
'model' => $model,
]) ?>
</div>

View File

@ -0,0 +1,49 @@
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\Transfer */
$this->title = $model->id_transfer;
$this->params['breadcrumbs'][] = ['label' => Yii::t('frontend/transfer', 'Transfers'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="transfer-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a(Yii::t('frontend/transfer', 'Update'), ['update', 'id' => $model->id_transfer], ['class' => 'btn btn-primary']) ?>
<?= Html::a(Yii::t('frontend/transfer', 'Delete'), ['delete', 'id' => $model->id_transfer], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => Yii::t('frontend/transfer', 'Are you sure you want to delete this item?'),
'method' => 'post',
],
]) ?>
</p>
<?= DetailView::widget([
'model' => $model,
'attributes' => [
'id_transfer',
'id_discount',
'id_currency',
'id_object',
'status',
'type',
'item_price',
'count',
'money',
'money_currency',
'rate',
'id_user',
'comment',
'created_at',
'updated_at',
],
]) ?>
</div>