Registration.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Registration extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_typeclass','typeclass');
  8. $this->load->_model('Model_registration','registration');
  9. $this->load->_model('Model_fullorder','fullorder');
  10. $this->load->_model('Model_fullordertt','fullordertt');
  11. $this->load->_model('Model_fullordersmt','fullordersmt');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullorderam','fullorderam');
  14. $this->load->_model('Model_shop','shop');
  15. }
  16. //定义方法的调用规则 获取URI第二段值
  17. public function _remap($arg,$arg_array)
  18. {
  19. if($arg == 'add')//添加
  20. {
  21. $this->_add();
  22. }
  23. else if($arg == 'edit')//修改
  24. {
  25. $this->_edit($arg_array);
  26. }
  27. else if($arg == 'del')//修改
  28. {
  29. $this->_del();
  30. }
  31. else if($arg == 'rows')//修改
  32. {
  33. $this->_rows();
  34. }
  35. else if($arg == 'see')//修改
  36. {
  37. $this->_see($arg_array);
  38. }
  39. else if($arg == 'order')//修改
  40. {
  41. $this->_order();
  42. }
  43. else
  44. {
  45. $this->_index();
  46. }
  47. }
  48. //管理
  49. public function _index()
  50. {
  51. if(isset($_SESSION['api']))
  52. {
  53. $user = $this->user->get_api($_SESSION['api']);
  54. $usp = $user;
  55. $fgshop = "";$sid = "";
  56. $usersp = explode('|',trim($user['shop'],'|'));
  57. foreach ($usersp as $value)
  58. {
  59. $fgshop .= " shop = ".$value." or";
  60. $sid .= " id = ".$value." or";
  61. }
  62. }
  63. else
  64. {
  65. $vip = 0;
  66. header('Location: /');exit;
  67. }
  68. $post = $this->input->post(NULL, TRUE);
  69. if(isset($post['page']))
  70. {
  71. $page = $this->input->post('page',true);
  72. $perpage = $this->input->post('perpage',true);
  73. $number = $this->input->post('number',true);
  74. $orderinfo = $this->input->post('orderinfo',true);
  75. $state = $this->input->post('state',true);
  76. $objective = $this->input->post('objective',true);
  77. $name = $this->input->post('name',true);
  78. $phone = $this->input->post('phone',true);
  79. $where = "1=1 and (".rtrim($fgshop,'or').")";
  80. //数据排序
  81. $order_str = "id desc";
  82. if(empty($page))
  83. {
  84. $start = 0;
  85. $perpage = 1;
  86. }
  87. else
  88. {
  89. $start = ($page - 1)*$perpage;
  90. }
  91. if($number)
  92. {
  93. $where .= " and number = '$number'";
  94. }
  95. if($orderinfo)
  96. {
  97. $where .= " and orderinfo = '$orderinfo'";
  98. }
  99. if($state)
  100. {
  101. $where .= " and state = '$state'";
  102. }
  103. if($objective)
  104. {
  105. $where .= " and objective = '$objective'";
  106. }
  107. if($name)
  108. {
  109. $where .= " and name like '%$name%'";
  110. }
  111. if($phone)
  112. {
  113. $where .= " and phone like '%$phone%'";
  114. }
  115. //取得信息列表
  116. $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent,img',$order_str,$start,$perpage);
  117. //格式化数据
  118. foreach ($info_list as $key=>$value)
  119. {
  120. $d = $this->registration->read($value['id']);
  121. if($value['state'] == 1)
  122. {
  123. $info_list[$key]['state'] = '沟通中';
  124. }
  125. else if($value['state'] == 2)
  126. {
  127. $info_list[$key]['state'] = '<font style="color:#F00">待客户上门</font>';
  128. }
  129. else if($value['state'] == 3)
  130. {
  131. $info_list[$key]['state'] = '已自提';
  132. }
  133. else if($value['state'] == 4)
  134. {
  135. $info_list[$key]['state'] = '已退货';
  136. }
  137. else if($value['state'] == 5)
  138. {
  139. $info_list[$key]['state'] = '已换货';
  140. }
  141. if($value['objective'] == 1)
  142. {
  143. $info_list[$key]['objective'] = '仅自提';
  144. }
  145. else if($value['objective'] == 2)
  146. {
  147. $info_list[$key]['objective'] = '仅退货';
  148. }
  149. else if($value['objective'] == 3)
  150. {
  151. $info_list[$key]['objective'] = '退换货';
  152. }
  153. else if($value['objective'] == 4)
  154. {
  155. $info_list[$key]['objective'] = '安装头套';
  156. }
  157. if($value['address'] == 1)
  158. {
  159. $info_list[$key]['address'] = 'BK850';
  160. }
  161. else if($value['address'] == 2)
  162. {
  163. $info_list[$key]['address'] = 'Manhattan819';
  164. }
  165. else if($value['address'] == 3)
  166. {
  167. $info_list[$key]['address'] = 'Flatbush933';
  168. }
  169. else if($value['address'] == 4)
  170. {
  171. $info_list[$key]['address'] = 'Dallas3333';
  172. }
  173. else if($value['address'] == 5)
  174. {
  175. $info_list[$key]['address'] = 'Atlanta';
  176. }
  177. $info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
  178. if($d['red'] == 1)
  179. {
  180. $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
  181. }
  182. $returnsimg = explode('|',trim($d['img'],'|'));
  183. $img = '';$i=1;
  184. if($d['img'] != '')
  185. {
  186. foreach ($returnsimg as $k=>$v)
  187. {
  188. $lx = explode(".",$v);
  189. $lx = strtolower(end($lx));
  190. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  191. {
  192. $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>";
  193. }
  194. else if($v != '')
  195. {
  196. $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);
  197. $url = explode('&',$url);
  198. $url = $url[0];
  199. $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>";
  200. }
  201. else
  202. {
  203. $img = '';
  204. }
  205. }
  206. }
  207. $info_list[$key]['img'] = $img;
  208. }
  209. $total = $this->registration->find_count($where);
  210. $pagenum = ceil($total/$perpage);
  211. $over = $total-($start+$perpage);
  212. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  213. echo json_encode($rows);exit;
  214. }
  215. $this->_Template('registration',$this->data);
  216. }
  217. //添加
  218. public function _add()
  219. {
  220. $post = $this->input->post(NULL, TRUE);
  221. if(isset($post['state']))
  222. {
  223. $post['number'] = $this->input->post('number',true);
  224. $img = $this->input->post('img',true);
  225. if($img)
  226. {
  227. $post['img'] = $img;
  228. }
  229. $post['orderinfo'] = $this->input->post('orderinfo',true);
  230. $post['objective'] = $this->input->post('objective',true);
  231. $post['thproduct'] = $this->input->post('thproduct',true);
  232. if($post['objective'] == 1 && $post['product'] == '')
  233. {
  234. echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
  235. }
  236. if($post['objective'] == 2 && $post['thproduct'] == '')
  237. {
  238. echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
  239. }
  240. if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
  241. {
  242. echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
  243. }
  244. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  245. $t = 0;
  246. foreach ($f as $v)
  247. {
  248. $fl = $v['bqsku'];
  249. $b = $this->$fl->get_number($post['number']);
  250. $d = $this->$fl->get_orderinfo($post['orderinfo']);
  251. if($d && $b)
  252. {
  253. $t += 1;
  254. }
  255. }
  256. if($t < 1)
  257. {
  258. echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
  259. }
  260. $red = $this->input->post('red',true);
  261. $post['ted'] = rtrim($red,',');
  262. unset($post['red']);
  263. if($this->registration->insert($post))
  264. {
  265. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  266. }
  267. else
  268. {
  269. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  270. }
  271. }
  272. $this->_Template('registration_add',$this->data);
  273. }
  274. //修改
  275. public function _edit($arg_array)
  276. {
  277. $post = $this->input->post(NULL, TRUE);
  278. if(isset($post['id']))
  279. {
  280. $id = $this->input->post('id',true);
  281. $t = 0;
  282. $post['number'] = $this->input->post('number',true);
  283. $img = $this->input->post('img',true);
  284. if($img)
  285. {
  286. $post['img'] = $img;
  287. }
  288. $post['orderinfo'] = $this->input->post('orderinfo',true);
  289. $post['objective'] = $this->input->post('objective',true);
  290. $post['thproduct'] = $this->input->post('thproduct',true);
  291. if($post['objective'] == 1 && $post['product'] == '')
  292. {
  293. echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
  294. }
  295. if($post['objective'] == 2 && $post['thproduct'] == '')
  296. {
  297. echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
  298. }
  299. if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
  300. {
  301. echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
  302. }
  303. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  304. foreach ($f as $v)
  305. {
  306. $fl = $v['bqsku'];
  307. $b = $this->$fl->get_number($post['number']);
  308. $d = $this->$fl->get_orderinfo($post['orderinfo']);
  309. if($d && $b)
  310. {
  311. $t += 1;
  312. }
  313. }
  314. if($t < 1)
  315. {
  316. echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
  317. }
  318. $red = $this->input->post('red',true);
  319. $post['ted'] = rtrim($red,',');
  320. unset($post['red']);
  321. if($this->registration->save($post,$id))
  322. {
  323. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  324. }
  325. else
  326. {
  327. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  328. }
  329. }
  330. $arg_array = $arg_array[0];
  331. $registration = $this->registration->read($arg_array);
  332. $returnsimg = explode('|',trim($registration['img'],'|'));
  333. $img = '';$i=1;
  334. if($registration['img'] != '')
  335. {
  336. foreach ($returnsimg as $k=>$v)
  337. {
  338. $lx = explode(".",$v);
  339. $lx = strtolower(end($lx));
  340. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  341. {
  342. $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>";
  343. }
  344. else if($v != '')
  345. {
  346. $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);
  347. $url = explode('&',$url);
  348. $url = $url[0];
  349. $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>";
  350. }
  351. else
  352. {
  353. $img = '';
  354. }
  355. }
  356. }
  357. $registration['img'] = $img;
  358. $this->data['registration'] = $registration;
  359. $this->_Template('registration_edit',$this->data);
  360. }
  361. //删除
  362. public function _del()
  363. {
  364. $post = $this->input->post(NULL, TRUE);
  365. if(isset($post['s']))
  366. {
  367. $id_arr = $this->input->post('s');
  368. $id_arr = explode(',',$id_arr);
  369. if(!$id_arr)
  370. {
  371. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  372. }
  373. //循环删除记录
  374. foreach ($id_arr as $v)
  375. {
  376. $this->registration->remove($v);
  377. }
  378. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  379. }
  380. }
  381. //数据
  382. public function _rows()
  383. {
  384. if(isset($_SESSION['api']))
  385. {
  386. $user = $this->user->get_api($_SESSION['api']);
  387. $fgshop = "";
  388. $warehouse = explode('|',trim($user['warehouse'],'|'));
  389. foreach ($warehouse as $value)
  390. {
  391. $fgshop .= " warehouse = ".$value." or";
  392. }
  393. }
  394. else
  395. {
  396. $vip = 0;
  397. header('Location: /');exit;
  398. }
  399. $post = $this->input->post(NULL, TRUE);
  400. if(isset($post['page']))
  401. {
  402. $page = $this->input->post('page',true);
  403. $perpage = $this->input->post('perpage',true);
  404. $number = $this->input->post('number',true);
  405. $orderinfo = $this->input->post('orderinfo',true);
  406. $state = $this->input->post('state',true);
  407. $objective = $this->input->post('objective',true);
  408. $name = $this->input->post('name',true);
  409. $phone = $this->input->post('phone',true);
  410. $where = "1=1 and (".rtrim($fgshop,'or').")";
  411. //数据排序
  412. $order_str = "id desc";
  413. if(empty($page))
  414. {
  415. $start = 0;
  416. $perpage = 1;
  417. }
  418. else
  419. {
  420. $start = ($page - 1)*$perpage;
  421. }
  422. if($number)
  423. {
  424. $where .= " and number = '$number'";
  425. }
  426. if($orderinfo)
  427. {
  428. $where .= " and orderinfo = '$orderinfo'";
  429. }
  430. if($state)
  431. {
  432. $where .= " and state = '$state'";
  433. }
  434. if($objective)
  435. {
  436. $where .= " and objective = '$objective'";
  437. }
  438. if($name)
  439. {
  440. $where .= " and name like '%$name%'";
  441. }
  442. if($phone)
  443. {
  444. $where .= " and phone like '%$phone%'";
  445. }
  446. //取得信息列表
  447. $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent',$order_str,$start,$perpage);
  448. //格式化数据
  449. foreach ($info_list as $key=>$value)
  450. {
  451. $d = $this->registration->read($value['id']);
  452. if($value['state'] == 1)
  453. {
  454. $info_list[$key]['state'] = '沟通中';
  455. }
  456. else if($value['state'] == 2)
  457. {
  458. $info_list[$key]['state'] = '<font style="color:#F00">待客户上门</font>';
  459. }
  460. else if($value['state'] == 3)
  461. {
  462. $info_list[$key]['state'] = '已自提';
  463. }
  464. else if($value['state'] == 4)
  465. {
  466. $info_list[$key]['state'] = '已退货';
  467. }
  468. else if($value['state'] == 5)
  469. {
  470. $info_list[$key]['state'] = '已换货';
  471. }
  472. if($value['objective'] == 1)
  473. {
  474. $info_list[$key]['objective'] = '仅自提';
  475. }
  476. else if($value['objective'] == 2)
  477. {
  478. $info_list[$key]['objective'] = '仅退货';
  479. }
  480. else if($value['objective'] == 3)
  481. {
  482. $info_list[$key]['objective'] = '退换货';
  483. }
  484. else if($value['objective'] == 4)
  485. {
  486. $info_list[$key]['objective'] = '安装头套';
  487. }
  488. if($value['address'] == 1)
  489. {
  490. $info_list[$key]['address'] = 'BK850';
  491. }
  492. else if($value['address'] == 2)
  493. {
  494. $info_list[$key]['address'] = 'Manhattan819';
  495. }
  496. else if($value['address'] == 3)
  497. {
  498. $info_list[$key]['address'] = 'Flatbush933';
  499. }
  500. $info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
  501. if($d['red'] == 1)
  502. {
  503. $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
  504. }
  505. }
  506. $total = $this->registration->find_count($where);
  507. $pagenum = ceil($total/$perpage);
  508. $over = $total-($start+$perpage);
  509. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  510. echo json_encode($rows);exit;
  511. }
  512. $this->_Template('registration_rows',$this->data);
  513. }
  514. public function _see($arg_array)
  515. {
  516. $post = $this->input->post(NULL, TRUE);
  517. if(isset($post['id']))
  518. {
  519. $id = $this->input->post('id',true);
  520. if($this->registration->save($post,$id))
  521. {
  522. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  523. }
  524. else
  525. {
  526. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  527. }
  528. }
  529. $arg_array = $arg_array[0];
  530. $product = '';
  531. $registration = $this->registration->read($arg_array);
  532. $lk = explode(',',rtrim($registration['url'],','));
  533. for($i=0;$i<count($lk);$i++)
  534. {
  535. $product .= '<a href="'.$lk[$i].'" target="_blank">'.$lk[$i].'</a>,';
  536. }
  537. $registration['url'] = rtrim($product,',');
  538. $this->data['registration'] = $registration;
  539. $this->_Template('registration_see',$this->data);
  540. }
  541. public function _order()
  542. {
  543. $post = $this->input->post(NULL, TRUE);
  544. if(isset($post['number']))
  545. {
  546. $data = array();
  547. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  548. $number = $this->input->post('number',true);
  549. foreach ($f as $v)
  550. {
  551. $fl = $v['bqsku'];
  552. $d = $this->$fl->get_number($number);
  553. if($d)
  554. {
  555. $data = $d;
  556. continue;
  557. }
  558. }
  559. if($data)
  560. {
  561. if($data['source'] == 1)
  562. {
  563. $shop = $this->shop->read($data['shop']);
  564. $data['url'] = $shop['url'];
  565. }
  566. else
  567. {
  568. $product = '';
  569. $lk = explode(',',$data['link']);
  570. for($i=0;$i<count($lk);$i++)
  571. {
  572. $product .= $lk[$i].',';
  573. }
  574. $data['url'] = $product;
  575. }
  576. echo json_encode(array('msg'=>$data,'success'=>true));exit;
  577. }
  578. else
  579. {
  580. echo json_encode(array('msg'=>'请检查编号是否正确','success'=>false));exit;
  581. }
  582. }
  583. }
  584. }