mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-23 02:45:33 +08:00
85 lines
2.7 KiB
PHP
85 lines
2.7 KiB
PHP
<?php
|
||
/**
|
||
* Copyright © ShopeX (http://www.shopex.cn). All rights reserved.
|
||
* See LICENSE file for license details.
|
||
*/
|
||
|
||
class iostock_stock{
|
||
|
||
/**
|
||
* 获取库存查询结果
|
||
* @param
|
||
* @return
|
||
* @access public
|
||
* @author
|
||
*/
|
||
function get_stock_list($bn,$branch_id)
|
||
{
|
||
$db = kernel::database();
|
||
$SQL = '';
|
||
if ($branch_id) {
|
||
$SQL.=" AND branch_id=".$branch_id;
|
||
}
|
||
if ($bn) {
|
||
$SQL.=" AND bn='$bn'";
|
||
}
|
||
$io_types = $this->_get_iotypes();
|
||
$in_typeid = implode(',',$io_types['in_type']);
|
||
$out_typeid = implode(',',$io_types['out_type']);
|
||
|
||
|
||
$in_sql = "SELECT sum(nums) as stock_count FROM sdb_ome_iostock WHERE type_id in (".$in_typeid.") ".$SQL;
|
||
|
||
$in_stock = $db->selectrow($in_sql);
|
||
|
||
$in_stock_count = $in_stock['stock_count'];
|
||
$out_sql = "SELECT sum(nums) as stock_count FROM sdb_ome_iostock WHERE type_id in (".$out_typeid.") ".$SQL;
|
||
|
||
$out_stock = $db->selectrow($out_sql);
|
||
$out_stock_count = $out_stock['stock_count'];
|
||
$sub_stock = $in_stock_count-$out_stock_count;
|
||
$data = array('in_stock_count'=>$in_stock_count,'out_stock_count'=>$out_stock_count,'sub_stock'=>$sub_stock);
|
||
$product = $db->selectrow("SELECT bm_id AS product_id FROM sdb_material_basic_material WHERE material_bn='$bn'");
|
||
|
||
//$freeze_sql = "SELECT sum(bp.store_freeze) as store_freeze_count FROM sdb_ome_branch_product as bp WHERE bp.product_id=".$product['product_id']." AND bp.branch_id=".$branch_id;
|
||
|
||
//$freeze_stock = $db->selectrow($freeze_sql);
|
||
|
||
//$data['store_freeze_count'] = $freeze_stock['store_freeze_count'];
|
||
|
||
//根据仓库ID、基础物料ID获取该物料仓库级的预占
|
||
$basicMStockFreezeLib = kernel::single('material_basic_material_stock_freeze');
|
||
$data['store_freeze_count'] = $basicMStockFreezeLib->getBranchFreeze($product['product_id'], $branch_id);
|
||
|
||
return $data;
|
||
}
|
||
|
||
/**
|
||
* 获取出入库ID数组
|
||
* @param
|
||
* @return
|
||
* @access public
|
||
* @author
|
||
*/
|
||
function _get_iotypes()
|
||
{
|
||
$iostock = kernel::single('ome_iostock');
|
||
$iostock_types = $iostock->iostock_types;
|
||
$data = array();
|
||
$in_type = array();
|
||
$out_type = array();
|
||
foreach ( $iostock_types as $k=>$types ) {
|
||
if ($types['io'] == '1') {
|
||
$in_type[] = $k;
|
||
}else{
|
||
$out_type[] = $k;
|
||
}
|
||
}
|
||
$data = array('in_type'=>$in_type,'out_type'=>$out_type);
|
||
return $data;
|
||
}
|
||
|
||
|
||
}
|
||
|
||
?>
|