Warehouse.php 51 KB

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