Warehouse.php 54 KB

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