码迷,mamicode.com
首页 > 其他好文 > 详细

跟单统计

时间:2014-05-24 12:37:41      阅读:309      评论:0      收藏:0      [点我收藏+]

标签:des   style   class   blog   c   code   

123

bubuko.com,布布扣
/**
 * 返回跟单信息
 *
 * @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); }
bubuko.com,布布扣

 

跟单统计,布布扣,bubuko.com

跟单统计

标签:des   style   class   blog   c   code   

原文地址:http://www.cnblogs.com/tlijian/p/3748181.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!