Registration.php 17 KB

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