Registration.php 17 KB

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