Warehouse.php 50 KB

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