Zshitj.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. /**
  3. * 临时表获取统计
  4. * erp生成临时表的统计功能
  5. */
  6. class Zshitj extends Start_Controller
  7. {
  8. public function __construct()
  9. {
  10. parent::__construct();
  11. $this->load->_model('Model_shop', 'shop');
  12. $this->load->_model("Model_express","express");
  13. }
  14. //定义方法的调用规则 获取URI第二段值
  15. public function _remap($arg, $arg_array)
  16. {
  17. if ($arg == 'xcdyld') //
  18. {
  19. //获取标签出库的按条件导出的excel
  20. $this->_xcdyld($arg_array);
  21. }
  22. else {
  23. $this->_index();
  24. }
  25. }
  26. private function _index(){
  27. echo "!!!!!!!!!!!!";
  28. }
  29. /**
  30. * 许昌仓打印超过24小时的漏单
  31. */
  32. private function _xcdyld($arg_array){
  33. if(isset($_SESSION['api']))
  34. {
  35. $user = $this->user->get_api($_SESSION['api']);
  36. $owner_shop = explode('|',trim($user['shop'],'|'));
  37. }
  38. if($this->input->method() == 'post'){
  39. $params = $this->input->post(NULL,true);
  40. $time =time() - 24 * 60 * 60;
  41. $start_time = time() - 5 * 24 * 60 * 60 ;
  42. $table_name = $params['table_name'];
  43. $waybill = $this->input->post('waybill',true);
  44. $number = $this->input->post('number',true);
  45. $orderinfo = $this->input->post('orderinfo',true);
  46. $shop = $this->input->post('shop',true);
  47. $page = $this->input->post('page',true);
  48. $perpage = $this->input->post('perpage',true);
  49. $this->db->select("f.id,f.number,f.shop,f.state,f.express,f.waybill,f.printtime,f.print,f.library,f.type");
  50. $this->db->from($table_name . " as f");
  51. if($waybill){
  52. $this->db->where('f.waybill',$waybill);
  53. }
  54. if($number){
  55. $this->db->where('f.number',$number);
  56. }
  57. if($orderinfo){
  58. $this->db->where('f.orderinfo',$orderinfo);
  59. }
  60. if($shop){
  61. $this->db->where('f.shop',$shop);
  62. }else{
  63. if(!empty($owner_shop)){
  64. $this->db->where_in('f.shop',$owner_shop);
  65. }
  66. }
  67. $this->db->where_in(' f.type',['12','13','16']);
  68. $this->db->where(' f.state','207');
  69. $this->db->where(' f.print','3');
  70. $this->db->where(' f.printtime >= ', $start_time );
  71. $this->db->where(' f.printtime < ', $time );
  72. $this->db->where(' f.library','1');
  73. $this->db->where(" NOT EXISTS ( SELECT 1 FROM crowd_systemtransfer as s where s.number = f.number )", null, false);
  74. $this->db->order_by('f.printtime','desc');
  75. $list = $this->db->get()->result_array();
  76. if(empty($list)){
  77. $rows = array('total'=>0,'over'=>0,'pagenum'=>$page,'rows'=>([]));
  78. }else{
  79. $total = count($list);
  80. $split_arr = array_chunk($list,$perpage);
  81. $split_total = count($split_arr);
  82. $over = $split_total - $page;
  83. $r_list = $split_arr[$page-1];
  84. $shop_list = $this->shop->find_all("1 = 1","id,shopname");
  85. $shop_list = array_column($shop_list,'shopname','id');
  86. $express_list = $this->express->find_all("1 = 1","id,title");
  87. $express_list = array_column($express_list,'title','id');
  88. $f_list = [];
  89. foreach ($r_list as $key => $value) {
  90. $f_list[$key]['id'] = $value['id'];
  91. $f_list[$key]['number'] = $value['number'];
  92. $f_list[$key]['shop'] = isset($shop_list[$value['shop']])?$shop_list[$value['shop']]:"";
  93. $f_list[$key]['express'] = isset($express_list[$value['express']])? $express_list[$value['express']]:"";
  94. $f_list[$key]['waybill'] = $value['waybill'];
  95. $f_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  96. }
  97. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$page,'rows'=>($f_list));
  98. }
  99. echo json_encode($rows);exit;
  100. }else{
  101. $table_name = $arg_array[0];
  102. $this->data['table_name'] = $table_name;
  103. $this->_Template('zshitj_xcdyld', $this->data);
  104. }
  105. }
  106. }