Whlabel_bh.php 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Whlabel_bh extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  7. $this->load->_model('Model_warehouse','warehouse');
  8. $this->load->_model('Model_purchase','purchase');
  9. $this->load->_model('Model_excel','excel');
  10. $this->load->_model('Model_fullorder','fullorder');
  11. $this->load->_model('Model_fullordertt','fullordertt');
  12. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_shop','shop');
  16. $this->load->_model('Model_typeclass','typeclass');
  17. $this->load->_model('Model_country','country');
  18. $this->load->_model('Model_warehouse','warehouse');
  19. $this->load->_model('Model_kdniao','kdniao');
  20. $this->load->_model('Model_notice','notice');
  21. $this->load->_model('Model_dhl','dhl');
  22. $this->load->_model('Model_shop','shop');
  23. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  24. $this->load->_model('Model_ljg','ljg');
  25. $this->load->_model('Model_usps','usps');
  26. $this->load->_model('Model_specialstock','specialstock');
  27. $this->load->_model('Model_whlabellabel','whlabellabel');
  28. $this->load->_model('Model_whlabelwz','whlabelwz');
  29. $this->load->_model('Model_whlabelbarcode','whlabelbarcode');
  30. $this->load->_model('Model_whlabeltransport','whlabeltransport');
  31. $this->load->_model('Model_orderurl','orderurl');
  32. $this->load->_model('Model_brand','brand');
  33. $this->load->_model('Model_classid','classid');
  34. $this->load->_model('Model_apiyy','apiyy');
  35. $this->load->_model('Model_whlabel_bh_list','whlabel_bh_list');
  36. $this->load->_model('Model_whlabel','whlabel');
  37. $this->load->_model('Model_whlabel_bh_transfer','whlabel_bh_transfer');
  38. $this->load->_model('Model_transfer','transfer');
  39. }
  40. //定义方法的调用规则 获取URI第二段值
  41. public function _remap($arg,$arg_array)
  42. {
  43. if($arg == 'add')
  44. {
  45. $this->_add();
  46. }
  47. else if($arg == 'edit')
  48. {
  49. $this->_edit($arg_array);
  50. }
  51. else if($arg == 'del')//删除
  52. {
  53. $this->_del();
  54. }
  55. else if($arg == 'deltransfer')//删除
  56. {
  57. $this->_deltransfer();
  58. }
  59. else if($arg == 'cz')//删除
  60. {
  61. $this->_cz();
  62. }
  63. else if($arg == 'db')//删除
  64. {
  65. $this->_db();
  66. }
  67. else if($arg == 'kc')//删除
  68. {
  69. $this->_kc();
  70. }
  71. else if($arg == 'excel')//删除
  72. {
  73. $this->_excel();
  74. }
  75. else if($arg == 'xxpl')//删除
  76. {
  77. $this->_xxpl();
  78. }
  79. else if($arg == 'bbprint')//删除
  80. {
  81. $this->_bbprint();
  82. }
  83. else if($arg == 'operate')
  84. {
  85. $this->_operate();
  86. }
  87. else if($arg == 'out')
  88. {
  89. $this->_out();
  90. }
  91. else if($arg == 'bdbb')
  92. {
  93. $this->_bdbb();
  94. }
  95. else
  96. {
  97. $this->_index();
  98. }
  99. }
  100. //管理
  101. public function _index()
  102. {
  103. $post = $this->input->post(NULL, TRUE);
  104. if(isset($post['page']))
  105. {
  106. $page = $this->input->post('page',true);
  107. $perpage = $this->input->post('perpage',true);
  108. $orderinfo = $this->input->post('orderinfo',true);
  109. $jm = $this->input->post('jm',true);
  110. $title = $this->input->post('title',true);
  111. $pm = $this->input->post('pm',true);
  112. $category = $this->input->post('category',true);
  113. $size = $this->input->post('size',true);
  114. $grade = $this->input->post('grade',true);
  115. $color = $this->input->post('color',true);
  116. $lowe = $this->input->post('lowe',true);
  117. $type = $this->input->post('type',true);
  118. $shipremarks = $this->input->post('shipremarks',true);
  119. $type = $this->input->post('type',true);
  120. $state = $this->input->post('state',true);
  121. $timetk = $this->input->post('timetk',true);
  122. $timetj = $this->input->post('timetj',true);
  123. $timetk = strtotime($timetk);
  124. $timetj = strtotime($timetj);
  125. $where = "1=1 ";
  126. if($timetk && $timetj)
  127. {
  128. $where .= " and time > '$timetk' and time < '$timetj'";
  129. }
  130. if($orderinfo)
  131. {
  132. $where .= " and orderinfo like '%$orderinfo%'";
  133. }
  134. if($type != '')
  135. {
  136. $where .= " and type = '$type'";
  137. }
  138. if($jm)
  139. {
  140. $where .= " and jm like '%$jm%'";
  141. }
  142. if($title)
  143. {
  144. $where .= " and title like '%$title%'";
  145. }
  146. if($pm)
  147. {
  148. $where .= " and pm like '%$pm%'";
  149. }
  150. if($category)
  151. {
  152. $where .= " and shipremarks like '%-$category-%'";
  153. }
  154. if($size)
  155. {
  156. $where .= " and shipremarks like '%-$size-%'";
  157. }
  158. if($grade)
  159. {
  160. $where .= " and shipremarks like '%-$grade-%'";
  161. }
  162. if($color)
  163. {
  164. $where .= " and shipremarks like '%-$color-%'";
  165. }
  166. if($lowe)
  167. {
  168. $where .= " and shipremarks like '%-$lowe-%'";
  169. }
  170. if($type)
  171. {
  172. $where .= " and type = '$type'";
  173. }
  174. if($state)
  175. {
  176. $where .= " and state = '$state'";
  177. }
  178. if($shipremarks)
  179. {
  180. $where .= " and shipremarks like '%$shipremarks%'";
  181. }
  182. //数据排序
  183. $order_str = "time desc";
  184. if(empty($page))
  185. {
  186. $start = 0;
  187. $perpage = 1;
  188. }
  189. else
  190. {
  191. $start = ($page - 1)*$perpage;
  192. }
  193. $warehouse = $this->warehouse->find_all();
  194. $ck = array();
  195. foreach ($warehouse as $v)
  196. {
  197. $ck[$v['id']] = $v['title'];
  198. }
  199. //取得信息列表
  200. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,printnum,num,time,cscg',$order_str,$start,$perpage);
  201. foreach ($info_list as $key=>$value)
  202. {
  203. $d = $this->whlabel_bh->read($value['id']);
  204. $info_list[$key]['title'] = "<font data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>".$d['jm'].'</font><br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  205. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$d['number']."'");
  206. $printnum = array_sum(array_column($printnum,'ts'));
  207. $info_list[$key]['printnum'] = $printnum;
  208. $info_list[$key]['num'] = $value['bhnum']-$printnum;
  209. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  210. $info_list[$key]['cscg'] = "<span data-id='".$value['id']."' data-num='".$value['bhnum']."' class='whlabel_bh_print'>打印布标</span>";
  211. }
  212. $total = $this->whlabel_bh->find_count($where);
  213. $pagenum = ceil($total/$perpage);
  214. $over = $total-($start+$perpage);
  215. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  216. echo json_encode($rows);exit;
  217. /**
  218. $info_list = $this->whlabel_bh->find_all($where,'id,orderinfo,title,shipremarks,bhnum,kcnum,num,rknum,dbnum,state,time,scapi,dbapi',$order_str,$start,$perpage);
  219. foreach ($info_list as $key=>$value)
  220. {
  221. $d = $this->whlabel_bh->read($value['id']);
  222. if($d['print'] == 0)
  223. {
  224. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #2ca8a1;'>未打印</span></p>";
  225. }
  226. else
  227. {
  228. $print = "<p style='margin-top:15px;'><span data-id='".$value['id']."' data-num='".$value['num']."' class='whlabel_bh_print' style='background: #999;'>已打印</span></p>";
  229. }
  230. if($value['state'] == 0)
  231. {
  232. $info_list[$key]['state'] = "<p>待生产/外购</p><p><span data-id='".$value['id']."' data-cz='0' class='whlabel_bh_cz'>传输料号</span></p>";//开 始
  233. }
  234. else if($value['state'] == 1)
  235. {
  236. $info_list[$key]['state'] = "<p>生产/外购中</p><p><span data-id='".$value['id']."' data-cz='1' class='whlabel_bh_ks'>完成入库</span></p>".$print;
  237. }
  238. else if($value['state'] == 2)
  239. {
  240. $info_list[$key]['state'] = "<p>已完成</p><p>已全部入库</p>";
  241. }
  242. $info_list[$key]['time'] = date('Y-m-d',$value['time']).'<br>'.date('H:i:s',$value['time']);
  243. $info_list[$key]['title'] = $d['jm'].'<br><strong style="color:#fc5454;font-weight: bold;">'.$d['pm'].'</strong><br>'.$value['title'];
  244. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  245. $zc = '';
  246. foreach ($zd as $v)
  247. {
  248. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  249. }
  250. $info_list[$key]['scapi'] = $zc;
  251. $info_list[$key]['dbapi'] = "<span data-id='".$value['id']."' class='whlabel_bh_db'>调拨出库</span>";
  252. $info_list[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  253. }
  254. **/
  255. }
  256. if(isset($_SESSION['api']))
  257. {
  258. $user = $this->user->get_api($_SESSION['api']);
  259. }
  260. else
  261. {
  262. header('Location: /');exit;
  263. }
  264. $w = $this->shop->find_all("yyid != ''");
  265. $this->data['yyck'] = $w;
  266. if($user['userid'] == 'ch')
  267. {
  268. $user['vip'] = 1;
  269. }
  270. $this->data['vip'] = $user['vip'];
  271. $this->_Template('whlabel_bh',$this->data);
  272. }
  273. //入库操作
  274. public function _add()
  275. {
  276. $tc = $this->typeclass->find_all();
  277. $typeclass = array();
  278. foreach ($tc as $v)
  279. {
  280. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  281. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  282. }
  283. $post = $this->input->post(NULL, TRUE);
  284. if(isset($post['num']))
  285. {
  286. $list = array();
  287. $sku = $this->input->post('sku',true);
  288. $category = $this->input->post('category',true);
  289. $list['category'] = $category;
  290. $list['hairtype'] = $this->input->post('hairtype',true);
  291. $list['grade'] = $this->input->post('grade',true);
  292. $size = $this->input->post('size',true);
  293. $xzsku = $this->input->post('xzsku',true);
  294. $list['size'] = rtrim($size,',');
  295. $list['hairnumber'] = $this->input->post('hairnumber',true);
  296. $list['extension'] = $this->input->post('extension',true);
  297. if($category == 1297)
  298. {
  299. $list['sywignumber'] = $this->input->post('sywignumber',true);
  300. }
  301. if($category == 1702)
  302. {
  303. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  304. $list['syother'] = $this->input->post('syother',true);
  305. }
  306. if($category == 133)
  307. {
  308. $list['fittype'] = $this->input->post('fittype',true);
  309. $list['acother'] = $this->input->post('acother',true);
  310. }
  311. $list['color'] = $this->input->post('color',true);
  312. $list['lowe'] = $this->input->post('lowe',true);
  313. if($category == 127)
  314. {
  315. $list['type'] = $this->input->post('type',true);
  316. $list['headroad'] = $this->input->post('headroad',true);
  317. $list['density'] = $this->input->post('density',true);
  318. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  319. {
  320. $list['lacesize'] = $this->input->post('lacesize',true);
  321. }
  322. $list['lacecolor'] = $this->input->post('lacecolor',true);
  323. $list['lacetypes'] = $this->input->post('lacetypes',true);
  324. }
  325. if($category == 128)
  326. {
  327. $list['lacetype'] = $this->input->post('lacetype',true);
  328. $list['haircap'] = $this->input->post('haircap',true);
  329. $list['density'] = $this->input->post('density',true);
  330. $list['lacecolor'] = $this->input->post('lacecolor',true);
  331. $list['lacetypes'] = $this->input->post('lacetypes',true);
  332. $list['wigother'] = $this->input->post('wigother',true);
  333. $list['wigother2'] = $this->input->post('wigother2',true);
  334. }
  335. if($category == 129)
  336. {
  337. $list['wide'] = $this->input->post('wide',true);
  338. }
  339. if($category == 131)
  340. {
  341. $list['gifttype'] = $this->input->post('gifttype',true);
  342. $list['giftother'] = $this->input->post('giftother',true);
  343. }
  344. if($category == 134)
  345. {
  346. $list['pieceweight'] = $this->input->post('pieceweight',true);
  347. }
  348. if($category == 1297)
  349. {
  350. $list['synthetictype'] = $this->input->post('synthetictype',true);
  351. $list['sywigother'] = $this->input->post('sywigother',true);
  352. }
  353. if($category == 130 || $category == 133 || $category == 1702)
  354. {
  355. $list['items'] = $this->input->post('items',true);
  356. $list['weight'] = $this->input->post('weight',true);
  357. }
  358. if($category == 1702)
  359. {
  360. $list['syhairther'] = $this->input->post('syhairther',true);
  361. }
  362. $classid = $this->classid->sku();
  363. $pm = $classid;
  364. $jm = $classid;
  365. $sku = $sku;
  366. $title = '';$features = '';$cs = array();
  367. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  368. foreach($list as $k=>$v)
  369. {
  370. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  371. {
  372. if($typeclass[$v]['bm'] != '')
  373. {
  374. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  375. }
  376. }
  377. if($v != 0)
  378. {
  379. if($k != 'size')
  380. {
  381. $title .= $typeclass[$v]['title']." ";
  382. }
  383. $features .=$v.'-';
  384. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  385. if(isset($pm[$typeclass[$v]['classid']]))
  386. {
  387. if($typeclass[$v]['title'] == '9A')
  388. {
  389. $pm[$typeclass[$v]['classid']] = '9A';
  390. }
  391. else if($typeclass[$v]['title'] == '10A')
  392. {
  393. $pm[$typeclass[$v]['classid']] = '10A';
  394. }
  395. else
  396. {
  397. $clzh = $typeclass[$v]['zh'];
  398. if(stripos($typeclass[$v]['zh'],'|') !== false)
  399. {
  400. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  401. $clzh = $clzh[0];
  402. }
  403. $pm[$typeclass[$v]['classid']] = $clzh;
  404. }
  405. }
  406. if(isset($jm[$typeclass[$v]['classid']]))
  407. {
  408. if($typeclass[$v]['jm'])
  409. {
  410. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  411. }
  412. }
  413. }
  414. }
  415. $jm = array_filter($jm);//去除空值
  416. $jm = implode("-",$jm);
  417. $sku = array_filter($sku);//去除空值
  418. $sku = implode("-",$sku);
  419. $pm = array_filter($pm);//去除空值
  420. $pm = implode(" ",$pm);
  421. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  422. if($list['size'])
  423. {
  424. $typeclass = $this->typeclass->read($list['size']);
  425. $title .= $typeclass['title'];
  426. }
  427. $title = trim($title,' ');
  428. $post['num'] = $this->input->post('num',true);
  429. $ztime = $this->input->post('ztime',true);
  430. $post['ztime'] = strtotime($ztime);
  431. $post['bm'] = '03'.implode("",$bmpx);
  432. $post['jm'] = $jm;
  433. $post['sku'] = $sku;
  434. $post['pm'] = $pm;
  435. $post['title'] = $title;
  436. $post['features'] = '-'.$features;
  437. $post['number'] = date('YmdHis',time()).rand(100,999);
  438. if(!$post['num'])
  439. {
  440. $post['number'] = date("YmdHis").rand(100,999);
  441. }
  442. $time = time();
  443. $post['time'] = $time;//操作时间
  444. $post['printnum'] = $time;
  445. $post['type'] = 0;
  446. //传输料号开始
  447. $lc = 0;
  448. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  449. if(isset($lh['Data'][0]))
  450. {
  451. if($lh['Data'][0]['m_isSucess'] != 1)
  452. {
  453. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  454. {
  455. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  456. }
  457. }
  458. }
  459. else
  460. {
  461. echo json_encode(array('msg'=>'料号错误','cs'=>$lh,'success'=>false));exit;
  462. }
  463. if($this->whlabel_bh->insert($post))
  464. {
  465. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  466. }
  467. else
  468. {
  469. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  470. }
  471. }
  472. $w = $this->shop->find_all("yyid != ''");
  473. $this->data['yyck'] = $w;
  474. $purchase = $this->purchase->find_all("yyid != ''");
  475. $this->data['purchase'] = $purchase;
  476. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  477. $this->_Template('whlabel_bh_add',$this->data);
  478. }
  479. public function get_cjlp($data)//创建料品
  480. {
  481. $list["0"]["Code"] = $data['jm'];//料号,SKU
  482. $list["0"]["Code1"] = '';
  483. $list["0"]["Name"] = $data['zh'];//产品名称
  484. $list["0"]["MainItemCategory"]["Code"] = $data['bm'];
  485. $list["0"]["Org"]["Code"] = 001;
  486. $list["0"]["OtherID"] = 1;
  487. $list["0"]["PurchaseInfo"]["BudgetControlType"] = -1;
  488. $list["0"]["PurchaseInfo"]["PriceSource"] = 2;
  489. $list["0"]["PurchaseInfo"]["InquireRule"] = -1;
  490. $list["0"]["PurchaseInfo"]["InquireFixedPeriod"] = 0;
  491. $list["0"]["PurchaseInfo"]["StatisticPeriod"] = -1;
  492. $list["0"]["PurchaseInfo"]["IsPUTradePathModify"] = true;
  493. $list["0"]["PurchaseInfo"]["IsPURtnTradePathModify"] = true;
  494. $list["0"]["InventoryUOM"]["Code"] = '条';
  495. $list["0"]["InventorySecondUOM"]["Code"] = '';
  496. $list["0"]["IsDualUOM"] = false;
  497. $list["0"]["InventoryInfo"]["InventoryPlanningMethod"] = 4;
  498. $list["0"]["InventoryInfo"]["InventoryPlanTime"] = -1;
  499. $list["0"]["InventoryInfo"]["TurnOverRate"] = 1;
  500. $list["0"]["InventoryInfo"]["ReserveMode"] = -1;
  501. $list["0"]["InventoryInfo"]["SupplyMethod"] = -1;
  502. $list["0"]["DescFlexField"]["PrivateDescSeg1"] = 01;
  503. $list["0"]["DescFlexField"]["PubDescSeg5"] = 01;
  504. $list["0"]["Description"] = $data['title'];
  505. $list["0"]["ItemForm"] = 2001;
  506. $list["0"]["ItemFormAttribute"] = 10;
  507. $list["0"]["IsInventoryEnable"] = true;
  508. $list["0"]["IsPurchaseEnable"] = true;
  509. $list["0"]["IsSalesEnable"] = true;
  510. $list["0"]["IsBuildEnable"] = true;
  511. $list["0"]["IsOutsideOperationEnable"] = true;
  512. $list["0"]["IsMRPEnable"] = true;
  513. $list["0"]["IsBOMEnable"] = true;
  514. $list["0"]["IsCostCalByGrade"] = false;
  515. $list["0"]["IsCostCalByPotency"] = false;
  516. $list["0"]["IsGradeControl"] = false;
  517. $list["0"]["StandardGrade"] = -1;
  518. $list["0"]["StartGrade"] = -1;
  519. $list["0"]["EndGrade"] = -1;
  520. $list["0"]["IsPotencyControl"] = false;
  521. $list["0"]["StandardPotency"] = -1;
  522. $list["0"]["StartPotency"] = -1;
  523. $list["0"]["EndPotency"] = -1;
  524. $asd = $list;
  525. $list = json_encode($list);
  526. $token = $this->setting->get_yytoken_130();
  527. $url = 'http://172.31.105.167/U9C/webapi/ItemMaster/Create';
  528. $header[] = "Content-Type: application/json";
  529. $header[] = "Token: ".$token;
  530. $ch = curl_init();
  531. curl_setopt($ch, CURLOPT_URL, $url);
  532. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  533. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  534. curl_setopt($ch, CURLINFO_HEADER_OUT, TRUE);
  535. curl_setopt($ch, CURLOPT_POST, 1);
  536. curl_setopt($ch, CURLOPT_POSTFIELDS, $list);
  537. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  538. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  539. $res = curl_exec($ch);
  540. $res = json_decode($res,true);
  541. return $asd;
  542. }
  543. //修改产品
  544. public function _edit($arg_array)
  545. {
  546. $tc = $this->typeclass->find_all();
  547. $typeclass = array();
  548. foreach ($tc as $v)
  549. {
  550. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  551. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  552. }
  553. $post = $this->input->post(NULL, TRUE);
  554. if(isset($post['id']))
  555. {
  556. $id = $this->input->post('id',true);
  557. $list = array();
  558. $sku = $this->input->post('sku',true);
  559. $category = $this->input->post('category',true);
  560. $list['category'] = $category;
  561. $list['hairtype'] = $this->input->post('hairtype',true);
  562. $list['grade'] = $this->input->post('grade',true);
  563. $size = $this->input->post('size',true);
  564. $xzsku = $this->input->post('xzsku',true);
  565. $list['size'] = rtrim($size,',');
  566. $list['hairnumber'] = $this->input->post('hairnumber',true);
  567. $list['extension'] = $this->input->post('extension',true);
  568. if($category == 1297)
  569. {
  570. $list['sywignumber'] = $this->input->post('sywignumber',true);
  571. }
  572. if($category == 1702)
  573. {
  574. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  575. $list['syother'] = $this->input->post('syother',true);
  576. }
  577. if($category == 133)
  578. {
  579. $list['fittype'] = $this->input->post('fittype',true);
  580. $list['acother'] = $this->input->post('acother',true);
  581. }
  582. $list['color'] = $this->input->post('color',true);
  583. $list['lowe'] = $this->input->post('lowe',true);
  584. if($category == 127)
  585. {
  586. $list['type'] = $this->input->post('type',true);
  587. $list['headroad'] = $this->input->post('headroad',true);
  588. $list['density'] = $this->input->post('density',true);
  589. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  590. {
  591. $list['lacesize'] = $this->input->post('lacesize',true);
  592. }
  593. $list['lacecolor'] = $this->input->post('lacecolor',true);
  594. $list['lacetypes'] = $this->input->post('lacetypes',true);
  595. }
  596. if($category == 128)
  597. {
  598. $list['lacetype'] = $this->input->post('lacetype',true);
  599. $list['haircap'] = $this->input->post('haircap',true);
  600. $list['density'] = $this->input->post('density',true);
  601. $list['lacecolor'] = $this->input->post('lacecolor',true);
  602. $list['lacetypes'] = $this->input->post('lacetypes',true);
  603. $list['wigother'] = $this->input->post('wigother',true);
  604. $list['wigother2'] = $this->input->post('wigother2',true);
  605. }
  606. if($category == 129)
  607. {
  608. $list['wide'] = $this->input->post('wide',true);
  609. }
  610. if($category == 131)
  611. {
  612. $list['gifttype'] = $this->input->post('gifttype',true);
  613. $list['giftother'] = $this->input->post('giftother',true);
  614. }
  615. if($category == 134)
  616. {
  617. $list['pieceweight'] = $this->input->post('pieceweight',true);
  618. }
  619. if($category == 1297)
  620. {
  621. $list['synthetictype'] = $this->input->post('synthetictype',true);
  622. $list['sywigother'] = $this->input->post('sywigother',true);
  623. }
  624. if($category == 130 || $category == 133 || $category == 1702)
  625. {
  626. $list['items'] = $this->input->post('items',true);
  627. $list['weight'] = $this->input->post('weight',true);
  628. }
  629. if($category == 1702)
  630. {
  631. $list['syhairther'] = $this->input->post('syhairther',true);
  632. }
  633. $classid = $this->classid->sku();
  634. $pm = $classid;
  635. $jm = $classid;
  636. $sku = $sku;
  637. $title = '';$features = '';$cs = array();
  638. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  639. foreach($list as $k=>$v)
  640. {
  641. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  642. {
  643. if($typeclass[$v]['bm'] != '')
  644. {
  645. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  646. }
  647. }
  648. if($v != 0)
  649. {
  650. if($k != 'size')
  651. {
  652. $title .= $typeclass[$v]['title']." ";
  653. }
  654. $features .=$v.'-';
  655. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  656. if(isset($pm[$typeclass[$v]['classid']]))
  657. {
  658. if($typeclass[$v]['title'] == '9A')
  659. {
  660. $pm[$typeclass[$v]['classid']] = '9A';
  661. }
  662. else if($typeclass[$v]['title'] == '10A')
  663. {
  664. $pm[$typeclass[$v]['classid']] = '10A';
  665. }
  666. else
  667. {
  668. $clzh = $typeclass[$v]['zh'];
  669. if(stripos($typeclass[$v]['zh'],'|') !== false)
  670. {
  671. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  672. $clzh = $clzh[0];
  673. }
  674. $pm[$typeclass[$v]['classid']] = $clzh;
  675. }
  676. }
  677. if(isset($jm[$typeclass[$v]['classid']]))
  678. {
  679. if($typeclass[$v]['jm'])
  680. {
  681. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  682. }
  683. }
  684. }
  685. }
  686. $jm = array_filter($jm);//去除空值
  687. $jm = implode("-",$jm);
  688. $sku = array_filter($sku);//去除空值
  689. $sku = implode("-",$sku);
  690. $pm = array_filter($pm);//去除空值
  691. $pm = implode(" ",$pm);
  692. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  693. if($list['size'])
  694. {
  695. $typeclass = $this->typeclass->read($list['size']);
  696. $title .= $typeclass['title'];
  697. }
  698. $title = trim($title,' ');
  699. $post['num'] = $this->input->post('num',true);
  700. $ztime = $this->input->post('ztime',true);
  701. $post['ztime'] = strtotime($ztime);
  702. $post['bm'] = '03'.implode("",$bmpx);
  703. $post['jm'] = $jm;
  704. $post['sku'] = $sku;
  705. $post['pm'] = $pm;
  706. $post['title'] = $title;
  707. $post['features'] = '-'.$features;
  708. $ztime = $this->input->post('ztime',true);
  709. if($ztime)
  710. {
  711. $post['ztime'] = strtotime($ztime);
  712. }
  713. if($this->whlabel_bh->save($post,$id))
  714. {
  715. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  716. }
  717. else
  718. {
  719. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  720. }
  721. }
  722. $w = $this->shop->find_all("yyid != ''");
  723. $this->data['yyck'] = $w;
  724. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  725. $this->data['whlabel_bh'] = $whlabel_bh ;
  726. $purchase = $this->purchase->find_all("yyid != ''");
  727. $this->data['purchase'] = $purchase;
  728. $this->_Template('whlabel_bh_edit',$this->data);
  729. }
  730. public function _cz()
  731. {
  732. $post = $this->input->post(NULL, TRUE);
  733. if(isset($post['id']))
  734. {
  735. $id = $this->input->post('id',true);
  736. $cz = $this->input->post('cz',true);
  737. $num = $this->input->post('num',true);
  738. $cz = $cz+1;
  739. $w = $this->whlabel_bh->read($id);
  740. if(!$w)
  741. {
  742. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  743. }
  744. //传输料号开始
  745. $lc = 0;
  746. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  747. if(isset($lh['Data'][0]))
  748. {
  749. if($lh['Data'][0]['m_isSucess'] != 1)
  750. {
  751. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  752. {
  753. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  754. }
  755. }
  756. }
  757. else
  758. {
  759. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  760. }
  761. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'bm'=>$w['bm'],'success'=>true));
  762. /** 投产
  763. if($w['scapi'] != 99)
  764. {
  765. if($w['state'] == $cz)
  766. {
  767. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  768. }
  769. if($w['type'] == '0')
  770. {
  771. $type = '生产';
  772. $bhlx = 0;
  773. }
  774. else
  775. {
  776. $type = '外购';
  777. $bhlx = 1;
  778. }
  779. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  780. if($yy['c'] == 0)
  781. {
  782. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  783. {
  784. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  785. }
  786. else
  787. {
  788. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  789. }
  790. }
  791. else
  792. {
  793. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  794. }
  795. }
  796. else if($w['dbapi'] != 99 && $w['type'] == '0')
  797. {
  798. $cz = 1;
  799. if(!is_numeric($num))
  800. {
  801. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  802. }
  803. if($num > $w['num']-$w['rknum'])
  804. {
  805. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  806. }
  807. if($w['rknum']+$num == $w['num'])
  808. {
  809. $dbapi = 99;
  810. $cz = 2;
  811. }
  812. else
  813. {
  814. $dbapi = 0;
  815. }
  816. $w['ts'] = $num;
  817. $rk = $this->apiyy->_newrk($w);
  818. if($rk['c'] == 0)
  819. {
  820. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  821. {
  822. if($dbapi == 99)
  823. {
  824. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  825. }
  826. else
  827. {
  828. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  829. }
  830. }
  831. else
  832. {
  833. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  834. }
  835. }
  836. else
  837. {
  838. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  839. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  840. }
  841. }
  842. else if($w['dbapi'] != 99 && $w['type'] == '1')
  843. {
  844. $cz = 1;
  845. if(!is_numeric($num))
  846. {
  847. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  848. }
  849. if($num > $w['num']-$w['rknum'])
  850. {
  851. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  852. }
  853. if($w['rknum']+$num == $w['num'])
  854. {
  855. $dbapi = 99;
  856. $cz = 2;
  857. }
  858. else
  859. {
  860. $dbapi = 0;
  861. }
  862. $scid = explode('~',$w['scid']);
  863. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  864. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  865. {
  866. if($dbapi == 99)
  867. {
  868. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  869. }
  870. else
  871. {
  872. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  873. }
  874. }
  875. else
  876. {
  877. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  878. }
  879. }
  880. **/
  881. }
  882. }
  883. public function _db()
  884. {
  885. $post = $this->input->post(NULL, TRUE);
  886. if(isset($post['id']))
  887. {
  888. $id = $this->input->post('id',true);
  889. $num = $this->input->post('num',true);
  890. $warehouse = $this->input->post('warehouse',true);
  891. $w = $this->warehouse->read($warehouse);
  892. $data = $this->whlabel_bh->read($id);
  893. if(!$data)
  894. {
  895. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  896. }
  897. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  898. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  899. if($num > $data['rknum']-$ydbnum)
  900. {
  901. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  902. }
  903. $data['dccbm'] = 13001;//默认从许昌仓调出
  904. $data['ts'] = $num;
  905. $data['drcbm'] = $w['yybm'];
  906. $dc = $this->apiyy->get_cpdc($data);
  907. if(isset($dc['Data'][0]))
  908. {
  909. if($dc['Data'][0]['IsSucess'] != 1)
  910. {
  911. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  912. }
  913. else
  914. {
  915. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  916. if(isset($sh['Data'][0]))
  917. {
  918. $code = $sh['Data'][0]['Code'];
  919. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  920. }
  921. else
  922. {
  923. $code = '';
  924. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  925. }
  926. $p['uid'] = $id;
  927. $p['bm'] = $data['bm'];
  928. $p['sku'] = $data['jm'];
  929. $p['shipremarks'] = $data['shipremarks'];
  930. $p['title'] = $data['title'];
  931. $p['zh'] = $data['pm'];
  932. $p['fpdata'] = $data['features'];
  933. $p['num'] = $num;
  934. $p['warehouse'] = 13;//默认从许昌仓调出
  935. $p['rwarehouse'] = $warehouse;
  936. $p['time'] = time();//操作时间
  937. $p['code'] = $code;
  938. $this->whlabel_bh_list->insert($p);
  939. }
  940. }
  941. else
  942. {
  943. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  944. }
  945. }
  946. }
  947. public function _del()
  948. {
  949. $post = $this->input->post(NULL, TRUE);
  950. if(isset($post['s']))
  951. {
  952. $id_arr = $this->input->post('s');
  953. $id_arr = explode(',',trim($id_arr,','));
  954. if(!$id_arr)
  955. {
  956. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  957. }
  958. //循环删除记录
  959. foreach ($id_arr as $v)
  960. {
  961. $w = $this->whlabel_bh->read($v);
  962. if($w['state'] > 0)
  963. {
  964. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  965. }
  966. }
  967. foreach ($id_arr as $v)
  968. {
  969. $this->whlabel_bh->remove($v);
  970. }
  971. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  972. }
  973. }
  974. public function _deltransfer()
  975. {
  976. $post = $this->input->post(NULL, TRUE);
  977. if(isset($post['s']))
  978. {
  979. $id_arr = $this->input->post('s');
  980. $id_arr = explode(',',trim($id_arr,','));
  981. if(!$id_arr)
  982. {
  983. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  984. }
  985. if(count($id_arr) > 1)
  986. {
  987. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  988. }
  989. foreach ($id_arr as $v)
  990. {
  991. $this->whlabel_bh_transfer->remove($v);
  992. }
  993. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  994. }
  995. }
  996. public function _kc()
  997. {
  998. $post = $this->input->post(NULL, TRUE);
  999. if(isset($post['category']))
  1000. {
  1001. $list = array();
  1002. $sku = $this->input->post('sku',true);
  1003. $features = $this->input->post('features',true);
  1004. $category = $this->input->post('category',true);
  1005. $list['category'] = $category;
  1006. $list['hairtype'] = $this->input->post('hairtype',true);
  1007. $list['grade'] = $this->input->post('grade',true);
  1008. $size = $this->input->post('size',true);
  1009. $xzsku = $this->input->post('xzsku',true);
  1010. $list['size'] = rtrim($size,',');
  1011. $list['hairnumber'] = $this->input->post('hairnumber',true);
  1012. $list['extension'] = $this->input->post('extension',true);
  1013. if($category == 1297)
  1014. {
  1015. $list['sywignumber'] = $this->input->post('sywignumber',true);
  1016. }
  1017. if($category == 1702)
  1018. {
  1019. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  1020. $list['syother'] = $this->input->post('syother',true);
  1021. }
  1022. if($category == 133)
  1023. {
  1024. $list['fittype'] = $this->input->post('fittype',true);
  1025. $list['acother'] = $this->input->post('acother',true);
  1026. }
  1027. $list['color'] = $this->input->post('color',true);
  1028. $list['lowe'] = $this->input->post('lowe',true);
  1029. if($category == 127)
  1030. {
  1031. $list['type'] = $this->input->post('type',true);
  1032. $list['headroad'] = $this->input->post('headroad',true);
  1033. $list['density'] = $this->input->post('density',true);
  1034. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  1035. {
  1036. $list['lacesize'] = $this->input->post('lacesize',true);
  1037. }
  1038. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1039. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1040. }
  1041. if($category == 128)
  1042. {
  1043. $list['lacetype'] = $this->input->post('lacetype',true);
  1044. $list['haircap'] = $this->input->post('haircap',true);
  1045. $list['density'] = $this->input->post('density',true);
  1046. $list['lacecolor'] = $this->input->post('lacecolor',true);
  1047. $list['lacetypes'] = $this->input->post('lacetypes',true);
  1048. $list['wigother'] = $this->input->post('wigother',true);
  1049. $list['wigother2'] = $this->input->post('wigother2',true);
  1050. }
  1051. if($category == 129)
  1052. {
  1053. $list['wide'] = $this->input->post('wide',true);
  1054. }
  1055. if($category == 131)
  1056. {
  1057. $list['gifttype'] = $this->input->post('gifttype',true);
  1058. $list['giftother'] = $this->input->post('giftother',true);
  1059. }
  1060. if($category == 134)
  1061. {
  1062. $list['pieceweight'] = $this->input->post('pieceweight',true);
  1063. }
  1064. if($category == 1297)
  1065. {
  1066. $list['synthetictype'] = $this->input->post('synthetictype',true);
  1067. $list['sywigother'] = $this->input->post('sywigother',true);
  1068. }
  1069. if($category == 130 || $category == 133 || $category == 1702)
  1070. {
  1071. $list['items'] = $this->input->post('items',true);
  1072. $list['weight'] = $this->input->post('weight',true);
  1073. }
  1074. if($category == 1702)
  1075. {
  1076. $list['syhairther'] = $this->input->post('syhairther',true);
  1077. }
  1078. $shipremarks = '';
  1079. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1080. foreach($list as $k=>$v)
  1081. {
  1082. if($v != 0)
  1083. {
  1084. $shipremarks .=$v.'-';
  1085. }
  1086. }
  1087. $shipremarks = '-'.$shipremarks;
  1088. if($features)
  1089. {
  1090. $shipremarks = $features;
  1091. }
  1092. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1093. if($w > 0)
  1094. {
  1095. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1096. }
  1097. else
  1098. {
  1099. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1100. }
  1101. }
  1102. }
  1103. public function _excel()
  1104. {
  1105. $classid = $this->classid->sku();
  1106. $pm = $classid;
  1107. $typeclass = array();
  1108. $tc = $this->typeclass->find_all();
  1109. foreach ($tc as $v)
  1110. {
  1111. $typeclass[$v['id']] = $v;
  1112. }
  1113. $prc = array();
  1114. $purchase = $this->purchase->find_all();
  1115. foreach($purchase as $k=>$v)
  1116. {
  1117. $prc[$v['id']] = $v['title'];
  1118. }
  1119. if(isset($_GET['excel']))
  1120. {
  1121. $number = $this->input->post('number',true);
  1122. $sku = $this->input->post('sku',true);
  1123. $title = $this->input->post('title',true);
  1124. $pm = $this->input->post('pm',true);
  1125. $category = $this->input->post('category',true);
  1126. $size = $this->input->post('size',true);
  1127. $grade = $this->input->post('grade',true);
  1128. $color = $this->input->post('color',true);
  1129. $lowe = $this->input->post('lowe',true);
  1130. $state = $this->input->post('state',true);
  1131. $shipremarks = $this->input->post('shipremarks',true);
  1132. $type = $this->input->post('type',true);
  1133. $sid = $this->input->get('sid',true);
  1134. $ktime = $this->input->get('ktime',true);
  1135. $jtime = $this->input->get('jtime',true);
  1136. $ktime = strtotime($ktime);
  1137. $jtime = strtotime($jtime);
  1138. $where = "1=1";$gj = "";$ck = "";
  1139. if($number)
  1140. {
  1141. $where .= " and number like '%$number%'";
  1142. }
  1143. if($type != '')
  1144. {
  1145. $where .= " and type = '$type'";
  1146. }
  1147. if($sku)
  1148. {
  1149. $where .= " and sku like '%$sku%'";
  1150. }
  1151. if($title)
  1152. {
  1153. $where .= " and title like '%$title%'";
  1154. }
  1155. if($pm)
  1156. {
  1157. $where .= " and pm like '%$pm%'";
  1158. }
  1159. if($category)
  1160. {
  1161. $where .= " and shipremarks like '%-$category-%'";
  1162. }
  1163. if($size)
  1164. {
  1165. $where .= " and shipremarks like '%-$size-%'";
  1166. }
  1167. if($grade)
  1168. {
  1169. $where .= " and shipremarks like '%-$grade-%'";
  1170. }
  1171. if($color)
  1172. {
  1173. $where .= " and shipremarks like '%-$color-%'";
  1174. }
  1175. if($lowe)
  1176. {
  1177. $where .= " and shipremarks like '%-$lowe-%'";
  1178. }
  1179. if($state)
  1180. {
  1181. $where .= " and state = '$state'";
  1182. }
  1183. if($shipremarks)
  1184. {
  1185. $where .= " and shipremarks like '%$shipremarks%'";
  1186. }
  1187. $sidwhere = '';
  1188. if($sid)
  1189. {
  1190. $sd = "";
  1191. $s = explode(',',trim($sid,','));
  1192. foreach ($s as $value)
  1193. {
  1194. $sd .= " id = ".$value." or";
  1195. }
  1196. $sidwhere = " and (".rtrim($sd,'or').")";
  1197. }
  1198. //数据排序
  1199. $order_str = "time desc";
  1200. if(empty($page))
  1201. {
  1202. $start = 0;
  1203. $perpage = 1;
  1204. }
  1205. else
  1206. {
  1207. $start = ($page - 1)*$perpage;
  1208. }
  1209. //取得信息列表
  1210. /**
  1211. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1212. $rows = array();$list = array();
  1213. foreach ($info_list as $key=>$value)
  1214. {
  1215. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1216. }
  1217. **/
  1218. $warehouse = $this->warehouse->find_all();
  1219. $ck = array();
  1220. foreach ($warehouse as $v)
  1221. {
  1222. $ck[$v['id']] = $v['title'];
  1223. }
  1224. $list = array();
  1225. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1226. foreach ($rows as $key=>$value)
  1227. {
  1228. if($value['state'] == 0)
  1229. {
  1230. $rows[$key]['state'] = "待生产/外购";
  1231. }
  1232. else if($value['state'] == 1)
  1233. {
  1234. $rows[$key]['state'] = "生产/外购中";
  1235. }
  1236. else if($value['state'] == 2)
  1237. {
  1238. $rows[$key]['state'] = "已完成";
  1239. }
  1240. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1241. $zc = '';
  1242. foreach ($zd as $v)
  1243. {
  1244. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1245. }
  1246. $rows[$key]['id'] = $zc;
  1247. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1248. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1249. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1250. }
  1251. $title = '备货详情';
  1252. $titlename = "<table border=1>
  1253. <tr align='center'>
  1254. <td>状态</td>
  1255. <td>标题</td>
  1256. <td>流水码</td>
  1257. <td>简码</td>
  1258. <td>英文</td>
  1259. <td>中文</td>
  1260. <td>备注</td>
  1261. <td>备货数量</td>
  1262. <td>库存数量</td>
  1263. <td>生产/外购数量</td>
  1264. <td>入库数量</td>
  1265. <td>调拨数量</td>
  1266. <td>调拨详情</td>>
  1267. <td>生产时间</td>>
  1268. <td>操作时间</td>>
  1269. </tr>
  1270. </table>";
  1271. $filename = $title.".xls";
  1272. $tail = "";
  1273. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1274. }
  1275. }
  1276. public function _xxpl()
  1277. {
  1278. /* 订单加入键值-j */
  1279. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1280. $config['upload_path'] = '.'.$dir ;
  1281. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1282. $config['allowed_types'] = 'xls|xlsx|csv';
  1283. $config['max_size'] = 10240;
  1284. $this->load->library('upload', $config);
  1285. $this->upload->initialize($config);
  1286. if ($this->upload->do_upload('userfile'))
  1287. {
  1288. $full_path = $dir.$this->upload->data('file_name');
  1289. $fileName = '.' . $full_path;
  1290. if (!file_exists($fileName))
  1291. {
  1292. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1293. }
  1294. else
  1295. {
  1296. require_once "./data/excel/PHPExcel/IOFactory.php";
  1297. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1298. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1299. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1300. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1301. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1302. ++$column;//如果列数大于26行
  1303. $list = array();
  1304. for ($i = 2; $i <= $row; $i++) // 行数循环
  1305. {
  1306. $data = array();
  1307. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1308. {
  1309. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1310. }
  1311. $list[] = $data;
  1312. }
  1313. }
  1314. $tc = $this->typeclass->find_all();
  1315. $typeclass = array();
  1316. foreach ($tc as $v)
  1317. {
  1318. $typeclass[$v['jm']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1319. }
  1320. $i = 0;$j = 0;$ed = array();
  1321. $classid = $this->classid->sku();
  1322. foreach($list as $val)
  1323. {
  1324. $pm = $classid;
  1325. $jm = $classid;
  1326. $title = '';$features = '';$cs = array();
  1327. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'',46=>'');
  1328. $val = $val[1];
  1329. if($val == '')
  1330. {
  1331. continue;
  1332. }
  1333. $cfjm = explode('-',trim($val,'-'));
  1334. foreach($cfjm as $v)
  1335. {
  1336. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1337. {
  1338. if($typeclass[$v]['classid'] == '18')//头套
  1339. {
  1340. $bmpx[16] = '0103';
  1341. }
  1342. else if($typeclass[$v]['classid'] == '25' || $typeclass[$v]['classid'] == '26')//发块
  1343. {
  1344. $bmpx[16] = '0102';
  1345. }
  1346. else if($typeclass[$v]['classid'] == '33')//接发
  1347. {
  1348. $bmpx[16] = '0104';
  1349. }
  1350. else if($typeclass[$v]['classid'] == '35')//配件
  1351. {
  1352. $bmpx[16] = '0105';
  1353. }
  1354. else if($typeclass[$v]['classid'] == '41')//化纤头套
  1355. {
  1356. $bmpx[16] = '0201';
  1357. }
  1358. else if($typeclass[$v]['classid'] == '46')//化纤其它
  1359. {
  1360. $bmpx[16] = '0202';
  1361. }
  1362. else if($typeclass[$v]['classid'] == '49')//礼物
  1363. {
  1364. $bmpx[16] = '99';
  1365. }
  1366. else
  1367. {
  1368. $bmpx[16] = '0101';//发条
  1369. }
  1370. if($typeclass[$v]['bm'] != '')
  1371. {
  1372. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1373. }
  1374. }
  1375. if(isset($typeclass[$v]['title']))
  1376. {
  1377. $title .= $typeclass[$v]['title']." ";
  1378. }
  1379. if($v != 0)
  1380. {
  1381. if(isset($pm[$typeclass[$v]['classid']]))
  1382. {
  1383. if($typeclass[$v]['title'] == '9A')
  1384. {
  1385. $pm[$typeclass[$v]['classid']] = '9A';
  1386. }
  1387. else if($typeclass[$v]['title'] == '10A')
  1388. {
  1389. $pm[$typeclass[$v]['classid']] = '10A';
  1390. }
  1391. else
  1392. {
  1393. $clzh = $typeclass[$v]['zh'];
  1394. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1395. {
  1396. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1397. $clzh = $clzh[0];
  1398. }
  1399. $pm[$typeclass[$v]['classid']] = $clzh;
  1400. }
  1401. }
  1402. }
  1403. }
  1404. $jm = $val;
  1405. $pm = array_filter($pm);//去除空值
  1406. $pm = implode(" ",$pm);
  1407. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  1408. $title = trim($title,' ');
  1409. $bm = '03'.implode("",$bmpx);
  1410. $chuanshu = $this->_cslh($jm,$title,$pm,$bm);
  1411. if($chuanshu['x'] != 2)
  1412. {
  1413. $j++;
  1414. $ed[] = array($chuanshu['msg'],$jm,$bm);
  1415. }
  1416. }
  1417. if($j > 0)
  1418. {
  1419. $time = date('Ymd',time());
  1420. $title = '错误信息-'.$time;
  1421. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1422. $tail = "\n";
  1423. $filename = $title.".xls";
  1424. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1425. $dir = '/data/excel/'.$time.'/';
  1426. $file_name = 'error_'.$time.rand(1000,9999);
  1427. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1428. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1429. fwrite($myfile,$ecl);
  1430. fclose($myfile);
  1431. $error = $dir.$file_name.'.xls';
  1432. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1433. }
  1434. else
  1435. {
  1436. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1437. }
  1438. }
  1439. else
  1440. {
  1441. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1442. }
  1443. }
  1444. public function _cslh($jm,$title,$pm,$bm)
  1445. {
  1446. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1447. if(isset($lh['Data'][0]))
  1448. {
  1449. if($lh['Data'][0]['m_isSucess'] != 1)
  1450. {
  1451. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1452. {
  1453. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1454. }
  1455. }
  1456. }
  1457. else
  1458. {
  1459. return array('msg'=>'料号错误','x'=>1);exit;
  1460. }
  1461. return array('x'=>2);exit;
  1462. }
  1463. public function _bbprint()
  1464. {
  1465. $time = time();
  1466. $post = $this->input->post(NULL);
  1467. if(isset($post['d']))
  1468. {
  1469. $order = 0;$time = time();
  1470. $d = $this->input->post('d',true);
  1471. $n = $this->input->post('n',true);//打印数量
  1472. $data = $this->whlabel_bh->read($d);
  1473. if(!$data)
  1474. {
  1475. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1476. }
  1477. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1478. $printnum = array_sum(array_column($printnum,'ts'));
  1479. if($data['bhnum']-$printnum-$n < 0)
  1480. {
  1481. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1482. }
  1483. $post['number'] = $data['number'];
  1484. $post['orderinfo'] = $data['orderinfo'];
  1485. $post['type'] = 0;//0生产 1外购
  1486. $post['features'] = $data['features'];
  1487. $post['jm'] = $data['jm'];
  1488. $post['bm'] = $data['bm'];
  1489. $post['pm'] = $data['pm'];
  1490. $post['sku'] = $data['sku'];
  1491. $post['features'] = $data['features'];
  1492. $post['number'] = $data['number'];
  1493. $post['title'] = $data['title'];
  1494. $post['printtime'] = $time;
  1495. $post['ts'] = $n;
  1496. $post['rk'] = "|15|";//默认订单中心 打印后直接入库
  1497. $post['rktime'] = "|".$time."|";
  1498. $post['ctime15'] = $time;
  1499. $post['time'] = $time;
  1500. $post['gtime'] = date('Yms',$time);
  1501. $rows = array();
  1502. $label = substr($time,1).rand(10,99);
  1503. $post['label'] = $label;
  1504. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['jm'],'n'=>$n);
  1505. if($this->whlabel_bh_transfer->insert($post))
  1506. {
  1507. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1508. }
  1509. else
  1510. {
  1511. $this->db->trans_rollback();
  1512. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1513. }
  1514. }
  1515. }
  1516. public function _operate()
  1517. {
  1518. $post = $this->input->post(NULL, TRUE);
  1519. if(isset($post['page']))
  1520. {
  1521. $api = $this->input->post('api',true);
  1522. $page = $this->input->post('page',true);
  1523. $perpage = $this->input->post('perpage',true);
  1524. $orderinfo = $this->input->post('number',true);
  1525. $color = $this->input->post('color',true);
  1526. $pm = $this->input->post('pm',true);
  1527. $purchase = $this->input->post('purchase',true);
  1528. $transfer = $this->input->post('transfer',true);
  1529. $lx = $this->input->post('lx',true);
  1530. $timetk = $this->input->post('timetk',true);
  1531. $timetj = $this->input->post('timetj',true);
  1532. $timetk = strtotime($timetk);
  1533. $timetj = strtotime($timetj);
  1534. $where = "1=1";
  1535. if($transfer)
  1536. {
  1537. $ctime = 'ctime'.$transfer;
  1538. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1539. }
  1540. else
  1541. {
  1542. $where .= " and time > '$timetk' and time < '$timetj'";
  1543. }
  1544. if($orderinfo)
  1545. {
  1546. $where .= " and orderinfo like '%$orderinfo%'";
  1547. }
  1548. if($transfer)
  1549. {
  1550. $where .= " and rk like '%|".$transfer."|%'";
  1551. }
  1552. if($purchase)
  1553. {
  1554. $where .= " and purchase = '$purchase'";
  1555. }
  1556. if($pm)
  1557. {
  1558. $where .= " and pm like '%$pm%'";
  1559. }
  1560. if($color)
  1561. {
  1562. $where .= " and fpdata like '%-".$color."-%'";
  1563. }
  1564. //数据排序
  1565. $order_str = "id desc";
  1566. if(empty($page))
  1567. {
  1568. $start = 0;
  1569. $perpage = 1;
  1570. }
  1571. else
  1572. {
  1573. $start = ($page - 1)*$perpage;
  1574. }
  1575. //取得信息列表
  1576. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1577. $transfer = $this->transfer->find_all();
  1578. $t = array();$ot = array();
  1579. foreach ($transfer as $v)
  1580. {
  1581. $t[$v['id']] = $v['title'];
  1582. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1583. }
  1584. //格式化数据
  1585. foreach ($info_list as $key=>$value)
  1586. {
  1587. $dd = $this->whlabel_bh_transfer->read($value['id']);
  1588. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1589. $rk = explode('|',trim($dd['rk'],'|'));
  1590. $rktime = explode('|',trim($dd['rktime'],'|'));
  1591. $ck = explode('|',trim($dd['ck'],'|'));
  1592. $cktime = explode('|',trim($dd['cktime'],'|'));
  1593. $info_list[$key]['time'] = '';
  1594. for($i=0;$i<count($rk);$i++)
  1595. {
  1596. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1597. {
  1598. $d = '<em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br>';
  1599. }
  1600. else
  1601. {
  1602. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1603. }
  1604. $info_list[$key]['time'] .= $d;
  1605. if(isset($ck[$i]) && $ck[$i] != '')
  1606. {
  1607. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1608. }
  1609. }
  1610. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1611. }
  1612. $total = $this->whlabel_bh_transfer->find_count($where);
  1613. $pagenum = ceil($total/$perpage);
  1614. $over = $total-($start+$perpage);
  1615. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1616. echo json_encode($rows);exit;
  1617. }
  1618. if(isset($_SESSION['api']))
  1619. {
  1620. $user = $this->user->get_api($_SESSION['api']);
  1621. $usp = $user;
  1622. $pid = "";$tid="";$sid="";$wid="";
  1623. $purchase = explode('|',trim($user['purchase'],'|'));
  1624. $transfer = explode('|',trim($user['transfer'],'|'));
  1625. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1626. foreach ($purchase as $value)
  1627. {
  1628. $pid .= " id = ".$value." or";
  1629. }
  1630. foreach ($transfer as $value)
  1631. {
  1632. $tid .= " id = ".$value." or";
  1633. }
  1634. foreach ($warehouse as $value)
  1635. {
  1636. $wid .= " id = ".$value." or";
  1637. }
  1638. }
  1639. else
  1640. {
  1641. header('Location: /');exit;
  1642. }
  1643. $kx = '';$zjtab = '';
  1644. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1645. $this->data['warehouse'] = $warehouse;
  1646. $purchase = $this->purchase->find_all("yyid != ''");
  1647. $this->data['purchase'] = $purchase;
  1648. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1649. $this->data['transfer'] = $transfer;
  1650. $this->data['vip'] = $user['vip'];
  1651. $this->_Template('whlabel_bh_operate',$this->data);
  1652. }
  1653. public function _out()
  1654. {
  1655. $post = $this->input->post(NULL, TRUE);
  1656. if(isset($post['label']))
  1657. {
  1658. $time = time();
  1659. $label = $this->input->post('label',true);
  1660. $cz = $this->input->post('cz',true);
  1661. $transfer = $this->input->post('transfer',true);
  1662. if(!$label)
  1663. {
  1664. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1665. }
  1666. if(!$transfer)
  1667. {
  1668. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1669. }
  1670. $lb = $this->whlabel_bh_transfer->get_label($label);
  1671. if(!$lb)
  1672. {
  1673. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1674. }
  1675. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1676. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1677. if($cz == 1)
  1678. {
  1679. $lb['rk'] .= $transfer.'|';
  1680. $lb['rktime'] .= $time.'|';
  1681. if($lbrk[0] == $transfer)
  1682. {
  1683. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1684. }
  1685. }
  1686. else if($cz == 2)
  1687. {
  1688. $lb['ck'] .= $transfer.'|';
  1689. $lb['cktime'] .= $time.'|';
  1690. if($lbck[0] == $transfer)
  1691. {
  1692. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1693. }
  1694. }
  1695. $cztime = 'ctime'.$transfer;
  1696. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1697. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1698. {
  1699. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1700. }
  1701. if($this->whlabel_bh_transfer->save(array('rk'=>$lb['rk'],'rktime'=>$lb['rktime'],'ck'=>$lb['ck'],'cktime'=>$lb['cktime'],'time'=>$time,'gtime'=>date('YmdH',$time),$cztime=>$time),$lb['id']))
  1702. {
  1703. echo json_encode(array('music'=>'1','success'=>true));exit;
  1704. }
  1705. else
  1706. {
  1707. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1708. }
  1709. }
  1710. }
  1711. public function _bdbb()
  1712. {
  1713. $post = $this->input->post(NULL, TRUE);
  1714. if(isset($post['s']))
  1715. {
  1716. $id_arr = $this->input->post('s');
  1717. $id_arr = explode(',',trim($id_arr,','));
  1718. if(!$id_arr)
  1719. {
  1720. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1721. }
  1722. //循环删除记录
  1723. foreach ($id_arr as $v)
  1724. {
  1725. $t = $this->whlabel_bh_transfer->read($v);
  1726. if(!isset($t['number']))
  1727. {
  1728. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1729. }
  1730. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
  1731. }
  1732. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1733. }
  1734. }
  1735. }