Warehouse.php 51 KB

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