load->library('session'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_wigprint','wigprint'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_warehouse','warehouse'); $this->load->_model('Model_productprice','productprice'); $this->load->_model('Model_express','express'); $this->load->_model('Model_excel','excel'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'excel') { $this->_excel(); } else if($arg == 'rk') { $this->_rk(); } else if($arg == 'bbprint') { $this->_bbprint(); } else { $this->_index(); } } //管理 public function _index() { if(isset($_SESSION['api'])) { $power = 0; $user = $this->user->get_api($_SESSION['api']); if($user['power'] == 37)//老厂小单 { $power = $user['power']; } } $post = $this->input->post(NULL, TRUE); if(isset($post['page'])) { $page = $this->input->post('page',true); $perpage = $this->input->post('perpage',true); $number = $this->input->post('number',true); $wiglibrary = $this->input->post('wiglibrary',true); $wigprint = $this->input->post('wigprint',true); $shipremarks = $this->input->post('shipremarks',true); $czwarehouse = $this->input->post('czwarehouse',true); $time = $this->input->post('time',true); $timetk = $this->input->post('timetk',true); $timetj = $this->input->post('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1 "; //数据排序 $order_str = "$time desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } if($timetk && $timetj) { $where .= " and ".$time." > '$timetk' and ".$time." < '$timetj'"; } if($number) { $where .= " and number like '%$number%'"; } if($wiglibrary) { $where .= " and wiglibrary = '$wiglibrary'"; } if($wigprint) { $where .= " and wigprint = '$wigprint'"; } if($shipremarks) { $where .= " and shipremarks like '%$shipremarks%'"; } if($czwarehouse != '') { $where .= " and czwarehouse = '$czwarehouse'"; } //取得信息列表 $info_list = $this->wigprint->find_all($where,'id,number,printtime,wiglibraryrtime,wigprinttime,shipremarks',$order_str,$start,$perpage); //格式化数据 foreach ($info_list as $key=>$value) { if($value['printtime'] != 0) { $info_list[$key]['printtime'] = date('Y-m-d H:i',$value['printtime']); } else { $info_list[$key]['printtime'] = '无'; } if($value['wiglibraryrtime'] != 0) { $info_list[$key]['wiglibraryrtime'] = date('Y-m-d H:i',$value['wiglibraryrtime']); } else { $info_list[$key]['wiglibraryrtime'] = '无'; } if($value['wigprinttime'] != 0) { $info_list[$key]['wigprinttime'] = date('Y-m-d H:i',$value['wigprinttime']); } else { $info_list[$key]['wigprinttime'] = '无'; } $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('<','>'),$value['shipremarks']); } $total = $this->wigprint->find_count($where); $pagenum = ceil($total/$perpage); $over = $total-($start+$perpage); $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list)); echo json_encode($rows);exit; } $this->data['czwarehouse'] = $power; $this->_Template('wigprint',$this->data); } public function _rk() { if(isset($_SESSION['api'])) { $power = 0; $user = $this->user->get_api($_SESSION['api']); if($user['power'] == 37)//老厂小单 { $power = $user['power']; } } $post = $this->input->post(NULL, TRUE); if(isset($post['barcode'])) { $barcode = $this->input->post('barcode',true); $outtype = 1; $y = $this->fullorder->find_all("number = '$barcode' and print = '3'"); if(!$y) { $y = $this->fullordersmt->find_all("number = '$barcode' and print = '3'"); if(!$y) { $y = $this->fullordertt->find_all("number = '$barcode' and print = '3'"); if(!$y) { echo json_encode(array('msg'=>'无此数据','success'=>false));exit; } } } $y = $y[0]; $wy = $this->wigprint->get_number($y['number']); if($wy) { if($this->wigprint->save(array('type'=>$y['type'],'express'=>$y['express'],'waybill'=>$y['waybill'],'printtime'=>$y['printtime'],'wiglibraryrtime'=>time(),'shipremarks'=>$y['shipremarks'],'czwarehouse'=>$power),$wy['id'])) { echo json_encode(array('msg'=>'已有此编号的数据,信息已更新','success'=>false));exit; } else { echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit; } } if($this->wigprint->insert(array('shop'=>$y['shop'],'type'=>$y['type'],'number'=>$y['number'],'express'=>$y['express'],'waybill'=>$y['waybill'],'printtime'=>$y['printtime'],'wiglibrary'=>1,'wiglibraryrtime'=>time(),'shipremarks'=>$y['shipremarks'],'czwarehouse'=>$power))) { echo json_encode(array('success'=>true));exit; } else { echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit; } } } public function _bbprint_()//一单一单检测是否打印完成版本 先保留 不要删 { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $v = $this->input->post('s'); $va = explode(',',rtrim($v,',')); $n = $this->input->post('n'); $text = array();$text['data'] = array();$time = time(); $data = $this->wigprint->read($va[$n]); $dd = $this->fullordersmt->get_number($data['number']); if(!$dd) { $dd = $this->fullorder->get_number($data['number']); } if(!$dd) { $dd = $this->fullordertt->get_number($data['number']); } if(!$dd) { echo json_encode(array('msg'=>'未找到此订单','success'=>false));exit; } else if($dd['type'] == 5) { echo json_encode(array('msg'=>'该单已改成美国仓发货,不用再安排生产!','success'=>false));exit; } $rows = array('number'=>$data['number'],'shipremarks'=>$data['shipremarks'],'data'=>$v,'n'=>$n-1); if($this->wigprint->save(array('wigprint'=>2,'wigprinttime'=>$time),$data['id'])) { echo json_encode(array('rows'=>($rows),'success'=>true));exit; } else { echo json_encode(array('msg'=>'数据写入异常,请重新打印!','success'=>false));exit; } } } public function _bbprint()//全部发送不检测 { $fx = ''; if(isset($_SESSION['api'])) { $power = 0; $user = $this->user->get_api($_SESSION['api']); if($user['power'] == 27)//成品库 { $fx = '***成品库返修***'; } } $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $rows = array(); $s = $this->input->post('s'); $s = explode(',',rtrim($s,',')); $time = time(); /**测试用 foreach ($s as $v) { $ck = ''; $data = $this->wigprint->read($v); if($data['type'] == '16') { $warehouse = $this->warehouse->read($data['type']); $ck = $warehouse['title'].' '; } $express = $this->express->read($data['express']); $shipremarks = str_replace(array('<','>'),array('<','>'),$data['shipremarks']); $rows[] = array('number'=>$data['number'],'shipremarks'=>$ck.$shipremarks,'ex'=>$express['servicename'],'time'=>date('Y-m-d H:i:s',$data['printtime'])); } echo json_encode(array('rows'=>($rows),'success'=>true));exit; **/ $this->db->trans_begin(); foreach ($s as $v) { if($this->wigprint->save(array('wigprint'=>2,'wigprinttime'=>$time),$v)) { $ck = ''; $data = $this->wigprint->read($v); if($data['type'] == '16') { $warehouse = $this->warehouse->read($data['type']); $ck = $warehouse['title'].' '; } $express = $this->express->read($data['express']); $shipremarks = str_replace(array('<','>'),array('<','>'),$data['shipremarks']); $rows[] = array('number'=>$data['number'],'shipremarks'=>$ck.$shipremarks,'ex'=>$express['servicename'],'time'=>date('Y-m-d H:i:s',$data['printtime']),'fx'=>$fx); } } if ($this->db->trans_status() === TRUE) { $this->db->trans_commit(); echo json_encode(array('rows'=>($rows),'success'=>true));exit; } else { $this->db->trans_commit(); echo json_encode(array('msg'=>'数据异常,请重试!','success'=>false));exit; } } } public function _excel() { if(isset($_GET['fexcel'])) { $ex = array(); $express = $this->express->find_all(); foreach ($express as $v) { $ex[$v['id']] = $v['servicename']; } $number = $this->input->get('number',true); $wiglibrary = $this->input->get('wiglibrary',true); $wigprint = $this->input->get('wigprint',true); $shipremarks = $this->input->get('shipremarks',true); $czwarehouse = $this->input->get('czwarehouse',true); $time = $this->input->get('time',true); $timetk = $this->input->get('timetk',true); $timetj = $this->input->get('timetj',true); $timetk = strtotime($timetk); $timetj = strtotime($timetj); $where = "1=1"; $order_str = "$time desc"; if($timetk) { $where .= " and $time > '$timetk' and $time < '$timetj'"; } if($number) { $where .= " and number like '%$number%'"; } if($wiglibrary) { $where .= " and wiglibrary = '$wiglibrary'"; } if($wigprint) { $where .= " and wigprint = '$wigprint'"; } if($shipremarks) { $where .= " and shipremarks like '%$shipremarks%'"; } if($czwarehouse != '') { $where .= " and czwarehouse = '$czwarehouse'"; } $info_list = $this->wigprint->find_all($where,'number,express,printtime,wiglibraryrtime,wigprinttime,shipremarks',$order_str); foreach ($info_list as $key=>$value) { $info_list[$key]['express'] = $ex[$value['express']]; $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']); if($value['wiglibraryrtime'] > 0) { $info_list[$key]['wiglibraryrtime'] = date('Y-m-d H:i:s',$value['wiglibraryrtime']); } else { $info_list[$key]['wiglibraryrtime'] = ''; } if($value['wigprinttime'] > 0) { $info_list[$key]['wigprinttime'] = date('Y-m-d H:i:s',$value['wigprinttime']); } else { $info_list[$key]['wigprinttime'] = ''; } } $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj).' 头套仓统计'; $titlename = "
编号 物流类型 发货单时间 扫码时间 打印时间 仓库品名
"; $filename = $title.".xls"; $tail = "\n"; $this->excel->get_fz2($info_list,$titlename,$filename,$tail); } } }