Finish 33 ( product )
This commit is contained in:
commit
e2fe006899
62
Gruntfile.coffee
Normal file
62
Gruntfile.coffee
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
module.exports = (grunt) ->
|
||||||
|
|
||||||
|
# Project configuration.
|
||||||
|
grunt.initConfig
|
||||||
|
pkg: grunt.file.readJSON('package.json')
|
||||||
|
|
||||||
|
config:
|
||||||
|
src: 'assets/coffee'
|
||||||
|
dest: 'assets/js'
|
||||||
|
|
||||||
|
clean:
|
||||||
|
build:
|
||||||
|
src: [ 'frontend/web/stylesheet','backend/web/stylesheet' ]
|
||||||
|
|
||||||
|
compass:
|
||||||
|
frontend:
|
||||||
|
options:
|
||||||
|
sassDir: 'frontend/web/scss'
|
||||||
|
cssDir: 'frontend/web/stylesheet'
|
||||||
|
backend:
|
||||||
|
options:
|
||||||
|
sassDir: 'backend/web/scss'
|
||||||
|
cssDir: 'backend/web/stylesheet'
|
||||||
|
|
||||||
|
coffee:
|
||||||
|
frontend:
|
||||||
|
options:
|
||||||
|
sourceMap: true
|
||||||
|
bare: false
|
||||||
|
join: true
|
||||||
|
files:
|
||||||
|
'frontend/web/js/frontend.js': ['frontend/web/coffee/**/*.coffee']
|
||||||
|
backend:
|
||||||
|
options:
|
||||||
|
sourceMap: true
|
||||||
|
bare: false
|
||||||
|
join: true
|
||||||
|
files:
|
||||||
|
'backend/web/js/backend.js': ['backend/web/coffee/**/*.coffee']
|
||||||
|
|
||||||
|
watch:
|
||||||
|
options:
|
||||||
|
spawn: false
|
||||||
|
interrupt: true
|
||||||
|
atBegin: true
|
||||||
|
interval: 500
|
||||||
|
coffeewatch:
|
||||||
|
files: ['frontend/web/coffee/**/*.coffee','backend/web/coffee/**/*.coffee']
|
||||||
|
tasks: ['any-newer:coffee']
|
||||||
|
sasswatch:
|
||||||
|
files: ['frontend/web/scss/*.scss','backend/web/scss/*.scss']
|
||||||
|
tasks: ['compass']
|
||||||
|
|
||||||
|
|
||||||
|
#grunt.loadNpmTasks 'grunt-contrib-compass'
|
||||||
|
|
||||||
|
require('matchdep').filterDev('grunt-*').forEach grunt.loadNpmTasks
|
||||||
|
|
||||||
|
# Tasks
|
||||||
|
#grunt.registerTask 'default', ['concurrent:compile']
|
||||||
|
grunt.registerTask 'default', ['compass','coffee']
|
||||||
|
#grunt.registerTask 'production', ['clean', 'concurrent:compile', 'concurrent:optimize']
|
||||||
@ -40,6 +40,7 @@ class AdminMenuStructure{
|
|||||||
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
$items[] = ['label' => 'Kedvezmények', 'url' => ['/discount/index'] ];
|
||||||
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
$items[] = ['label' => 'Termék kategóriák', 'url' => ['/product-category/index'] ];
|
||||||
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
$items[] = ['label' => 'Bérlet típusok', 'url' => ['/ticket-type/index'] ];
|
||||||
|
$items[] = ['label' => 'Termékek', 'url' => ['/product/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,
|
||||||
|
|||||||
135
backend/controllers/ProductController.php
Normal file
135
backend/controllers/ProductController.php
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\controllers;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use common\models\Product;
|
||||||
|
use backend\models\ProductSearch;
|
||||||
|
use yii\web\Controller;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
use yii\filters\VerbFilter;
|
||||||
|
use common\models\Account;
|
||||||
|
use common\models\ProductCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductController implements the CRUD actions for Product model.
|
||||||
|
*/
|
||||||
|
class ProductController extends Controller
|
||||||
|
{
|
||||||
|
public function behaviors()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'verbs' => [
|
||||||
|
'class' => VerbFilter::className(),
|
||||||
|
'actions' => [
|
||||||
|
'delete' => ['post'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists all Product models.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionIndex()
|
||||||
|
{
|
||||||
|
$searchModel = new ProductSearch();
|
||||||
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||||
|
|
||||||
|
return $this->render('index', [
|
||||||
|
'searchModel' => $searchModel,
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays a single Product model.
|
||||||
|
* @param integer $id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionView($id)
|
||||||
|
{
|
||||||
|
return $this->render('view', [
|
||||||
|
'model' => $this->findModel($id),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Product model.
|
||||||
|
* If creation is successful, the browser will be redirected to the 'view' page.
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function actionCreate()
|
||||||
|
{
|
||||||
|
$model = new Product();
|
||||||
|
$model->stock = 0;
|
||||||
|
$model->status = Product::STATUS_ACTIVE;
|
||||||
|
$accounts = Account::readAccounts(null);
|
||||||
|
$categories = ProductCategory::read(null);
|
||||||
|
|
||||||
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
|
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
|
} else {
|
||||||
|
return $this->render('create', [
|
||||||
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates an existing Product 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);
|
||||||
|
|
||||||
|
$accounts = Account::readAccounts($model->id_account);
|
||||||
|
$categories = ProductCategory::read($model->id_product_category);
|
||||||
|
|
||||||
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
|
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
|
} else {
|
||||||
|
return $this->render('update', [
|
||||||
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an existing Product 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 Product model based on its primary key value.
|
||||||
|
* If the model is not found, a 404 HTTP exception will be thrown.
|
||||||
|
* @param integer $id
|
||||||
|
* @return Product the loaded model
|
||||||
|
* @throws NotFoundHttpException if the model cannot be found
|
||||||
|
*/
|
||||||
|
protected function findModel($id)
|
||||||
|
{
|
||||||
|
if (($model = Product::findOne($id)) !== null) {
|
||||||
|
return $model;
|
||||||
|
} else {
|
||||||
|
throw new NotFoundHttpException('The requested page does not exist.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
backend/models/ProductSearch.php
Normal file
69
backend/models/ProductSearch.php
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace backend\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
use yii\base\Model;
|
||||||
|
use yii\data\ActiveDataProvider;
|
||||||
|
use common\models\Product;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ProductSearch represents the model behind the search form about `common\models\Product`.
|
||||||
|
*/
|
||||||
|
class ProductSearch extends Product
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[[ 'id_product_category', 'id_account', 'status'], 'integer'],
|
||||||
|
[['product_number', 'barcode' ], '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 = Product::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_product_category' => $this->id_product_category,
|
||||||
|
'id_account' => $this->id_account,
|
||||||
|
'status' => $this->status,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$query->andFilterWhere(['like', 'product_number', $this->product_number])
|
||||||
|
->andFilterWhere(['like', 'barcode', $this->barcode]);
|
||||||
|
|
||||||
|
return $dataProvider;
|
||||||
|
}
|
||||||
|
}
|
||||||
47
backend/views/product/_form.php
Normal file
47
backend/views/product/_form.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Product */
|
||||||
|
/* @var $accounts common\models\Account[] */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
|
||||||
|
$product_category_options = ArrayHelper::map($categories, 'id_product_category', 'name');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="product-form">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'id_product_category')->dropDownList($product_category_options) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'product_number')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'barcode')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'purchase_price')->input('number') ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'sale_price')->input('number')?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'profit_margins')->textInput() ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/product', "Active") ]) ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'description')->textarea(['maxlength' => true])->hint( Yii::t( 'common/product', "Max 255 character")) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/product', 'Create') : Yii::t('common/product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
63
backend/views/product/_search.php
Normal file
63
backend/views/product/_search.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
use common\models\Product;
|
||||||
|
use common\models\ProductCategory;
|
||||||
|
use yii\helpers\ArrayHelper;
|
||||||
|
use common\models\Account;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model backend\models\ProductSearch */
|
||||||
|
/* @var $form yii\widgets\ActiveForm */
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function mkOptions($options){
|
||||||
|
$o = $options;
|
||||||
|
$o[''] = Yii::t('common/product','All' ) ;
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
$statusOptions = mkOptions( Product::statuses() );
|
||||||
|
|
||||||
|
$productCategories = mkOptions( ArrayHelper::map( ProductCategory::read(null) ,'id_product_category','name') );
|
||||||
|
|
||||||
|
$accounts = mkOptions( ArrayHelper::map( Account::readAccounts(null) ,'id_account','name'));
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="product-search">
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin([
|
||||||
|
'action' => ['index'],
|
||||||
|
'method' => 'get',
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_product_category')->dropDownList($productCategories) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'id_account')->dropDownList($accounts) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?php echo $form->field($model, 'status')->dropDownList($statusOptions) ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'product_number') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
<?= $form->field($model, 'barcode') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton(Yii::t('common/product', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
24
backend/views/product/create.php
Normal file
24
backend/views/product/create.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Product */
|
||||||
|
/* @var $accounts common\models\Account[] */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/product', 'Create Product');
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="product-create">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
51
backend/views/product/index.php
Normal file
51
backend/views/product/index.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\grid\GridView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $searchModel backend\models\ProductSearch */
|
||||||
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/product', 'Products');
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="product-index">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= GridView::widget([
|
||||||
|
'dataProvider' => $dataProvider,
|
||||||
|
'columns' => [
|
||||||
|
[
|
||||||
|
'attribute' => 'name',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_product_category',
|
||||||
|
'value' => 'productCategoryName',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_account',
|
||||||
|
'value' => 'accountName',
|
||||||
|
],
|
||||||
|
'product_number',
|
||||||
|
'barcode',
|
||||||
|
'sale_price',
|
||||||
|
[
|
||||||
|
'attribute' => 'status',
|
||||||
|
'value' => 'statusHuman',
|
||||||
|
|
||||||
|
],
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn',
|
||||||
|
'template' => '{view} {update}'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
23
backend/views/product/update.php
Normal file
23
backend/views/product/update.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Product */
|
||||||
|
|
||||||
|
$this->title = Yii::t('common/product', 'Update product:' ) . ' ' . $model->name;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_product]];
|
||||||
|
$this->params['breadcrumbs'][] = Yii::t('common/product', 'Update');
|
||||||
|
?>
|
||||||
|
<div class="product-update">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<?= $this->render('_form', [
|
||||||
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
42
backend/views/product/view.php
Normal file
42
backend/views/product/view.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
|
/* @var $this yii\web\View */
|
||||||
|
/* @var $model common\models\Product */
|
||||||
|
|
||||||
|
$this->title = $model->name ;
|
||||||
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
|
?>
|
||||||
|
<div class="product-view">
|
||||||
|
|
||||||
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<?= Html::a(Yii::t('common/product', 'Update'), ['update', 'id' => $model->id_product], ['class' => 'btn btn-primary']) ?>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<?= DetailView::widget([
|
||||||
|
'model' => $model,
|
||||||
|
'attributes' => [
|
||||||
|
'productCategoryName',
|
||||||
|
'accountName',
|
||||||
|
'product_number',
|
||||||
|
'barcode',
|
||||||
|
'purchase_price',
|
||||||
|
'sale_price',
|
||||||
|
'profit_margins',
|
||||||
|
'statusHuman',
|
||||||
|
[
|
||||||
|
'attribute' => 'description',
|
||||||
|
'value' => nl2br($model->description),
|
||||||
|
'format' => 'raw'
|
||||||
|
],
|
||||||
|
'created_at:datetime',
|
||||||
|
'updated_at:datetime',
|
||||||
|
],
|
||||||
|
]) ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
43
common/messages/hu/common/product.php
Normal file
43
common/messages/hu/common/product.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Message translations.
|
||||||
|
*
|
||||||
|
* This file is automatically generated by 'yii message' command.
|
||||||
|
* It contains the localizable messages extracted from source code.
|
||||||
|
* You may modify this file by translating the extracted messages.
|
||||||
|
*
|
||||||
|
* Each array element represents the translation (value) of a message (key).
|
||||||
|
* If the value is empty, the message is considered as not translated.
|
||||||
|
* Messages that no longer need translation will have their translations
|
||||||
|
* enclosed between a pair of '@@' marks.
|
||||||
|
*
|
||||||
|
* Message string can be used with plural forms format. Check i18n section
|
||||||
|
* of the guide for details.
|
||||||
|
*
|
||||||
|
* NOTE: this file must be saved in UTF-8 encoding.
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'Active' => 'Aktív',
|
||||||
|
'All' => 'Mind',
|
||||||
|
'Barcode' => 'Vonalkód',
|
||||||
|
'Create' => 'Mentés',
|
||||||
|
'Create Product' => 'Új termék',
|
||||||
|
'Created At' => 'Létrehozás ideje',
|
||||||
|
'Description' => 'Leírás',
|
||||||
|
'Id Account' => 'Kassza',
|
||||||
|
'Id Product' => 'Termék',
|
||||||
|
'Id Product Category' => 'Termék kategória',
|
||||||
|
'Inactive' => 'Inaktív',
|
||||||
|
'Max 255 character' => 'Max 255 karakter',
|
||||||
|
'Name' => 'Név',
|
||||||
|
'Product Number' => 'Termék szám',
|
||||||
|
'Products' => 'Termékek',
|
||||||
|
'Profit Margins' => 'Haszonkulcs',
|
||||||
|
'Purchase Price' => 'Beszerzési ár',
|
||||||
|
'Sale Price' => 'Eladási ár',
|
||||||
|
'Search' => 'Keresés',
|
||||||
|
'Status' => 'Státusz',
|
||||||
|
'Update' => 'Módosítás',
|
||||||
|
'Update product:' => 'Termék módosítása:',
|
||||||
|
'Updated At' => 'Módosítás ideje',
|
||||||
|
];
|
||||||
@ -108,4 +108,21 @@ class Account extends \yii\db\ActiveRecord
|
|||||||
return $this->status == self::STATUS_DELETED;
|
return $this->status == self::STATUS_DELETED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||||
|
* */
|
||||||
|
public static function readAccounts($forceIncludeAccount = null){
|
||||||
|
$accounts = null;
|
||||||
|
|
||||||
|
if ( $forceIncludeAccount == null){
|
||||||
|
$accounts = Account::find()->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||||
|
}else{
|
||||||
|
$accounts = Account::find()->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $forceIncludeAccount ] ])->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $accounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
113
common/models/Product.php
Normal file
113
common/models/Product.php
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\models;
|
||||||
|
|
||||||
|
use Yii;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the model class for table "product".
|
||||||
|
*
|
||||||
|
* @property integer $id_product
|
||||||
|
* @property string $name length 64
|
||||||
|
* @property integer $id_product_category
|
||||||
|
* @property integer $id_account
|
||||||
|
* @property string $product_number
|
||||||
|
* @property string $barcode
|
||||||
|
* @property integer $purchase_price
|
||||||
|
* @property integer $sale_price
|
||||||
|
* @property integer $profit_margins
|
||||||
|
* @property integer $status
|
||||||
|
* @property integer $stock
|
||||||
|
* @property string $description
|
||||||
|
* @property string $created_at
|
||||||
|
* @property string $updated_at
|
||||||
|
*/
|
||||||
|
class Product extends \common\models\BaseFitnessActiveRecord {
|
||||||
|
|
||||||
|
const STATUS_DELETED = 0;
|
||||||
|
const STATUS_ACTIVE = 10;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static function tableName()
|
||||||
|
{
|
||||||
|
return 'product';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[['id_product_category', 'id_account', 'name'], 'required'],
|
||||||
|
[['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
|
||||||
|
[['product_number', 'barcode'], 'string', 'max' => 20],
|
||||||
|
[['name'], 'string', 'max' => 128],
|
||||||
|
[['description'], 'string', 'max' => 255],
|
||||||
|
[['product_number'], 'unique' ],
|
||||||
|
[['barcode'], 'unique' ],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public function attributeLabels()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id_product' => Yii::t('common/product', 'Id Product'),
|
||||||
|
'id_product_category' => Yii::t('common/product', 'Id Product Category'),
|
||||||
|
'id_account' => Yii::t('common/product', 'Id Account'),
|
||||||
|
'product_number' => Yii::t('common/product', 'Product Number'),
|
||||||
|
'barcode' => Yii::t('common/product', 'Barcode'),
|
||||||
|
'purchase_price' => Yii::t('common/product', 'Purchase Price'),
|
||||||
|
'sale_price' => Yii::t('common/product', 'Sale Price'),
|
||||||
|
'profit_margins' => Yii::t('common/product', 'Profit Margins'),
|
||||||
|
'status' => Yii::t('common/product', 'Status'),
|
||||||
|
'name' => Yii::t('common/product', 'Name'),
|
||||||
|
'description' => Yii::t('common/product', 'Description'),
|
||||||
|
'created_at' => Yii::t('common/product', 'Created At'),
|
||||||
|
'updated_at' => Yii::t('common/product', 'Updated At'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function getAccount() {
|
||||||
|
return $this->hasOne ( Account::className (), [
|
||||||
|
'id_account' => 'id_account'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
public function getAccountName() {
|
||||||
|
return $this->account->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getProductCategory() {
|
||||||
|
return $this->hasOne ( ProductCategory::className (), [
|
||||||
|
'id_product_category' => 'id_product_category'
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
public function getProductCategoryName() {
|
||||||
|
return $this->productCategory->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @formatter:on
|
||||||
|
*/
|
||||||
|
static function statuses() {
|
||||||
|
return [
|
||||||
|
self::STATUS_ACTIVE => Yii::t ( 'common/product', 'Active' ),
|
||||||
|
self::STATUS_DELETED => Yii::t ( 'common/product', 'Inactive' )
|
||||||
|
];
|
||||||
|
}
|
||||||
|
public function getStatusHuman() {
|
||||||
|
$result = null;
|
||||||
|
$s = self::statuses ( );
|
||||||
|
if (array_key_exists ( $this->status, $s )) {
|
||||||
|
$result = $s [$this->status];
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -69,4 +69,20 @@ class ProductCategory extends \common\models\BaseFitnessActiveRecord
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $param int $forceIncludeAccount id account, that should be included in list, even if it is inactive
|
||||||
|
* */
|
||||||
|
public static function read($forceIncludeObjectWithId = null){
|
||||||
|
$categories = null;
|
||||||
|
|
||||||
|
if ( $forceIncludeObjectWithId == null){
|
||||||
|
$categories = ProductCategory::find()->andWhere(['status' => ProductCategory::STATUS_ACTIVE])->all();
|
||||||
|
}else{
|
||||||
|
$categories = ProductCategory::find()->andWhere( ['or', ['status' => ProductCategory::STATUS_ACTIVE], ['id_product_category' => $forceIncludeObjectWithId ] ])->all();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $categories;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class TicketType extends \common\models\BaseFitnessActiveRecord {
|
|||||||
}
|
}
|
||||||
public function getStatusHuman() {
|
public function getStatusHuman() {
|
||||||
$result = null;
|
$result = null;
|
||||||
$s = self::statuses ( $this->status );
|
$s = self::statuses ( );
|
||||||
if (array_key_exists ( $this->status, $s )) {
|
if (array_key_exists ( $this->status, $s )) {
|
||||||
$result = $s [$this->status];
|
$result = $s [$this->status];
|
||||||
}
|
}
|
||||||
|
|||||||
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "5fe15fcdcc6c43b39968ffd29104ac62",
|
"hash": "8580bd82955b1fbb80d47024e184056e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bower-asset/bootstrap",
|
"name": "bower-asset/bootstrap",
|
||||||
|
|||||||
49
console/migrations/m150922_133505_add__table__product.php
Normal file
49
console/migrations/m150922_133505_add__table__product.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m150922_133505_add__table__product 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('{{%product}}', [
|
||||||
|
'id_product' => $this->primaryKey(),
|
||||||
|
'id_product_type' => $this->integer()->notNull(),
|
||||||
|
'id_account' => $this->integer()->notNull(),
|
||||||
|
'product_number' => $this->string(20),
|
||||||
|
'barcode' => $this->string(20),
|
||||||
|
'purchase_price' => $this->integer(),
|
||||||
|
'sale_price' => $this->integer(),
|
||||||
|
'profit_margins' => $this->integer(),
|
||||||
|
'status' => $this->smallInteger()->notNull()->defaultValue(10),
|
||||||
|
'description' => $this->string(255),
|
||||||
|
'created_at' => $this->timestamp()->notNull(),
|
||||||
|
'updated_at' => $this->timestamp()->notNull(),
|
||||||
|
], $tableOptions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m150922_133505_add__table__product cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
use common\models\Product;
|
||||||
|
|
||||||
|
class m150924_162425_alter__table__product_fix_columns extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->renameColumn('product','id_product_type','id_product_category');
|
||||||
|
$this->addColumn('product','stock', 'int(11)' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m150924_162425_alter__table__product_fix_columns cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m150924_170806_alter__table__product__add__column__name extends Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->addColumn('product','name', 'varchar(128)' );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
echo "m150924_170806_alter__table__product__add__column__name cannot be reverted.\n";
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Use safeUp/safeDown to run migration code within a transaction
|
||||||
|
public function safeUp()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function safeDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user