123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 |
- <?php defined('BASEPATH') OR exit('No direct script access allowed');
- class Registration extends Start_Controller {
- public function __construct(){
- parent::__construct();
- $this->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'] = '<font style="color:#F00">待客户上门</font>';
- }
- 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'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
- if($d['red'] == 1)
- {
- $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
- }
- $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 .= "<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em>";
- }
- 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 .= "<img src='".site_url('img/thumb')."?src=".$url."&w=150&h=150' data-src='".$v."'></a>"."<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em>";
- }
- 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 .= '<span class="deldata"><video src="'.$v.'" controls="controls"></video>'."<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em></span>";
- }
- 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 .= '<span class="deldata"><a href="'.$url.'" target="_blank">'."<img src='".site_url('img/thumb')."?src=".$url."&w=500&h=500' data-src='".$v."'></a>"."<em style='width:30px;height:30px;line-height:30px;text-align: center;display: inline-block;position: absolute;top: 0px;right: 20px;z-index: 10;background-color: #FFF;cursor: pointer;' title='点击删除'>X</em></span>";
- }
- 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'] = '<font style="color:#F00">待客户上门</font>';
- }
- 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'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
- if($d['red'] == 1)
- {
- $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
- }
- }
- $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<count($lk);$i++)
- {
- $product .= '<a href="'.$lk[$i].'" target="_blank">'.$lk[$i].'</a>,';
- }
- $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<count($lk);$i++)
- {
- $product .= $lk[$i].',';
- }
- $data['url'] = $product;
- }
- echo json_encode(array('msg'=>$data,'success'=>true));exit;
- }
- else
- {
- echo json_encode(array('msg'=>'请检查编号是否正确','success'=>false));exit;
- }
- }
- }
- }
|