Zshitj.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. }
  12. //定义方法的调用规则 获取URI第二段值
  13. public function _remap($arg, $arg_array)
  14. {
  15. if ($arg == 'xcdyld') //
  16. {
  17. //获取标签出库的按条件导出的excel
  18. $this->_xcdyld($arg_array);
  19. }
  20. else {
  21. $this->_index();
  22. }
  23. }
  24. private function _index(){
  25. echo "!!!!!!!!!!!!";
  26. }
  27. /**
  28. * 许昌仓打印超过24小时的漏单
  29. */
  30. private function _xcdyld($arg_array){
  31. if(isset($_SESSION['api']))
  32. {
  33. $user = $this->user->get_api($_SESSION['api']);
  34. $owner_shop = explode('|',trim($user['shop'],'|'));
  35. }
  36. if($this->input->method() == 'post'){
  37. $params = $this->input->post(NULL,true);
  38. $time =time() - 24 * 60 * 60;
  39. $start_time = time() - 5 * 24 * 60 * 60 ;
  40. $table_name = $params['table_name'];
  41. $waybill = $this->input->post('waybill',true);
  42. $number = $this->input->post('number',true);
  43. $orderinfo = $this->input->post('orderinfo',true);
  44. $shop = $this->input->post('shop',true);
  45. $page = $this->input->post('page',true);
  46. $perpage = $this->input->post('perpage',true);
  47. $this->db->select("f.state,f.shop,f.dtime,f.number,f.printtime,f.print,f.library,f.type");
  48. $this->db->from($table_name . " as f");
  49. if($waybill){
  50. $this->db->where('f.waybill',$waybill);
  51. }
  52. if($number){
  53. $this->db->where('f.number',$number);
  54. }
  55. if($orderinfo){
  56. $this->db->where('f.orderinfo',$orderinfo);
  57. }
  58. if($shop){
  59. $this->db->where('f.shop',$shop);
  60. }else{
  61. if(!empty($owner_shop)){
  62. $this->db->where_in('f.shop',$owner_shop);
  63. }
  64. }
  65. $this->db->where(' f.type','13');
  66. $this->db->where(' f.state','207');
  67. $this->db->where(' f.print','3');
  68. $this->db->where(' f.printtime >= ', $start_time );
  69. $this->db->where(' f.printtime < ', $time );
  70. $this->db->where(' f.library','1');
  71. $this->db->where(" NOT EXISTS ( SELECT 1 FROM crowd_systemtransfer as s where s.number = f.number )", null, false);
  72. $this->db->order_by('f.printtime','desc');
  73. $list = $this->db->get()->result_array();
  74. if(empty($list)){
  75. $rows = array('total'=>0,'over'=>0,'pagenum'=>$page,'rows'=>([]));
  76. }else{
  77. $total = count($list);
  78. $split_arr = array_chunk($list,$perpage);
  79. $split_total = count($split_arr);
  80. $over = $split_total - $page;
  81. $r_list = $split_arr[$page-1];
  82. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$page,'rows'=>($r_list));
  83. }
  84. echo json_encode($rows);exit;
  85. }else{
  86. $table_name = $arg_array[0];
  87. $this->data['table_name'] = $table_name;
  88. $this->_Template('zshitj_xcdyld', $this->data);
  89. }
  90. }
  91. }