load->library('session'); $this->load->_model('Model_user','user'); $this->load->_model('Model_typeclass','typeclass'); $this->load->_model('Model_registration','registration'); $this->load->_model('Model_fullorder','fullorder'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullordersmt','fullordersmt'); $this->load->_model('Model_fullordertt','fullordertt'); $this->load->_model('Model_fullorderam','fullorderam'); $this->load->_model('Model_shop','shop'); } //定义方法的调用规则 获取URI第二段值 public function _remap($arg,$arg_array) { if($arg == 'add')//添加 { $this->_add(); } else if($arg == 'edit')//修改 { $this->_edit($arg_array); } else if($arg == 'del')//修改 { $this->_del(); } else if($arg == 'rows')//修改 { $this->_rows(); } else if($arg == 'see')//修改 { $this->_see($arg_array); } else if($arg == 'order')//修改 { $this->_order(); } else { $this->_index(); } } //管理 public function _index() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $usp = $user; $fgshop = "";$sid = ""; $usersp = explode('|',trim($user['shop'],'|')); foreach ($usersp as $value) { $fgshop .= " shop = ".$value." or"; $sid .= " id = ".$value." or"; } } else { $vip = 0; header('Location: /');exit; } $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); $orderinfo = $this->input->post('orderinfo',true); $state = $this->input->post('state',true); $objective = $this->input->post('objective',true); $name = $this->input->post('name',true); $phone = $this->input->post('phone',true); $where = "1=1 and (".rtrim($fgshop,'or').")"; //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } if($number) { $where .= " and number = '$number'"; } if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($state) { $where .= " and state = '$state'"; } if($objective) { $where .= " and objective = '$objective'"; } if($name) { $where .= " and name like '%$name%'"; } if($phone) { $where .= " and phone like '%$phone%'"; } //取得信息列表 $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent,img',$order_str,$start,$perpage); //格式化数据 foreach ($info_list as $key=>$value) { $d = $this->registration->read($value['id']); if($value['state'] == 1) { $info_list[$key]['state'] = '沟通中'; } else if($value['state'] == 2) { $info_list[$key]['state'] = '待客户上门'; } else if($value['state'] == 3) { $info_list[$key]['state'] = '已自提'; } else if($value['state'] == 4) { $info_list[$key]['state'] = '已退货'; } else if($value['state'] == 5) { $info_list[$key]['state'] = '已换货'; } if($value['objective'] == 1) { $info_list[$key]['objective'] = '仅自提'; } else if($value['objective'] == 2) { $info_list[$key]['objective'] = '仅退货'; } else if($value['objective'] == 3) { $info_list[$key]['objective'] = '退换货'; } else if($value['objective'] == 4) { $info_list[$key]['objective'] = '安装头套'; } if($value['address'] == 1) { $info_list[$key]['address'] = 'BK850'; } else if($value['address'] == 2) { $info_list[$key]['address'] = 'Manhattan819'; } else if($value['address'] == 3) { $info_list[$key]['address'] = 'Flatbush933'; } $info_list[$key]['number'] = "

".$value['number']."

".$d['orderinfo']."

