Warehouse.php 51 KB

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