Whlabel_bh.php 58 KB

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