Warehouse.php 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  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. // 5*5没货的,5*7、5*9如果有货,给提醒
  633. if(stripos($cp,'-297-') !== false) //13*4 HD13*4
  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('-297-','-2062-',$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. $gpp2 = str_replace('-297-','-1254-',$newcp);
  655. $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.",%')");//通用
  656. if($ccxh >= $num[1])
  657. {
  658. $hdtx .= $v['title'].' - 5*9有货;';
  659. }
  660. }
  661. // 180%货的,200、250如果有货,给提醒
  662. if(stripos($cp,'-72-') !== false) //13*4 HD13*4
  663. {
  664. $cc1 = explode('-',trim($cc[1],'-'));
  665. $newcp = '-';
  666. foreach ($cc1 as $kk=>$vv)
  667. {
  668. if($kk == 1)
  669. {
  670. $newcp .= $vv.'-'.$cc[0].'-';
  671. }
  672. else
  673. {
  674. $newcp .= $vv.'-';
  675. }
  676. }
  677. $gpp = str_replace('-72-','-73-',$newcp);
  678. $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.",%')");//通用
  679. if($ccxh >= $num[1])
  680. {
  681. $hdtx .= $v['title'].' - 200%密度有货;';
  682. }
  683. $gpp2 = str_replace('-72-','-74-',$newcp);
  684. $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.",%')");//通用
  685. if($ccxh >= $num[1])
  686. {
  687. $hdtx .= $v['title'].' - 250%密度有货;';
  688. }
  689. }
  690. if(stripos($cp,'-73-') !== false) //200% 250%
  691. {
  692. $cc1 = explode('-',trim($cc[1],'-'));
  693. $newcp = '-';
  694. foreach ($cc1 as $kk=>$vv)
  695. {
  696. if($kk == 1)
  697. {
  698. $newcp .= $vv.'-'.$cc[0].'-';
  699. }
  700. else
  701. {
  702. $newcp .= $vv.'-';
  703. }
  704. }
  705. $gpp2 = str_replace('-73-','-74-',$newcp);
  706. $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.",%')");//通用
  707. if($ccxh >= $num[1])
  708. {
  709. $hdtx .= $v['title'].' - 250%密度有货;';
  710. }
  711. }
  712. //HD相互提醒
  713. if(stripos($cp,'-146-') !== false || stripos($cp,'-331-') !== false) //13*4 HD13*4
  714. {
  715. $cc1 = explode('-',trim($cc[1],'-'));
  716. $newcp = '-';
  717. foreach ($cc1 as $kk=>$vv)
  718. {
  719. if($kk == 1)
  720. {
  721. $newcp .= $vv.'-'.$cc[0].'-';
  722. }
  723. else
  724. {
  725. $newcp .= $vv.'-';
  726. }
  727. }
  728. if(stripos($cp,'-146-') !== false)
  729. {
  730. $gpp = str_replace('-146-','-331-',$newcp);
  731. $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.",%')");//通用
  732. if($ccxh >= $num[1])
  733. {
  734. $hdtx .= $v['title'].' - HD13*4有货;';
  735. }
  736. }
  737. else if(stripos($cp,'-331-') !== false)
  738. {
  739. $gpp = str_replace('-331-','-146-',$newcp);
  740. $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.",%')");//通用
  741. if($ccxh >= $num[1])
  742. {
  743. $hdtx .= $v['title'].' - 13*4有货;';
  744. }
  745. }
  746. }
  747. if(stripos($cp,'-322-') !== false || stripos($cp,'-341-') !== false)//13*6 HD13*6
  748. {
  749. $cc1 = explode('-',trim($cc[1],'-'));
  750. $newcp = '-';
  751. foreach ($cc1 as $kk=>$vv)
  752. {
  753. if($kk == 1)
  754. {
  755. $newcp .= $vv.'-'.$cc[0].'-';
  756. }
  757. else
  758. {
  759. $newcp .= $vv.'-';
  760. }
  761. }
  762. if(stripos($cp,'-322-') !== false)
  763. {
  764. $gpp = str_replace('-322-','-341-',$newcp);
  765. $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.",%')");//通用
  766. if($ccxh >= $num[1])
  767. {
  768. $hdtx .= $v['title'].' - HD13*6有货;';
  769. }
  770. }
  771. else if(stripos($cp,'-341-') !== false)
  772. {
  773. $gpp = str_replace('-341-','-322-',$newcp);
  774. $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.",%')");//通用
  775. if($ccxh >= $num[1])
  776. {
  777. $hdtx .= $v['title'].' - 13*6有货;';
  778. }
  779. }
  780. }
  781. if(stripos($cp,'-147-') !== false || stripos($cp,'-781-') !== false)//4*4 HD4*4
  782. {
  783. $cc1 = explode('-',trim($cc[1],'-'));
  784. $newcp = '-';
  785. foreach ($cc1 as $kk=>$vv)
  786. {
  787. if($kk == 1)
  788. {
  789. $newcp .= $vv.'-'.$cc[0].'-';
  790. }
  791. else
  792. {
  793. $newcp .= $vv.'-';
  794. }
  795. }
  796. if(stripos($cp,'-147-') !== false)
  797. {
  798. $gpp = str_replace('-147-','-781-',$newcp);
  799. $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.",%')");//通用
  800. if($ccxh >= $num[1])
  801. {
  802. $hdtx .= $v['title'].' - HD4*4有货;';
  803. }
  804. }
  805. else if(stripos($cp,'-781-') !== false)
  806. {
  807. $gpp = str_replace('-781-','-147-',$newcp);
  808. $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.",%')");//通用
  809. if($ccxh >= $num[1])
  810. {
  811. $hdtx .= $v['title'].' - 4*4有货;';
  812. }
  813. }
  814. }
  815. if(stripos($cp,'-297-') !== false || stripos($cp,'-540-') !== false)//5*5 HD5*5
  816. {
  817. $cc1 = explode('-',trim($cc[1],'-'));
  818. $newcp = '-';
  819. foreach ($cc1 as $kk=>$vv)
  820. {
  821. if($kk == 1)
  822. {
  823. $newcp .= $vv.'-'.$cc[0].'-';
  824. }
  825. else
  826. {
  827. $newcp .= $vv.'-';
  828. }
  829. }
  830. if(stripos($cp,'-297-') !== false)
  831. {
  832. $gpp = str_replace('-297-','-540-',$newcp);
  833. $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.",%')");//通用
  834. if($ccxh >= $num[1])
  835. {
  836. $hdtx .= $v['title'].' - HD5*5有货;';
  837. }
  838. }
  839. else if(stripos($cp,'-540-') !== false)
  840. {
  841. $gpp = str_replace('-540-','-297-',$newcp);
  842. $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.",%')");//通用
  843. if($ccxh >= $num[1])
  844. {
  845. $hdtx .= $v['title'].' - 5*5有货;';
  846. }
  847. }
  848. }
  849. if(stripos($cp,'-298-') !== false || stripos($cp,'-370-') !== false)//6*6 HD6*6
  850. {
  851. $cc1 = explode('-',trim($cc[1],'-'));
  852. $newcp = '-';
  853. foreach ($cc1 as $kk=>$vv)
  854. {
  855. if($kk == 1)
  856. {
  857. $newcp .= $vv.'-'.$cc[0].'-';
  858. }
  859. else
  860. {
  861. $newcp .= $vv.'-';
  862. }
  863. }
  864. if(stripos($cp,'-298-') !== false)
  865. {
  866. $gpp = str_replace('-298-','-370-',$newcp);
  867. $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.",%')");//通用
  868. if($ccxh >= $num[1])
  869. {
  870. $hdtx .= $v['title'].' - HD6*6有货;';
  871. }
  872. }
  873. else if(stripos($cp,'-370-') !== false)
  874. {
  875. $gpp = str_replace('-370-','-298-',$newcp);
  876. $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.",%')");//通用
  877. if($ccxh >= $num[1])
  878. {
  879. $hdtx .= $v['title'].' - 6*6有货;';
  880. }
  881. }
  882. }
  883. if(stripos($cp,'-935-') !== false || stripos($cp,'-854-') !== false)//#P4/27/613 #P4/613
  884. {
  885. $cc1 = explode('-',trim($cc[1],'-'));
  886. $newcp = '-';
  887. foreach ($cc1 as $kk=>$vv)
  888. {
  889. if($kk == 1)
  890. {
  891. $newcp .= $vv.'-'.$cc[0].'-';
  892. }
  893. else
  894. {
  895. $newcp .= $vv.'-';
  896. }
  897. }
  898. if(stripos($cp,'-935-') !== false)
  899. {
  900. $gpp = str_replace('-935-','-854-',$newcp);
  901. $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.",%')");//通用
  902. if($ccxh >= $num[1])
  903. {
  904. $hdtx .= $v['title'].' - #P4/613;';
  905. }
  906. }
  907. else if(stripos($cp,'-854-') !== false)
  908. {
  909. $gpp = str_replace('-854-','-935-',$newcp);
  910. $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.",%')");//通用
  911. if($ccxh >= $num[1])
  912. {
  913. $hdtx .= $v['title'].' - #P4/27/613;';
  914. }
  915. }
  916. }
  917. //HD相互提醒结束
  918. if(isset($cc[1])){
  919. $cc1 = explode('-',trim($cc[1],'-'));
  920. $newcp = '-';
  921. foreach ($cc1 as $kk=>$vv)
  922. {
  923. if($kk == 1)
  924. {
  925. $newcp .= $vv.'-'.$cc[0].'-';
  926. }
  927. else
  928. {
  929. $newcp .= $vv.'-';
  930. }
  931. }
  932. }else{
  933. //$this->logic_ding->sendToDing("仓库kcpd提醒cc".json_encode($cc).'cp'.json_encode($cp)."ccpp".json_encode($ccpp)."number:".$number);
  934. $newcp = $cc[0];
  935. }
  936. //在途库存
  937. $transportlist = $this->whlabeltransport->find_all("features = '".$newcp."' and cz = 0 and warehouse = '".$v['id']."'");
  938. $transportMsg = "";
  939. if(count($transportlist) > 0)
  940. {
  941. $transportItem = $transportlist[0];
  942. $transportMsg = "<br/>". $transportItem['sku'] . " 在途库存: <b>" . $transportItem['num'] . " </b> 预达时间: ".date("Y-m-d",$transportItem['stime']). " <br/> 备注 : " . $transportItem['text'];
  943. }
  944. }
  945. else
  946. {
  947. if($v['id'] == '5')
  948. {
  949. $mgc++;
  950. }
  951. else
  952. {
  953. $kxw .= $v['title'].';';
  954. }
  955. }
  956. }
  957. if(!isset($save[0]))//非预设仓库提醒
  958. {
  959. //$kxw .= $v['title'].';';
  960. }
  961. else
  962. {
  963. if($v['id'] == '5' && $tdxh == '0')
  964. {
  965. $kxw .= $v['title'].'(当前尺寸无货,提一档有货) ;';
  966. }
  967. if($thqd == 0 && $htpd > 0)
  968. {
  969. $kxw .= $v['title'].'(当前曲度无货,'.$thqdzh.'有货) ;';
  970. }
  971. if($wearToGo > 0)
  972. {
  973. $kxw .= $v['title'].'(ReadytoGo有货) ;';
  974. }
  975. if($hdtx != '')
  976. {
  977. $kxw .= $hdtx;
  978. }
  979. if (!empty($transportMsg)) {
  980. $kxw .= $transportMsg;
  981. }
  982. }
  983. }
  984. }
  985. if(isset($pp) && $mgc == count($pp))
  986. {
  987. $kxw .= '美国店;';
  988. }
  989. if($kxw == '可用现货仓:')
  990. {
  991. echo json_encode(array('msg'=>$kxw.'无','cs'=>$cs,'success'=>true));exit;
  992. }
  993. else
  994. {
  995. echo json_encode(array('msg'=>rtrim($kxw,';'),'success'=>true));exit;
  996. }
  997. }
  998. }
  999. public function str_replace_limit($search, $replace, $subject)
  1000. {
  1001. $pos = strpos($subject, $search);
  1002. if ($pos !== false)
  1003. {
  1004. return substr_replace($subject, $replace, $pos, strlen($search));
  1005. }
  1006. return $subject;
  1007. }
  1008. public function _orderlist()
  1009. {
  1010. $post = $this->input->post(NULL, TRUE);
  1011. if(isset($_SESSION['api']))
  1012. {
  1013. $user = $this->user->get_api($_SESSION['api']);
  1014. $usp = $user;
  1015. $fgshop = "";$sid = "";$wid="";$wtype="";
  1016. $usersp = explode('|',trim($user['shop'],'|'));
  1017. $userwh = explode('|',trim($user['warehouse'],'|'));
  1018. foreach ($usersp as $value)
  1019. {
  1020. $fgshop .= " shop = ".$value." or";
  1021. $sid .= " id = ".$value." or";
  1022. }
  1023. foreach ($userwh as $value)
  1024. {
  1025. $wid .= " id = ".$value." or";
  1026. $wtype .= " type = ".$value." or";
  1027. }
  1028. }
  1029. if(isset($post['page']))
  1030. {
  1031. $page = $this->input->post('page',true);
  1032. $perpage = $this->input->post('perpage',true);
  1033. $timetk = $this->input->post('timetk',true);
  1034. $timetj = $this->input->post('timetj',true);
  1035. $orderinfo = $this->input->post('orderinfo',true);
  1036. $number = $this->input->post('number',true);
  1037. $print = $this->input->post('print',true);
  1038. $shop = $this->input->post('shop',true);
  1039. $type = $this->input->post('type',true);
  1040. $ckfl = $this->input->post('ckfl',true);
  1041. $so = $this->input->post('so',true);
  1042. $sfxh = $this->input->post('sfxh',true);
  1043. $library = $this->input->post('library',true);
  1044. $libraryconfirm = $this->input->post('libraryconfirm',true);
  1045. $timetk = strtotime($timetk);
  1046. $timetj = strtotime($timetj);
  1047. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1048. if($orderinfo)
  1049. {
  1050. $where .= " and orderinfo = '$orderinfo'";
  1051. }
  1052. if($number)
  1053. {
  1054. $where .= " and number = '$number'";
  1055. }
  1056. if($print)
  1057. {
  1058. $where .= " and print = '$print'";
  1059. if($print == 3)
  1060. {
  1061. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1062. }
  1063. }
  1064. if($shop)
  1065. {
  1066. $where .= " and shop = '$shop'";
  1067. }
  1068. if($type)
  1069. {
  1070. $where .= " and type = '$type'";
  1071. }
  1072. if($so)
  1073. {
  1074. $where .= " and shipremarks like '%$so%'";
  1075. }
  1076. if($ckfl)
  1077. {
  1078. $where .= " and ckfl = '$ckfl'";
  1079. }
  1080. if($library)
  1081. {
  1082. $where .= " and library = '$library'";
  1083. }
  1084. if($type)
  1085. {
  1086. $where .= " and type = '$type'";
  1087. }
  1088. if($libraryconfirm)
  1089. {
  1090. $where .= " and libraryconfirm = '$libraryconfirm'";
  1091. }
  1092. //数据排序
  1093. $order_str = ($print != 3)?"id desc":"printtime desc";
  1094. if(empty($page))
  1095. {
  1096. $start = 0;
  1097. $perpage = 1;
  1098. }
  1099. else
  1100. {
  1101. $start = ($page - 1)*$perpage;
  1102. }
  1103. $t = array();
  1104. $transfer = $this->transfer->find_all();
  1105. foreach ($transfer as $v)
  1106. {
  1107. $t[$v['id']] = $v['title'];
  1108. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1109. }
  1110. //取得信息列表
  1111. $info_list = $this->fullorder->find_all($where,'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1112. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1113. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,shop,orderinfo,number,printtime,librarytime,shipremarks',$order_str,$start,$perpage);
  1114. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1115. //格式化数据
  1116. foreach ($rows as $key=>$value)
  1117. {
  1118. $rows[$key]['id'] = $value['id'].'-fullorder';
  1119. $shop = $this->shop->read($value['shop']);
  1120. $rows[$key]['shop'] = $shop['shopname'];
  1121. if($value['printtime'] > 0)
  1122. {
  1123. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1124. }
  1125. else
  1126. {
  1127. $rows[$key]['printtime'] = '未打印';
  1128. }
  1129. if(isset($value['librarytime']) && $value['librarytime'] > 0)
  1130. {
  1131. $rows[$key]['librarytime'] = date('Y-m-d H:s',$value['librarytime']);
  1132. }
  1133. else
  1134. {
  1135. $rows[$key]['librarytime'] = '未出库';
  1136. }
  1137. $rows[$key]['orderinfo'] = "<h9 class='window' data-h='/warehouse/ordersee/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p></h9>";
  1138. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1139. $out = '';
  1140. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1141. if(!empty($tf)){
  1142. if($tf[0]['is_jiaji']){
  1143. $rows[$key]['number'] = "<a href='javascript:void(0)' style='color:red'>".$rows[$key]['number']."加急!!!</a>";
  1144. }
  1145. }
  1146. foreach ($tf as $k=>$v)
  1147. {
  1148. if(count($tf) > 1)
  1149. {
  1150. $out .= $k.'<br>';
  1151. }
  1152. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1153. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1154. foreach ($data as $k=>$v)
  1155. {
  1156. $type = ($v['type']==1)?'入库':'出库';
  1157. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1158. }
  1159. }
  1160. $rows[$key]['outread'] = trim($out,'<br>');
  1161. }
  1162. $dlz = $this->fullorder->find_count($where);
  1163. $smt = $this->fullordersmt->find_count($where);
  1164. $tt = $this->fullordertt->find_count($where);
  1165. //$total += $this->fullorder_smt->find_count($where);
  1166. $total = $dlz+$smt+$tt;
  1167. //$rows = array_slice($rows,$start,$perpage);
  1168. $pagenum = ceil($total/$perpage);
  1169. $over = $total-($start+$perpage);
  1170. $tmp = array();
  1171. if($print == 3)
  1172. {
  1173. foreach ($rows as $key => $val)
  1174. {
  1175. $tmp[$key] = $val['printtime'];
  1176. }
  1177. array_multisort($tmp,SORT_DESC,$rows);
  1178. }
  1179. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1180. echo json_encode($rows);exit;
  1181. }
  1182. if(isset($_SESSION['api']))
  1183. {
  1184. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1185. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1186. $this->data['wlshop'] = $wlshop;
  1187. $this->data['warehouse'] = $warehouse;
  1188. }
  1189. $this->_Template('warehouse_orderlist',$this->data);
  1190. }
  1191. public function _orderlistck()//华荣厂查看
  1192. {
  1193. $post = $this->input->post(NULL, TRUE);
  1194. if(isset($_SESSION['api']))
  1195. {
  1196. $user = $this->user->get_api($_SESSION['api']);
  1197. $usp = $user;
  1198. $fgshop = "";$sid = "";$wid="";$wtype="";
  1199. $usersp = explode('|',trim($user['shop'],'|'));
  1200. $userwh = explode('|',trim($user['warehouse'],'|'));
  1201. foreach ($usersp as $value)
  1202. {
  1203. $fgshop .= " shop = ".$value." or";
  1204. $sid .= " id = ".$value." or";
  1205. }
  1206. foreach ($userwh as $value)
  1207. {
  1208. $wid .= " id = ".$value." or";
  1209. $wtype .= " type = ".$value." or";
  1210. }
  1211. }
  1212. if(isset($post['page']))
  1213. {
  1214. $page = $this->input->post('page',true);
  1215. $perpage = $this->input->post('perpage',true);
  1216. $number = $this->input->post('number',true);
  1217. $so = $this->input->post('so',true);
  1218. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1219. if($number)
  1220. {
  1221. $where .= " and number = '$number'";
  1222. }
  1223. if($so)
  1224. {
  1225. $where .= " and shipremarks like '%$so%'";
  1226. }
  1227. if(!$so && !$number)
  1228. {
  1229. $where = "id < 0";
  1230. }
  1231. //数据排序
  1232. $order_str = "id desc";
  1233. if(empty($page))
  1234. {
  1235. $start = 0;
  1236. $perpage = 1;
  1237. }
  1238. else
  1239. {
  1240. $start = ($page - 1)*$perpage;
  1241. }
  1242. $info_list = array();
  1243. $info_listsmt = array();
  1244. $dlz = 0; $smt = 0;
  1245. //取得信息列表
  1246. $info_list = $this->fullorder->find_all($where,'id,number,shipremarks',$order_str,$start,$perpage);
  1247. $info_listsmt = $this->fullordersmt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1248. $info_listtt = $this->fullordertt->find_all($where." and mergeid != '1'",'id,number,shipremarks',$order_str,$start,$perpage);
  1249. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1250. //格式化数据
  1251. foreach ($rows as $key=>$value)
  1252. {
  1253. $rows[$key]['id'] = $value['id'].'-fullorder';
  1254. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1255. $systemwigsout = $this->systemwigsout->get_number($value['number']);
  1256. $wigsout = '';
  1257. if($systemwigsout)
  1258. {
  1259. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1260. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1261. $zw = array();
  1262. $t = $this->transfer->find_all("1=1");
  1263. foreach ($t as $v)
  1264. {
  1265. $zw[$v['id']] = $v['title'];
  1266. }
  1267. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1268. {
  1269. for($i=0;$i<count($cz);$i++)
  1270. {
  1271. if(!isset($cztime[$i]))
  1272. {
  1273. $wigsout .= $zw[$cz[$i]];
  1274. }
  1275. else
  1276. {
  1277. $wigsout .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).',';
  1278. }
  1279. }
  1280. }
  1281. }
  1282. $rows[$key]['systemwigsout'] = rtrim($wigsout,',');
  1283. }
  1284. $dlz = $this->fullorder->find_count($where);
  1285. $smt = $this->fullordersmt->find_count($where);
  1286. $tt = $this->fullordersmt->find_count($where);
  1287. //$total += $this->fullorder_smt->find_count($where);
  1288. $total = $dlz+$smt+$tt;
  1289. //$rows = array_slice($rows,$start,$perpage);
  1290. $pagenum = ceil($total/$perpage);
  1291. $over = $total-($start+$perpage);
  1292. $tmp = array();
  1293. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($rows),'cs'=>$where);//array_merge($info_list,$info_list_smt,$info_listsmt)
  1294. echo json_encode($rows);exit;
  1295. }
  1296. if(isset($_SESSION['api']))
  1297. {
  1298. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  1299. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1300. $this->data['wlshop'] = $wlshop;
  1301. $this->data['warehouse'] = $warehouse;
  1302. }
  1303. $this->_Template('warehouse_orderlistck',$this->data);
  1304. }
  1305. public function _ordersee($arg_array)
  1306. {
  1307. $arg_array = $arg_array[0];
  1308. $fullorder = 'fullorder';
  1309. $data = $this->fullorder->read($arg_array);
  1310. if(!$data)
  1311. {
  1312. $fullorder = 'fullordersmt';
  1313. $data = $this->fullordersmt->read($arg_array);
  1314. }
  1315. if(!$data)
  1316. {
  1317. $fullorder = 'fullordertt';
  1318. $data = $this->fullordertt->read($arg_array);
  1319. }
  1320. $fpdata = array();
  1321. $fullorder = $this->$fullorder->read($arg_array);
  1322. if(stripos($fullorder['fpdata'],';') !== false)
  1323. {
  1324. $fpdata = explode(';',rtrim($fullorder['fpdata'],';'));
  1325. foreach ($fpdata as $k=>$v)
  1326. {
  1327. $fpdata[$k] = explode('|',$v);
  1328. }
  1329. }
  1330. $systemwigsout = $this->systemwigsout->get_number($fullorder['number']);
  1331. $wigsout = array();
  1332. if($systemwigsout)
  1333. {
  1334. $cz = explode('|',trim($systemwigsout['cz'],'|'));
  1335. $cztime = explode('|',trim($systemwigsout['cztime'],'|'));
  1336. $zw = array();
  1337. $t = $this->transfer->find_all("1=1");
  1338. foreach ($t as $v)
  1339. {
  1340. $zw[$v['id']] = $v['title'];
  1341. }
  1342. if($systemwigsout['cz'] != '' && count($cz) > 0)
  1343. {
  1344. for($i=0;$i<count($cz);$i++)
  1345. {
  1346. if(!isset($cztime[$i]))
  1347. {
  1348. $wigsout[] = $zw[$cz[$i]];
  1349. }
  1350. else
  1351. {
  1352. $wigsout[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]);
  1353. }
  1354. }
  1355. }
  1356. }
  1357. $this->data['systemwigsout'] = $wigsout;
  1358. $this->data['fpdata'] = $fpdata;
  1359. $this->data['data'] = $data;
  1360. $this->_Template('warehouse_ordersee',$this->data);
  1361. }
  1362. public function _orderlistexcel()
  1363. {
  1364. $post = $this->input->post(NULL, TRUE);
  1365. if(isset($_SESSION['api']))
  1366. {
  1367. $user = $this->user->get_api($_SESSION['api']);
  1368. $usp = $user;
  1369. $fgshop = "";$sid = "";$wid="";$wtype="";
  1370. $usersp = explode('|',trim($user['shop'],'|'));
  1371. $userwh = explode('|',trim($user['warehouse'],'|'));
  1372. foreach ($usersp as $value)
  1373. {
  1374. $fgshop .= " shop = ".$value." or";
  1375. $sid .= " id = ".$value." or";
  1376. }
  1377. foreach ($userwh as $value)
  1378. {
  1379. $wid .= " id = ".$value." or";
  1380. $wtype .= " type = ".$value." or";
  1381. }
  1382. }
  1383. if(isset($_GET['excel']))
  1384. {
  1385. $a = $this->input->get('a',true);
  1386. $id_is = '';$id_smt = '';
  1387. if($a)
  1388. {
  1389. $a = explode(',',rtrim($a,','));
  1390. foreach ($a as $value)
  1391. {
  1392. $v = explode('-',$value);
  1393. if($v[1] == 'fullorder')
  1394. {
  1395. $id_is .= "id = ".$v[0]." or ";
  1396. }
  1397. else
  1398. {
  1399. $id_smt .= "id = ".$v[0]." or ";
  1400. }
  1401. }
  1402. if($id_is)
  1403. {
  1404. $id_is = " and (".rtrim($id_is,'or ').")";
  1405. }
  1406. if($id_smt)
  1407. {
  1408. $id_smt = " and (".rtrim($id_smt,'or ').")";
  1409. }
  1410. }
  1411. $timetk = $this->input->get('timetk',true);
  1412. $timetj = $this->input->get('timetj',true);
  1413. $orderinfo = $this->input->get('orderinfo',true);
  1414. $number = $this->input->get('number',true);
  1415. $print = $this->input->get('print',true);
  1416. $shop = $this->input->get('shop',true);
  1417. $type = $this->input->get('type',true);
  1418. $ckfl = $this->input->get('ckfl',true);
  1419. $so = $this->input->get('so',true);
  1420. $sfxh = $this->input->get('sfxh',true);
  1421. $library = $this->input->get('library',true);
  1422. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1423. $timetk = strtotime($timetk);
  1424. $timetj = strtotime($timetj);
  1425. $where = (isset($_SESSION['api']))?"(".rtrim($fgshop,'or').") and (".rtrim($wtype,'or').")":"id = '0'";
  1426. if($orderinfo)
  1427. {
  1428. $where .= " and orderinfo = '$orderinfo'";
  1429. }
  1430. if($number)
  1431. {
  1432. $where .= " and number = '$number'";
  1433. }
  1434. if($print)
  1435. {
  1436. $where .= " and print = '$print'";
  1437. if($print == 3)
  1438. {
  1439. $where .= " and printtime > '$timetk' and printtime < '$timetj'";
  1440. }
  1441. }
  1442. if($shop)
  1443. {
  1444. $where .= " and shop = '$shop'";
  1445. }
  1446. if($type)
  1447. {
  1448. $where .= " and type = '$type'";
  1449. }
  1450. if($so)
  1451. {
  1452. $where .= " and shipremarks like '%$so%'";
  1453. }
  1454. if($ckfl)
  1455. {
  1456. $where .= " and ckfl = '$ckfl'";
  1457. }
  1458. if($library)
  1459. {
  1460. $where .= " and library = '$library'";
  1461. }
  1462. if($libraryconfirm)
  1463. {
  1464. $where .= " and libraryconfirm = '$libraryconfirm'";
  1465. }
  1466. $t = array();
  1467. $transfer = $this->transfer->find_all();
  1468. foreach ($transfer as $v)
  1469. {
  1470. $t[$v['id']] = $v['title'];
  1471. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1472. }
  1473. $order_str = ($print != 3)?"id desc":"printtime desc";
  1474. $info_list = $this->fullorder->find_all($where.$id_is,'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1475. $info_listsmt = $this->fullordersmt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1476. $info_listtt = $this->fullordertt->find_all($where.$id_smt." and mergeid != '1'",'number,shipremarks,ts,printtime,library,libraryconfirm,librarynot,systemwigsout',$order_str);
  1477. $rows = array_merge($info_list,$info_listsmt,$info_listtt);
  1478. foreach ($rows as $key=>$value)
  1479. {
  1480. if($value['printtime'] > 0)
  1481. {
  1482. $rows[$key]['printtime'] = date('Y-m-d H:s',$value['printtime']);
  1483. }
  1484. else
  1485. {
  1486. $rows[$key]['printtime'] = '未打印';
  1487. }
  1488. if($value['library'] == 1)
  1489. {
  1490. $rows[$key]['library'] = "未出库";
  1491. }
  1492. else if($value['library'] == 2)
  1493. {
  1494. $rows[$key]['library'] = "已出库";
  1495. }
  1496. else if($value['library'] == 3)
  1497. {
  1498. $rows[$key]['printtime'] = '已退库';
  1499. }
  1500. if($value['libraryconfirm'] == 1)
  1501. {
  1502. $rows[$key]['libraryconfirm'] = '不允许出库';
  1503. }
  1504. else
  1505. {
  1506. $rows[$key]['libraryconfirm'] = '允许出库';
  1507. }
  1508. $rows[$key]['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['shipremarks']);
  1509. $out = '';
  1510. $tf = $this->systemtransfer->find_all("number = '".$value['number']."'");
  1511. foreach ($tf as $k=>$v)
  1512. {
  1513. if(count($tf) > 1)
  1514. {
  1515. $out .= $k.'<br>';
  1516. }
  1517. $data = $this->systemtransfer_cr->find_all("fid = '".$v['id']."'");
  1518. $out = "订单打印 :".date('Y-m-d H:i',$value['printtime']).'<br>';
  1519. foreach ($data as $k=>$v)
  1520. {
  1521. $type = ($v['type']==1)?'入库':'出库';
  1522. $out .= $t[$v['lx']].$type.' :'.date('Y-m-d H:i',$v['time']).'<br>';
  1523. }
  1524. }
  1525. $rows[$key]['systemwigsout'] = trim($out,'<br>');
  1526. }
  1527. $title = date('Y-m-d',$timetk).'至'.date('Y-m-d',$timetj).'进销存详情';
  1528. $titlename = "<table border=1>
  1529. <tr><th colspan='9' align='center'><h3>".$title."<h3></th></tr>
  1530. <tr align='center'>
  1531. <td>编号</td>
  1532. <td>仓库品名</td>
  1533. <td>条数</td>
  1534. <td>打印时间</td>
  1535. <td>出库状态</td>
  1536. <td>出库确认</td>
  1537. <td>禁止出库原因</td>
  1538. <td>追踪</td>
  1539. </tr>
  1540. </table>";
  1541. $filename = $title.".xls";
  1542. $tail = "";
  1543. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1544. }
  1545. }
  1546. }