inventory changes
This commit is contained in:
@@ -12,6 +12,7 @@ use common\models\User;
|
||||
use common\models\Product;
|
||||
use common\models\InventoryGroup;
|
||||
use common\components\Helper;
|
||||
use common\models\Inventory;
|
||||
|
||||
/**
|
||||
* InventoryItemSearch represents the model behind the search form about `common\models\InventoryItem`.
|
||||
@@ -58,6 +59,10 @@ class InventoryItemSearch extends InventoryItem
|
||||
'coalesce(inventory_item.count_in,0) as item_count_in',
|
||||
'coalesce(inventory_item.count_sold,0) as item_count_sold',
|
||||
'coalesce(inventory_item.count,0) as item_count',
|
||||
'coalesce(inventory_item.count_system,0) as item_count_system',
|
||||
'inventory.created_at as inventory_created_at',
|
||||
'inventory_prev.id_inventory as inventory_prev_id_inventory',
|
||||
'inventory_prev.name as inventory_prev_name',
|
||||
new Expression('(inventory_item.count - ( inventory_item.count_prev + inventory_item.count_in - inventory_item.count_sold )) as item_difference'),
|
||||
]);
|
||||
$query->from(InventoryItem::tableName());
|
||||
@@ -66,8 +71,12 @@ class InventoryItemSearch extends InventoryItem
|
||||
$query->innerJoin(User::tableName(), "user.id = inventory_item.id_user");
|
||||
$query->leftJoin(Product::tableName(), "product.id_product = inventory_item.id_product");
|
||||
$query->leftJoin(InventoryGroup::tableName(), "inventory_group.id_inventory_group = inventory_item.id_inventory_group");
|
||||
$query->leftJoin(Inventory::tableName(), "inventory.id_inventory = inventory_item.id_inventory");
|
||||
|
||||
$query->andWhere( ['id_inventory' => $this->inventory->id_inventory] );
|
||||
$query->leftJoin( "inventory_item as item_prev", "item_prev.id_inventory_item = inventory_item.id_inventory_item_prev" );
|
||||
$query->leftJoin( "inventory as inventory_prev", "inventory_prev.id_inventory = item_prev.id_inventory" );
|
||||
|
||||
$query->andWhere( ['inventory_item.id_inventory' => $this->inventory->id_inventory] );
|
||||
|
||||
$dataProvider = new ActiveDataProvider(
|
||||
['query' => $query ,
|
||||
@@ -82,6 +91,10 @@ class InventoryItemSearch extends InventoryItem
|
||||
['item_count', 'item_count'],
|
||||
['item_count', 'item_count'],
|
||||
['item_difference', 'item_difference'],
|
||||
['item_count_system', 'item_count_system'],
|
||||
['inventory.id_inventory', 'inventory_id_inventory'],
|
||||
['inventory.name', 'inventory_name'],
|
||||
['inventory_prev_name', 'inventory_prev_name'],
|
||||
])
|
||||
,
|
||||
]
|
||||
@@ -96,17 +109,12 @@ class InventoryItemSearch extends InventoryItem
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id_inventory_item' => $this->id_inventory_item,
|
||||
'id_inventory' => $this->id_inventory,
|
||||
'count_in' => $this->count_in,
|
||||
'count_sold' => $this->count_sold,
|
||||
'count' => $this->count,
|
||||
'type' => $this->type,
|
||||
'id_product' => $this->id_product,
|
||||
'id_inventory_group' => $this->id_inventory_group,
|
||||
'id_user' => $this->id_user,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'inventory_item.id_inventory_item' => $this->id_inventory_item,
|
||||
'inventory_item.type' => $this->type,
|
||||
'inventory_item.id_product' => $this->id_product,
|
||||
'inventory_item.id_inventory_group' => $this->id_inventory_group,
|
||||
'inventory_item.id_user' => $this->id_user,
|
||||
'inventory_item.created_at' => $this->created_at,
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
|
||||
Reference in New Issue
Block a user