Warehouse.php 53 KB

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