Warehouse.php 56 KB

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