Warehouse.php 51 KB

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