Warehouse.php 50 KB

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