Apt2.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. header("Access-Control-Allow-Origin: *");
  3. class Apt 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_productprice','productprice');
  10. $this->load->_model('Model_excel','excel');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_express','express');
  14. $this->load->_model('Model_shop','shop');
  15. $this->load->_model('Model_typeclass','typeclass');
  16. $this->load->_model('Model_country','country');
  17. $this->load->_model('Model_warehouse','warehouse');
  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_shop','shop');
  22. $this->load->_model('Model_user','user');
  23. }
  24. //定义方法的调用规则 获取URI第二段值
  25. public function _remap($arg,$arg_array)
  26. {
  27. if($arg == 'fout')//出库页
  28. {
  29. $this->_fout();
  30. }
  31. else if($arg == 'printing')//打印操作
  32. {
  33. $this->_printing();
  34. }
  35. else if($arg == 'print')//打印操作
  36. {
  37. $this->_print();
  38. }
  39. else if($arg == 'fhd')//发货单
  40. {
  41. $this->_fhd($arg_array);
  42. }
  43. else if($arg == 'fhddata')//发货单
  44. {
  45. $this->_fhddata();
  46. }
  47. else if($arg == 'fpdata')//发货单
  48. {
  49. $this->_fpdata();
  50. }
  51. else if($arg == 'shop')//发货单
  52. {
  53. $this->_shop();
  54. }
  55. else if($arg == 'express')//发货单
  56. {
  57. $this->_express();
  58. }
  59. else if($arg == 'retreat')//发货单
  60. {
  61. $this->_retreat();
  62. }
  63. else if($arg == 'excel')//发货单
  64. {
  65. $this->_excel();
  66. }
  67. else
  68. {
  69. $this->_index();
  70. }
  71. }
  72. //管理
  73. public function _index()
  74. {
  75. $post = $this->input->post(NULL, TRUE);
  76. if(isset($post['userid']))
  77. {
  78. $userid = $this->input->post('userid',true);
  79. $userpass = $this->input->post('userpass',true);
  80. $password = sha1($userpass);
  81. $user = $this->user->get_uid($userid);
  82. if($user)
  83. {
  84. if($user['type'] == 2)
  85. {
  86. echo json_encode(array('msg'=>"账户已停用",'success'=>false));exit;
  87. }
  88. if($user['userpass'] == $password)
  89. {
  90. $this->user->get_land($user); //更新登录数据
  91. echo json_encode(array('url'=>'?id='.$user['api'],'success'=>true));exit;
  92. }
  93. else
  94. {
  95. echo json_encode(array('msg'=>"用户或密码不正确",'success'=>false));exit;
  96. }
  97. }
  98. else
  99. {
  100. echo json_encode(array('msg'=>"用户不正确",'success'=>false));exit;
  101. }
  102. }
  103. }
  104. //出库
  105. public function _fout()
  106. {
  107. $post = $this->input->post(NULL, TRUE);
  108. if(isset($post['order']))
  109. {
  110. $time = time();
  111. $order = $this->input->post('order',true);
  112. $y = $this->fullorder->get_waybill($order);
  113. if(!$y)
  114. {
  115. $y = $this->fullorder->get_number($order);
  116. if(!$y)
  117. {
  118. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  119. }
  120. }
  121. if($y['libraryconfirm'] == 1)
  122. {
  123. echo json_encode(array('msg'=>$y['librarynot'],'success'=>false));exit;
  124. }
  125. if($y['library'] == 2)
  126. {
  127. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['librarytime']).' 已操作','success'=>false));exit;
  128. }
  129. if($this->fullorder->save(array('library'=>2,'librarytime'=>$time),$y['id']))
  130. {
  131. echo json_encode(array('success'=>true));exit;
  132. }
  133. else
  134. {
  135. echo json_encode(array('msg'=>'出库失败,请重试','success'=>false));exit;
  136. }
  137. }
  138. if(isset($post['page']))
  139. {
  140. $page = $this->input->post('page',true);
  141. $perpage = $this->input->post('perpage',true);
  142. $timetk = $this->input->post('timetk',true);
  143. $timetj = $this->input->post('timetj',true);
  144. $shop = $this->input->post('shop',true);
  145. $source = $this->input->post('source',true);
  146. $orderinfo = $this->input->post('orderinfo',true);
  147. $number = $this->input->post('number',true);
  148. $library = $this->input->post('library',true);
  149. $waybill = $this->input->post('waybill',true);
  150. $express = $this->input->post('express',true);
  151. $timetk = strtotime($timetk);
  152. $timetj = strtotime($timetj);
  153. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  154. if($timetk && $timetj && $library == 2)
  155. {
  156. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  157. }
  158. if($shop)
  159. {
  160. $where .= " and shop = '$shop'";
  161. }
  162. if($number)
  163. {
  164. $where .= " and number = '$number'";
  165. }
  166. if($library)
  167. {
  168. $where .= " and library = '$library'";
  169. }
  170. if($waybill)
  171. {
  172. $where .= " and waybill = '$waybill'";
  173. }
  174. if($express)
  175. {
  176. $where .= " and express = '$express'";
  177. }
  178. if($orderinfo)
  179. {
  180. $where .= " and orderinfo = '$orderinfo'";
  181. }
  182. //数据排序
  183. $order_str = "librarytime desc";
  184. if(empty($page))
  185. {
  186. $start = 0;
  187. $perpage = 1;
  188. }
  189. else
  190. {
  191. $start = ($page - 1)*$perpage;
  192. }
  193. //取得信息列表
  194. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,library,librarytime',$order_str,$start,$perpage);
  195. //格式化数据
  196. foreach ($info_list as $key=>$value)
  197. {
  198. $shop = $this->shop->read($value['shop']);
  199. $info_list[$key]['shop'] = $shop['shopname'];
  200. if($value['waybill'] == 0)
  201. {
  202. $info_list[$key]['waybill'] = "";
  203. }
  204. $express = $this->express->read($value['express']);
  205. $info_list[$key]['express'] = $express['servicename'];
  206. $warehouse = $this->warehouse->read($value['type']);
  207. $info_list[$key]['type'] = $warehouse['title'];
  208. if($value['print'] == 1)
  209. {
  210. $info_list[$key]['print'] = '不可打印';
  211. }
  212. else if($value['print'] == 2)
  213. {
  214. $info_list[$key]['print'] = '未打印';
  215. }
  216. else if($value['print'] == 3)
  217. {
  218. $info_list[$key]['print'] = '已打印';
  219. }
  220. if($value['library'] == 1)
  221. {
  222. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  223. }
  224. else if($value['library'] == 2)
  225. {
  226. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  227. }
  228. else if($value['library'] == 3)
  229. {
  230. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  231. }
  232. if($value['librarytime'] == '0')
  233. {
  234. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  235. }
  236. else
  237. {
  238. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  239. }
  240. }
  241. $total = $this->fullorder->find_count($where);
  242. $pagenum = ceil($total/$perpage);
  243. $over = $total-($start+$perpage);
  244. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  245. echo json_encode($rows);exit;
  246. }
  247. $this->data['express'] = $this->express->find_all();
  248. $this->_Template('whlabel_fout',$this->data);
  249. }
  250. //退库
  251. public function _retreat()
  252. {
  253. $post = $this->input->post(NULL, TRUE);
  254. if(isset($post['order']))
  255. {
  256. $time = time();
  257. $order = $this->input->post('order',true);
  258. $y = $this->fullorder->get_waybill($order);
  259. if(!$y)
  260. {
  261. $y = $this->fullorder->get_number($order);
  262. if(!$y)
  263. {
  264. echo json_encode(array('msg'=>'无此数据','success'=>false));exit;
  265. }
  266. }
  267. if($y['library'] == 3)
  268. {
  269. echo json_encode(array('msg'=>'此数据 '.date('Y-m-d H:i:s',$y['retreattime']).' 已操作','success'=>false));exit;
  270. }
  271. if($y['library'] == 1)
  272. {
  273. echo json_encode(array('msg'=>'此数据未出库','success'=>false));exit;
  274. }
  275. if($this->fullorder->save(array('library'=>3,'retreattime'=>$time),$y['id']))
  276. {
  277. echo json_encode(array('success'=>true));exit;
  278. }
  279. else
  280. {
  281. echo json_encode(array('msg'=>'退库失败,请重试','success'=>false));exit;
  282. }
  283. }
  284. if(isset($post['page']))
  285. {
  286. $page = $this->input->post('page',true);
  287. $perpage = $this->input->post('perpage',true);
  288. $timetk = $this->input->post('timetk',true);
  289. $timetj = $this->input->post('timetj',true);
  290. $shop = $this->input->post('shop',true);
  291. $source = $this->input->post('source',true);
  292. $orderinfo = $this->input->post('orderinfo',true);
  293. $number = $this->input->post('number',true);
  294. $waybill = $this->input->post('waybill',true);
  295. $express = $this->input->post('express',true);
  296. $timetk = strtotime($timetk);
  297. $timetj = strtotime($timetj);
  298. $where = "library=3 and gtime > 20190127";
  299. if($timetk && $timetj)
  300. {
  301. $where .= " and retreattime > '$timetk' and retreattime < '$timetj'";
  302. }
  303. if($shop)
  304. {
  305. $where .= " and shop = '$shop'";
  306. }
  307. if($orderinfo)
  308. {
  309. $where .= " and orderinfo = '$orderinfo'";
  310. }
  311. if($number)
  312. {
  313. $where .= " and number = '$number'";
  314. }
  315. if($waybill)
  316. {
  317. $where .= " and waybill = '$waybill'";
  318. }
  319. if($express)
  320. {
  321. $where .= " and express = '$express'";
  322. }
  323. if($orderinfo)
  324. {
  325. $where .= " and orderinfo = '$orderinfo'";
  326. }
  327. //数据排序
  328. $order_str = "retreattime desc";
  329. if(empty($page))
  330. {
  331. $start = 0;
  332. $perpage = 1;
  333. }
  334. else
  335. {
  336. $start = ($page - 1)*$perpage;
  337. }
  338. //取得信息列表
  339. $info_list = $this->fullorder->find_all($where,'id,shop,type,orderinfo,number,waybill,express,print,state,retreattime',$order_str,$start,$perpage);
  340. //格式化数据
  341. foreach ($info_list as $key=>$value)
  342. {
  343. $shop = $this->shop->read($value['shop']);
  344. $info_list[$key]['shop'] = $shop['shopname'];
  345. if($value['waybill'] == 0)
  346. {
  347. $info_list[$key]['waybill'] = "";
  348. }
  349. $express = $this->express->read($value['express']);
  350. $info_list[$key]['express'] = $express['servicename'];
  351. $warehouse = $this->warehouse->read($value['type']);
  352. $info_list[$key]['type'] = $warehouse['title'];
  353. $typeclass = $this->typeclass->read($value['state']);
  354. $info_list[$key]['state'] = $typeclass['spare'];
  355. if($value['print'] == 1)
  356. {
  357. $info_list[$key]['print'] = '不可打印';
  358. }
  359. else if($value['print'] == 2)
  360. {
  361. $info_list[$key]['print'] = '未打印';
  362. }
  363. else if($value['print'] == 3)
  364. {
  365. $info_list[$key]['print'] = '已打印';
  366. }
  367. if($value['retreattime'] == '0')
  368. {
  369. $info_list[$key]['retreattime'] = '<em class="t"></em>';
  370. }
  371. else
  372. {
  373. $info_list[$key]['retreattime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['retreattime']).'</em>';
  374. }
  375. }
  376. $total = $this->fullorder->find_count($where);
  377. $pagenum = ceil($total/$perpage);
  378. $over = $total-($start+$perpage);
  379. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  380. echo json_encode($rows);exit;
  381. }
  382. $this->data['express'] = $this->express->find_all();
  383. $this->_Template('whlabel_fout',$this->data);
  384. }
  385. //打印页面
  386. public function _print()
  387. {
  388. $post = $this->input->post(NULL, TRUE);
  389. if(isset($post['page']))
  390. {
  391. $page = $this->input->post('page',true);
  392. $perpage = $this->input->post('perpage',true);
  393. $timetk = $this->input->post('timetk',true);
  394. $timetj = $this->input->post('timetj',true);
  395. $shop = $this->input->post('shop',true);
  396. $print = $this->input->post('print',true);
  397. $express = $this->input->post('express',true);
  398. $waybill = $this->input->post('waybill',true);
  399. $printtype = $this->input->post('printtype',true);
  400. $orderinfo = $this->input->post('orderinfo',true);
  401. $number = $this->input->post('number',true);
  402. $timetk = strtotime($timetk);
  403. $timetj = strtotime($timetj);
  404. $where = "type = 1 and express != 0 and printtype > 0 and printtype < 3 and print != 1 and review > 4";
  405. if($timetk && $timetj && $print == 3)
  406. {
  407. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  408. }
  409. if($shop)
  410. {
  411. $where .= " and shop = '$shop'";
  412. }
  413. if($print)
  414. {
  415. if($print == 2)
  416. {
  417. $where .= " and state = 207 and print = '$print'";
  418. }
  419. else
  420. {
  421. $where .= " and print = '$print'";
  422. }
  423. }
  424. if($express)
  425. {
  426. $where .= " and express = '$express'";
  427. }
  428. if($printtype)
  429. {
  430. $where .= " and printtype = '$printtype'";
  431. }
  432. if($orderinfo)
  433. {
  434. $where .= " and orderinfo = '$orderinfo'";
  435. }
  436. if($number)
  437. {
  438. $where .= " and number = '$number'";
  439. }
  440. if($waybill)
  441. {
  442. $where .= " and waybill = '$waybill'";
  443. }
  444. //数据排序
  445. $order_str = "id desc";
  446. if(empty($page))
  447. {
  448. $start = 0;
  449. $perpage = 1;
  450. }
  451. else
  452. {
  453. $start = ($page - 1)*$perpage;
  454. }
  455. //取得信息列表
  456. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,express,waybill,print,printtype,printnumber,printtime',$order_str,$start,$perpage);
  457. //格式化数据
  458. foreach ($info_list as $key=>$value)
  459. {
  460. $shop = $this->shop->read($value['shop']);
  461. $info_list[$key]['shop'] = $shop['shopname'];
  462. $express = $this->express->read($value['express']);
  463. if($express)
  464. {
  465. $info_list[$key]['express'] = $express['servicename'];
  466. }
  467. else
  468. {
  469. $info_list[$key]['express'] = '未选择';
  470. }
  471. if($value['printtime'] != 0)
  472. {
  473. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  474. }
  475. else
  476. {
  477. $info_list[$key]['printtime'] = '无';
  478. }
  479. if($value['print'] == 1)
  480. {
  481. $info_list[$key]['print'] = "禁止打印";
  482. }
  483. else if($value['print'] == 2)
  484. {
  485. $info_list[$key]['print'] = "未打印";
  486. }
  487. else if($value['print'] == 3)
  488. {
  489. $info_list[$key]['print'] = "已打印";
  490. }
  491. if($value['printtype'] == 1)
  492. {
  493. $info_list[$key]['printtype'] = "运单";
  494. }
  495. else if($value['printtype'] == 2)
  496. {
  497. $info_list[$key]['printtype'] = "发货单";
  498. }
  499. else if($value['printtype'] == 0)
  500. {
  501. $info_list[$key]['printtype'] = "未选择";
  502. }
  503. }
  504. $total = $this->fullorder->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('whlabel_print',$this->data);
  511. }
  512. //打印
  513. public function _printing()
  514. {
  515. $post = $this->input->post(NULL, TRUE);
  516. $dhlover = 1;
  517. if(isset($post['s']))
  518. {
  519. $v = $this->input->post('s');
  520. $va = explode(',',rtrim($v,','));
  521. $n = $this->input->post('n');
  522. $fullorder = $this->fullorder->read($va[$n]);
  523. $exp = $this->express->read($fullorder['express']);//获取快递信息
  524. if($fullorder['printtype'] == 1)
  525. {
  526. //获取所用相关信息
  527. $warehouse = $this->warehouse->read($fullorder['type']);
  528. $al = $this->country->read($warehouse['country']);
  529. foreach ($warehouse as $kk=>$vv)
  530. {
  531. $warehouse['al'] = $al['lb'];
  532. }
  533. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  534. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  535. $country = $this->country->get_al($fullorder['baddress'][1]);
  536. $fullorder['baddress'][1] = $country['ename'];
  537. $fcountry = $this->country->read($warehouse['country']);
  538. $warehouse['country'] = $fcountry['ename'];
  539. $fullorder['warehouse'] = $warehouse;
  540. $fullorder['al'] = $country['lb'];//收货加改联邦名 此项过完春节口可以去掉,之前订单同步没添加此项
  541. $fullorder['country'] = $country['ename'];
  542. //获取完毕
  543. if($exp['servicecode'] == "DHLGF")//如果打印过那么重新获取运单
  544. {
  545. $barcode = $this->dhl->get_data($fullorder);//获取DHL快递信息
  546. if(isset($barcode['AirwayBillNumber']))
  547. {
  548. $Hwaybill = $barcode['AirwayBillNumber'];
  549. $Hfp = $this->_pdf($barcode['LabelImage']['MultiLabels']['MultiLabel']['DocImageVal'],'f'.$Hwaybill);
  550. $Hyd = $this->_pdf($barcode['LabelImage']['OutputImage'],'y'.$Hwaybill);
  551. }
  552. else if(isset($barcode['Response']['Status']['Condition']['ConditionData']))
  553. {
  554. $dhlover = $barcode['Response']['Status']['Condition']['ConditionData'];
  555. }
  556. else if(isset($barcode['Response']['Status']['Condition'][0]['ConditionData']))
  557. {
  558. $dhlover = $barcode['Response']['Status']['Condition'][0]['ConditionData'];
  559. }
  560. else
  561. {
  562. $dhlover = "错误!";
  563. }
  564. }
  565. if(isset($Hfp) && isset($Hyd) && isset($Hwaybill))
  566. {
  567. if($this->fullorder->save(array('waybill'=>$Hwaybill,'fp'=>$Hfp,'yd'=>$Hyd,'libraryconfirm'=>2,'librarynot'=>'','printtime'=>time(),'printnumber'=>$fullorder['printnumber']+1,'print'=>3),$va[$n]))
  568. {
  569. $rows = array('type'=>1,'t'=>11000,'n'=>$n-1,'data'=>$v,'rows'=>array('1'=>$Hfp,'0'=>$Hyd,'2'=>$va[$n]));
  570. }
  571. }
  572. }
  573. else if($fullorder['printtype'] == 2)
  574. {
  575. if($this->fullorder->save(array('libraryconfirm'=>2,'librarynot'=>'','printtime'=>time(),'printnumber'=>$fullorder['printnumber']+1,'print'=>3),$va[$n]))
  576. {
  577. $country = $this->country->read($fullorder['country']);
  578. $rows = array('type'=>2,'fhd'=>$va[$n],'t'=>3000,'n'=>$n-1,'data'=>$v);
  579. }
  580. }
  581. if(isset($rows))
  582. {
  583. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  584. }
  585. else
  586. {
  587. if($dhlover != 1)
  588. {
  589. echo json_encode(array('msg'=>"订单号:".$fullorder['orderinfo']." - ".$dhlover,'success'=>false));exit;
  590. }
  591. else
  592. {
  593. echo json_encode(array('msg'=>"订单号:".$fullorder['orderinfo']."打印类型错误!请跳过!",'success'=>false));exit;
  594. }
  595. }
  596. }
  597. }
  598. public function _excel()
  599. {
  600. if(isset($_GET['fexcel']))
  601. {
  602. $dowid = $this->input->get('a');
  603. $wid = "";
  604. if($dowid != "")
  605. {
  606. $id_arr = explode(',',rtrim($dowid,','));
  607. foreach ($id_arr as $v)
  608. {
  609. $wid .= " id = 0 or";
  610. $wid .= " id = '$v' or";
  611. }
  612. $wid = " and".rtrim($wid,'or');
  613. }
  614. $t = $this->input->get('t',true);
  615. $timetk = $this->input->get('timetk',true);
  616. $timetj = $this->input->get('timetj',true);
  617. $shop = $this->input->get('shop',true);
  618. $source = $this->input->get('source',true);
  619. $orderinfo = $this->input->get('orderinfo',true);
  620. $number = $this->input->get('number',true);
  621. $library = $this->input->get('library',true);
  622. $waybill = $this->input->get('waybill',true);
  623. $express = $this->input->get('express',true);
  624. $timetk = strtotime($timetk);
  625. $timetj = strtotime($timetj);
  626. $where = "library!=3 and libraryconfirm=2 and mergeid = 0 and print = 3";
  627. if($timetk && $timetj && $library == 2)
  628. {
  629. $where .= " and librarytime > '$timetk' and librarytime < '$timetj'";
  630. }
  631. if($shop)
  632. {
  633. $where .= " and shop = '$shop'";
  634. }
  635. if($number)
  636. {
  637. $where .= " and number = '$number'";
  638. }
  639. if($library)
  640. {
  641. $where .= " and library = '$library'";
  642. }
  643. if($waybill)
  644. {
  645. $where .= " and waybill = '$waybill'";
  646. }
  647. if($express)
  648. {
  649. $where .= " and express = '$express'";
  650. }
  651. if($orderinfo)
  652. {
  653. $where .= " and orderinfo = '$orderinfo'";
  654. }
  655. //数据排序
  656. $order_str = "librarytime desc";
  657. if(empty($page))
  658. {
  659. $start = 0;
  660. $perpage = 1;
  661. }
  662. else
  663. {
  664. $start = ($page - 1)*$perpage;
  665. }
  666. //取得信息列表
  667. $info_list = $this->fullorder->find_all($where.$wid,'shop,type,orderinfo,number,waybill,express,print,library,librarytime',$order_str);
  668. //格式化数据
  669. foreach ($info_list as $key=>$value)
  670. {
  671. $shop = $this->shop->read($value['shop']);
  672. $info_list[$key]['shop'] = $shop['shopname'];
  673. if($value['waybill'] == 0)
  674. {
  675. $info_list[$key]['waybill'] = "";
  676. }
  677. $express = $this->express->read($value['express']);
  678. $info_list[$key]['express'] = $express['servicename'];
  679. $warehouse = $this->warehouse->read($value['type']);
  680. $info_list[$key]['type'] = $warehouse['title'];
  681. if($value['print'] == 1)
  682. {
  683. $info_list[$key]['print'] = '不可打印';
  684. }
  685. else if($value['print'] == 2)
  686. {
  687. $info_list[$key]['print'] = '未打印';
  688. }
  689. else if($value['print'] == 3)
  690. {
  691. $info_list[$key]['print'] = '已打印';
  692. }
  693. if($value['library'] == 1)
  694. {
  695. $info_list[$key]['library'] = '<em class="c">未出库</em>';
  696. }
  697. else if($value['library'] == 2)
  698. {
  699. $info_list[$key]['library'] = '<em class="c">已出库</em>';
  700. }
  701. else if($value['library'] == 3)
  702. {
  703. $info_list[$key]['library'] = '<em class="c">已退库</em>';
  704. }
  705. if($value['librarytime'] == '0')
  706. {
  707. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  708. }
  709. else
  710. {
  711. $info_list[$key]['librarytime'] = '<em class="t">'.date('Y-m-d H:i:s',$value['librarytime']).'</em>';
  712. }
  713. }
  714. $title = '订单出库-'.date('Ymd',time());
  715. $titlename = "<table border=1>".$t."</table>";
  716. $tail = "\n";
  717. $filename = $title.".xls";
  718. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  719. }
  720. }
  721. public function _pdf($pdf,$title)
  722. {
  723. $time = date('Ymd',time());
  724. $pdf_path = './data/pdf/'.$time.'/';
  725. $file_base64 = $pdf;
  726. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  727. $file_base64 = base64_decode($file_base64);
  728. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  729. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  730. return 'data/pdf/'.$time.'/'.$title.'.pdf';
  731. }
  732. public function _fhd($arg_array)
  733. {
  734. $id = $arg_array[0];
  735. $data = $this->fullorder->read($id);
  736. $country = $this->country->read($data['country']);
  737. $express = $this->express->read($data['express']);
  738. $data['country'] = $country['ename'];
  739. $data['express'] = $express['servicename'];
  740. $this->data['data'] = $data;
  741. $this->_Template('apt_fhd',$this->data);
  742. }
  743. public function _fhddata()
  744. {
  745. $post = $this->input->post(NULL, TRUE);
  746. if(isset($post['g']))
  747. {
  748. $id = $this->input->post('g',true);
  749. $data = $this->fullorder->read($id);
  750. $country = $this->country->read($data['country']);
  751. $express = $this->express->read($data['express']);
  752. $data['country'] = $country['ename'];
  753. $data['express'] = $express['servicename'];
  754. echo json_encode(array('express'=>$data['express'],'orderinfo'=>$data['orderinfo'],'country'=>$data['country'],'number'=>$data['number'],'shipremarks'=>$data['shipremarks'],'ts'=>$data['ts'],'printnumber'=>$data['printnumber'],'barcode'=>'<img id="imgId" src="http://'.$_SERVER['HTTP_HOST'].$data['barcode'].'" style="width:75%;margin: 10px 0 0 70px;" />','success'=>true));exit;
  755. }
  756. }
  757. public function _fpdata()
  758. {
  759. $post = $this->input->post(NULL, TRUE);
  760. if(isset($post['g']))
  761. {
  762. $id = $this->input->post('g',true);
  763. $fullorder = $this->fullorder->read($id);
  764. $warehouse = $this->warehouse->read($fullorder['type']);
  765. $al = $this->country->read($warehouse['country']);
  766. foreach ($warehouse as $kk=>$vv)
  767. {
  768. $warehouse['al'] = $al['lb'];
  769. }
  770. $fullorder['baddress'] = explode(',',$fullorder['baddress']);
  771. $fullorder['baddress'] = array_reverse($fullorder['baddress']);
  772. $country = $this->country->get_al($fullorder['baddress'][1]);
  773. $fullorder['baddress'][1] = $country['ename'];
  774. $fcountry = $this->country->read($warehouse['country']);
  775. $warehouse['country'] = $fcountry['ename'];
  776. $fullorder['warehouse'] = $warehouse;
  777. $fullorder['al'] = $country['lb'];
  778. $fullorder['country'] = $country['ename'];
  779. $fullorder['time'] = date('Y-m-d',time());
  780. $fullorder['sbbm']= ($fullorder['sbpm'] == 'Hair Sample') ? 67042000 : 67041100;
  781. $fullorder['adr'] = 0;
  782. if(strlen($fullorder['address'].$fullorder['address2']) > 44)
  783. {
  784. $adl = $fullorder['address'].$fullorder['address2'];
  785. $adl1 = substr($adl,0,44);//截取44字符前内容
  786. $adlnum = strripos($adl1," ");//查找最后一次出现空格位置
  787. $adl1 = substr($adl,0,$adlnum);//0到空格前之间的内容
  788. $adl2 = substr($adl,$adlnum+1,strlen($adl));//空格后到最后的内容
  789. $fullorder['adr'] = 1;
  790. $fullorder['adr1'] = $adl1;
  791. $fullorder['adr2'] = $adl2;
  792. }
  793. echo json_encode(array('data'=>$fullorder,'success'=>true));exit;
  794. }
  795. }
  796. public function _shop()
  797. {
  798. $post = $this->input->post(NULL, TRUE);
  799. if(isset($post['shop']))
  800. {
  801. $shop = $this->shop->find_all();
  802. echo json_encode(array('msg'=>$shop));exit;
  803. }
  804. }
  805. public function _express()
  806. {
  807. $post = $this->input->post(NULL, TRUE);
  808. if(isset($post['express']))
  809. {
  810. $express = $this->express->find_all();
  811. echo json_encode(array('msg'=>$express));exit;
  812. }
  813. }
  814. }