add product

This commit is contained in:
2015-09-24 22:14:09 +02:00
parent fcc18d79f6
commit a2b835225a
15 changed files with 229 additions and 80 deletions

View 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',
];

View File

@@ -8,7 +8,8 @@ use Yii;
* This is the model class for table "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 string $product_number
* @property string $barcode
@@ -16,6 +17,7 @@ use Yii;
* @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
@@ -39,10 +41,13 @@ class Product extends \common\models\BaseFitnessActiveRecord {
public function rules()
{
return [
[['id_product_type', 'id_account'], 'required'],
[['id_product_type', 'id_account', 'purchase_price', 'sale_price', 'profit_margins', 'status'], 'integer'],
[['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],
[['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 [
'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'),
'product_number' => Yii::t('common/product', 'Product Number'),
'barcode' => Yii::t('common/product', 'Barcode'),
@@ -61,6 +66,7 @@ class Product extends \common\models\BaseFitnessActiveRecord {
'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'),

View File

@@ -69,4 +69,20 @@ class ProductCategory extends \common\models\BaseFitnessActiveRecord
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;
}
}