Warehouse.php 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Warehouse extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_warehouse','warehouse');
  7. $this->load->_model('Model_country','country');
  8. $this->load->_model('Model_express','express');
  9. $this->load->_model('Model_whlabel','whlabel');
  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_typeclass','typeclass');
  14. $this->load->_model('Model_shop','shop');
  15. $this->load->_model('Model_systemwigsout','systemwigsout');
  16. $this->load->_model('Model_excel','excel');
  17. $this->load->_model('Model_transfer','transfer');
  18. $this->load->_model('Model_systemtransfer','systemtransfer');
  19. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  20. $this->load->_model('Model_systemtransfer_cr', 'systemtransfer_cr');
  21. }
  22. //定义方法的调用规则 获取URI第二段值
  23. public function _remap($arg,$arg_array)
  24. {
  25. if($arg == 'add')//添加
  26. {
  27. $this->_add();
  28. }
  29. else if($arg == 'edit')
  30. {
  31. $this->_edit($arg_array);
  32. }
  33. else if($arg == 'del')
  34. {
  35. $this->_del();
  36. }
  37. else if($arg == 'rows')
  38. {
  39. $this->_rows();
  40. }
  41. else if($arg == 'list')
  42. {
  43. $this->_list();
  44. }
  45. else if($arg == 'kcpd')
  46. {
  47. $this->_kcpd();
  48. }
  49. else if($arg == 'orderlist')
  50. {
  51. $this->_orderlist();
  52. }
  53. else if($arg == 'orderlistck')//华荣厂查看
  54. {
  55. $this->_orderlistck();
  56. }
  57. else if($arg == 'orderlistexcel')
  58. {
  59. $this->_orderlistexcel();
  60. }
  61. else if($arg == 'ordersee')
  62. {
  63. $this->_ordersee($arg_array);
  64. }
  65. else
  66. {
  67. $this->_index();
  68. }
  69. }
  70. //管理
  71. public function _index()
  72. {
  73. $post = $this->input->post(NULL, TRUE);
  74. if(isset($post['page']))
  75. {
  76. $page = $this->input->post('page',true);
  77. $perpage = $this->input->post('perpage',true);
  78. $title = $this->input->post('title',true);
  79. $where = "1=1 ";
  80. if($title)
  81. {
  82. $where .= " and title = '$title'";
  83. }
  84. //数据排序
  85. $order_str = "id asc";
  86. if(empty($page))
  87. {
  88. $start = 0;
  89. $perpage = 1;
  90. }
  91. else
  92. {
  93. $start = ($page - 1)*$perpage;
  94. }
  95. //取得信息列表
  96. $info_list = $this->warehouse->find_all($where,'id,title,show,zd,zdms,fpzd,wz,fpsx,express,bdcountry,yybm',$order_str,$start,$perpage);
  97. foreach ($info_list as $key=>$value)
  98. {
  99. if($value['show'] == 1)
  100. {
  101. $info_list[$key]['show'] = "是";
  102. }
  103. else
  104. {
  105. $info_list[$key]['show'] = "否";
  106. }
  107. if($value['zd'] == 1)
  108. {
  109. $info_list[$key]['zd'] = "启用";
  110. }
  111. else
  112. {
  113. $info_list[$key]['zd'] = "无";
  114. }
  115. if($value['zdms'] == 1)
  116. {
  117. $info_list[$key]['zdms'] = "单独占单";
  118. }
  119. else if(($value['zdms'] == 2))
  120. {
  121. $info_list[$key]['zdms'] = "全占";
  122. }
  123. else if(($value['zdms'] == 3))
  124. {
  125. $info_list[$key]['zdms'] = "混占";
  126. }
  127. else
  128. {
  129. $info_list[$key]['zdms'] = "无";
  130. }
  131. if($value['express'] == 0)
  132. {
  133. $info_list[$key]['express'] = "无";
  134. }
  135. else
  136. {
  137. $express = $this->express->read($value['express']);
  138. $info_list[$key]['express'] = $express['servicename'];
  139. }
  140. if($value['fpzd'] == 1)
  141. {
  142. $info_list[$key]['fpzd'] = "自动";
  143. }
  144. else
  145. {
  146. $info_list[$key]['fpzd'] = "否";
  147. }
  148. if($value['wz'] == 1)
  149. {
  150. $info_list[$key]['wz'] = "开启";
  151. }
  152. else
  153. {
  154. $info_list[$key]['wz'] = "关闭";
  155. }
  156. if($value['bdcountry'] != 0)
  157. {
  158. $country = $this->country->read($value['bdcountry']);
  159. $info_list[$key]['bdcountry'] = $country['name'];
  160. }
  161. else
  162. {
  163. $info_list[$key]['bdcountry'] = "";
  164. }
  165. }
  166. $total = $this->warehouse->find_count($where);
  167. $pagenum = ceil($total/$perpage);
  168. $over = $total-($start+$perpage);
  169. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  170. echo json_encode($rows);exit;
  171. }
  172. $this->_Template('warehouse',$this->data);
  173. }
  174. //添加
  175. public function _add()
  176. {
  177. $post = $this->input->post(NULL, TRUE);
  178. if(isset($post['title']))
  179. {
  180. $post['title'] = $this->input->post('title',true);
  181. $post['company'] = $this->input->post('company',true);
  182. $post['user'] = $this->input->post('user',true);
  183. $post['show'] = $this->input->post('show',true);
  184. //$post['function'] = $this->input->post('function',true);
  185. //$post['functiontext'] = $this->input->post('functiontext',true);
  186. $post['country'] = $this->input->post('country',true);
  187. $post['name'] = $this->input->post('name',true);
  188. $post['phone'] = $this->input->post('phone',true);
  189. $post['province'] = $this->input->post('province',true);
  190. $post['city'] = $this->input->post('city',true);
  191. $post['zipcode'] = $this->input->post('zipcode',true);
  192. $post['address'] = $this->input->post('address',true);
  193. $post['address2'] = $this->input->post('address2',true);
  194. $post['hz'] = $this->input->post('hz',true);
  195. $post['zd'] = $this->input->post('zd',true);
  196. $post['bdck'] = $this->input->post('bdck',true);
  197. if($post['zd'] == 1 && $post['bdck'] == '')
  198. {
  199. echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit;
  200. }
  201. if($post['zd'] == 1 && $post['hz'] == '')
  202. {
  203. echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit;
  204. }
  205. if($post['zd'] == 1 && !ctype_alpha($post['hz']))
  206. {
  207. echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit;
  208. }
  209. if($this->warehouse->insert($post))
  210. {
  211. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  212. }
  213. else
  214. {
  215. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  216. }
  217. }
  218. $country = $this->country->find_all();
  219. $this->data['country'] = $country;
  220. $this->_Template('warehouse_add',$this->data);
  221. }
  222. //修改
  223. public function _edit($arg_array)
  224. {
  225. $post = $this->input->post(NULL, TRUE);
  226. if(isset($post['id']))
  227. {
  228. $id = $this->input->post('id',true);
  229. $data = $this->warehouse->read($id);
  230. $post['title'] = $this->input->post('title',true);
  231. $post['company'] = $this->input->post('company',true);
  232. $post['user'] = $this->input->post('user',true);
  233. $post['show'] = $this->input->post('show',true);
  234. /**
  235. $post['out'] = $this->input->post('out',true);
  236. if($post['out'] == 1)
  237. {
  238. //$post['mode'] = $this->input->post('mode',true);
  239. $post['mode'] = 0;
  240. }
  241. else
  242. {
  243. $post['mode'] = 0;
  244. }
  245. **/
  246. //$post['function'] = $this->input->post('function',true);
  247. //$post['functiontext'] = $this->input->post('functiontext',true);
  248. $post['country'] = $this->input->post('country',true);
  249. $post['name'] = $this->input->post('name',true);
  250. $post['phone'] = $this->input->post('phone',true);
  251. $post['province'] = $this->input->post('province',true);
  252. $post['city'] = $this->input->post('city',true);
  253. $post['zipcode'] = $this->input->post('zipcode',true);
  254. $post['address'] = $this->input->post('address',true);
  255. $post['address2'] = $this->input->post('address2',true);
  256. $post['hz'] = $this->input->post('hz',true);
  257. $post['zd'] = $this->input->post('zd',true);
  258. $post['bdck'] = $this->input->post('bdck',true);
  259. if($post['zd'] == 1 && $post['bdck'] == '' && $data['bdck'] == '')
  260. {
  261. echo json_encode(array('msg'=>'开启占单模式必须填写绑定库','success'=>false));exit;
  262. }
  263. if($post['zd'] == 1 && $post['hz'] == '' && $data['hz'] == '')
  264. {
  265. echo json_encode(array('msg'=>'开启占单模式必须填写占单后缀','success'=>false));exit;
  266. }
  267. if($post['hz'] && !ctype_alpha($post['hz']))
  268. {
  269. echo json_encode(array('msg'=>'占单后缀只允许是字母','success'=>false));exit;
  270. }
  271. if($data['bdck'] != '')
  272. {
  273. $post['bdck'] = $data['bdck'];
  274. }
  275. if($data['hz'] != '')
  276. {
  277. $post['hz'] = $data['hz'];
  278. }
  279. if($this->warehouse->save($post,$id))
  280. {
  281. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  282. }
  283. else
  284. {
  285. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  286. }
  287. }
  288. $arg_array = $arg_array[0];
  289. $warehouse = $this->warehouse->read($arg_array);
  290. $country = $this->country->find_all();
  291. $this->data['country'] = $country;
  292. $this->data['warehouse'] = $warehouse;
  293. $this->_Template('warehouse_edit',$this->data);
  294. }
  295. //删除
  296. public function _del()
  297. {
  298. $post = $this->input->post(NULL, TRUE);
  299. if(isset($post['s']))
  300. {
  301. $id_arr = $this->input->post('s');
  302. $id_arr = explode(',',$id_arr);
  303. if(!$id_arr)
  304. {
  305. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  306. }
  307. //循环删除记录
  308. foreach ($id_arr as $v)
  309. {
  310. $this->warehouse->remove($v);
  311. }
  312. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  313. }
  314. }
  315. //获取数据
  316. public function _rows()
  317. {
  318. $post = $this->input->post(NULL, TRUE);
  319. if(isset($post['rows']))
  320. {
  321. $rows = $this->input->post('rows',true);
  322. $bn = array('0'=>array('id'=>'3','title'=>'销售出库'),'1'=>array('id'=>'4','title'=>'非更换SKU方式调拨出库'));
  323. $cn = array('0'=>array('id'=>'5','title'=>'采购入库'),'1'=>array('id'=>'6','title'=>'单产品入库'),'2'=>array('id'=>'7','title'=>'非更换SKU方式调拨入库'));
  324. $an = array('0'=>array('id'=>'1','title'=>'出库','bn'=>$bn),'1'=>array('id'=>'2','title'=>'入库','bn'=>$cn));
  325. $warehouse = array();
  326. if($rows != "null")
  327. {
  328. $warehouse = $this->warehouse->read($rows);//找出次ID的权限内容
  329. if($warehouse['function'])
  330. {
  331. $warehouse = explode('|',trim($warehouse['function'],'|'));//数组化权限内容
  332. }
  333. }
  334. echo json_encode(array('msg'=>($an),'power'=>($warehouse),'success'=>true));
  335. }
  336. }
  337. public function _list()
  338. {
  339. $post = $this->input->post(NULL, TRUE);
  340. if(isset($post['id']))
  341. {
  342. $id = $this->input->post('id',true);
  343. $warehouse = $this->warehouse->read($id);
  344. if(isset($warehouse['zd']))
  345. {
  346. if(($warehouse['zd'] == '1' && $warehouse['ys'] == '1') || $warehouse['zd'] == '0')
  347. {
  348. $zd = '0';
  349. }
  350. else
  351. {
  352. $zd = '1';
  353. }
  354. echo json_encode(array('msg'=>$zd,'success'=>true));exit;
  355. }
  356. else
  357. {
  358. echo json_encode(array('msg'=>'错误,请重试','success'=>false));
  359. }
  360. }
  361. }
  362. public function _kcpd()
  363. {
  364. header("Access-Control-Allow-Origin: *");
  365. //echo json_encode(array('msg'=>'','success'=>true));exit;
  366. //暂时不用
  367. $post = $this->input->post(NULL, TRUE);
  368. if(isset($post['warehouse']))
  369. {
  370. $warehouse = $this->input->post('warehouse',true);
  371. $warehouse = $this->warehouse->read($warehouse);
  372. $whlabel = $this->input->post('whlabel',true);
  373. $shop = $this->input->post('shop',true);
  374. $data = $this->input->post('data',true);
  375. $data = str_replace('--','-',$data);
  376. $number = $this->input->post('number',true);
  377. $y = $this->fullordersmt->get_number($number);
  378. if(!$y)
  379. {
  380. $y = $this->fullorder->get_number($number);
  381. }
  382. if(!$y)
  383. {
  384. $y = $this->fullordertt->get_number($number);
  385. }
  386. if(!preg_match('/[0-9]/',$whlabel))
  387. {
  388. echo json_encode(array('msg'=>"无",'success'=>true));exit;
  389. }
  390. $typeclass = array();
  391. $tdata = $this->typeclass->find_all();
  392. foreach ($tdata as $v)
  393. {
  394. $typeclass[$v['id']] = $v['classid'];
  395. }
  396. $kxw = '';
  397. if(1==1)//($warehouse['zd'] == '0' || ($warehouse['zd'] == '1' && stripos($whlabel,$warehouse['hz'].'|') === false))
  398. {
  399. $kxw = '可用现货仓:';$tdfh = '';$cs = array();
  400. $warehousedata = $this->warehouse->find_all("zd = '1' and id != '8'");
  401. $pp = explode('|',trim($whlabel,'|'));
  402. $ccpp = explode('|',trim($data,'|'));
  403. $mgc = 0;//美国仓计数
  404. foreach ($warehousedata as $v)
  405. {
  406. if($y['country'] != '192' && $v['id'] == 5)
  407. {
  408. continue;
  409. }
  410. $x = 0;$j = 0;$save = array();$tdxh = 0;$thqd = 0;$thqdzh = '';$tdwh = 0;$tdshopwh = 0;$htpd = 0;$wearToGo = 0;$hdtx = '';
  411. foreach ($pp as $va)
  412. {
  413. $num = explode('-',$va);
  414. if($num[1] < 1)
  415. {
  416. continue;
  417. }
  418. $wh = $this->whlabel->find_count("state = '0' and number = '$num[0]' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");
  419. $x++;
  420. if($wh < $num[1])
  421. {
  422. $cp = $ccpp[$x-1];
  423. $cp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$cp);
  424. $save[] = $x-1;//提前先加X不然出错,所以要减1
  425. $cc = explode(',',$cp);
  426. if($v['id'] == '5')//美国仓提档检测是否有货
  427. {
  428. $xcc = $this->typeclass->read($cc[0]+1);
  429. if($xcc['classid'] == '14')
  430. {
  431. $tdnum = $this->str_replace_limit($cc[0],$xcc['id'],$num[0]);
  432. $tdwh = $this->whlabel->find_count("state = '0' and number = '$tdnum' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");
  433. }
  434. if($tdwh < $num[1])
  435. {
  436. $tdxh += 1;//提前先加X不然出错,所以要减1
  437. }
  438. }
  439. //美国仓提档检测是否有货结束
  440. if(stripos($cp,'-103-') !== false || stripos($cp,'-1647-') !== false)
  441. {
  442. $htpd += 1;
  443. $cc1 = explode('-',trim($cc[1],'-'));
  444. $newcp = '-';
  445. foreach ($cc1 as $kk=>$vv)
  446. {
  447. if($kk == 1)
  448. {
  449. $newcp .= $vv.'-'.$cc[0].'-';
  450. }
  451. else
  452. {
  453. $newcp .= $vv.'-';
  454. }
  455. }
  456. if(stripos($newcp,'-103-') !== false)
  457. {
  458. $gpp = str_replace('-103-','-1647-',$newcp);
  459. $thqdzh = 'Loose Body';
  460. }
  461. else
  462. {
  463. $gpp = str_replace('-1647-','-103-',$newcp);
  464. $thqdzh = 'Body';
  465. }
  466. $qdth_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  467. if($qdth_wh < $num[1])
  468. {
  469. $thqd += 1;//提前先加X不然出错,所以要减1
  470. }
  471. }
  472. /**
  473. if(stripos($cp,'-1181-') !== false)
  474. {
  475. $cc1 = explode('-',trim($cc[1],'-'));
  476. $newcp = '-';
  477. foreach ($cc1 as $kk=>$vv)
  478. {
  479. if($kk == 1)
  480. {
  481. $newcp .= $vv.'-'.$cc[0].'-';
  482. }
  483. else
  484. {
  485. $newcp .= $vv.'-';
  486. }
  487. }
  488. $gpp = str_replace('-1181-','-2071-',$newcp);
  489. $wtgo_wh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  490. if($wtgo_wh >= $num[1])
  491. {
  492. $wearToGo += 1;
  493. }
  494. }
  495. */
  496. /** /HKK
  497. if(stripos($cp,'-2028-') !== false)
  498. {
  499. $cc1 = explode('-',trim($cc[1],'-'));
  500. $newcp = '-';
  501. foreach ($cc1 as $kk=>$vv)
  502. {
  503. if($kk == 1)
  504. {
  505. $newcp .= $vv.'-'.$cc[0].'-';
  506. }
  507. else
  508. {
  509. $newcp .= $vv.'-';
  510. }
  511. }
  512. $gpp = str_replace('-2028-','-',$newcp);
  513. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  514. if($ccxh >= $num[1])
  515. {
  516. $hdtx .= $v['title'].' - 非HKK有货;';
  517. }
  518. }
  519. else if(stripos($cp,'-128-') !== false)
  520. {
  521. $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套
  522. $cc1 = explode('-',trim($cc[1],'-'));
  523. $cptt[$typeclass[$cc[0]]] = $cc[0];
  524. $newcp = '-';
  525. foreach ($cc1 as $kk=>$vv)
  526. {
  527. $cptt[$typeclass[$vv]] = $vv;
  528. }
  529. if($cptt[44] != '')
  530. {
  531. continue;
  532. }
  533. else
  534. {
  535. $cptt[44] = '2028';
  536. $cptt = array_filter($cptt);
  537. }
  538. $gpp = '-'.implode("-",$cptt).'-';
  539. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  540. if($ccxh >= $num[1])
  541. {
  542. $hdtx .= $v['title'].' - HKK有货;';
  543. }
  544. }
  545. **/
  546. //RTGWL
  547. if(stripos($cp,'-2076-') !== false)
  548. {
  549. $cc1 = explode('-',trim($cc[1],'-'));
  550. $newcp = '-';
  551. foreach ($cc1 as $kk=>$vv)
  552. {
  553. if($kk == 1)
  554. {
  555. $newcp .= $vv.'-'.$cc[0].'-';
  556. }
  557. else
  558. {
  559. $newcp .= $vv.'-';
  560. }
  561. }
  562. $gpp = str_replace('-2076-','-',$newcp);
  563. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  564. if($ccxh >= $num[1])
  565. {
  566. $hdtx .= $v['title'].' - 非RTGWL有货;';
  567. }
  568. }
  569. else if(stripos($cp,'-128-') !== false)
  570. {
  571. $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套
  572. $cc1 = explode('-',trim($cc[1],'-'));
  573. $cptt[$typeclass[$cc[0]]] = $cc[0];
  574. $newcp = '-';
  575. foreach ($cc1 as $kk=>$vv)
  576. {
  577. $cptt[$typeclass[$vv]] = $vv;
  578. }
  579. if($cptt[44] != '')
  580. {
  581. continue;
  582. }
  583. else
  584. {
  585. $cptt[44] = '2076';
  586. $cptt = array_filter($cptt);
  587. }
  588. $gpp = '-'.implode("-",$cptt).'-';
  589. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  590. if($ccxh >= $num[1])
  591. {
  592. $hdtx .= $v['title'].' - RTGWL有货;';
  593. }
  594. }
  595. // 4*7没货的,5*7如果有货,给提醒
  596. if(stripos($cp,'-1253-') !== false)
  597. {
  598. $cc1 = explode('-',trim($cc[1],'-'));
  599. $newcp = '-';
  600. foreach ($cc1 as $kk=>$vv)
  601. {
  602. if($kk == 1)
  603. {
  604. $newcp .= $vv.'-'.$cc[0].'-';
  605. }
  606. else
  607. {
  608. $newcp .= $vv.'-';
  609. }
  610. }
  611. $gpp = str_replace('-1253-','-2062-',$newcp);
  612. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  613. if($ccxh >= $num[1])
  614. {
  615. $hdtx .= $v['title'].' - 5*7有货;';
  616. }
  617. }
  618. // 5*5没货的,5*7、5*9如果有货,给提醒
  619. if(stripos($cp,'-297-') !== false) //13*4 HD13*4
  620. {
  621. $cc1 = explode('-',trim($cc[1],'-'));
  622. $newcp = '-';
  623. foreach ($cc1 as $kk=>$vv)
  624. {
  625. if($kk == 1)
  626. {
  627. $newcp .= $vv.'-'.$cc[0].'-';
  628. }
  629. else
  630. {
  631. $newcp .= $vv.'-';
  632. }
  633. }
  634. $gpp = str_replace('-297-','-2062-',$newcp);
  635. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  636. if($ccxh >= $num[1])
  637. {
  638. $hdtx .= $v['title'].' - 5*7有货;';
  639. }
  640. $gpp2 = str_replace('-297-','-1254-',$newcp);
  641. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  642. if($ccxh >= $num[1])
  643. {
  644. $hdtx .= $v['title'].' - 5*9有货;';
  645. }
  646. }
  647. // 180%货的,200、250如果有货,给提醒
  648. if(stripos($cp,'-72-') !== false) //13*4 HD13*4
  649. {
  650. $cc1 = explode('-',trim($cc[1],'-'));
  651. $newcp = '-';
  652. foreach ($cc1 as $kk=>$vv)
  653. {
  654. if($kk == 1)
  655. {
  656. $newcp .= $vv.'-'.$cc[0].'-';
  657. }
  658. else
  659. {
  660. $newcp .= $vv.'-';
  661. }
  662. }
  663. $gpp = str_replace('-72-','-73-',$newcp);
  664. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  665. if($ccxh >= $num[1])
  666. {
  667. $hdtx .= $v['title'].' - 200%密度有货;';
  668. }
  669. $gpp2 = str_replace('-72-','-74-',$newcp);
  670. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  671. if($ccxh >= $num[1])
  672. {
  673. $hdtx .= $v['title'].' - 250%密度有货;';
  674. }
  675. }
  676. if(stripos($cp,'-73-') !== false) //200% 250%
  677. {
  678. $cc1 = explode('-',trim($cc[1],'-'));
  679. $newcp = '-';
  680. foreach ($cc1 as $kk=>$vv)
  681. {
  682. if($kk == 1)
  683. {
  684. $newcp .= $vv.'-'.$cc[0].'-';
  685. }
  686. else
  687. {
  688. $newcp .= $vv.'-';
  689. }
  690. }
  691. $gpp2 = str_replace('-73-','-74-',$newcp);
  692. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp2' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  693. if($ccxh >= $num[1])
  694. {
  695. $hdtx .= $v['title'].' - 250%密度有货;';
  696. }
  697. }
  698. //HD相互提醒
  699. if(stripos($cp,'-146-') !== false || stripos($cp,'-331-') !== false) //13*4 HD13*4
  700. {
  701. $cc1 = explode('-',trim($cc[1],'-'));
  702. $newcp = '-';
  703. foreach ($cc1 as $kk=>$vv)
  704. {
  705. if($kk == 1)
  706. {
  707. $newcp .= $vv.'-'.$cc[0].'-';
  708. }
  709. else
  710. {
  711. $newcp .= $vv.'-';
  712. }
  713. }
  714. if(stripos($cp,'-146-') !== false)
  715. {
  716. $gpp = str_replace('-146-','-331-',$newcp);
  717. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  718. if($ccxh >= $num[1])
  719. {
  720. $hdtx .= $v['title'].' - HD13*4有货;';
  721. }
  722. }
  723. else if(stripos($cp,'-331-') !== false)
  724. {
  725. $gpp = str_replace('-331-','-146-',$newcp);
  726. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  727. if($ccxh >= $num[1])
  728. {
  729. $hdtx .= $v['title'].' - 13*4有货;';
  730. }
  731. }
  732. }
  733. if(stripos($cp,'-322-') !== false || stripos($cp,'-341-') !== false)//13*6 HD13*6
  734. {
  735. $cc1 = explode('-',trim($cc[1],'-'));
  736. $newcp = '-';
  737. foreach ($cc1 as $kk=>$vv)
  738. {
  739. if($kk == 1)
  740. {
  741. $newcp .= $vv.'-'.$cc[0].'-';
  742. }
  743. else
  744. {
  745. $newcp .= $vv.'-';
  746. }
  747. }
  748. if(stripos($cp,'-322-') !== false)
  749. {
  750. $gpp = str_replace('-322-','-341-',$newcp);
  751. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  752. if($ccxh >= $num[1])
  753. {
  754. $hdtx .= $v['title'].' - HD13*6有货;';
  755. }
  756. }
  757. else if(stripos($cp,'-341-') !== false)
  758. {
  759. $gpp = str_replace('-341-','-322-',$newcp);
  760. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  761. if($ccxh >= $num[1])
  762. {
  763. $hdtx .= $v['title'].' - 13*6有货;';
  764. }
  765. }
  766. }
  767. if(stripos($cp,'-147-') !== false || stripos($cp,'-781-') !== false)//4*4 HD4*4
  768. {
  769. $cc1 = explode('-',trim($cc[1],'-'));
  770. $newcp = '-';
  771. foreach ($cc1 as $kk=>$vv)
  772. {
  773. if($kk == 1)
  774. {
  775. $newcp .= $vv.'-'.$cc[0].'-';
  776. }
  777. else
  778. {
  779. $newcp .= $vv.'-';
  780. }
  781. }
  782. if(stripos($cp,'-147-') !== false)
  783. {
  784. $gpp = str_replace('-147-','-781-',$newcp);
  785. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  786. if($ccxh >= $num[1])
  787. {
  788. $hdtx .= $v['title'].' - HD4*4有货;';
  789. }
  790. }
  791. else if(stripos($cp,'-781-') !== false)
  792. {
  793. $gpp = str_replace('-781-','-147-',$newcp);
  794. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  795. if($ccxh >= $num[1])
  796. {
  797. $hdtx .= $v['title'].' - 4*4有货;';
  798. }
  799. }
  800. }
  801. if(stripos($cp,'-297-') !== false || stripos($cp,'-540-') !== false)//5*5 HD5*5
  802. {
  803. $cc1 = explode('-',trim($cc[1],'-'));
  804. $newcp = '-';
  805. foreach ($cc1 as $kk=>$vv)
  806. {
  807. if($kk == 1)
  808. {
  809. $newcp .= $vv.'-'.$cc[0].'-';
  810. }
  811. else
  812. {
  813. $newcp .= $vv.'-';
  814. }
  815. }
  816. if(stripos($cp,'-297-') !== false)
  817. {
  818. $gpp = str_replace('-297-','-540-',$newcp);
  819. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  820. if($ccxh >= $num[1])
  821. {
  822. $hdtx .= $v['title'].' - HD5*5有货;';
  823. }
  824. }
  825. else if(stripos($cp,'-540-') !== false)
  826. {
  827. $gpp = str_replace('-540-','-297-',$newcp);
  828. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  829. if($ccxh >= $num[1])
  830. {
  831. $hdtx .= $v['title'].' - 5*5有货;';
  832. }
  833. }
  834. }
  835. if(stripos($cp,'-298-') !== false || stripos($cp,'-370-') !== false)//6*6 HD6*6
  836. {
  837. $cc1 = explode('-',trim($cc[1],'-'));
  838. $newcp = '-';
  839. foreach ($cc1 as $kk=>$vv)
  840. {
  841. if($kk == 1)
  842. {
  843. $newcp .= $vv.'-'.$cc[0].'-';
  844. }
  845. else
  846. {
  847. $newcp .= $vv.'-';
  848. }
  849. }
  850. if(stripos($cp,'-298-') !== false)
  851. {
  852. $gpp = str_replace('-298-','-370-',$newcp);
  853. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  854. if($ccxh >= $num[1])
  855. {
  856. $hdtx .= $v['title'].' - HD6*6有货;';
  857. }
  858. }
  859. else if(stripos($cp,'-370-') !== false)
  860. {
  861. $gpp = str_replace('-370-','-298-',$newcp);
  862. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  863. if($ccxh >= $num[1])
  864. {
  865. $hdtx .= $v['title'].' - 6*6有货;';
  866. }
  867. }
  868. }
  869. if(stripos($cp,'-935-') !== false || stripos($cp,'-854-') !== false)//#P4/27/613 #P4/613
  870. {
  871. $cc1 = explode('-',trim($cc[1],'-'));
  872. $newcp = '-';
  873. foreach ($cc1 as $kk=>$vv)
  874. {
  875. if($kk == 1)
  876. {
  877. $newcp .= $vv.'-'.$cc[0].'-';
  878. }
  879. else
  880. {
  881. $newcp .= $vv.'-';
  882. }
  883. }
  884. if(stripos($cp,'-935-') !== false)
  885. {
  886. $gpp = str_replace('-935-','-854-',$newcp);
  887. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  888. if($ccxh >= $num[1])
  889. {
  890. $hdtx .= $v['title'].' - #P4/613;';
  891. }
  892. }
  893. else if(stripos($cp,'-854-') !== false)
  894. {
  895. $gpp = str_replace('-854-','-935-',$newcp);
  896. $ccxh = $this->whlabel->find_count("state = '0' and features = '$gpp' and warehouse = '".$v['id']."' and zd = '' and (shop IS NULL or shop = '' or shop like '%,".$shop.",%')");//通用
  897. if($ccxh >= $num[1])
  898. {
  899. $hdtx .= $v['title'].' - #P4/27/613;';
  900. }
  901. }
  902. }
  903. //HD相互提醒结束
  904. $cc1 = explode('-',trim($cc[1],'-'));
  905. $newcp = '-';
  906. foreach ($cc1 as $kk=>$vv)
  907. {
  908. if($kk == 1)
  909. {
  910. $newcp .= $vv.'-'.$cc[0].'-';
  911. }
  912. else
  913. {
  914. $newcp .= $vv.'-';
  915. }
  916. }
  917. //在途库存
  918. $transportlist = $this->whlabeltransport->find_all("features = '".$newcp."' and cz = 0 and warehouse = '".$v['id']."'");
  919. $transportMsg = "";
  920. if(count($transportlist) > 0)
  921. {
  922. $transportItem = $transportlist[0];
  923. $transportMsg = "<br/>". $transportItem['sku'] . " 在途库存: <b>" . $transportItem['num'] . " </b> 预达时间: ".date("Y-m-d",$transportItem['stime']). " <br/> 备注 : " . $transportItem['text'];
  924. }
  925. }
  926. else
  927. {
  928. if($v['id'] == '5')
  929. {
  930. $mgc++;
  931. }
  932. else
  933. {
  934. $kxw .= $v['title'].';';
  935. }
  936. }
  937. }
  938. if(!isset($save[0]))//非预设仓库提醒
  939. {
  940. //$kxw .= $v['title'].';';
  941. }
  942. else
  943. {
  944. if($v['id'] == '5' && $tdxh == '0')
  945. {
  946. $kxw .= $v['title'].'(当前尺寸无货,提一档有货) ;';
  947. }
  948. if($thqd == 0 && $htpd > 0)
  949. {
  950. $kxw .= $v['title'].'(当前曲度无货,'.$thqdzh.'有货) ;';
  951. }
  952. if($wearToGo > 0)
  953. {
  954. $kxw .= $v['title'].'(ReadytoGo有货) ;';
  955. }
  956. if($hdtx != '')
  957. {
  958. $kxw .= $hdtx;
  959. }
  960. if (!empty($transportMsg)) {
  961. $kxw .= $transportMsg;
  962. }
  963. }
  964. }
  965. }
  966. if(isset($pp) && $mgc == count($pp))
  967. {
  968. $kxw .= '美国店;';
  969. }
  970. if($kxw == '可用现货仓:')
  971. {
  972. echo json_encode(array('msg'=>$kxw.'无','cs'=>$cs,'success'=>true));exit;
  973. }
  974. else
  975. {
  976. echo json_encode(array('msg'=>rtrim($kxw,';'),'success'=>true));exit;
  977. }
  978. }
  979. }
  980. public function str_replace_limit($search, $replace, $subject)
  981. {
  982. $pos = strpos($subject, $search);
  983. if ($pos !== false)
  984. {
  985. return substr_replace($subject, $replace, $pos, strlen($search));
  986. }
  987. return $subject;
  988. }
  989. public function _orderlist()
  990. {
  991. $post = $this->input->post(NULL, TRUE);
  992. if(isset($_SESSION['api']))
  993. {
  994. $user = $this->user->get_api($_SESSION['api']);
  995. $usp = $user;
  996. $fgshop = "";$sid = "";$wid="";$wtype="";
  997. $usersp = explode('|',trim($user['shop'],'|'));
  998. $userwh = explode('|',trim($user['warehouse'],'|'));
  999. foreach ($usersp as $value)
  1000. {
  1001. $fgshop .= " shop = ".$value." or";
  1002. $sid .= " id = ".$value." or";
  1003. }
  1004. foreach ($userwh as $value)
  1005. {
  1006. $wid .= " id = ".$value." or";
  1007. $wtype .= " type = ".$value." or";
  1008. }
  1009. }
  1010. if(isset($post['page']))
  1011. {
  1012. $page = $this->input->post('page',true);
  1013. $perpage = $this->input->post('perpage',true);
  1014. $timetk = $this->input->post('timetk',true);
  1015. $timetj = $this->input->post('timetj',true);
  1016. $orderinfo = $this->input->post('orderinfo',true);
  1017. $number = $this->input->post('number',true);
  1018. $print = $this->input->post('print',true);
  1019. $shop = $this->input->post('shop',true);
  1020. $type = $this->input->post('type',true);
  1021. $ckfl = $this->input->post('ckfl',true);
  1022. $so = $this->input->post('so',true);
  1023. $sfxh = $this->input->post('sfxh',true);
  1024. $library = $this->input->post('library',true);
  1025. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1026. $timetk = strtotime($timetk);
  1027. $timetj = strtotime($timetj);
  1028. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1029. if($orderinfo)
  1030. {
  1031. $where .= " and orderinfo = '$orderinfo'";
  1032. }
  1033. if($number)
  1034. {
  1035. $where .= " and number = '$number'";
  1036. }
  1037. if($print)
  1038. {
  1039. $where .= " and print = '$print'";
  1040. if($print == 3)
  1041. {
  1042. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1043. }
  1044. }
  1045. if($shop)
  1046. {
  1047. $where .= " and shop = '$shop'";
  1048. }
  1049. if($type)
  1050. {
  1051. $where .= " and type = '$type'";
  1052. }
  1053. if($so)
  1054. {
  1055. $where .= " and shipremarks like '%$so%'";
  1056. }
  1057. if($ckfl)
  1058. {
  1059. $where .= " and ckfl = '$ckfl'";
  1060. }
  1061. if($library)
  1062. {
  1063. $where .= " and library = '$library'";
  1064. }
  1065. if($type)
  1066. {
  1067. $where .= " and type = '$type'";
  1068. }
  1069. if($libraryconfirm)
  1070. {
  1071. $where .= " and libraryconfirm = '$libraryconfirm'";
  1072. }
  1073. //数据排序
  1074. $order_str = ($print != 3)?"id desc":"printtime desc";
  1075. if(empty($page))
  1076. {
  1077. $start = 0;
  1078. $perpage = 1;
  1079. }
  1080. else
  1081. {
  1082. $start = ($page - 1)*$perpage;
  1083. }
  1084. $t = array();
  1085. $transfer = $this->transfer->find_all();
  1086. foreach ($transfer as $v)
  1087. {
  1088. $t[$v['id']] = $v['title'];
  1089. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1090. }
  1091. //取得信息列表
  1092. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1093. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1094. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1095. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1096. //格式化数据
  1097. foreach ($rows as $key=>$value)
  1098. {
  1099. $rows[$key]['id'] = $value['id'].'-fullorder';
  1100. $shop = $this->shop->read($value['shop']);
  1101. $rows[$key]['shop'] = $shop['shopname'];
  1102. if($value['printtime'] > 0)
  1103. {
  1104. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1105. }
  1106. else
  1107. {
  1108. $rows[$key]['printtime'] = '未打印';
  1109. }
  1110. if(isset($value['librarytime']) && $value['librarytime'] > 0)
  1111. {
  1112. $rows[$key]['librarytime'] = date('Y-m-d H:s',$value['librarytime']);
  1113. }
  1114. else
  1115. {
  1116. $rows[$key]['librarytime'] = '未出库';
  1117. }
  1118. $rows[$key]['orderinfo'] = "<h9 class='window' data-h='/warehouse/ordersee/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>";
  1119. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1120. $out = '';
  1121. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1122. if(!empty($tf)){
  1123. if($tf[0]['is_jiaji']){
  1124. $rows[$key]['number'] = "<a href='javascript:void(0)' style='color:red'>".$rows[$key]['number']."加急!!!</a>";
  1125. }
  1126. }
  1127. foreach ($tf as $k=>$v)
  1128. {
  1129. if(count($tf) > 1)
  1130. {
  1131. $out .= $k.'<br>';
  1132. }
  1133. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1134. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1135. foreach ($data as $k=>$v)
  1136. {
  1137. $type = ($v['type']==1)?'入库':'出库';
  1138. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1139. }
  1140. }
  1141. $rows[$key]['outread'] = trim($out,'<br>');
  1142. }
  1143. $dlz = $this->fullorder->find_count($where);
  1144. $smt = $this->fullordersmt->find_count($where);
  1145. $tt = $this->fullordertt->find_count($where);
  1146. //$total += $this->fullorder_smt->find_count($where);
  1147. $total = $dlz+$smt+$tt;
  1148. //$rows = array_slice($rows,$start,$perpage);
  1149. $pagenum = ceil($total/$perpage);
  1150. $over = $total-($start+$perpage);
  1151. $tmp = array();
  1152. if($print == 3)
  1153. {
  1154. foreach ($rows as $key => $val)
  1155. {
  1156. $tmp[$key] = $val['printtime'];
  1157. }
  1158. array_multisort($tmp,SORT_DESC,$rows);
  1159. }
  1160. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1161. echo json_encode($rows);exit;
  1162. }
  1163. if(isset($_SESSION['api']))
  1164. {
  1165. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1166. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1167. $this->data['wlshop'] = $wlshop;
  1168. $this->data['warehouse'] = $warehouse;
  1169. }
  1170. $this->_Template('warehouse_orderlist',$this->data);
  1171. }
  1172. public function _orderlistck()//华荣厂查看
  1173. {
  1174. $post = $this->input->post(NULL, TRUE);
  1175. if(isset($_SESSION['api']))
  1176. {
  1177. $user = $this->user->get_api($_SESSION['api']);
  1178. $usp = $user;
  1179. $fgshop = "";$sid = "";$wid="";$wtype="";
  1180. $usersp = explode('|',trim($user['shop'],'|'));
  1181. $userwh = explode('|',trim($user['warehouse'],'|'));
  1182. foreach ($usersp as $value)
  1183. {
  1184. $fgshop .= " shop = ".$value." or";
  1185. $sid .= " id = ".$value." or";
  1186. }
  1187. foreach ($userwh as $value)
  1188. {
  1189. $wid .= " id = ".$value." or";
  1190. $wtype .= " type = ".$value." or";
  1191. }
  1192. }
  1193. if(isset($post['page']))
  1194. {
  1195. $page = $this->input->post('page',true);
  1196. $perpage = $this->input->post('perpage',true);
  1197. $number = $this->input->post('number',true);
  1198. $so = $this->input->post('so',true);
  1199. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1200. if($number)
  1201. {
  1202. $where .= " and number = '$number'";
  1203. }
  1204. if($so)
  1205. {
  1206. $where .= " and shipremarks like '%$so%'";
  1207. }
  1208. if(!$so && !$number)
  1209. {
  1210. $where = "id < 0";
  1211. }
  1212. //数据排序
  1213. $order_str = "id desc";
  1214. if(empty($page))
  1215. {
  1216. $start = 0;
  1217. $perpage = 1;
  1218. }
  1219. else
  1220. {
  1221. $start = ($page - 1)*$perpage;
  1222. }
  1223. $info_list = array();
  1224. $info_listsmt = array();
  1225. $dlz = 0; $smt = 0;
  1226. //取得信息列表
  1227. $info_list = $this->fullorder->find_all($where,'id,number,shipremarks',$order_str,$start,$perpage);
  1228. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1229. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1230. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1231. //格式化数据
  1232. foreach ($rows as $key=>$value)
  1233. {
  1234. $rows[$key]['id'] = $value['id'].'-fullorder';
  1235. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1236. $systemwigsout = $this->systemwigsout->get_number($value['number']);
  1237. $wigsout = '';
  1238. if($systemwigsout)
  1239. {
  1240. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1241. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1242. $zw = array();
  1243. $t = $this->transfer->find_all("1=1");
  1244. foreach ($t as $v)
  1245. {
  1246. $zw[$v['id']] = $v['title'];
  1247. }
  1248. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1249. {
  1250. for($i=0;$i<count($cz);$i++)
  1251. {
  1252. if(!isset($cztime[$i]))
  1253. {
  1254. $wigsout .= $zw[$cz[$i]];
  1255. }
  1256. else
  1257. {
  1258. $wigsout .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).',';
  1259. }
  1260. }
  1261. }
  1262. }
  1263. $rows[$key]['systemwigsout'] = rtrim($wigsout,',');
  1264. }
  1265. $dlz = $this->fullorder->find_count($where);
  1266. $smt = $this->fullordersmt->find_count($where);
  1267. $tt = $this->fullordersmt->find_count($where);
  1268. //$total += $this->fullorder_smt->find_count($where);
  1269. $total = $dlz+$smt+$tt;
  1270. //$rows = array_slice($rows,$start,$perpage);
  1271. $pagenum = ceil($total/$perpage);
  1272. $over = $total-($start+$perpage);
  1273. $tmp = array();
  1274. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1275. echo json_encode($rows);exit;
  1276. }
  1277. if(isset($_SESSION['api']))
  1278. {
  1279. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1280. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1281. $this->data['wlshop'] = $wlshop;
  1282. $this->data['warehouse'] = $warehouse;
  1283. }
  1284. $this->_Template('warehouse_orderlistck',$this->data);
  1285. }
  1286. public function _ordersee($arg_array)
  1287. {
  1288. $arg_array = $arg_array[0];
  1289. $fullorder = 'fullorder';
  1290. $data = $this->fullorder->read($arg_array);
  1291. if(!$data)
  1292. {
  1293. $fullorder = 'fullordersmt';
  1294. $data = $this->fullordersmt->read($arg_array);
  1295. }
  1296. if(!$data)
  1297. {
  1298. $fullorder = 'fullordertt';
  1299. $data = $this->fullordertt->read($arg_array);
  1300. }
  1301. $fpdata = array();
  1302. $fullorder = $this->$fullorder->read($arg_array);
  1303. if(stripos($fullorder['fpdata'],';') !== false)
  1304. {
  1305. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  1306. foreach ($fpdata as $k=>$v)
  1307. {
  1308. $fpdata[$k] = explode('|',$v);
  1309. }
  1310. }
  1311. $systemwigsout = $this->systemwigsout->get_number($fullorder['number']);
  1312. $wigsout = array();
  1313. if($systemwigsout)
  1314. {
  1315. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1316. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1317. $zw = array();
  1318. $t = $this->transfer->find_all("1=1");
  1319. foreach ($t as $v)
  1320. {
  1321. $zw[$v['id']] = $v['title'];
  1322. }
  1323. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1324. {
  1325. for($i=0;$i<count($cz);$i++)
  1326. {
  1327. if(!isset($cztime[$i]))
  1328. {
  1329. $wigsout[] = $zw[$cz[$i]];
  1330. }
  1331. else
  1332. {
  1333. $wigsout[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]);
  1334. }
  1335. }
  1336. }
  1337. }
  1338. $this->data['systemwigsout'] = $wigsout;
  1339. $this->data['fpdata'] = $fpdata;
  1340. $this->data['data'] = $data;
  1341. $this->_Template('warehouse_ordersee',$this->data);
  1342. }
  1343. public function _orderlistexcel()
  1344. {
  1345. $post = $this->input->post(NULL, TRUE);
  1346. if(isset($_SESSION['api']))
  1347. {
  1348. $user = $this->user->get_api($_SESSION['api']);
  1349. $usp = $user;
  1350. $fgshop = "";$sid = "";$wid="";$wtype="";
  1351. $usersp = explode('|',trim($user['shop'],'|'));
  1352. $userwh = explode('|',trim($user['warehouse'],'|'));
  1353. foreach ($usersp as $value)
  1354. {
  1355. $fgshop .= " shop = ".$value." or";
  1356. $sid .= " id = ".$value." or";
  1357. }
  1358. foreach ($userwh as $value)
  1359. {
  1360. $wid .= " id = ".$value." or";
  1361. $wtype .= " type = ".$value." or";
  1362. }
  1363. }
  1364. if(isset($_GET['excel']))
  1365. {
  1366. $a = $this->input->get('a',true);
  1367. $id_is = '';$id_smt = '';
  1368. if($a)
  1369. {
  1370. $a = explode(',',rtrim($a,','));
  1371. foreach ($a as $value)
  1372. {
  1373. $v = explode('-',$value);
  1374. if($v[1] == 'fullorder')
  1375. {
  1376. $id_is .= "id = ".$v[0]." or ";
  1377. }
  1378. else
  1379. {
  1380. $id_smt .= "id = ".$v[0]." or ";
  1381. }
  1382. }
  1383. if($id_is)
  1384. {
  1385. $id_is = " and (".rtrim($id_is,'or ').")";
  1386. }
  1387. if($id_smt)
  1388. {
  1389. $id_smt = " and (".rtrim($id_smt,'or ').")";
  1390. }
  1391. }
  1392. $timetk = $this->input->get('timetk',true);
  1393. $timetj = $this->input->get('timetj',true);
  1394. $orderinfo = $this->input->get('orderinfo',true);
  1395. $number = $this->input->get('number',true);
  1396. $print = $this->input->get('print',true);
  1397. $shop = $this->input->get('shop',true);
  1398. $type = $this->input->get('type',true);
  1399. $ckfl = $this->input->get('ckfl',true);
  1400. $so = $this->input->get('so',true);
  1401. $sfxh = $this->input->get('sfxh',true);
  1402. $library = $this->input->get('library',true);
  1403. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1404. $timetk = strtotime($timetk);
  1405. $timetj = strtotime($timetj);
  1406. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1407. if($orderinfo)
  1408. {
  1409. $where .= " and orderinfo = '$orderinfo'";
  1410. }
  1411. if($number)
  1412. {
  1413. $where .= " and number = '$number'";
  1414. }
  1415. if($print)
  1416. {
  1417. $where .= " and print = '$print'";
  1418. if($print == 3)
  1419. {
  1420. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1421. }
  1422. }
  1423. if($shop)
  1424. {
  1425. $where .= " and shop = '$shop'";
  1426. }
  1427. if($type)
  1428. {
  1429. $where .= " and type = '$type'";
  1430. }
  1431. if($so)
  1432. {
  1433. $where .= " and shipremarks like '%$so%'";
  1434. }
  1435. if($ckfl)
  1436. {
  1437. $where .= " and ckfl = '$ckfl'";
  1438. }
  1439. if($library)
  1440. {
  1441. $where .= " and library = '$library'";
  1442. }
  1443. if($libraryconfirm)
  1444. {
  1445. $where .= " and libraryconfirm = '$libraryconfirm'";
  1446. }
  1447. $t = array();
  1448. $transfer = $this->transfer->find_all();
  1449. foreach ($transfer as $v)
  1450. {
  1451. $t[$v['id']] = $v['title'];
  1452. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1453. }
  1454. $order_str = ($print != 3)?"id desc":"printtime desc";
  1455. $info_list = $this->fullorder->find_all($where.$id_is,'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1456. $info_listsmt = $this->fullordersmt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1457. $info_listtt = $this->fullordertt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1458. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1459. foreach ($rows as $key=>$value)
  1460. {
  1461. if($value['printtime'] > 0)
  1462. {
  1463. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1464. }
  1465. else
  1466. {
  1467. $rows[$key]['printtime'] = '未打印';
  1468. }
  1469. if($value['library'] == 1)
  1470. {
  1471. $rows[$key]['library'] = "未出库";
  1472. }
  1473. else if($value['library'] == 2)
  1474. {
  1475. $rows[$key]['library'] = "已出库";
  1476. }
  1477. else if($value['library'] == 3)
  1478. {
  1479. $rows[$key]['printtime'] = '已退库';
  1480. }
  1481. if($value['libraryconfirm'] == 1)
  1482. {
  1483. $rows[$key]['libraryconfirm'] = '不允许出库';
  1484. }
  1485. else
  1486. {
  1487. $rows[$key]['libraryconfirm'] = '允许出库';
  1488. }
  1489. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1490. $out = '';
  1491. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1492. foreach ($tf as $k=>$v)
  1493. {
  1494. if(count($tf) > 1)
  1495. {
  1496. $out .= $k.'<br>';
  1497. }
  1498. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1499. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1500. foreach ($data as $k=>$v)
  1501. {
  1502. $type = ($v['type']==1)?'入库':'出库';
  1503. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1504. }
  1505. }
  1506. $rows[$key]['systemwigsout'] = trim($out,'<br>');
  1507. }
  1508. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'进销存详情';
  1509. $titlename = "<table border=1>
  1510. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  1511. <tr align='center'>
  1512. <td>编号</td>
  1513. <td>仓库品名</td>
  1514. <td>条数</td>
  1515. <td>打印时间</td>
  1516. <td>出库状态</td>
  1517. <td>出库确认</td>
  1518. <td>禁止出库原因</td>
  1519. <td>追踪</td>
  1520. </tr>
  1521. </table>";
  1522. $filename = $title.".xls";
  1523. $tail = "";
  1524. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1525. }
  1526. }
  1527. }