首页 > 代码库 > 跟单统计
跟单统计
123
/** * 返回跟单信息 * * @return array 返回跟单相关信息 * @author ZP 2013-12-17 11:55:16 * @modify YLP 2014-5-13 17:30:29 未采购和未到货不需要同时显示明细 */ function get_order_trail_info(){ //获取已审核过并未占用库存的订单商品的供应商ID和联系人 $supplier_list = $GLOBALS[‘db‘]->getAll(‘select distinct supplier_id, supplier_linkman from ‘ . $GLOBALS[‘site‘]->table ( ‘order_goods‘ ) .‘ where supplier_id > 0 and (status in (11,19) or (status = 13 and inventory_id = 0))‘); //有跟单权限的用户
$gendan_admin_user = $GLOBALS[‘db‘]->getAll ( " select user_id,user_name,supplier_list from " . $GLOBALS[‘site‘]->table ( ‘admin_user‘ ) . " where supplier_list != ‘‘ " ); $total_un_purchase = 0; $total_un_receive = 0; $date_info = array();//按天记录未采购和未到货的信息 if(empty($_REQUEST [‘status‘])){ $status = 1; }else{ $status = $_REQUEST [‘status‘]; } $date_un_receive = array();//未到货 $date_un_purchase = array();//未采购 if($status == 1){ $query_un_purchase = $GLOBALS[‘db‘]->query ( " select count(b.id) as num, FROM_UNIXTIME( b.handle_time, ‘%Y-%m-%d‘ ) as handle_time from " . $GLOBALS[‘site‘]->table ( ‘order_goods‘ ) . " as b inner join " . $GLOBALS [‘site‘]->table ( ‘order‘ ) . " as a on a.order_id = b.order_id and a.status =1 and a.is_delete = 0 where b.status in (11, 19) group by FROM_UNIXTIME( b.handle_time, ‘%Y-%m-%d‘ ) " ); while($row = $GLOBALS[‘db‘]->fetchRow($query_un_purchase)){ $date_un_purchase[$row[‘handle_time‘]] = $row[‘num‘]; } $query_date_order = $GLOBALS[‘db‘]->getCol ( " select FROM_UNIXTIME( b.handle_time, ‘%Y-%m-%d‘ ) as handle_time from " . $GLOBALS[‘site‘]->table ( ‘order_goods‘ ) . " as b inner join " . $GLOBALS [‘site‘]->table ( ‘order‘ ) . " as a on a.order_id = b.order_id and a.status =1 and a.is_delete = 0 where b.status in (11, 19) group by FROM_UNIXTIME( b.handle_time, ‘%Y-%m-%d‘ ) order by b.handle_time desc" ); foreach($query_date_order as $k=>$v){ $date_info[] = array( ‘handle_time‘ => $v, ‘un_purchase‘ => intval($date_un_purchase[$v]), ); $total_un_purchase += intval($date_un_purchase[$v]); } $beihuo_un_purchase = $GLOBALS [‘db‘]->getOne ("SELECT sum(quantity) as total FROM " . $GLOBALS [‘site‘]->table ( ‘beihuo‘ ) . " where quantity !=0"); }elseif($status == 2){ $query_un_receive = $GLOBALS[‘db‘]->query ( " select count(b.inventory_id) as num, DATE_FORMAT( b.add_time, ‘%Y-%m-%d‘ ) as handle_time from " . $GLOBALS[‘site‘]->table ( ‘inventory‘ ) . " as b where b.inventory_status = 0 and b.inventory_type in (0, 1) and b.is_delete = 0 group by DATE_FORMAT( b.add_time, ‘%Y-%m-%d‘ ) " ); while($row = $GLOBALS[‘db‘]->fetchRow($query_un_receive) ){ $date_un_receive[$row[‘handle_time‘]] = $row[‘num‘]; } $query_date_inventory = $GLOBALS[‘db‘]->getCol ( " select DATE_FORMAT( b.add_time, ‘%Y-%m-%d‘ ) as handle_time from " . $GLOBALS[‘site‘]->table ( ‘inventory‘ ) . " as b where b.inventory_status = 0 and b.inventory_type in (0, 1) and b.is_delete = 0 group by DATE_FORMAT( b.add_time, ‘%Y-%m-%d‘ ) order by DATE_FORMAT( b.add_time, ‘%Y-%m-%d‘ ) desc " ); foreach($query_date_inventory as $k=>$v){ $date_info[] = array( ‘handle_time‘ => $v, ‘un_receive‘ => intval($date_un_receive[$v]) ); $total_un_receive += intval($date_un_receive[$v]); } } if(intval ( $_REQUEST [‘status‘] == 2)){ $order_goods_info = gendan_inventory_list(); }elseif(intval ( $_REQUEST [‘status‘] == 1)){ $order_goods_info = order_goods_batch_buy_list(); } return array(‘date_info‘ => $date_info, ‘status‘=>$status, ‘supplier_list‘ => $supplier_list, ‘gendan_admin_user‘ => $gendan_admin_user, ‘total_un_purchase‘ => $total_un_purchase, ‘total_un_receive‘ => $total_un_receive,‘beihuo_un_purchase‘ => $beihuo_un_purchase, ‘order_goods_info‘ => $order_goods_info); }
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。