add inventory changes
This commit is contained in:
@@ -6,6 +6,7 @@ use Yii;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use common\components\UserAwareBehavior;
|
||||
use common\components\Helper;
|
||||
use common\components\ProductAwareBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "inventory_item".
|
||||
@@ -45,6 +46,8 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['count'],'integer'] ,
|
||||
[['count'],'required'] ,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -58,7 +61,7 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
'id_inventory' => Yii::t('common/inventory_item', 'Id Inventory'),
|
||||
'count_in' => Yii::t('common/inventory_item', 'Count In'),
|
||||
'count_sold' => Yii::t('common/inventory_item', 'Count Sold'),
|
||||
'count' => Yii::t('common/inventory_item', 'Count'),
|
||||
'count' => Yii::t('common/inventory_item', 'Leltározott mennyiség'),
|
||||
'type' => Yii::t('common/inventory_item', 'Type'),
|
||||
'id_product' => Yii::t('common/inventory_item', 'Id Product'),
|
||||
'id_inventory_group' => Yii::t('common/inventory_item', 'Id Inventory Group'),
|
||||
@@ -72,6 +75,9 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
return ArrayHelper::merge( [
|
||||
[
|
||||
'class' => UserAwareBehavior::className(),
|
||||
],
|
||||
[
|
||||
'class' => ProductAwareBehavior::className(),
|
||||
]
|
||||
], parent::behaviors());
|
||||
}
|
||||
@@ -133,4 +139,13 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function afterSave($insert, $changedAttributes){
|
||||
if ( !$insert ){
|
||||
$product = $this->product;
|
||||
$product->stock = $this->count;
|
||||
$product->save(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user