Warehouse.php 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598
  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. $this->logic_ding->sendToDing("仓库kcpd提醒ccpp".json_encode($ccpp)."number:".$number."[pp]".json_encode($pp));
  408. $mgc = 0;//美国仓计数
  409. foreach ($warehousedata as $v)
  410. {
  411. if($y['country'] != '192' && $v['id'] == 5)
  412. {
  413. continue;
  414. }
  415. $x = 0;$j = 0;$save = array();$tdxh = 0;$thqd = 0;$thqdzh = '';$tdwh = 0;$tdshopwh = 0;$htpd = 0;$wearToGo = 0;$hdtx = '';
  416. foreach ($pp as $va)
  417. {
  418. $num = explode('-',$va);
  419. if($num[1] < 1)
  420. {
  421. continue;
  422. }
  423. $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.",%')");
  424. $x++;
  425. if($wh < $num[1])
  426. {
  427. $cp = $ccpp[$x-1];
  428. $cp = str_replace(array('-163-','-164-','-165-','-166-'),'-',$cp);
  429. $save[] = $x-1;//提前先加X不然出错,所以要减1
  430. $cc = explode(',',$cp);
  431. if($v['id'] == '5')//美国仓提档检测是否有货
  432. {
  433. $xcc = $this->typeclass->read($cc[0]+1);
  434. if($xcc['classid'] == '14')
  435. {
  436. $tdnum = $this->str_replace_limit($cc[0],$xcc['id'],$num[0]);
  437. $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.",%')");
  438. }
  439. if($tdwh < $num[1])
  440. {
  441. $tdxh += 1;//提前先加X不然出错,所以要减1
  442. }
  443. }
  444. //美国仓提档检测是否有货结束
  445. //103 Body Wave 1647 LooseBody
  446. if(stripos($cp,'-103-') !== false || stripos($cp,'-1647-') !== false)
  447. {
  448. $htpd += 1;
  449. $cc1 = explode('-',trim($cc[1],'-'));
  450. $newcp = '-';
  451. foreach ($cc1 as $kk=>$vv)
  452. {
  453. //曲度后边加了长度
  454. if($kk == 1)
  455. {
  456. $newcp .= $vv.'-'.$cc[0].'-';
  457. }
  458. else
  459. {
  460. $newcp .= $vv.'-';
  461. }
  462. }
  463. if(stripos($newcp,'-103-') !== false)
  464. {
  465. $gpp = str_replace('-103-','-1647-',$newcp);
  466. $thqdzh = 'Loose Body';
  467. }
  468. else
  469. {
  470. $gpp = str_replace('-1647-','-103-',$newcp);
  471. $thqdzh = 'Body';
  472. }
  473. $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.",%')");//通用
  474. if($qdth_wh < $num[1])
  475. {
  476. $thqd += 1;//提前先加X不然出错,所以要减1
  477. }
  478. }
  479. /**
  480. if(stripos($cp,'-1181-') !== false)
  481. {
  482. $cc1 = explode('-',trim($cc[1],'-'));
  483. $newcp = '-';
  484. foreach ($cc1 as $kk=>$vv)
  485. {
  486. if($kk == 1)
  487. {
  488. $newcp .= $vv.'-'.$cc[0].'-';
  489. }
  490. else
  491. {
  492. $newcp .= $vv.'-';
  493. }
  494. }
  495. $gpp = str_replace('-1181-','-2071-',$newcp);
  496. $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.",%')");//通用
  497. if($wtgo_wh >= $num[1])
  498. {
  499. $wearToGo += 1;
  500. }
  501. }
  502. */
  503. /** /HKK
  504. if(stripos($cp,'-2028-') !== false)
  505. {
  506. $cc1 = explode('-',trim($cc[1],'-'));
  507. $newcp = '-';
  508. foreach ($cc1 as $kk=>$vv)
  509. {
  510. if($kk == 1)
  511. {
  512. $newcp .= $vv.'-'.$cc[0].'-';
  513. }
  514. else
  515. {
  516. $newcp .= $vv.'-';
  517. }
  518. }
  519. $gpp = str_replace('-2028-','-',$newcp);
  520. $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.",%')");//通用
  521. if($ccxh >= $num[1])
  522. {
  523. $hdtx .= $v['title'].' - 非HKK有货;';
  524. }
  525. }
  526. else if(stripos($cp,'-128-') !== false)
  527. {
  528. $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套
  529. $cc1 = explode('-',trim($cc[1],'-'));
  530. $cptt[$typeclass[$cc[0]]] = $cc[0];
  531. $newcp = '-';
  532. foreach ($cc1 as $kk=>$vv)
  533. {
  534. $cptt[$typeclass[$vv]] = $vv;
  535. }
  536. if($cptt[44] != '')
  537. {
  538. continue;
  539. }
  540. else
  541. {
  542. $cptt[44] = '2028';
  543. $cptt = array_filter($cptt);
  544. }
  545. $gpp = '-'.implode("-",$cptt).'-';
  546. $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.",%')");//通用
  547. if($ccxh >= $num[1])
  548. {
  549. $hdtx .= $v['title'].' - HKK有货;';
  550. }
  551. }
  552. **/
  553. //RTGWL 注释掉了
  554. // if(stripos($cp,'-2076-') !== false)
  555. // {
  556. // $cc1 = explode('-',trim($cc[1],'-'));
  557. // $newcp = '-';
  558. // foreach ($cc1 as $kk=>$vv)
  559. // {
  560. // if($kk == 1)
  561. // {
  562. // $newcp .= $vv.'-'.$cc[0].'-';
  563. // }
  564. // else
  565. // {
  566. // $newcp .= $vv.'-';
  567. // }
  568. // }
  569. // $gpp = str_replace('-2076-','-',$newcp);
  570. // $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.",%')");//通用
  571. // if($ccxh >= $num[1])
  572. // {
  573. // $hdtx .= $v['title'].' - 非RTGWL有货;';
  574. // }
  575. // }
  576. // else if(stripos($cp,'-128-') !== false)
  577. // {
  578. // $cptt = array(16=>128,13=>80,14=>'',43=>'',8=>'57',15=>'',18=>'',6=>30,10=>72,9=>'',39=>'',44=>'');//头套
  579. // $cc1 = explode('-',trim($cc[1],'-'));
  580. // $cptt[$typeclass[$cc[0]]] = $cc[0];
  581. // $newcp = '-';
  582. // foreach ($cc1 as $kk=>$vv)
  583. // {
  584. // $cptt[$typeclass[$vv]] = $vv;
  585. // }
  586. // if($cptt[44] != '')
  587. // {
  588. // continue;
  589. // }
  590. // else
  591. // {
  592. // $cptt[44] = '2076';
  593. // $cptt = array_filter($cptt);
  594. // }
  595. // $gpp = '-'.implode("-",$cptt).'-';
  596. // $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.",%')");//通用
  597. // if($ccxh >= $num[1])
  598. // {
  599. // $hdtx .= $v['title'].' - RTGWL有货;';
  600. // }
  601. // }
  602. // 4*7没货的,5*7如果有货,给提醒
  603. if(stripos($cp,'-1253-') !== false)
  604. {
  605. $cc1 = explode('-',trim($cc[1],'-'));
  606. $newcp = '-';
  607. foreach ($cc1 as $kk=>$vv)
  608. {
  609. if($kk == 1)
  610. {
  611. $newcp .= $vv.'-'.$cc[0].'-';
  612. }
  613. else
  614. {
  615. $newcp .= $vv.'-';
  616. }
  617. }
  618. $gpp = str_replace('-1253-','-2062-',$newcp);
  619. $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.",%')");//通用
  620. if($ccxh >= $num[1])
  621. {
  622. $hdtx .= $v['title'].' - 5*7有货;';
  623. }
  624. }
  625. // 5*5没货的,5*7、5*9如果有货,给提醒
  626. if(stripos($cp,'-297-') !== false) //13*4 HD13*4
  627. {
  628. $cc1 = explode('-',trim($cc[1],'-'));
  629. $newcp = '-';
  630. foreach ($cc1 as $kk=>$vv)
  631. {
  632. if($kk == 1)
  633. {
  634. $newcp .= $vv.'-'.$cc[0].'-';
  635. }
  636. else
  637. {
  638. $newcp .= $vv.'-';
  639. }
  640. }
  641. $gpp = str_replace('-297-','-2062-',$newcp);
  642. $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.",%')");//通用
  643. if($ccxh >= $num[1])
  644. {
  645. $hdtx .= $v['title'].' - 5*7有货;';
  646. }
  647. $gpp2 = str_replace('-297-','-1254-',$newcp);
  648. $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.",%')");//通用
  649. if($ccxh >= $num[1])
  650. {
  651. $hdtx .= $v['title'].' - 5*9有货;';
  652. }
  653. }
  654. // 180%货的,200、250如果有货,给提醒
  655. if(stripos($cp,'-72-') !== false) //13*4 HD13*4
  656. {
  657. $cc1 = explode('-',trim($cc[1],'-'));
  658. $newcp = '-';
  659. foreach ($cc1 as $kk=>$vv)
  660. {
  661. if($kk == 1)
  662. {
  663. $newcp .= $vv.'-'.$cc[0].'-';
  664. }
  665. else
  666. {
  667. $newcp .= $vv.'-';
  668. }
  669. }
  670. $gpp = str_replace('-72-','-73-',$newcp);
  671. $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.",%')");//通用
  672. if($ccxh >= $num[1])
  673. {
  674. $hdtx .= $v['title'].' - 200%密度有货;';
  675. }
  676. $gpp2 = str_replace('-72-','-74-',$newcp);
  677. $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.",%')");//通用
  678. if($ccxh >= $num[1])
  679. {
  680. $hdtx .= $v['title'].' - 250%密度有货;';
  681. }
  682. }
  683. if(stripos($cp,'-73-') !== false) //200% 250%
  684. {
  685. $cc1 = explode('-',trim($cc[1],'-'));
  686. $newcp = '-';
  687. foreach ($cc1 as $kk=>$vv)
  688. {
  689. if($kk == 1)
  690. {
  691. $newcp .= $vv.'-'.$cc[0].'-';
  692. }
  693. else
  694. {
  695. $newcp .= $vv.'-';
  696. }
  697. }
  698. $gpp2 = str_replace('-73-','-74-',$newcp);
  699. $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.",%')");//通用
  700. if($ccxh >= $num[1])
  701. {
  702. $hdtx .= $v['title'].' - 250%密度有货;';
  703. }
  704. }
  705. //HD相互提醒
  706. if(stripos($cp,'-146-') !== false || stripos($cp,'-331-') !== false) //13*4 HD13*4
  707. {
  708. $cc1 = explode('-',trim($cc[1],'-'));
  709. $newcp = '-';
  710. foreach ($cc1 as $kk=>$vv)
  711. {
  712. if($kk == 1)
  713. {
  714. $newcp .= $vv.'-'.$cc[0].'-';
  715. }
  716. else
  717. {
  718. $newcp .= $vv.'-';
  719. }
  720. }
  721. if(stripos($cp,'-146-') !== false)
  722. {
  723. $gpp = str_replace('-146-','-331-',$newcp);
  724. $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.",%')");//通用
  725. if($ccxh >= $num[1])
  726. {
  727. $hdtx .= $v['title'].' - HD13*4有货;';
  728. }
  729. }
  730. else if(stripos($cp,'-331-') !== false)
  731. {
  732. $gpp = str_replace('-331-','-146-',$newcp);
  733. $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.",%')");//通用
  734. if($ccxh >= $num[1])
  735. {
  736. $hdtx .= $v['title'].' - 13*4有货;';
  737. }
  738. }
  739. }
  740. if(stripos($cp,'-322-') !== false || stripos($cp,'-341-') !== false)//13*6 HD13*6
  741. {
  742. $cc1 = explode('-',trim($cc[1],'-'));
  743. $newcp = '-';
  744. foreach ($cc1 as $kk=>$vv)
  745. {
  746. if($kk == 1)
  747. {
  748. $newcp .= $vv.'-'.$cc[0].'-';
  749. }
  750. else
  751. {
  752. $newcp .= $vv.'-';
  753. }
  754. }
  755. if(stripos($cp,'-322-') !== false)
  756. {
  757. $gpp = str_replace('-322-','-341-',$newcp);
  758. $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.",%')");//通用
  759. if($ccxh >= $num[1])
  760. {
  761. $hdtx .= $v['title'].' - HD13*6有货;';
  762. }
  763. }
  764. else if(stripos($cp,'-341-') !== false)
  765. {
  766. $gpp = str_replace('-341-','-322-',$newcp);
  767. $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.",%')");//通用
  768. if($ccxh >= $num[1])
  769. {
  770. $hdtx .= $v['title'].' - 13*6有货;';
  771. }
  772. }
  773. }
  774. if(stripos($cp,'-147-') !== false || stripos($cp,'-781-') !== false)//4*4 HD4*4
  775. {
  776. $cc1 = explode('-',trim($cc[1],'-'));
  777. $newcp = '-';
  778. foreach ($cc1 as $kk=>$vv)
  779. {
  780. if($kk == 1)
  781. {
  782. $newcp .= $vv.'-'.$cc[0].'-';
  783. }
  784. else
  785. {
  786. $newcp .= $vv.'-';
  787. }
  788. }
  789. if(stripos($cp,'-147-') !== false)
  790. {
  791. $gpp = str_replace('-147-','-781-',$newcp);
  792. $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.",%')");//通用
  793. if($ccxh >= $num[1])
  794. {
  795. $hdtx .= $v['title'].' - HD4*4有货;';
  796. }
  797. }
  798. else if(stripos($cp,'-781-') !== false)
  799. {
  800. $gpp = str_replace('-781-','-147-',$newcp);
  801. $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.",%')");//通用
  802. if($ccxh >= $num[1])
  803. {
  804. $hdtx .= $v['title'].' - 4*4有货;';
  805. }
  806. }
  807. }
  808. if(stripos($cp,'-297-') !== false || stripos($cp,'-540-') !== false)//5*5 HD5*5
  809. {
  810. $cc1 = explode('-',trim($cc[1],'-'));
  811. $newcp = '-';
  812. foreach ($cc1 as $kk=>$vv)
  813. {
  814. if($kk == 1)
  815. {
  816. $newcp .= $vv.'-'.$cc[0].'-';
  817. }
  818. else
  819. {
  820. $newcp .= $vv.'-';
  821. }
  822. }
  823. if(stripos($cp,'-297-') !== false)
  824. {
  825. $gpp = str_replace('-297-','-540-',$newcp);
  826. $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.",%')");//通用
  827. if($ccxh >= $num[1])
  828. {
  829. $hdtx .= $v['title'].' - HD5*5有货;';
  830. }
  831. }
  832. else if(stripos($cp,'-540-') !== false)
  833. {
  834. $gpp = str_replace('-540-','-297-',$newcp);
  835. $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.",%')");//通用
  836. if($ccxh >= $num[1])
  837. {
  838. $hdtx .= $v['title'].' - 5*5有货;';
  839. }
  840. }
  841. }
  842. if(stripos($cp,'-298-') !== false || stripos($cp,'-370-') !== false)//6*6 HD6*6
  843. {
  844. $cc1 = explode('-',trim($cc[1],'-'));
  845. $newcp = '-';
  846. foreach ($cc1 as $kk=>$vv)
  847. {
  848. if($kk == 1)
  849. {
  850. $newcp .= $vv.'-'.$cc[0].'-';
  851. }
  852. else
  853. {
  854. $newcp .= $vv.'-';
  855. }
  856. }
  857. if(stripos($cp,'-298-') !== false)
  858. {
  859. $gpp = str_replace('-298-','-370-',$newcp);
  860. $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.",%')");//通用
  861. if($ccxh >= $num[1])
  862. {
  863. $hdtx .= $v['title'].' - HD6*6有货;';
  864. }
  865. }
  866. else if(stripos($cp,'-370-') !== false)
  867. {
  868. $gpp = str_replace('-370-','-298-',$newcp);
  869. $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.",%')");//通用
  870. if($ccxh >= $num[1])
  871. {
  872. $hdtx .= $v['title'].' - 6*6有货;';
  873. }
  874. }
  875. }
  876. if(stripos($cp,'-935-') !== false || stripos($cp,'-854-') !== false)//#P4/27/613 #P4/613
  877. {
  878. $cc1 = explode('-',trim($cc[1],'-'));
  879. $newcp = '-';
  880. foreach ($cc1 as $kk=>$vv)
  881. {
  882. if($kk == 1)
  883. {
  884. $newcp .= $vv.'-'.$cc[0].'-';
  885. }
  886. else
  887. {
  888. $newcp .= $vv.'-';
  889. }
  890. }
  891. if(stripos($cp,'-935-') !== false)
  892. {
  893. $gpp = str_replace('-935-','-854-',$newcp);
  894. $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.",%')");//通用
  895. if($ccxh >= $num[1])
  896. {
  897. $hdtx .= $v['title'].' - #P4/613;';
  898. }
  899. }
  900. else if(stripos($cp,'-854-') !== false)
  901. {
  902. $gpp = str_replace('-854-','-935-',$newcp);
  903. $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.",%')");//通用
  904. if($ccxh >= $num[1])
  905. {
  906. $hdtx .= $v['title'].' - #P4/27/613;';
  907. }
  908. }
  909. }
  910. //HD相互提醒结束
  911. if(isset($cc[1])){
  912. $cc1 = explode('-',trim($cc[1],'-'));
  913. $newcp = '-';
  914. foreach ($cc1 as $kk=>$vv)
  915. {
  916. if($kk == 1)
  917. {
  918. $newcp .= $vv.'-'.$cc[0].'-';
  919. }
  920. else
  921. {
  922. $newcp .= $vv.'-';
  923. }
  924. }
  925. }else{
  926. $this->logic_ding->sendToDing("仓库kcpd提醒cc".json_encode($cc).'cp'.json_encode($cp)."ccpp".json_encode($ccpp)."number:".$number."[pp]".json_encode($pp));
  927. $newcp = '-';
  928. }
  929. //在途库存
  930. $transportlist = $this->whlabeltransport->find_all("features = '".$newcp."' and cz = 0 and warehouse = '".$v['id']."'");
  931. $transportMsg = "";
  932. if(count($transportlist) > 0)
  933. {
  934. $transportItem = $transportlist[0];
  935. $transportMsg = "<br/>". $transportItem['sku'] . " 在途库存: <b>" . $transportItem['num'] . " </b> 预达时间: ".date("Y-m-d",$transportItem['stime']). " <br/> 备注 : " . $transportItem['text'];
  936. }
  937. }
  938. else
  939. {
  940. if($v['id'] == '5')
  941. {
  942. $mgc++;
  943. }
  944. else
  945. {
  946. $kxw .= $v['title'].';';
  947. }
  948. }
  949. }
  950. if(!isset($save[0]))//非预设仓库提醒
  951. {
  952. //$kxw .= $v['title'].';';
  953. }
  954. else
  955. {
  956. if($v['id'] == '5' && $tdxh == '0')
  957. {
  958. $kxw .= $v['title'].'(当前尺寸无货,提一档有货) ;';
  959. }
  960. if($thqd == 0 && $htpd > 0)
  961. {
  962. $kxw .= $v['title'].'(当前曲度无货,'.$thqdzh.'有货) ;';
  963. }
  964. if($wearToGo > 0)
  965. {
  966. $kxw .= $v['title'].'(ReadytoGo有货) ;';
  967. }
  968. if($hdtx != '')
  969. {
  970. $kxw .= $hdtx;
  971. }
  972. if (!empty($transportMsg)) {
  973. $kxw .= $transportMsg;
  974. }
  975. }
  976. }
  977. }
  978. if(isset($pp) && $mgc == count($pp))
  979. {
  980. $kxw .= '美国店;';
  981. }
  982. if($kxw == '可用现货仓:')
  983. {
  984. echo json_encode(array('msg'=>$kxw.'无','cs'=>$cs,'success'=>true));exit;
  985. }
  986. else
  987. {
  988. echo json_encode(array('msg'=>rtrim($kxw,';'),'success'=>true));exit;
  989. }
  990. }
  991. }
  992. public function str_replace_limit($search, $replace, $subject)
  993. {
  994. $pos = strpos($subject, $search);
  995. if ($pos !== false)
  996. {
  997. return substr_replace($subject, $replace, $pos, strlen($search));
  998. }
  999. return $subject;
  1000. }
  1001. public function _orderlist()
  1002. {
  1003. $post = $this->input->post(NULL, TRUE);
  1004. if(isset($_SESSION['api']))
  1005. {
  1006. $user = $this->user->get_api($_SESSION['api']);
  1007. $usp = $user;
  1008. $fgshop = "";$sid = "";$wid="";$wtype="";
  1009. $usersp = explode('|',trim($user['shop'],'|'));
  1010. $userwh = explode('|',trim($user['warehouse'],'|'));
  1011. foreach ($usersp as $value)
  1012. {
  1013. $fgshop .= " shop = ".$value." or";
  1014. $sid .= " id = ".$value." or";
  1015. }
  1016. foreach ($userwh as $value)
  1017. {
  1018. $wid .= " id = ".$value." or";
  1019. $wtype .= " type = ".$value." or";
  1020. }
  1021. }
  1022. if(isset($post['page']))
  1023. {
  1024. $page = $this->input->post('page',true);
  1025. $perpage = $this->input->post('perpage',true);
  1026. $timetk = $this->input->post('timetk',true);
  1027. $timetj = $this->input->post('timetj',true);
  1028. $orderinfo = $this->input->post('orderinfo',true);
  1029. $number = $this->input->post('number',true);
  1030. $print = $this->input->post('print',true);
  1031. $shop = $this->input->post('shop',true);
  1032. $type = $this->input->post('type',true);
  1033. $ckfl = $this->input->post('ckfl',true);
  1034. $so = $this->input->post('so',true);
  1035. $sfxh = $this->input->post('sfxh',true);
  1036. $library = $this->input->post('library',true);
  1037. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1038. $timetk = strtotime($timetk);
  1039. $timetj = strtotime($timetj);
  1040. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1041. if($orderinfo)
  1042. {
  1043. $where .= " and orderinfo = '$orderinfo'";
  1044. }
  1045. if($number)
  1046. {
  1047. $where .= " and number = '$number'";
  1048. }
  1049. if($print)
  1050. {
  1051. $where .= " and print = '$print'";
  1052. if($print == 3)
  1053. {
  1054. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1055. }
  1056. }
  1057. if($shop)
  1058. {
  1059. $where .= " and shop = '$shop'";
  1060. }
  1061. if($type)
  1062. {
  1063. $where .= " and type = '$type'";
  1064. }
  1065. if($so)
  1066. {
  1067. $where .= " and shipremarks like '%$so%'";
  1068. }
  1069. if($ckfl)
  1070. {
  1071. $where .= " and ckfl = '$ckfl'";
  1072. }
  1073. if($library)
  1074. {
  1075. $where .= " and library = '$library'";
  1076. }
  1077. if($type)
  1078. {
  1079. $where .= " and type = '$type'";
  1080. }
  1081. if($libraryconfirm)
  1082. {
  1083. $where .= " and libraryconfirm = '$libraryconfirm'";
  1084. }
  1085. //数据排序
  1086. $order_str = ($print != 3)?"id desc":"printtime desc";
  1087. if(empty($page))
  1088. {
  1089. $start = 0;
  1090. $perpage = 1;
  1091. }
  1092. else
  1093. {
  1094. $start = ($page - 1)*$perpage;
  1095. }
  1096. $t = array();
  1097. $transfer = $this->transfer->find_all();
  1098. foreach ($transfer as $v)
  1099. {
  1100. $t[$v['id']] = $v['title'];
  1101. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1102. }
  1103. //取得信息列表
  1104. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1105. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1106. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1107. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1108. //格式化数据
  1109. foreach ($rows as $key=>$value)
  1110. {
  1111. $rows[$key]['id'] = $value['id'].'-fullorder';
  1112. $shop = $this->shop->read($value['shop']);
  1113. $rows[$key]['shop'] = $shop['shopname'];
  1114. if($value['printtime'] > 0)
  1115. {
  1116. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1117. }
  1118. else
  1119. {
  1120. $rows[$key]['printtime'] = '未打印';
  1121. }
  1122. if(isset($value['librarytime']) && $value['librarytime'] > 0)
  1123. {
  1124. $rows[$key]['librarytime'] = date('Y-m-d H:s',$value['librarytime']);
  1125. }
  1126. else
  1127. {
  1128. $rows[$key]['librarytime'] = '未出库';
  1129. }
  1130. $rows[$key]['orderinfo'] = "<h9 class='window' data-h='/warehouse/ordersee/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>";
  1131. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1132. $out = '';
  1133. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1134. if(!empty($tf)){
  1135. if($tf[0]['is_jiaji']){
  1136. $rows[$key]['number'] = "<a href='javascript:void(0)' style='color:red'>".$rows[$key]['number']."加急!!!</a>";
  1137. }
  1138. }
  1139. foreach ($tf as $k=>$v)
  1140. {
  1141. if(count($tf) > 1)
  1142. {
  1143. $out .= $k.'<br>';
  1144. }
  1145. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1146. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1147. foreach ($data as $k=>$v)
  1148. {
  1149. $type = ($v['type']==1)?'入库':'出库';
  1150. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1151. }
  1152. }
  1153. $rows[$key]['outread'] = trim($out,'<br>');
  1154. }
  1155. $dlz = $this->fullorder->find_count($where);
  1156. $smt = $this->fullordersmt->find_count($where);
  1157. $tt = $this->fullordertt->find_count($where);
  1158. //$total += $this->fullorder_smt->find_count($where);
  1159. $total = $dlz+$smt+$tt;
  1160. //$rows = array_slice($rows,$start,$perpage);
  1161. $pagenum = ceil($total/$perpage);
  1162. $over = $total-($start+$perpage);
  1163. $tmp = array();
  1164. if($print == 3)
  1165. {
  1166. foreach ($rows as $key => $val)
  1167. {
  1168. $tmp[$key] = $val['printtime'];
  1169. }
  1170. array_multisort($tmp,SORT_DESC,$rows);
  1171. }
  1172. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1173. echo json_encode($rows);exit;
  1174. }
  1175. if(isset($_SESSION['api']))
  1176. {
  1177. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1178. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1179. $this->data['wlshop'] = $wlshop;
  1180. $this->data['warehouse'] = $warehouse;
  1181. }
  1182. $this->_Template('warehouse_orderlist',$this->data);
  1183. }
  1184. public function _orderlistck()//华荣厂查看
  1185. {
  1186. $post = $this->input->post(NULL, TRUE);
  1187. if(isset($_SESSION['api']))
  1188. {
  1189. $user = $this->user->get_api($_SESSION['api']);
  1190. $usp = $user;
  1191. $fgshop = "";$sid = "";$wid="";$wtype="";
  1192. $usersp = explode('|',trim($user['shop'],'|'));
  1193. $userwh = explode('|',trim($user['warehouse'],'|'));
  1194. foreach ($usersp as $value)
  1195. {
  1196. $fgshop .= " shop = ".$value." or";
  1197. $sid .= " id = ".$value." or";
  1198. }
  1199. foreach ($userwh as $value)
  1200. {
  1201. $wid .= " id = ".$value." or";
  1202. $wtype .= " type = ".$value." or";
  1203. }
  1204. }
  1205. if(isset($post['page']))
  1206. {
  1207. $page = $this->input->post('page',true);
  1208. $perpage = $this->input->post('perpage',true);
  1209. $number = $this->input->post('number',true);
  1210. $so = $this->input->post('so',true);
  1211. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1212. if($number)
  1213. {
  1214. $where .= " and number = '$number'";
  1215. }
  1216. if($so)
  1217. {
  1218. $where .= " and shipremarks like '%$so%'";
  1219. }
  1220. if(!$so && !$number)
  1221. {
  1222. $where = "id < 0";
  1223. }
  1224. //数据排序
  1225. $order_str = "id desc";
  1226. if(empty($page))
  1227. {
  1228. $start = 0;
  1229. $perpage = 1;
  1230. }
  1231. else
  1232. {
  1233. $start = ($page - 1)*$perpage;
  1234. }
  1235. $info_list = array();
  1236. $info_listsmt = array();
  1237. $dlz = 0; $smt = 0;
  1238. //取得信息列表
  1239. $info_list = $this->fullorder->find_all($where,'id,number,shipremarks',$order_str,$start,$perpage);
  1240. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1241. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1242. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1243. //格式化数据
  1244. foreach ($rows as $key=>$value)
  1245. {
  1246. $rows[$key]['id'] = $value['id'].'-fullorder';
  1247. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1248. $systemwigsout = $this->systemwigsout->get_number($value['number']);
  1249. $wigsout = '';
  1250. if($systemwigsout)
  1251. {
  1252. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1253. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1254. $zw = array();
  1255. $t = $this->transfer->find_all("1=1");
  1256. foreach ($t as $v)
  1257. {
  1258. $zw[$v['id']] = $v['title'];
  1259. }
  1260. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1261. {
  1262. for($i=0;$i<count($cz);$i++)
  1263. {
  1264. if(!isset($cztime[$i]))
  1265. {
  1266. $wigsout .= $zw[$cz[$i]];
  1267. }
  1268. else
  1269. {
  1270. $wigsout .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).',';
  1271. }
  1272. }
  1273. }
  1274. }
  1275. $rows[$key]['systemwigsout'] = rtrim($wigsout,',');
  1276. }
  1277. $dlz = $this->fullorder->find_count($where);
  1278. $smt = $this->fullordersmt->find_count($where);
  1279. $tt = $this->fullordersmt->find_count($where);
  1280. //$total += $this->fullorder_smt->find_count($where);
  1281. $total = $dlz+$smt+$tt;
  1282. //$rows = array_slice($rows,$start,$perpage);
  1283. $pagenum = ceil($total/$perpage);
  1284. $over = $total-($start+$perpage);
  1285. $tmp = array();
  1286. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1287. echo json_encode($rows);exit;
  1288. }
  1289. if(isset($_SESSION['api']))
  1290. {
  1291. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1292. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1293. $this->data['wlshop'] = $wlshop;
  1294. $this->data['warehouse'] = $warehouse;
  1295. }
  1296. $this->_Template('warehouse_orderlistck',$this->data);
  1297. }
  1298. public function _ordersee($arg_array)
  1299. {
  1300. $arg_array = $arg_array[0];
  1301. $fullorder = 'fullorder';
  1302. $data = $this->fullorder->read($arg_array);
  1303. if(!$data)
  1304. {
  1305. $fullorder = 'fullordersmt';
  1306. $data = $this->fullordersmt->read($arg_array);
  1307. }
  1308. if(!$data)
  1309. {
  1310. $fullorder = 'fullordertt';
  1311. $data = $this->fullordertt->read($arg_array);
  1312. }
  1313. $fpdata = array();
  1314. $fullorder = $this->$fullorder->read($arg_array);
  1315. if(stripos($fullorder['fpdata'],';') !== false)
  1316. {
  1317. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  1318. foreach ($fpdata as $k=>$v)
  1319. {
  1320. $fpdata[$k] = explode('|',$v);
  1321. }
  1322. }
  1323. $systemwigsout = $this->systemwigsout->get_number($fullorder['number']);
  1324. $wigsout = array();
  1325. if($systemwigsout)
  1326. {
  1327. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1328. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1329. $zw = array();
  1330. $t = $this->transfer->find_all("1=1");
  1331. foreach ($t as $v)
  1332. {
  1333. $zw[$v['id']] = $v['title'];
  1334. }
  1335. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1336. {
  1337. for($i=0;$i<count($cz);$i++)
  1338. {
  1339. if(!isset($cztime[$i]))
  1340. {
  1341. $wigsout[] = $zw[$cz[$i]];
  1342. }
  1343. else
  1344. {
  1345. $wigsout[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]);
  1346. }
  1347. }
  1348. }
  1349. }
  1350. $this->data['systemwigsout'] = $wigsout;
  1351. $this->data['fpdata'] = $fpdata;
  1352. $this->data['data'] = $data;
  1353. $this->_Template('warehouse_ordersee',$this->data);
  1354. }
  1355. public function _orderlistexcel()
  1356. {
  1357. $post = $this->input->post(NULL, TRUE);
  1358. if(isset($_SESSION['api']))
  1359. {
  1360. $user = $this->user->get_api($_SESSION['api']);
  1361. $usp = $user;
  1362. $fgshop = "";$sid = "";$wid="";$wtype="";
  1363. $usersp = explode('|',trim($user['shop'],'|'));
  1364. $userwh = explode('|',trim($user['warehouse'],'|'));
  1365. foreach ($usersp as $value)
  1366. {
  1367. $fgshop .= " shop = ".$value." or";
  1368. $sid .= " id = ".$value." or";
  1369. }
  1370. foreach ($userwh as $value)
  1371. {
  1372. $wid .= " id = ".$value." or";
  1373. $wtype .= " type = ".$value." or";
  1374. }
  1375. }
  1376. if(isset($_GET['excel']))
  1377. {
  1378. $a = $this->input->get('a',true);
  1379. $id_is = '';$id_smt = '';
  1380. if($a)
  1381. {
  1382. $a = explode(',',rtrim($a,','));
  1383. foreach ($a as $value)
  1384. {
  1385. $v = explode('-',$value);
  1386. if($v[1] == 'fullorder')
  1387. {
  1388. $id_is .= "id = ".$v[0]." or ";
  1389. }
  1390. else
  1391. {
  1392. $id_smt .= "id = ".$v[0]." or ";
  1393. }
  1394. }
  1395. if($id_is)
  1396. {
  1397. $id_is = " and (".rtrim($id_is,'or ').")";
  1398. }
  1399. if($id_smt)
  1400. {
  1401. $id_smt = " and (".rtrim($id_smt,'or ').")";
  1402. }
  1403. }
  1404. $timetk = $this->input->get('timetk',true);
  1405. $timetj = $this->input->get('timetj',true);
  1406. $orderinfo = $this->input->get('orderinfo',true);
  1407. $number = $this->input->get('number',true);
  1408. $print = $this->input->get('print',true);
  1409. $shop = $this->input->get('shop',true);
  1410. $type = $this->input->get('type',true);
  1411. $ckfl = $this->input->get('ckfl',true);
  1412. $so = $this->input->get('so',true);
  1413. $sfxh = $this->input->get('sfxh',true);
  1414. $library = $this->input->get('library',true);
  1415. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1416. $timetk = strtotime($timetk);
  1417. $timetj = strtotime($timetj);
  1418. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1419. if($orderinfo)
  1420. {
  1421. $where .= " and orderinfo = '$orderinfo'";
  1422. }
  1423. if($number)
  1424. {
  1425. $where .= " and number = '$number'";
  1426. }
  1427. if($print)
  1428. {
  1429. $where .= " and print = '$print'";
  1430. if($print == 3)
  1431. {
  1432. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1433. }
  1434. }
  1435. if($shop)
  1436. {
  1437. $where .= " and shop = '$shop'";
  1438. }
  1439. if($type)
  1440. {
  1441. $where .= " and type = '$type'";
  1442. }
  1443. if($so)
  1444. {
  1445. $where .= " and shipremarks like '%$so%'";
  1446. }
  1447. if($ckfl)
  1448. {
  1449. $where .= " and ckfl = '$ckfl'";
  1450. }
  1451. if($library)
  1452. {
  1453. $where .= " and library = '$library'";
  1454. }
  1455. if($libraryconfirm)
  1456. {
  1457. $where .= " and libraryconfirm = '$libraryconfirm'";
  1458. }
  1459. $t = array();
  1460. $transfer = $this->transfer->find_all();
  1461. foreach ($transfer as $v)
  1462. {
  1463. $t[$v['id']] = $v['title'];
  1464. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1465. }
  1466. $order_str = ($print != 3)?"id desc":"printtime desc";
  1467. $info_list = $this->fullorder->find_all($where.$id_is,'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1468. $info_listsmt = $this->fullordersmt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1469. $info_listtt = $this->fullordertt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1470. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1471. foreach ($rows as $key=>$value)
  1472. {
  1473. if($value['printtime'] > 0)
  1474. {
  1475. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1476. }
  1477. else
  1478. {
  1479. $rows[$key]['printtime'] = '未打印';
  1480. }
  1481. if($value['library'] == 1)
  1482. {
  1483. $rows[$key]['library'] = "未出库";
  1484. }
  1485. else if($value['library'] == 2)
  1486. {
  1487. $rows[$key]['library'] = "已出库";
  1488. }
  1489. else if($value['library'] == 3)
  1490. {
  1491. $rows[$key]['printtime'] = '已退库';
  1492. }
  1493. if($value['libraryconfirm'] == 1)
  1494. {
  1495. $rows[$key]['libraryconfirm'] = '不允许出库';
  1496. }
  1497. else
  1498. {
  1499. $rows[$key]['libraryconfirm'] = '允许出库';
  1500. }
  1501. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1502. $out = '';
  1503. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1504. foreach ($tf as $k=>$v)
  1505. {
  1506. if(count($tf) > 1)
  1507. {
  1508. $out .= $k.'<br>';
  1509. }
  1510. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1511. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1512. foreach ($data as $k=>$v)
  1513. {
  1514. $type = ($v['type']==1)?'入库':'出库';
  1515. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1516. }
  1517. }
  1518. $rows[$key]['systemwigsout'] = trim($out,'<br>');
  1519. }
  1520. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'进销存详情';
  1521. $titlename = "<table border=1>
  1522. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  1523. <tr align='center'>
  1524. <td>编号</td>
  1525. <td>仓库品名</td>
  1526. <td>条数</td>
  1527. <td>打印时间</td>
  1528. <td>出库状态</td>
  1529. <td>出库确认</td>
  1530. <td>禁止出库原因</td>
  1531. <td>追踪</td>
  1532. </tr>
  1533. </table>";
  1534. $filename = $title.".xls";
  1535. $tail = "";
  1536. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1537. }
  1538. }
  1539. }