add product
This commit is contained in:
parent
fcc18d79f6
commit
a2b835225a
@ -9,6 +9,7 @@ use yii\web\Controller;
|
|||||||
use yii\web\NotFoundHttpException;
|
use yii\web\NotFoundHttpException;
|
||||||
use yii\filters\VerbFilter;
|
use yii\filters\VerbFilter;
|
||||||
use common\models\Account;
|
use common\models\Account;
|
||||||
|
use common\models\ProductCategory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ProductController implements the CRUD actions for Product model.
|
* ProductController implements the CRUD actions for Product model.
|
||||||
@ -62,8 +63,10 @@ class ProductController extends Controller
|
|||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$model = new Product();
|
$model = new Product();
|
||||||
|
$model->stock = 0;
|
||||||
|
$model->status = Product::STATUS_ACTIVE;
|
||||||
$accounts = Account::readAccounts(null);
|
$accounts = Account::readAccounts(null);
|
||||||
|
$categories = ProductCategory::read(null);
|
||||||
|
|
||||||
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
@ -71,6 +74,8 @@ class ProductController extends Controller
|
|||||||
return $this->render('create', [
|
return $this->render('create', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'accounts' => $accounts,
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,11 +90,16 @@ class ProductController extends Controller
|
|||||||
{
|
{
|
||||||
$model = $this->findModel($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()) {
|
if ($model->load(Yii::$app->request->post()) && $model->save()) {
|
||||||
return $this->redirect(['view', 'id' => $model->id_product]);
|
return $this->redirect(['view', 'id' => $model->id_product]);
|
||||||
} else {
|
} else {
|
||||||
return $this->render('update', [
|
return $this->render('update', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,8 @@ class ProductSearch extends Product
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id_product', 'id_product_type', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
|
[[ 'id_product_category', 'id_account', 'status'], 'integer'],
|
||||||
[['product_number', 'barcode', 'description', 'created_at', 'updated_at'], 'safe'],
|
[['product_number', 'barcode' ], 'safe'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,20 +56,13 @@ class ProductSearch extends Product
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query->andFilterWhere([
|
$query->andFilterWhere([
|
||||||
'id_product' => $this->id_product,
|
'id_product_category' => $this->id_product_category,
|
||||||
'id_product_type' => $this->id_product_type,
|
|
||||||
'id_account' => $this->id_account,
|
'id_account' => $this->id_account,
|
||||||
'purchase_price' => $this->purchase_price,
|
|
||||||
'sale_price' => $this->sale_price,
|
|
||||||
'profit_margins' => $this->profit_margins,
|
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'created_at' => $this->created_at,
|
|
||||||
'updated_at' => $this->updated_at,
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$query->andFilterWhere(['like', 'product_number', $this->product_number])
|
$query->andFilterWhere(['like', 'product_number', $this->product_number])
|
||||||
->andFilterWhere(['like', 'barcode', $this->barcode])
|
->andFilterWhere(['like', 'barcode', $this->barcode]);
|
||||||
->andFilterWhere(['like', 'description', $this->description]);
|
|
||||||
|
|
||||||
return $dataProvider;
|
return $dataProvider;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,14 +11,19 @@ use yii\helpers\ArrayHelper;
|
|||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
|
$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
|
||||||
|
$product_category_options = ArrayHelper::map($categories, 'id_product_category', 'name');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div class="product-form">
|
<div class="product-form">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin(); ?>
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
|
||||||
|
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_account')->dropDownList($account_options) ?>
|
<?= $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, 'product_number')->textInput(['maxlength' => true]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'barcode')->textInput(['maxlength' => true]) ?>
|
<?= $form->field($model, 'barcode')->textInput(['maxlength' => true]) ?>
|
||||||
@ -31,10 +36,10 @@ $account_options = ArrayHelper::map($accounts, 'id_account', 'name');
|
|||||||
|
|
||||||
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/product', "Active") ]) ?>
|
<?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' => Yii::t('common/product', "Active") ]) ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'description')->textarea(['maxlength' => true])->hint( Yii::t( 'common/prodcut', "Max 255 character")) ?>
|
<?= $form->field($model, 'description')->textarea(['maxlength' => true])->hint( Yii::t( 'common/product', "Max 255 character")) ?>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket_type', 'Create') : Yii::t('common/ticket_type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
<?= Html::submitButton($model->isNewRecord ? Yii::t('common/product', 'Create') : Yii::t('common/product', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|||||||
@ -2,12 +2,30 @@
|
|||||||
|
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
use yii\widgets\ActiveForm;
|
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 $this yii\web\View */
|
||||||
/* @var $model backend\models\ProductSearch */
|
/* @var $model backend\models\ProductSearch */
|
||||||
/* @var $form yii\widgets\ActiveForm */
|
/* @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">
|
<div class="product-search">
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin([
|
<?php $form = ActiveForm::begin([
|
||||||
@ -15,33 +33,29 @@ use yii\widgets\ActiveForm;
|
|||||||
'method' => 'get',
|
'method' => 'get',
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
<?= $form->field($model, 'id_product') ?>
|
<div class="row">
|
||||||
|
<div class="col-md-4">
|
||||||
<?= $form->field($model, 'id_product_type') ?>
|
<?= $form->field($model, 'id_product_category')->dropDownList($productCategories) ?>
|
||||||
|
</div>
|
||||||
<?= $form->field($model, 'id_account') ?>
|
<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') ?>
|
<?= $form->field($model, 'product_number') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
<?= $form->field($model, 'barcode') ?>
|
<?= $form->field($model, 'barcode') ?>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'purchase_price') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'sale_price') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'profit_margins') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'status') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'description') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'created_at') ?>
|
|
||||||
|
|
||||||
<?php // echo $form->field($model, 'updated_at') ?>
|
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?= Html::submitButton(Yii::t('common/ticket_type', 'Search'), ['class' => 'btn btn-primary']) ?>
|
<?= Html::submitButton(Yii::t('common/product', 'Search'), ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::resetButton(Yii::t('common/ticket_type', 'Reset'), ['class' => 'btn btn-default']) ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|||||||
@ -7,8 +7,8 @@ use yii\helpers\Html;
|
|||||||
/* @var $model common\models\Product */
|
/* @var $model common\models\Product */
|
||||||
/* @var $accounts common\models\Account[] */
|
/* @var $accounts common\models\Account[] */
|
||||||
|
|
||||||
$this->title = Yii::t('common/ticket_type', 'Create Product');
|
$this->title = Yii::t('common/product', 'Create Product');
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket_type', 'Products'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="product-create">
|
<div class="product-create">
|
||||||
@ -18,6 +18,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<?= $this->render('_form', [
|
<?= $this->render('_form', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'accounts' => $accounts,
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -7,23 +7,26 @@ use yii\grid\GridView;
|
|||||||
/* @var $searchModel backend\models\ProductSearch */
|
/* @var $searchModel backend\models\ProductSearch */
|
||||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||||
|
|
||||||
$this->title = Yii::t('common/ticket_type', 'Products');
|
$this->title = Yii::t('common/product', 'Products');
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="product-index">
|
<div class="product-index">
|
||||||
|
|
||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
<?php // echo $this->render('_search', ['model' => $searchModel]); ?>
|
<?php echo $this->render('_search', ['model' => $searchModel]); ?>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a(Yii::t('common/ticket_type', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?>
|
<?= Html::a(Yii::t('common/product', 'Create Product'), ['create'], ['class' => 'btn btn-success']) ?>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= GridView::widget([
|
<?= GridView::widget([
|
||||||
'dataProvider' => $dataProvider,
|
'dataProvider' => $dataProvider,
|
||||||
'columns' => [
|
'columns' => [
|
||||||
[
|
[
|
||||||
'attribute' => 'id_product_type',
|
'attribute' => 'name',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'attribute' => 'id_product_category',
|
||||||
'value' => 'productCategoryName',
|
'value' => 'productCategoryName',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -32,15 +35,16 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
],
|
],
|
||||||
'product_number',
|
'product_number',
|
||||||
'barcode',
|
'barcode',
|
||||||
'purchase_price',
|
|
||||||
'sale_price',
|
'sale_price',
|
||||||
'profit_margins',
|
[
|
||||||
'status',
|
'attribute' => 'status',
|
||||||
'description',
|
'value' => 'statusHuman',
|
||||||
'created_at:datetime',
|
|
||||||
'updated_at:datetime',
|
|
||||||
|
|
||||||
['class' => 'yii\grid\ActionColumn'],
|
],
|
||||||
|
|
||||||
|
['class' => 'yii\grid\ActionColumn',
|
||||||
|
'template' => '{view} {update}'
|
||||||
|
],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
|
|||||||
@ -5,12 +5,10 @@ use yii\helpers\Html;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Product */
|
/* @var $model common\models\Product */
|
||||||
|
|
||||||
$this->title = Yii::t('common/ticket_type', 'Update {modelClass}: ', [
|
$this->title = Yii::t('common/product', 'Update product:' ) . ' ' . $model->name;
|
||||||
'modelClass' => 'Product',
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
]) . ' ' . $model->id_product;
|
$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id_product]];
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket_type', 'Products'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = Yii::t('common/product', 'Update');
|
||||||
$this->params['breadcrumbs'][] = ['label' => $model->id_product, 'url' => ['view', 'id' => $model->id_product]];
|
|
||||||
$this->params['breadcrumbs'][] = Yii::t('common/ticket_type', 'Update');
|
|
||||||
?>
|
?>
|
||||||
<div class="product-update">
|
<div class="product-update">
|
||||||
|
|
||||||
@ -18,6 +16,8 @@ $this->params['breadcrumbs'][] = Yii::t('common/ticket_type', 'Update');
|
|||||||
|
|
||||||
<?= $this->render('_form', [
|
<?= $this->render('_form', [
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'accounts' => $accounts,
|
||||||
|
'categories' => $categories ,
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,8 +6,8 @@ use yii\widgets\DetailView;
|
|||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $model common\models\Product */
|
/* @var $model common\models\Product */
|
||||||
|
|
||||||
$this->title = $model->id_product;
|
$this->title = $model->name ;
|
||||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/ticket_type', 'Products'), 'url' => ['index']];
|
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/product', 'Products'), 'url' => ['index']];
|
||||||
$this->params['breadcrumbs'][] = $this->title;
|
$this->params['breadcrumbs'][] = $this->title;
|
||||||
?>
|
?>
|
||||||
<div class="product-view">
|
<div class="product-view">
|
||||||
@ -15,31 +15,27 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||||||
<h1><?= Html::encode($this->title) ?></h1>
|
<h1><?= Html::encode($this->title) ?></h1>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<?= Html::a(Yii::t('common/ticket_type', 'Update'), ['update', 'id' => $model->id_product], ['class' => 'btn btn-primary']) ?>
|
<?= Html::a(Yii::t('common/product', 'Update'), ['update', 'id' => $model->id_product], ['class' => 'btn btn-primary']) ?>
|
||||||
<?= Html::a(Yii::t('common/ticket_type', 'Delete'), ['delete', 'id' => $model->id_product], [
|
|
||||||
'class' => 'btn btn-danger',
|
|
||||||
'data' => [
|
|
||||||
'confirm' => Yii::t('common/ticket_type', 'Are you sure you want to delete this item?'),
|
|
||||||
'method' => 'post',
|
|
||||||
],
|
|
||||||
]) ?>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<?= DetailView::widget([
|
<?= DetailView::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
'id_product',
|
'productCategoryName',
|
||||||
'id_product_type',
|
'accountName',
|
||||||
'id_account',
|
|
||||||
'product_number',
|
'product_number',
|
||||||
'barcode',
|
'barcode',
|
||||||
'purchase_price',
|
'purchase_price',
|
||||||
'sale_price',
|
'sale_price',
|
||||||
'profit_margins',
|
'profit_margins',
|
||||||
'status',
|
'statusHuman',
|
||||||
'description',
|
[
|
||||||
'created_at',
|
'attribute' => 'description',
|
||||||
'updated_at',
|
'value' => nl2br($model->description),
|
||||||
|
'format' => 'raw'
|
||||||
|
],
|
||||||
|
'created_at:datetime',
|
||||||
|
'updated_at:datetime',
|
||||||
],
|
],
|
||||||
]) ?>
|
]) ?>
|
||||||
|
|
||||||
|
|||||||
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',
|
||||||
|
];
|
||||||
@ -8,7 +8,8 @@ use Yii;
|
|||||||
* This is the model class for table "product".
|
* This is the model class for table "product".
|
||||||
*
|
*
|
||||||
* @property integer $id_product
|
* @property integer $id_product
|
||||||
* @property integer $id_product_type
|
* @property string $name length 64
|
||||||
|
* @property integer $id_product_category
|
||||||
* @property integer $id_account
|
* @property integer $id_account
|
||||||
* @property string $product_number
|
* @property string $product_number
|
||||||
* @property string $barcode
|
* @property string $barcode
|
||||||
@ -16,6 +17,7 @@ use Yii;
|
|||||||
* @property integer $sale_price
|
* @property integer $sale_price
|
||||||
* @property integer $profit_margins
|
* @property integer $profit_margins
|
||||||
* @property integer $status
|
* @property integer $status
|
||||||
|
* @property integer $stock
|
||||||
* @property string $description
|
* @property string $description
|
||||||
* @property string $created_at
|
* @property string $created_at
|
||||||
* @property string $updated_at
|
* @property string $updated_at
|
||||||
@ -39,10 +41,13 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['id_product_type', 'id_account'], 'required'],
|
[['id_product_category', 'id_account', 'name'], 'required'],
|
||||||
[['id_product_type', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
|
[['id_product_category', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
|
||||||
[['product_number', 'barcode'], 'string', 'max' => 20],
|
[['product_number', 'barcode'], 'string', 'max' => 20],
|
||||||
[['description'], 'string', 'max' => 255]
|
[['name'], 'string', 'max' => 128],
|
||||||
|
[['description'], 'string', 'max' => 255],
|
||||||
|
[['product_number'], 'unique' ],
|
||||||
|
[['barcode'], 'unique' ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +58,7 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id_product' => Yii::t('common/product', 'Id Product'),
|
'id_product' => Yii::t('common/product', 'Id Product'),
|
||||||
'id_product_type' => Yii::t('common/product', 'Id Product Type'),
|
'id_product_category' => Yii::t('common/product', 'Id Product Category'),
|
||||||
'id_account' => Yii::t('common/product', 'Id Account'),
|
'id_account' => Yii::t('common/product', 'Id Account'),
|
||||||
'product_number' => Yii::t('common/product', 'Product Number'),
|
'product_number' => Yii::t('common/product', 'Product Number'),
|
||||||
'barcode' => Yii::t('common/product', 'Barcode'),
|
'barcode' => Yii::t('common/product', 'Barcode'),
|
||||||
@ -61,6 +66,7 @@ class Product extends \common\models\BaseFitnessActiveRecord {
|
|||||||
'sale_price' => Yii::t('common/product', 'Sale Price'),
|
'sale_price' => Yii::t('common/product', 'Sale Price'),
|
||||||
'profit_margins' => Yii::t('common/product', 'Profit Margins'),
|
'profit_margins' => Yii::t('common/product', 'Profit Margins'),
|
||||||
'status' => Yii::t('common/product', 'Status'),
|
'status' => Yii::t('common/product', 'Status'),
|
||||||
|
'name' => Yii::t('common/product', 'Name'),
|
||||||
'description' => Yii::t('common/product', 'Description'),
|
'description' => Yii::t('common/product', 'Description'),
|
||||||
'created_at' => Yii::t('common/product', 'Created At'),
|
'created_at' => Yii::t('common/product', 'Created At'),
|
||||||
'updated_at' => Yii::t('common/product', 'Updated At'),
|
'updated_at' => Yii::t('common/product', 'Updated At'),
|
||||||
|
|||||||
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,8 +17,7 @@
|
|||||||
"php": ">=5.4.0",
|
"php": ">=5.4.0",
|
||||||
"yiisoft/yii2": ">=2.0.6",
|
"yiisoft/yii2": ">=2.0.6",
|
||||||
"yiisoft/yii2-bootstrap": "*",
|
"yiisoft/yii2-bootstrap": "*",
|
||||||
"yiisoft/yii2-swiftmailer": "*",
|
"yiisoft/yii2-swiftmailer": "*"
|
||||||
"npm-asset/grunt": "^0.4.5"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-codeception": "*",
|
"yiisoft/yii2-codeception": "*",
|
||||||
|
|||||||
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",
|
||||||
|
|||||||
@ -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