Systemretreat.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Systemretreat extends Start_Controller {
  4. public function __construct(){
  5. parent::__construct();
  6. $this->load->library('session');
  7. $this->load->_model('Model_whlabel','whlabel');
  8. $this->load->_model('Model_warehouse','warehouse');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullordersmt','fullordersmt');
  13. $this->load->_model('Model_outbound','outbound');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_kdniao','kdniao');
  19. $this->load->_model('Model_notice','notice');
  20. $this->load->_model('Model_dhl','dhl');
  21. $this->load->_model('Model_usps','usps');
  22. $this->load->_model('Model_fedex','fedex');
  23. $this->load->_model('Model_ups','ups');
  24. $this->load->_model('Model_ali','ali');
  25. $this->load->_model('Model_dpd','dpd');
  26. $this->load->_model('Model_shop','shop');
  27. $this->load->_model('Model_user','user');
  28. $this->load->_model('Model_whlabel','whlabel');
  29. $this->load->_model('Model_specialstock','specialstock');
  30. $this->load->_model('Model_fullorderxw','fullorderxw');
  31. $this->load->helper('url');
  32. }
  33. //定义方法的调用规则 获取URI第二段值
  34. public function _remap($arg,$arg_array)
  35. {
  36. if($arg == 'out')
  37. {
  38. $this->_out();
  39. }
  40. else if($arg == 'excel')
  41. {
  42. $this->_excel();
  43. }
  44. else
  45. {
  46. $this->_index();
  47. }
  48. }
  49. public function _out()
  50. {
  51. $post = $this->input->post(NULL, TRUE);
  52. if(isset($post['order']))
  53. {
  54. $time = time();
  55. $order = $this->input->post('order',true);
  56. if(substr($order,0,3) == '788' && substr($order,-4,4) == '0430')//Fedex联邦
  57. {
  58. $order = substr($order,0,12);
  59. }
  60. $y = $this->fullorder->get_waybill($order);
  61. $fullorder_name = 'fullorder';
  62. if(!$y)
  63. {
  64. $y = $this->fullorder->get_number($order);
  65. if(!$y)
  66. {
  67. $fullorder_name = 'fullordersmt';
  68. $y = $this->fullordersmt->get_waybill($order);
  69. if(!$y)
  70. {
  71. $y = $this->fullordersmt->get_number($order);
  72. if(!$y)
  73. {
  74. if(!$y)
  75. {
  76. $fullorder_name = 'fullordertt';
  77. $y = $this->fullordertt->get_waybill($order);
  78. if(!$y)
  79. {
  80. $y = $this->fullordertt->get_number($order);
  81. if(!$y)
  82. {
  83. $fullorder_name = 'fullorderxw';
  84. $y = $this->fullorderxw->get_waybill($order);
  85. if(!$y)
  86. {
  87. $y = $this->fullorderxw->get_number($order);
  88. if(!$y)
  89. {
  90. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  91. }
  92. }
  93. }
  94. }
  95. }
  96. }
  97. }
  98. }
  99. }
  100. if($y['library'] == 3)
  101. {
  102. //echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['retreattime']).' 已操作','success'=>false));exit;
  103. }
  104. if($y['library'] == 1)
  105. {
  106. echo json_encode(array('msg'=>'此数据未出库','success'=>false));exit;
  107. }
  108. $warehouse = $this->warehouse->read($y['type']);
  109. $this->db->trans_begin();
  110. if($warehouse['zd'] == '1')
  111. {
  112. $wl = $this->whlabel->find_all("zd = '".$y['number']."'");//查找是否有占用库存情况
  113. if($wl)//如果有那么清除所有占用
  114. {
  115. foreach ($wl as $v)
  116. {
  117. $this->whlabel->save(array('state'=>0,'rktype'=>5,'zd'=>'','retreat'=>$time,'time'=>$time),$v['id']);//专属
  118. }
  119. }
  120. }
  121. if(stripos($y['whlabel'],'z|') !== false)
  122. {
  123. $wl = $this->specialstock->find_all("zd = '".$y['number']."'");
  124. if($wl)//如果有那么清除所有占用
  125. {
  126. foreach ($wl as $v)
  127. {
  128. $this->specialstock->save(array('state'=>0,'rktype'=>5,'zd'=>'','retreat'=>$time,'time'=>$time),$v['id']);
  129. }
  130. }
  131. }
  132. $hbcfw = explode('|',trim($y['whlabel'],'|'));
  133. $hbcff = explode(';',trim($y['fpdata'],';'));
  134. $c = 0;
  135. $hbw = array();
  136. $hbf = array();
  137. for($i=0;$i<count($hbcfw);$i++)
  138. {
  139. $w = explode('-',$hbcfw[$i]);
  140. $f = explode('|',$hbcff[$i]);
  141. $f[9] = 0;
  142. $w[2] = 0;
  143. $hbw[] = implode("-",$w);
  144. $hbf[] = implode("|",$f);
  145. }
  146. $this->$fullorder_name->save(array('whlabel'=>'|'.implode("|",$hbw).'|','fpdata'=>implode(";",$hbf).';'),$y['id']);
  147. $user = $this->user->get_api($_SESSION['api']);
  148. $this->$fullorder_name->save(array('library'=>3,'retreattime'=>$time,'retreatdata'=>$y['retreatdata'].'['.$user['userid'].':'.date('Y-m-d H:i:s',time()).':'.$this->input->ip_address().']-'),$y['id']);
  149. if ($this->db->trans_status() === FALSE)
  150. {
  151. $this->db->trans_commit();
  152. echo json_encode(array('msg'=>'退库失败,请重试','success'=>false));exit;
  153. }
  154. else
  155. {
  156. $this->db->trans_commit();
  157. echo json_encode(array('success'=>true));exit;
  158. }
  159. }
  160. }
  161. public function _index()
  162. {
  163. $post = $this->input->post(NULL, TRUE);
  164. if(isset($_SESSION['api']))
  165. {
  166. $user = $this->user->get_api($_SESSION['api']);
  167. $usp = $user;
  168. $fgshop = "";$sid = "";$wid="";$wtype="";
  169. $usersp = explode('|',trim($user['shop'],'|'));
  170. $userwh = explode('|',trim($user['warehouse'],'|'));
  171. foreach ($usersp as $value)
  172. {
  173. $fgshop .= " shop = ".$value." or";
  174. $sid .= " id = ".$value." or";
  175. }
  176. foreach ($userwh as $value)
  177. {
  178. $wid .= " id = ".$value." or";
  179. $wtype .= " type = ".$value." or";
  180. }
  181. }
  182. if(isset($post['page']))
  183. {
  184. $page = $this->input->post('page',true);
  185. $perpage = $this->input->post('perpage',true);
  186. $timetk = $this->input->post('timetk',true);
  187. $timetj = $this->input->post('timetj',true);
  188. $shop = $this->input->post('shop',true);
  189. $source = $this->input->post('source',true);
  190. $orderinfo = $this->input->post('orderinfo',true);
  191. $number = $this->input->post('number',true);
  192. $waybill = $this->input->post('waybill',true);
  193. $express = $this->input->post('express',true);
  194. $type = $this->input->post('type',true);
  195. $lowe = $this->input->post('lowe',true);
  196. $timetk = strtotime($timetk);
  197. $timetj = strtotime($timetj);
  198. $where = (isset($_SESSION['api']))?"library = 3 and (".rtrim($wtype,'or').")":"id= '0'";
  199. if($timetk && $timetj)
  200. {
  201. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  202. }
  203. if($shop)
  204. {
  205. $where .= " and shop = '$shop'";
  206. }
  207. if($orderinfo)
  208. {
  209. $where .= " and orderinfo = '$orderinfo'";
  210. }
  211. if($number)
  212. {
  213. $where .= " and number = '$number'";
  214. }
  215. if($waybill)
  216. {
  217. $where .= " and waybill = '$waybill'";
  218. }
  219. if($express)
  220. {
  221. $where .= " and express = '$express'";
  222. }
  223. if($orderinfo)
  224. {
  225. $where .= " and orderinfo = '$orderinfo'";
  226. }
  227. if($type)
  228. {
  229. $where .= " and type = '$type'";
  230. }
  231. if($lowe)
  232. {
  233. $where .= " and shipremarks like '%$lowe%'";
  234. }
  235. //数据排序
  236. $order_str = "retreattime desc";
  237. if(empty($page))
  238. {
  239. $start = 0;
  240. $perpage = 1;
  241. }
  242. else
  243. {
  244. $start = ($page - 1)*$perpage;
  245. }
  246. //取得信息列表
  247. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks',$order_str,$start,$perpage);
  248. //格式化数据
  249. foreach ($info_list as $key=>$value)
  250. {
  251. $shop = $this->shop->read($value['shop']);
  252. $info_list[$key]['shop'] = $shop['shopname'];
  253. if($value['waybill'] == 0)
  254. {
  255. $info_list[$key]['waybill'] = "";
  256. }
  257. $express = $this->express->read($value['express']);
  258. $info_list[$key]['express'] = $express['servicename'];
  259. $warehouse = $this->warehouse->read($value['type']);
  260. $info_list[$key]['type'] = $warehouse['title'];
  261. $typeclass = $this->typeclass->read($value['state']);
  262. $info_list[$key]['state'] = $typeclass['spare'];
  263. $info_list[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  264. if($value['retreattime'] == '0')
  265. {
  266. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  267. }
  268. else
  269. {
  270. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i',$value['retreattime']).'</em>';
  271. }
  272. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  273. }
  274. $info_listtt = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  275. //格式化数据
  276. foreach ($info_listtt as $key=>$value)
  277. {
  278. $shop = $this->shop->read($value['shop']);
  279. $info_listtt[$key]['shop'] = $shop['shopname'];
  280. if($value['waybill'] == 0)
  281. {
  282. $info_listtt[$key]['waybill'] = "";
  283. }
  284. $express = $this->express->read($value['express']);
  285. $info_listtt[$key]['express'] = $express['servicename'];
  286. $warehouse = $this->warehouse->read($value['type']);
  287. $info_listtt[$key]['type'] = $warehouse['title'];
  288. $typeclass = $this->typeclass->read($value['state']);
  289. $info_listtt[$key]['state'] = $typeclass['spare'];
  290. if($value['print'] == 1)
  291. {
  292. $info_listtt[$key]['print'] = '不可打印';
  293. }
  294. else if($value['print'] == 2)
  295. {
  296. $info_listtt[$key]['print'] = '未打印';
  297. }
  298. else if($value['print'] == 3)
  299. {
  300. $info_listtt[$key]['print'] = '已打印';
  301. }
  302. if($value['retreattime'] == '0')
  303. {
  304. $info_listtt[$key]['retreattime'] = '<em class="t"></em>';
  305. }
  306. else
  307. {
  308. $info_listtt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  309. }
  310. }
  311. $info_listxw = $this->fullorderxw->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  312. //格式化数据
  313. foreach ($info_listxw as $key=>$value)
  314. {
  315. $shop = $this->shop->read($value['shop']);
  316. $info_listxw[$key]['shop'] = $shop['shopname'];
  317. if($value['waybill'] == 0)
  318. {
  319. $info_listxw[$key]['waybill'] = "";
  320. }
  321. $express = $this->express->read($value['express']);
  322. $info_listxw[$key]['express'] = $express['servicename'];
  323. $warehouse = $this->warehouse->read($value['type']);
  324. $info_listxw[$key]['type'] = $warehouse['title'];
  325. $typeclass = $this->typeclass->read($value['state']);
  326. $info_listxw[$key]['state'] = $typeclass['spare'];
  327. if($value['print'] == 1)
  328. {
  329. $info_listxw[$key]['print'] = '不可打印';
  330. }
  331. else if($value['print'] == 2)
  332. {
  333. $info_listxw[$key]['print'] = '未打印';
  334. }
  335. else if($value['print'] == 3)
  336. {
  337. $info_listxw[$key]['print'] = '已打印';
  338. }
  339. if($value['retreattime'] == '0')
  340. {
  341. $info_listxw[$key]['retreattime'] = '<em class="t"></em>';
  342. }
  343. else
  344. {
  345. $info_listxw[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  346. }
  347. }
  348. $info_listsmt = $this->fullordersmt->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime,shipremarks',$order_str,$start,$perpage);
  349. //格式化数据
  350. foreach ($info_listsmt as $key=>$value)
  351. {
  352. $shop = $this->shop->read($value['shop']);
  353. $info_listsmt[$key]['shop'] = $shop['shopname'];
  354. if($value['waybill'] == 0)
  355. {
  356. $info_listsmt[$key]['waybill'] = "";
  357. }
  358. $express = $this->express->read($value['express']);
  359. $info_listsmt[$key]['express'] = $express['servicename'];
  360. $warehouse = $this->warehouse->read($value['type']);
  361. $info_listsmt[$key]['type'] = $warehouse['title'];
  362. $typeclass = $this->typeclass->read($value['state']);
  363. $info_listsmt[$key]['state'] = $typeclass['spare'];
  364. if($value['print'] == 1)
  365. {
  366. $info_listsmt[$key]['print'] = '不可打印';
  367. }
  368. else if($value['print'] == 2)
  369. {
  370. $info_listsmt[$key]['print'] = '未打印';
  371. }
  372. else if($value['print'] == 3)
  373. {
  374. $info_listsmt[$key]['print'] = '已打印';
  375. }
  376. if($value['retreattime'] == '0')
  377. {
  378. $info_listsmt[$key]['retreattime'] = '<em class="t"></em>';
  379. }
  380. else
  381. {
  382. $info_listsmt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  383. }
  384. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  385. }
  386. $total = $this->fullorder->find_count($where);
  387. $total += $this->fullordertt->find_count($where);
  388. $total += $this->fullorderxw->find_count($where);
  389. $total += $this->fullordersmt->find_count($where);
  390. $pagenum = ceil($total/$perpage);
  391. $over = $total-($start+$perpage);
  392. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt)));//$info_list_smt
  393. echo json_encode($rows);exit;
  394. }
  395. if(isset($_SESSION['api']))
  396. {
  397. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  398. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'));
  399. $this->data['wlshop'] = $wlshop;
  400. $this->data['warehouse'] = $warehouse;
  401. }
  402. $this->_Template('systemretreat',$this->data);
  403. }
  404. public function _excel()
  405. {
  406. $post = $this->input->get(NULL, TRUE);
  407. if(isset($_GET['excel']))
  408. {
  409. if(isset($_SESSION['api']))
  410. {
  411. $user = $this->user->get_api($_SESSION['api']);
  412. $usp = $user;
  413. $fgshop = "";$sid = "";$wid="";$wtype="";
  414. $usersp = explode('|',trim($user['shop'],'|'));
  415. $userwh = explode('|',trim($user['warehouse'],'|'));
  416. foreach ($usersp as $value)
  417. {
  418. $fgshop .= " shop = ".$value." or";
  419. $sid .= " id = ".$value." or";
  420. }
  421. foreach ($userwh as $value)
  422. {
  423. $wid .= " id = ".$value." or";
  424. $wtype .= " type = ".$value." or";
  425. }
  426. }
  427. if(isset($post['page']))
  428. {
  429. $timetk = $this->input->get('timetk',true);
  430. $timetj = $this->input->get('timetj',true);
  431. $shop = $this->input->get('shop',true);
  432. $source = $this->input->get('source',true);
  433. $orderinfo = $this->input->get('orderinfo',true);
  434. $number = $this->input->get('number',true);
  435. $waybill = $this->input->get('waybill',true);
  436. $express = $this->input->get('express',true);
  437. $type = $this->input->get('type',true);
  438. $lowe = $this->input->get('lowe',true);
  439. $sdd = $this->input->get('sid',true);
  440. $timetk = strtotime($timetk);
  441. $timetj = strtotime($timetj);
  442. $where = (isset($_SESSION['api']))?"library = 3 and (".rtrim($wtype,'or').")":"id= '0'";
  443. if($timetk && $timetj)
  444. {
  445. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  446. }
  447. if($shop)
  448. {
  449. $where .= " and shop = '$shop'";
  450. }
  451. if($orderinfo)
  452. {
  453. $where .= " and orderinfo = '$orderinfo'";
  454. }
  455. if($number)
  456. {
  457. $where .= " and number = '$number'";
  458. }
  459. if($waybill)
  460. {
  461. $where .= " and waybill = '$waybill'";
  462. }
  463. if($express)
  464. {
  465. $where .= " and express = '$express'";
  466. }
  467. if($orderinfo)
  468. {
  469. $where .= " and orderinfo = '$orderinfo'";
  470. }
  471. if($type)
  472. {
  473. $where .= " and type = '$type'";
  474. }
  475. if($lowe)
  476. {
  477. $where .= " and shipremarks like '%$lowe%'";
  478. }
  479. $sidwhere = '';
  480. if($sdd)
  481. {
  482. $sd = "";
  483. $s = explode(',',trim($sdd,','));
  484. foreach ($s as $value)
  485. {
  486. $sd .= " id = ".$value." or";
  487. }
  488. $sidwhere = " and (".rtrim($sd,'or').")";
  489. }
  490. //数据排序
  491. $order_str = "retreattime desc";
  492. if(empty($page))
  493. {
  494. $start = 0;
  495. $perpage = 1;
  496. }
  497. else
  498. {
  499. $start = ($page - 1)*$perpage;
  500. }
  501. //取得信息列表
  502. $info_list = $this->fullorder->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  503. //格式化数据
  504. foreach ($info_list as $key=>$value)
  505. {
  506. $shop = $this->shop->read($value['shop']);
  507. $info_list[$key]['shop'] = $shop['shopname'];
  508. if($value['waybill'] == 0)
  509. {
  510. $info_list[$key]['waybill'] = "";
  511. }
  512. $express = $this->express->read($value['express']);
  513. $info_list[$key]['express'] = $express['servicename'];
  514. $warehouse = $this->warehouse->read($value['type']);
  515. $info_list[$key]['type'] = $warehouse['title'];
  516. $typeclass = $this->typeclass->read($value['state']);
  517. $info_list[$key]['state'] = $typeclass['spare'];
  518. $info_list[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  519. if($value['retreattime'] == '0')
  520. {
  521. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  522. }
  523. else
  524. {
  525. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i',$value['retreattime']).'</em>';
  526. }
  527. $info_list[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  528. }
  529. $info_listtt = $this->fullordertt->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  530. //格式化数据
  531. foreach ($info_listtt as $key=>$value)
  532. {
  533. $shop = $this->shop->read($value['shop']);
  534. $info_listtt[$key]['shop'] = $shop['shopname'];
  535. if($value['waybill'] == 0)
  536. {
  537. $info_listtt[$key]['waybill'] = "";
  538. }
  539. $express = $this->express->read($value['express']);
  540. $info_listtt[$key]['express'] = $express['servicename'];
  541. $warehouse = $this->warehouse->read($value['type']);
  542. $info_listtt[$key]['type'] = $warehouse['title'];
  543. $typeclass = $this->typeclass->read($value['state']);
  544. $info_listtt[$key]['state'] = $typeclass['spare'];
  545. $info_listtt[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  546. if($value['retreattime'] == '0')
  547. {
  548. $info_listtt[$key]['retreattime'] = '<em class="t"></em>';
  549. }
  550. else
  551. {
  552. $info_listtt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  553. }
  554. }
  555. $info_listxw = $this->fullorderxw->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  556. //格式化数据
  557. foreach ($info_listxw as $key=>$value)
  558. {
  559. $shop = $this->shop->read($value['shop']);
  560. $info_listxw[$key]['shop'] = $shop['shopname'];
  561. if($value['waybill'] == 0)
  562. {
  563. $info_listxw[$key]['waybill'] = "";
  564. }
  565. $express = $this->express->read($value['express']);
  566. $info_listxw[$key]['express'] = $express['servicename'];
  567. $warehouse = $this->warehouse->read($value['type']);
  568. $info_listxw[$key]['type'] = $warehouse['title'];
  569. $typeclass = $this->typeclass->read($value['state']);
  570. $info_listxw[$key]['state'] = $typeclass['spare'];
  571. $info_listxw[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  572. if($value['retreattime'] == '0')
  573. {
  574. $info_listxw[$key]['retreattime'] = '<em class="t"></em>';
  575. }
  576. else
  577. {
  578. $info_listxw[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  579. }
  580. }
  581. $info_listsmt = $this->fullordersmt->find_all($where.$sidwhere,'shop,type,orderinfo,number,waybill,express,state,librarytime,retreattime,shipremarks');
  582. //格式化数据
  583. foreach ($info_listsmt as $key=>$value)
  584. {
  585. $shop = $this->shop->read($value['shop']);
  586. $info_listsmt[$key]['shop'] = $shop['shopname'];
  587. if($value['waybill'] == 0)
  588. {
  589. $info_listsmt[$key]['waybill'] = "";
  590. }
  591. $express = $this->express->read($value['express']);
  592. $info_listsmt[$key]['express'] = $express['servicename'];
  593. $warehouse = $this->warehouse->read($value['type']);
  594. $info_listsmt[$key]['type'] = $warehouse['title'];
  595. $typeclass = $this->typeclass->read($value['state']);
  596. $info_listsmt[$key]['state'] = $typeclass['spare'];
  597. $info_listsmt[$key]['librarytime'] = date('Y-m-d H:i',$value['librarytime']);
  598. if($value['retreattime'] == '0')
  599. {
  600. $info_listsmt[$key]['retreattime'] = '<em class="t"></em>';
  601. }
  602. else
  603. {
  604. $info_listsmt[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  605. }
  606. $info_listsmt[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  607. }
  608. $rows = array_merge($info_list,$info_listtt,$info_listxw,$info_listsmt);//$info_list_smt
  609. $title = '订单退库-'.date('Y-m-d H-i-s',time());
  610. $titlename = "<table border=1>
  611. <tr align='center'>
  612. <td>店铺名称</td>
  613. <td>发货仓库</td>
  614. <td>订单号</td>
  615. <td>编号</td>
  616. <td>运单号</td>
  617. <td>快递公司</td>
  618. <td>订单状态</td>
  619. <td>出库时间</td>
  620. <td>退库时间</td>
  621. <td>仓库品名</td>
  622. </tr>
  623. </table>";
  624. $tail = "\n";
  625. $filename = $title.".xls";
  626. $this->excel->get_fz2(array_merge($info_list,$info_listsmt,$info_listtt,$info_listxw),$titlename,$filename,$tail);
  627. }
  628. }
  629. }
  630. }