add inventory admin fix, add procurement update
This commit is contained in:
@@ -32,6 +32,21 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
|
||||
public static $TYPE_PRODUCT = 10;
|
||||
public static $TYPE_INVENTORY_GROUP = 20;
|
||||
|
||||
|
||||
public static $UPDATE_COUNT = "
|
||||
UPDATE product as p1
|
||||
inner JOIN ( select inventory_item.id_product as id_product , inventory_item.count as count
|
||||
from inventory_item
|
||||
where inventory_item.type = 10
|
||||
and inventory_item.id_inventory = :id_inventory
|
||||
and inventory_item.count is not null
|
||||
) as t
|
||||
on t.id_product = p1.id_product
|
||||
SET p1.stock = case when t.id_product is null then ( p1.stock ) else ( t.count ) end
|
||||
";
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -142,14 +157,14 @@ class InventoryItem extends BaseFitnessActiveRecord
|
||||
|
||||
public function afterSave($insert, $changedAttributes){
|
||||
if ( !$insert ){
|
||||
if ( $this->type == 'product'){
|
||||
$product = $this->product;
|
||||
$product->stock = $this->count;
|
||||
if ( !$product->save(false) ){
|
||||
\Yii::error("Failed to save product stock");
|
||||
throw new \Exception("A leltár elem mentése nem sikerült");
|
||||
}
|
||||
}
|
||||
// if ( $this->type == 'product'){
|
||||
// $product = $this->product;
|
||||
// $product->stock = $this->count;
|
||||
// if ( !$product->save(false) ){
|
||||
// \Yii::error("Failed to save product stock");
|
||||
// throw new \Exception("A leltár elem mentése nem sikerült");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user