add product
This commit is contained in:
@@ -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'),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user