Warehouse.php 50 KB

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