Registration.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  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. $info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
  170. if($d['red'] == 1)
  171. {
  172. $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
  173. }
  174. $returnsimg = explode('|',trim($d['img'],'|'));
  175. $img = '';$i=1;
  176. if($d['img'] != '')
  177. {
  178. foreach ($returnsimg as $k=>$v)
  179. {
  180. $lx = explode(".",$v);
  181. $lx = strtolower(end($lx));
  182. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  183. {
  184. $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>";
  185. }
  186. else if($v != '')
  187. {
  188. $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);
  189. $url = explode('&',$url);
  190. $url = $url[0];
  191. $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>";
  192. }
  193. else
  194. {
  195. $img = '';
  196. }
  197. }
  198. }
  199. $info_list[$key]['img'] = $img;
  200. }
  201. $total = $this->registration->find_count($where);
  202. $pagenum = ceil($total/$perpage);
  203. $over = $total-($start+$perpage);
  204. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  205. echo json_encode($rows);exit;
  206. }
  207. $this->_Template('registration',$this->data);
  208. }
  209. //添加
  210. public function _add()
  211. {
  212. $post = $this->input->post(NULL, TRUE);
  213. if(isset($post['state']))
  214. {
  215. $post['number'] = $this->input->post('number',true);
  216. $img = $this->input->post('img',true);
  217. if($img)
  218. {
  219. $post['img'] = $img;
  220. }
  221. $post['orderinfo'] = $this->input->post('orderinfo',true);
  222. $post['objective'] = $this->input->post('objective',true);
  223. $post['thproduct'] = $this->input->post('thproduct',true);
  224. if($post['objective'] == 1 && $post['product'] == '')
  225. {
  226. echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
  227. }
  228. if($post['objective'] == 2 && $post['thproduct'] == '')
  229. {
  230. echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
  231. }
  232. if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
  233. {
  234. echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
  235. }
  236. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  237. $t = 0;
  238. foreach ($f as $v)
  239. {
  240. $fl = $v['bqsku'];
  241. $b = $this->$fl->get_number($post['number']);
  242. $d = $this->$fl->get_orderinfo($post['orderinfo']);
  243. if($d && $b)
  244. {
  245. $t += 1;
  246. }
  247. }
  248. if($t < 1)
  249. {
  250. echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
  251. }
  252. $red = $this->input->post('red',true);
  253. $post['ted'] = rtrim($red,',');
  254. if($this->registration->insert($post))
  255. {
  256. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  257. }
  258. else
  259. {
  260. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  261. }
  262. }
  263. $this->_Template('registration_add',$this->data);
  264. }
  265. //修改
  266. public function _edit($arg_array)
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if(isset($post['id']))
  270. {
  271. $id = $this->input->post('id',true);
  272. $t = 0;
  273. $post['number'] = $this->input->post('number',true);
  274. $img = $this->input->post('img',true);
  275. if($img)
  276. {
  277. $post['img'] = $img;
  278. }
  279. $post['orderinfo'] = $this->input->post('orderinfo',true);
  280. $post['objective'] = $this->input->post('objective',true);
  281. $post['thproduct'] = $this->input->post('thproduct',true);
  282. if($post['objective'] == 1 && $post['product'] == '')
  283. {
  284. echo json_encode(array('msg'=>'必须填写待取货物!','success'=>false));exit;
  285. }
  286. if($post['objective'] == 2 && $post['thproduct'] == '')
  287. {
  288. echo json_encode(array('msg'=>'必须填写退货货物!','success'=>false));exit;
  289. }
  290. if($post['objective'] == 3 && ($post['thproduct'] == '' || $post['product'] == ''))
  291. {
  292. echo json_encode(array('msg'=>'必须填写待取货物和退货货物!','success'=>false));exit;
  293. }
  294. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  295. foreach ($f as $v)
  296. {
  297. $fl = $v['bqsku'];
  298. $b = $this->$fl->get_number($post['number']);
  299. $d = $this->$fl->get_orderinfo($post['orderinfo']);
  300. if($d && $b)
  301. {
  302. $t += 1;
  303. }
  304. }
  305. if($t < 1)
  306. {
  307. echo json_encode(array('msg'=>'编号或订单号填写错误','success'=>false));exit;
  308. }
  309. $red = $this->input->post('red',true);
  310. $post['ted'] = rtrim($red,',');
  311. if($this->registration->save($post,$id))
  312. {
  313. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  314. }
  315. else
  316. {
  317. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  318. }
  319. }
  320. $arg_array = $arg_array[0];
  321. $registration = $this->registration->read($arg_array);
  322. $returnsimg = explode('|',trim($registration['img'],'|'));
  323. $img = '';$i=1;
  324. if($registration['img'] != '')
  325. {
  326. foreach ($returnsimg as $k=>$v)
  327. {
  328. $lx = explode(".",$v);
  329. $lx = strtolower(end($lx));
  330. if($lx == "3gp" || $lx == "rmvb" || $lx == "flv" || $lx == "wmv" || $lx == "avi" || $lx == "mkv" || $lx == "wav" || $lx == "mp4")
  331. {
  332. $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>";
  333. }
  334. else if($v != '')
  335. {
  336. $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);
  337. $url = explode('&',$url);
  338. $url = $url[0];
  339. $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>";
  340. }
  341. else
  342. {
  343. $img = '';
  344. }
  345. }
  346. }
  347. $registration['img'] = $img;
  348. $this->data['registration'] = $registration;
  349. $this->_Template('registration_edit',$this->data);
  350. }
  351. //删除
  352. public function _del()
  353. {
  354. $post = $this->input->post(NULL, TRUE);
  355. if(isset($post['s']))
  356. {
  357. $id_arr = $this->input->post('s');
  358. $id_arr = explode(',',$id_arr);
  359. if(!$id_arr)
  360. {
  361. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  362. }
  363. //循环删除记录
  364. foreach ($id_arr as $v)
  365. {
  366. $this->registration->remove($v);
  367. }
  368. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  369. }
  370. }
  371. //数据
  372. public function _rows()
  373. {
  374. if(isset($_SESSION['api']))
  375. {
  376. $user = $this->user->get_api($_SESSION['api']);
  377. $fgshop = "";
  378. $warehouse = explode('|',trim($user['warehouse'],'|'));
  379. foreach ($warehouse as $value)
  380. {
  381. $fgshop .= " warehouse = ".$value." or";
  382. }
  383. }
  384. else
  385. {
  386. $vip = 0;
  387. header('Location: /');exit;
  388. }
  389. $post = $this->input->post(NULL, TRUE);
  390. if(isset($post['page']))
  391. {
  392. $page = $this->input->post('page',true);
  393. $perpage = $this->input->post('perpage',true);
  394. $number = $this->input->post('number',true);
  395. $orderinfo = $this->input->post('orderinfo',true);
  396. $state = $this->input->post('state',true);
  397. $objective = $this->input->post('objective',true);
  398. $name = $this->input->post('name',true);
  399. $phone = $this->input->post('phone',true);
  400. $where = "1=1 and (".rtrim($fgshop,'or').")";
  401. //数据排序
  402. $order_str = "id desc";
  403. if(empty($page))
  404. {
  405. $start = 0;
  406. $perpage = 1;
  407. }
  408. else
  409. {
  410. $start = ($page - 1)*$perpage;
  411. }
  412. if($number)
  413. {
  414. $where .= " and number = '$number'";
  415. }
  416. if($orderinfo)
  417. {
  418. $where .= " and orderinfo = '$orderinfo'";
  419. }
  420. if($state)
  421. {
  422. $where .= " and state = '$state'";
  423. }
  424. if($objective)
  425. {
  426. $where .= " and objective = '$objective'";
  427. }
  428. if($name)
  429. {
  430. $where .= " and name like '%$name%'";
  431. }
  432. if($phone)
  433. {
  434. $where .= " and phone like '%$phone%'";
  435. }
  436. //取得信息列表
  437. $info_list = $this->registration->find_all($where,'id,number,state,objective,address,stime,product,name,phone,content,usacontent',$order_str,$start,$perpage);
  438. //格式化数据
  439. foreach ($info_list as $key=>$value)
  440. {
  441. $d = $this->registration->read($value['id']);
  442. if($value['state'] == 1)
  443. {
  444. $info_list[$key]['state'] = '沟通中';
  445. }
  446. else if($value['state'] == 2)
  447. {
  448. $info_list[$key]['state'] = '<font style="color:#F00">待客户上门</font>';
  449. }
  450. else if($value['state'] == 3)
  451. {
  452. $info_list[$key]['state'] = '已自提';
  453. }
  454. else if($value['state'] == 4)
  455. {
  456. $info_list[$key]['state'] = '已退货';
  457. }
  458. else if($value['state'] == 5)
  459. {
  460. $info_list[$key]['state'] = '已换货';
  461. }
  462. if($value['objective'] == 1)
  463. {
  464. $info_list[$key]['objective'] = '仅自提';
  465. }
  466. else if($value['objective'] == 2)
  467. {
  468. $info_list[$key]['objective'] = '仅退货';
  469. }
  470. else if($value['objective'] == 3)
  471. {
  472. $info_list[$key]['objective'] = '退换货';
  473. }
  474. else if($value['objective'] == 4)
  475. {
  476. $info_list[$key]['objective'] = '安装头套';
  477. }
  478. if($value['address'] == 1)
  479. {
  480. $info_list[$key]['address'] = 'BK850';
  481. }
  482. else if($value['address'] == 2)
  483. {
  484. $info_list[$key]['address'] = 'Manhattan819';
  485. }
  486. else if($value['address'] == 3)
  487. {
  488. $info_list[$key]['address'] = 'Flatbush933';
  489. }
  490. $info_list[$key]['number'] = "<p>".$value['number']."</p><p>".$d['orderinfo']."</p>";
  491. if($d['red'] == 1)
  492. {
  493. $info_list[$key]['content'] = "<font style='color:#F00'>".$value['content']."</font>";
  494. }
  495. }
  496. $total = $this->registration->find_count($where);
  497. $pagenum = ceil($total/$perpage);
  498. $over = $total-($start+$perpage);
  499. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  500. echo json_encode($rows);exit;
  501. }
  502. $this->_Template('registration_rows',$this->data);
  503. }
  504. public function _see($arg_array)
  505. {
  506. $post = $this->input->post(NULL, TRUE);
  507. if(isset($post['id']))
  508. {
  509. $id = $this->input->post('id',true);
  510. if($this->registration->save($post,$id))
  511. {
  512. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  513. }
  514. else
  515. {
  516. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  517. }
  518. }
  519. $arg_array = $arg_array[0];
  520. $product = '';
  521. $registration = $this->registration->read($arg_array);
  522. $lk = explode(',',rtrim($registration['url'],','));
  523. for($i=0;$i<count($lk);$i++)
  524. {
  525. $product .= '<a href="'.$lk[$i].'" target="_blank">'.$lk[$i].'</a>,';
  526. }
  527. $registration['url'] = rtrim($product,',');
  528. $this->data['registration'] = $registration;
  529. $this->_Template('registration_see',$this->data);
  530. }
  531. public function _order()
  532. {
  533. $post = $this->input->post(NULL, TRUE);
  534. if(isset($post['number']))
  535. {
  536. $data = array();
  537. $f = $this->typeclass->find_all("classid = '32' and id != 2297");
  538. $number = $this->input->post('number',true);
  539. foreach ($f as $v)
  540. {
  541. $fl = $v['bqsku'];
  542. $d = $this->$fl->get_number($number);
  543. if($d)
  544. {
  545. $data = $d;
  546. continue;
  547. }
  548. }
  549. if($data)
  550. {
  551. if($data['source'] == 1)
  552. {
  553. $shop = $this->shop->read($data['shop']);
  554. $data['url'] = $shop['url'];
  555. }
  556. else
  557. {
  558. $product = '';
  559. $lk = explode(',',$data['link']);
  560. for($i=0;$i<count($lk);$i++)
  561. {
  562. $product .= $lk[$i].',';
  563. }
  564. $data['url'] = $product;
  565. }
  566. echo json_encode(array('msg'=>$data,'success'=>true));exit;
  567. }
  568. else
  569. {
  570. echo json_encode(array('msg'=>'请检查编号是否正确','success'=>false));exit;
  571. }
  572. }
  573. }
  574. }