"; if($d['red'] == 1) { $info_list[$key]['content'] = "".$value['content'].""; } $returnsimg = explode('|',trim($d['img'],'|')); $img = '';$i=1; if($d['img'] != '') { foreach ($returnsimg as $k=>$v) { $lx = explode(".",$v); $lx = strtolower(end($lx)); if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4") { $img .= "X"; } else if($v != '') { $url = str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','/img/thumb?src='),'',$v); $url = explode('&',$url); $url = $url[0]; $img .= ""."X"; } else { $img = ''; } } } $info_list[$key]['img'] = $img; } $total = $this->registration->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->_Template('registration',$this->data); } //添加 public function _add() { $post = $this->input->post(NULL, TRUE); if(isset($post['state'])) { $post['number'] = $this->input->post('number',true); $img = $this->input->post('img',true); if($img) { $post['img'] = $img; } $post['orderinfo'] = $this->input->post('orderinfo',true); $post['objective'] = $this->input->post('objective',true); $post['thproduct'] = $this->input->post('thproduct',true); if($post['objective'] == 1 && $post['product'] == '') { echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit; } if($post['objective'] == 2 && $post['thproduct'] == '') { echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit; } if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == '')) { echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit; } $f = $this->typeclass->find_all("classid = '32' and id != 2297"); $t = 0; foreach ($f as $v) { $fl = $v['bqsku']; $b = $this->$fl->get_number($post['number']); $d = $this->$fl->get_orderinfo($post['orderinfo']); if($d && $b) { $t += 1; } } if($t < 1) { echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit; } $red = $this->input->post('red',true); $post['ted'] = rtrim($red,','); if($this->registration->insert($post)) { echo json_encode(array('msg'=>'添加成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit; } } $this->_Template('registration_add',$this->data); } //修改 public function _edit($arg_array) { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); $t = 0; $post['number'] = $this->input->post('number',true); $img = $this->input->post('img',true); if($img) { $post['img'] = $img; } $post['orderinfo'] = $this->input->post('orderinfo',true); $post['objective'] = $this->input->post('objective',true); $post['thproduct'] = $this->input->post('thproduct',true); if($post['objective'] == 1 && $post['product'] == '') { echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit; } if($post['objective'] == 2 && $post['thproduct'] == '') { echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit; } if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == '')) { echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit; } $f = $this->typeclass->find_all("classid = '32' and id != 2297"); foreach ($f as $v) { $fl = $v['bqsku']; $b = $this->$fl->get_number($post['number']); $d = $this->$fl->get_orderinfo($post['orderinfo']); if($d && $b) { $t += 1; } } if($t < 1) { echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit; } $red = $this->input->post('red',true); $post['ted'] = rtrim($red,','); if($this->registration->save($post,$id)) { echo json_encode(array('msg'=>'修改成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit; } } $arg_array = $arg_array[0]; $registration = $this->registration->read($arg_array); $returnsimg = explode('|',trim($registration['img'],'|')); $img = '';$i=1; if($registration['img'] != '') { foreach ($returnsimg as $k=>$v) { $lx = explode(".",$v); $lx = strtolower(end($lx)); if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4") { $img .= ''."X"; } else if($v != '') { $url = str_replace(array('http://'.$_SERVER['HTTP_HOST'],'http://erp.hnwmzp.cn','https://erp.hnwmzp.cn','http://1.wepolicy.cn/','https://1.wepolicy.cn/','/img/thumb?src='),'',$v); $url = explode('&',$url); $url = $url[0]; $img .= ''.""."X"; } else { $img = ''; } } } $registration['img'] = $img; $this->data['registration'] = $registration; $this->_Template('registration_edit',$this->data); } //删除 public function _del() { $post = $this->input->post(NULL, TRUE); if(isset($post['s'])) { $id_arr = $this->input->post('s'); $id_arr = explode(',',$id_arr); if(!$id_arr) { echo json_encode(array('msg'=>'参数错误!','success'=>false));exit; } //循环删除记录 foreach ($id_arr as $v) { $this->registration->remove($v); } echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true)); } } //数据 public function _rows() { if(isset($_SESSION['api'])) { $user = $this->user->get_api($_SESSION['api']); $fgshop = ""; $warehouse = explode('|',trim($user['warehouse'],'|')); foreach ($warehouse as $value) { $fgshop .= " warehouse = ".$value." or"; } } else { $vip = 0; header('Location: /');exit; } $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); $orderinfo = $this->input->post('orderinfo',true); $state = $this->input->post('state',true); $objective = $this->input->post('objective',true); $name = $this->input->post('name',true); $phone = $this->input->post('phone',true); $where = "1=1 and (".rtrim($fgshop,'or').")"; //数据排序 $order_str = "id desc"; if(empty($page)) { $start = 0; $perpage = 1; } else { $start = ($page - 1)*$perpage; } if($number) { $where .= " and number = '$number'"; } if($orderinfo) { $where .= " and orderinfo = '$orderinfo'"; } if($state) { $where .= " and state = '$state'"; } if($objective) { $where .= " and objective = '$objective'"; } if($name) { $where .= " and name like '%$name%'"; } if($phone) { $where .= " and phone like '%$phone%'"; } //取得信息列表 $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent',$order_str,$start,$perpage); //格式化数据 foreach ($info_list as $key=>$value) { $d = $this->registration->read($value['id']); if($value['state'] == 1) { $info_list[$key]['state'] = '沟通中'; } else if($value['state'] == 2) { $info_list[$key]['state'] = '待客户上门'; } else if($value['state'] == 3) { $info_list[$key]['state'] = '已自提'; } else if($value['state'] == 4) { $info_list[$key]['state'] = '已退货'; } else if($value['state'] == 5) { $info_list[$key]['state'] = '已换货'; } if($value['objective'] == 1) { $info_list[$key]['objective'] = '仅自提'; } else if($value['objective'] == 2) { $info_list[$key]['objective'] = '仅退货'; } else if($value['objective'] == 3) { $info_list[$key]['objective'] = '退换货'; } else if($value['objective'] == 4) { $info_list[$key]['objective'] = '安装头套'; } if($value['address'] == 1) { $info_list[$key]['address'] = 'BK850'; } else if($value['address'] == 2) { $info_list[$key]['address'] = 'Manhattan819'; } else if($value['address'] == 3) { $info_list[$key]['address'] = 'Flatbush933'; } $info_list[$key]['number'] = "

".$value['number']."

".$d['orderinfo']."

"; if($d['red'] == 1) { $info_list[$key]['content'] = "".$value['content'].""; } } $total = $this->registration->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->_Template('registration_rows',$this->data); } public function _see($arg_array) { $post = $this->input->post(NULL, TRUE); if(isset($post['id'])) { $id = $this->input->post('id',true); if($this->registration->save($post,$id)) { echo json_encode(array('msg'=>'修改成功','success'=>true));exit; } else { echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit; } } $arg_array = $arg_array[0]; $product = ''; $registration = $this->registration->read($arg_array); $lk = explode(',',rtrim($registration['url'],',')); for($i=0;$i'.$lk[$i].','; } $registration['url'] = rtrim($product,','); $this->data['registration'] = $registration; $this->_Template('registration_see',$this->data); } public function _order() { $post = $this->input->post(NULL, TRUE); if(isset($post['number'])) { $data = array(); $f = $this->typeclass->find_all("classid = '32' and id != 2297"); $number = $this->input->post('number',true); foreach ($f as $v) { $fl = $v['bqsku']; $d = $this->$fl->get_number($number); if($d) { $data = $d; continue; } } if($data) { if($data['source'] == 1) { $shop = $this->shop->read($data['shop']); $data['url'] = $shop['url']; } else { $product = ''; $lk = explode(',',$data['link']); for($i=0;$i$data,'success'=>true));exit; } else { echo json_encode(array('msg'=>'请检查编号是否正确','success'=>false));exit; } } } }