Whlabel_bh.php 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703
  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. }
  334. if($category == 129)
  335. {
  336. $list['wide'] = $this->input->post('wide',true);
  337. }
  338. if($category == 131)
  339. {
  340. $list['gifttype'] = $this->input->post('gifttype',true);
  341. $list['giftother'] = $this->input->post('giftother',true);
  342. }
  343. if($category == 134)
  344. {
  345. $list['pieceweight'] = $this->input->post('pieceweight',true);
  346. }
  347. if($category == 1297)
  348. {
  349. $list['synthetictype'] = $this->input->post('synthetictype',true);
  350. $list['sywigother'] = $this->input->post('sywigother',true);
  351. }
  352. if($category == 130 || $category == 133 || $category == 1702)
  353. {
  354. $list['items'] = $this->input->post('items',true);
  355. }
  356. if($category == 1702)
  357. {
  358. $list['syhairther'] = $this->input->post('syhairther',true);
  359. }
  360. $classid = $this->classid->sku();
  361. $pm = $classid;
  362. $jm = $classid;
  363. $sku = $sku;
  364. $title = '';$features = '';$cs = array();
  365. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  366. foreach($list as $k=>$v)
  367. {
  368. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  369. {
  370. if($typeclass[$v]['bm'] != '')
  371. {
  372. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  373. }
  374. }
  375. if(isset($typeclass[$v]['title']))
  376. {
  377. $title .= $typeclass[$v]['title']." ";
  378. }
  379. if($v != 0)
  380. {
  381. $features .=$v.'-';
  382. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  383. if(isset($pm[$typeclass[$v]['classid']]))
  384. {
  385. if($typeclass[$v]['title'] == '9A')
  386. {
  387. $pm[$typeclass[$v]['classid']] = '9A';
  388. }
  389. else if($typeclass[$v]['title'] == '10A')
  390. {
  391. $pm[$typeclass[$v]['classid']] = '10A';
  392. }
  393. else
  394. {
  395. $clzh = $typeclass[$v]['zh'];
  396. if(stripos($typeclass[$v]['zh'],'|') !== false)
  397. {
  398. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  399. $clzh = $clzh[0];
  400. }
  401. $pm[$typeclass[$v]['classid']] = $clzh;
  402. }
  403. }
  404. if(isset($jm[$typeclass[$v]['classid']]))
  405. {
  406. if($typeclass[$v]['jm'])
  407. {
  408. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  409. }
  410. }
  411. }
  412. }
  413. $jm = array_filter($jm);//去除空值
  414. $jm = implode("-",$jm);
  415. $sku = array_filter($sku);//去除空值
  416. $sku = implode("-",$sku);
  417. $pm = array_filter($pm);//去除空值
  418. $pm = implode(" ",$pm);
  419. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  420. $title = trim($title,' ');
  421. $post['num'] = $this->input->post('num',true);
  422. $ztime = $this->input->post('ztime',true);
  423. $post['ztime'] = strtotime($ztime);
  424. $post['bm'] = '03'.implode("",$bmpx);
  425. $post['jm'] = $jm;
  426. $post['sku'] = $sku;
  427. $post['pm'] = $pm;
  428. $post['title'] = $title;
  429. $post['features'] = '-'.$features;
  430. $post['number'] = date('YmdHis',time()).rand(100,999);
  431. if(!$post['num'])
  432. {
  433. $post['number'] = date("YmdHis").rand(100,999);
  434. }
  435. $time = time();
  436. $post['time'] = $time;//操作时间
  437. $post['printnum'] = $time;
  438. $post['type'] = 0;
  439. //传输料号开始
  440. $lc = 0;
  441. $lh = $this->apiyy->get_cjlp(array('jm'=>$post['jm'],'title'=>$post['title'],'zh'=>$post['pm'],'bm'=>$post['bm']));
  442. if(isset($lh['Data'][0]))
  443. {
  444. if($lh['Data'][0]['m_isSucess'] != 1)
  445. {
  446. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  447. {
  448. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$post['bm'],'jm'=>$post['jm'],'success'=>false));exit;
  449. }
  450. }
  451. }
  452. else
  453. {
  454. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  455. }
  456. if($this->whlabel_bh->insert($post))
  457. {
  458. echo json_encode(array('msg'=>'添加成功','cs'=>$cs,'success'=>true));exit;
  459. }
  460. else
  461. {
  462. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  463. }
  464. }
  465. $w = $this->shop->find_all("yyid != ''");
  466. $this->data['yyck'] = $w;
  467. $purchase = $this->purchase->find_all("yyid != ''");
  468. $this->data['purchase'] = $purchase;
  469. $this->data['data'] = (isset($_GET['data']))?$_GET['data']:'';
  470. $this->_Template('whlabel_bh_add',$this->data);
  471. }
  472. //修改产品
  473. public function _edit($arg_array)
  474. {
  475. $tc = $this->typeclass->find_all();
  476. $typeclass = array();
  477. foreach ($tc as $v)
  478. {
  479. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  480. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  481. }
  482. $post = $this->input->post(NULL, TRUE);
  483. if(isset($post['id']))
  484. {
  485. $id = $this->input->post('id',true);
  486. $list = array();
  487. $sku = $this->input->post('sku',true);
  488. $category = $this->input->post('category',true);
  489. $list['category'] = $category;
  490. $list['hairtype'] = $this->input->post('hairtype',true);
  491. $list['grade'] = $this->input->post('grade',true);
  492. $size = $this->input->post('size',true);
  493. $xzsku = $this->input->post('xzsku',true);
  494. $list['size'] = rtrim($size,',');
  495. $list['hairnumber'] = $this->input->post('hairnumber',true);
  496. $list['extension'] = $this->input->post('extension',true);
  497. if($category == 1297)
  498. {
  499. $list['sywignumber'] = $this->input->post('sywignumber',true);
  500. }
  501. if($category == 1702)
  502. {
  503. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  504. $list['syother'] = $this->input->post('syother',true);
  505. }
  506. if($category == 133)
  507. {
  508. $list['fittype'] = $this->input->post('fittype',true);
  509. $list['acother'] = $this->input->post('acother',true);
  510. }
  511. $list['color'] = $this->input->post('color',true);
  512. $list['lowe'] = $this->input->post('lowe',true);
  513. if($category == 127)
  514. {
  515. $list['type'] = $this->input->post('type',true);
  516. $list['headroad'] = $this->input->post('headroad',true);
  517. $list['density'] = $this->input->post('density',true);
  518. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  519. {
  520. $list['lacesize'] = $this->input->post('lacesize',true);
  521. }
  522. $list['lacecolor'] = $this->input->post('lacecolor',true);
  523. $list['lacetypes'] = $this->input->post('lacetypes',true);
  524. }
  525. if($category == 128)
  526. {
  527. $list['lacetype'] = $this->input->post('lacetype',true);
  528. $list['haircap'] = $this->input->post('haircap',true);
  529. $list['density'] = $this->input->post('density',true);
  530. $list['lacecolor'] = $this->input->post('lacecolor',true);
  531. $list['lacetypes'] = $this->input->post('lacetypes',true);
  532. $list['wigother'] = $this->input->post('wigother',true);
  533. }
  534. if($category == 129)
  535. {
  536. $list['wide'] = $this->input->post('wide',true);
  537. }
  538. if($category == 131)
  539. {
  540. $list['gifttype'] = $this->input->post('gifttype',true);
  541. $list['giftother'] = $this->input->post('giftother',true);
  542. }
  543. if($category == 134)
  544. {
  545. $list['pieceweight'] = $this->input->post('pieceweight',true);
  546. }
  547. if($category == 1297)
  548. {
  549. $list['synthetictype'] = $this->input->post('synthetictype',true);
  550. $list['sywigother'] = $this->input->post('sywigother',true);
  551. }
  552. if($category == 130 || $category == 133 || $category == 1702)
  553. {
  554. $list['items'] = $this->input->post('items',true);
  555. }
  556. if($category == 1702)
  557. {
  558. $list['syhairther'] = $this->input->post('syhairther',true);
  559. }
  560. $classid = $this->classid->sku();
  561. $pm = $classid;
  562. $jm = $classid;
  563. $sku = $sku;
  564. $title = '';$features = '';$cs = array();
  565. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  566. foreach($list as $k=>$v)
  567. {
  568. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  569. {
  570. if($typeclass[$v]['bm'] != '')
  571. {
  572. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  573. }
  574. }
  575. if(isset($typeclass[$v]['title']))
  576. {
  577. $title .= $typeclass[$v]['title']." ";
  578. }
  579. if($v != 0)
  580. {
  581. $features .=$v.'-';
  582. $sku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  583. if(isset($pm[$typeclass[$v]['classid']]))
  584. {
  585. if($typeclass[$v]['title'] == '9A')
  586. {
  587. $pm[$typeclass[$v]['classid']] = '9A';
  588. }
  589. else if($typeclass[$v]['title'] == '10A')
  590. {
  591. $pm[$typeclass[$v]['classid']] = '10A';
  592. }
  593. else
  594. {
  595. $clzh = $typeclass[$v]['zh'];
  596. if(stripos($typeclass[$v]['zh'],'|') !== false)
  597. {
  598. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  599. $clzh = $clzh[0];
  600. }
  601. $pm[$typeclass[$v]['classid']] = $clzh;
  602. }
  603. }
  604. if(isset($jm[$typeclass[$v]['classid']]))
  605. {
  606. if($typeclass[$v]['jm'])
  607. {
  608. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  609. }
  610. }
  611. }
  612. }
  613. $jm = array_filter($jm);//去除空值
  614. $jm = implode("-",$jm);
  615. $sku = array_filter($sku);//去除空值
  616. $sku = implode("-",$sku);
  617. $pm = array_filter($pm);//去除空值
  618. $pm = implode(" ",$pm);
  619. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  620. $title = trim($title,' ');
  621. $post['num'] = $this->input->post('num',true);
  622. $ztime = $this->input->post('ztime',true);
  623. $post['ztime'] = strtotime($ztime);
  624. $post['bm'] = '03'.implode("",$bmpx);
  625. $post['jm'] = $jm;
  626. $post['sku'] = $sku;
  627. $post['pm'] = $pm;
  628. $post['title'] = $title;
  629. $post['features'] = '-'.$features;
  630. $ztime = $this->input->post('ztime',true);
  631. if($ztime)
  632. {
  633. $post['ztime'] = strtotime($ztime);
  634. }
  635. if($this->whlabel_bh->save($post,$id))
  636. {
  637. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  638. }
  639. else
  640. {
  641. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  642. }
  643. }
  644. $w = $this->shop->find_all("yyid != ''");
  645. $this->data['yyck'] = $w;
  646. $whlabel_bh = $this->whlabel_bh->read($arg_array[0]);
  647. $this->data['whlabel_bh'] = $whlabel_bh ;
  648. $purchase = $this->purchase->find_all("yyid != ''");
  649. $this->data['purchase'] = $purchase;
  650. $this->_Template('whlabel_bh_edit',$this->data);
  651. }
  652. public function _cz()
  653. {
  654. $post = $this->input->post(NULL, TRUE);
  655. if(isset($post['id']))
  656. {
  657. $id = $this->input->post('id',true);
  658. $cz = $this->input->post('cz',true);
  659. $num = $this->input->post('num',true);
  660. $cz = $cz+1;
  661. $w = $this->whlabel_bh->read($id);
  662. if(!$w)
  663. {
  664. echo json_encode(array('msg'=>'操作的信息不存在!','success'=>false));exit;
  665. }
  666. //传输料号开始
  667. $lc = 0;
  668. $lh = $this->apiyy->get_cjlp(array('jm'=>$w['jm'],'title'=>$w['title'],'zh'=>$w['pm'],'bm'=>$w['bm']));
  669. if(isset($lh['Data'][0]))
  670. {
  671. if($lh['Data'][0]['m_isSucess'] != 1)
  672. {
  673. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  674. {
  675. echo json_encode(array('msg'=>$lh['Data'][0]['m_errorMsg'],'bm'=>$w['bm'],'jm'=>$w['jm'],'success'=>false));exit;
  676. }
  677. }
  678. }
  679. else
  680. {
  681. echo json_encode(array('msg'=>'料号错误','cs'=>json_encode($lh),'success'=>false));exit;
  682. }
  683. echo json_encode(array('msg'=>'操作成功!'.$lh['Data'][0]['m_isSucess'],'id'=>$id,'typetext'=>'传输料号','text'=>'','num'=>0,'cs'=>$lh,'success'=>true));
  684. /** 投产
  685. if($w['scapi'] != 99)
  686. {
  687. if($w['state'] == $cz)
  688. {
  689. echo json_encode(array('msg'=>'请刷新页面后再进行操作!','success'=>false));exit;
  690. }
  691. if($w['type'] == '0')
  692. {
  693. $type = '生产';
  694. $bhlx = 0;
  695. }
  696. else
  697. {
  698. $type = '外购';
  699. $bhlx = 1;
  700. }
  701. $yy = $this->apiyy->_peihuo($w,$w['kh'],$w['orderinfo'],$w['num'],2000);
  702. if($yy['c'] == 0)
  703. {
  704. if($this->whlabel_bh->save(array('state'=>$cz,'scapi'=>99,'scid'=>$yy['scid'],'sctime'=>time()),$id))
  705. {
  706. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已操作','text'=>$type.'中','success'=>true));
  707. }
  708. else
  709. {
  710. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  711. }
  712. }
  713. else
  714. {
  715. echo json_encode(array('msg'=>$yy['error'],'a'=>1,'success'=>false));exit;
  716. }
  717. }
  718. else if($w['dbapi'] != 99 && $w['type'] == '0')
  719. {
  720. $cz = 1;
  721. if(!is_numeric($num))
  722. {
  723. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  724. }
  725. if($num > $w['num']-$w['rknum'])
  726. {
  727. echo json_encode(array('msg'=>'完成数量大于生产总数量!','success'=>false));exit;
  728. }
  729. if($w['rknum']+$num == $w['num'])
  730. {
  731. $dbapi = 99;
  732. $cz = 2;
  733. }
  734. else
  735. {
  736. $dbapi = 0;
  737. }
  738. $w['ts'] = $num;
  739. $rk = $this->apiyy->_newrk($w);
  740. if($rk['c'] == 0)
  741. {
  742. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>$dbapi,'scid'=>$rk['scid']),$id))
  743. {
  744. if($dbapi == 99)
  745. {
  746. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  747. }
  748. else
  749. {
  750. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  751. }
  752. }
  753. else
  754. {
  755. echo json_encode(array('msg'=>'写入数据失败,请联系技术人员 ID:'.$w['id'].' - C:'.$cz,'success'=>false));
  756. }
  757. }
  758. else
  759. {
  760. $this->whlabel_bh->save(array('dbapi'=>$rk['dbapi'],'scid'=>$rk['scid']),$id);
  761. echo json_encode(array('msg'=>$rk['error'],'success'=>false));exit;
  762. }
  763. }
  764. else if($w['dbapi'] != 99 && $w['type'] == '1')
  765. {
  766. $cz = 1;
  767. if(!is_numeric($num))
  768. {
  769. echo json_encode(array('msg'=>'数量填写错误!','success'=>false));exit;
  770. }
  771. if($num > $w['num']-$w['rknum'])
  772. {
  773. echo json_encode(array('msg'=>'完成数量大于外购总数量!','success'=>false));exit;
  774. }
  775. if($w['rknum']+$num == $w['num'])
  776. {
  777. $dbapi = 99;
  778. $cz = 2;
  779. }
  780. else
  781. {
  782. $dbapi = 0;
  783. }
  784. $scid = explode('~',$w['scid']);
  785. $rkdata = array('od'=>$scid[1],'ts'=>$num,'title'=>$w['title']);
  786. if($this->whlabel_bh->save(array('state'=>$cz,'rknum'=>$w['rknum']+$num,'dbapi'=>99),$id))
  787. {
  788. if($dbapi == 99)
  789. {
  790. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'已全部入库','text'=>'已完成','num'=>$w['rknum']+$num,'success'=>true));
  791. }
  792. else
  793. {
  794. echo json_encode(array('msg'=>'操作成功!','id'=>$id,'typetext'=>'入库'.$num.'成功','text'=>'生产中','num'=>$w['rknum']+$num,'success'=>true));
  795. }
  796. }
  797. else
  798. {
  799. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  800. }
  801. }
  802. **/
  803. }
  804. }
  805. public function _db()
  806. {
  807. $post = $this->input->post(NULL, TRUE);
  808. if(isset($post['id']))
  809. {
  810. $id = $this->input->post('id',true);
  811. $num = $this->input->post('num',true);
  812. $warehouse = $this->input->post('warehouse',true);
  813. $w = $this->warehouse->read($warehouse);
  814. $data = $this->whlabel_bh->read($id);
  815. if(!$data)
  816. {
  817. echo json_encode(array('msg'=>'此备货信息已被删除','success'=>false));exit;
  818. }
  819. $d = $this->whlabel_bh_list->find_all("uid = '".$id."'");
  820. $ydbnum = sprintf("%01.2f",array_sum(array_column($d,'num')));
  821. if($num > $data['rknum']-$ydbnum)
  822. {
  823. echo json_encode(array('msg'=>'调拨数量不允许大于(备货入库数量-已调拨数量)','success'=>false));exit;
  824. }
  825. $data['dccbm'] = 13001;//默认从许昌仓调出
  826. $data['ts'] = $num;
  827. $data['drcbm'] = $w['yybm'];
  828. $dc = $this->apiyy->get_cpdc($data);
  829. if(isset($dc['Data'][0]))
  830. {
  831. if($dc['Data'][0]['IsSucess'] != 1)
  832. {
  833. echo json_encode(array('msg'=>$dc['Data'][0]['ErrorMsg'].'-1','success'=>false));exit;
  834. }
  835. else
  836. {
  837. $sh = $this->apiyy->get_order_sh($data,'SO/Submit','SO/Approve',130);
  838. if(isset($sh['Data'][0]))
  839. {
  840. $code = $sh['Data'][0]['Code'];
  841. echo json_encode(array('msg'=>$sh['Data'][0]['ErrorMsg'].'-2','success'=>false));
  842. }
  843. else
  844. {
  845. $code = '';
  846. echo json_encode(array('msg'=>'调出成功!','success'=>true));
  847. }
  848. $p['uid'] = $id;
  849. $p['bm'] = $data['bm'];
  850. $p['sku'] = $data['jm'];
  851. $p['shipremarks'] = $data['shipremarks'];
  852. $p['title'] = $data['title'];
  853. $p['zh'] = $data['pm'];
  854. $p['fpdata'] = $data['features'];
  855. $p['num'] = $num;
  856. $p['warehouse'] = 13;//默认从许昌仓调出
  857. $p['rwarehouse'] = $warehouse;
  858. $p['time'] = time();//操作时间
  859. $p['code'] = $code;
  860. $this->whlabel_bh_list->insert($p);
  861. }
  862. }
  863. else
  864. {
  865. echo json_encode(array('msg'=>json_encode($dc),'success'=>false));exit;
  866. }
  867. }
  868. }
  869. public function _del()
  870. {
  871. $post = $this->input->post(NULL, TRUE);
  872. if(isset($post['s']))
  873. {
  874. $id_arr = $this->input->post('s');
  875. $id_arr = explode(',',trim($id_arr,','));
  876. if(!$id_arr)
  877. {
  878. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  879. }
  880. //循环删除记录
  881. foreach ($id_arr as $v)
  882. {
  883. $w = $this->whlabel_bh->read($v);
  884. if($w['state'] > 0)
  885. {
  886. // echo json_encode(array('msg'=>'有已投产产品,无法删除!','success'=>true));exit;
  887. }
  888. }
  889. foreach ($id_arr as $v)
  890. {
  891. $this->whlabel_bh->remove($v);
  892. }
  893. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  894. }
  895. }
  896. public function _deltransfer()
  897. {
  898. $post = $this->input->post(NULL, TRUE);
  899. if(isset($post['s']))
  900. {
  901. $id_arr = $this->input->post('s');
  902. $id_arr = explode(',',trim($id_arr,','));
  903. if(!$id_arr)
  904. {
  905. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  906. }
  907. if(count($id_arr) > 1)
  908. {
  909. echo json_encode(array('msg'=>'为防止删错,每次只可删除一条数据!请检查','success'=>false));exit;
  910. }
  911. foreach ($id_arr as $v)
  912. {
  913. $this->whlabel_bh_transfer->remove($v);
  914. }
  915. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  916. }
  917. }
  918. public function _kc()
  919. {
  920. $post = $this->input->post(NULL, TRUE);
  921. if(isset($post['category']))
  922. {
  923. $list = array();
  924. $sku = $this->input->post('sku',true);
  925. $features = $this->input->post('features',true);
  926. $category = $this->input->post('category',true);
  927. $list['category'] = $category;
  928. $list['hairtype'] = $this->input->post('hairtype',true);
  929. $list['grade'] = $this->input->post('grade',true);
  930. $size = $this->input->post('size',true);
  931. $xzsku = $this->input->post('xzsku',true);
  932. $list['size'] = rtrim($size,',');
  933. $list['hairnumber'] = $this->input->post('hairnumber',true);
  934. $list['extension'] = $this->input->post('extension',true);
  935. if($category == 1297)
  936. {
  937. $list['sywignumber'] = $this->input->post('sywignumber',true);
  938. }
  939. if($category == 1702)
  940. {
  941. $list['syhairnumber'] = $this->input->post('syhairnumber',true);
  942. $list['syother'] = $this->input->post('syother',true);
  943. }
  944. if($category == 133)
  945. {
  946. $list['fittype'] = $this->input->post('fittype',true);
  947. $list['acother'] = $this->input->post('acother',true);
  948. }
  949. $list['color'] = $this->input->post('color',true);
  950. $list['lowe'] = $this->input->post('lowe',true);
  951. if($category == 127)
  952. {
  953. $list['type'] = $this->input->post('type',true);
  954. $list['headroad'] = $this->input->post('headroad',true);
  955. $list['density'] = $this->input->post('density',true);
  956. if($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199)
  957. {
  958. $list['lacesize'] = $this->input->post('lacesize',true);
  959. }
  960. $list['lacecolor'] = $this->input->post('lacecolor',true);
  961. $list['lacetypes'] = $this->input->post('lacetypes',true);
  962. }
  963. if($category == 128)
  964. {
  965. $list['lacetype'] = $this->input->post('lacetype',true);
  966. $list['haircap'] = $this->input->post('haircap',true);
  967. $list['density'] = $this->input->post('density',true);
  968. $list['lacecolor'] = $this->input->post('lacecolor',true);
  969. $list['lacetypes'] = $this->input->post('lacetypes',true);
  970. $list['wigother'] = $this->input->post('wigother',true);
  971. }
  972. if($category == 129)
  973. {
  974. $list['wide'] = $this->input->post('wide',true);
  975. }
  976. if($category == 131)
  977. {
  978. $list['gifttype'] = $this->input->post('gifttype',true);
  979. $list['giftother'] = $this->input->post('giftother',true);
  980. }
  981. if($category == 134)
  982. {
  983. $list['pieceweight'] = $this->input->post('pieceweight',true);
  984. }
  985. if($category == 1297)
  986. {
  987. $list['synthetictype'] = $this->input->post('synthetictype',true);
  988. $list['sywigother'] = $this->input->post('sywigother',true);
  989. }
  990. if($category == 130 || $category == 133 || $category == 1702)
  991. {
  992. $list['items'] = $this->input->post('items',true);
  993. }
  994. if($category == 1702)
  995. {
  996. $list['syhairther'] = $this->input->post('syhairther',true);
  997. }
  998. $shipremarks = '';
  999. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1000. foreach($list as $k=>$v)
  1001. {
  1002. if($v != 0)
  1003. {
  1004. $shipremarks .=$v.'-';
  1005. }
  1006. }
  1007. $shipremarks = '-'.$shipremarks;
  1008. if($features)
  1009. {
  1010. $shipremarks = $features;
  1011. }
  1012. $w = $this->whlabel->find_count("features = '$shipremarks' and state = '0' and zd = '' and warehouse = '13'");//默认许昌仓
  1013. if($w > 0)
  1014. {
  1015. echo json_encode(array('msg'=>$w,'success'=>true));exit;
  1016. }
  1017. else
  1018. {
  1019. echo json_encode(array('msg'=>'没有可用库存','cs'=>$shipremarks,'success'=>false));
  1020. }
  1021. }
  1022. }
  1023. public function _excel()
  1024. {
  1025. $classid = $this->classid->sku();
  1026. $pm = $classid;
  1027. $typeclass = array();
  1028. $tc = $this->typeclass->find_all();
  1029. foreach ($tc as $v)
  1030. {
  1031. $typeclass[$v['id']] = $v;
  1032. }
  1033. $prc = array();
  1034. $purchase = $this->purchase->find_all();
  1035. foreach($purchase as $k=>$v)
  1036. {
  1037. $prc[$v['id']] = $v['title'];
  1038. }
  1039. if(isset($_GET['excel']))
  1040. {
  1041. $number = $this->input->post('number',true);
  1042. $sku = $this->input->post('sku',true);
  1043. $title = $this->input->post('title',true);
  1044. $pm = $this->input->post('pm',true);
  1045. $category = $this->input->post('category',true);
  1046. $size = $this->input->post('size',true);
  1047. $grade = $this->input->post('grade',true);
  1048. $color = $this->input->post('color',true);
  1049. $lowe = $this->input->post('lowe',true);
  1050. $state = $this->input->post('state',true);
  1051. $shipremarks = $this->input->post('shipremarks',true);
  1052. $type = $this->input->post('type',true);
  1053. $sid = $this->input->get('sid',true);
  1054. $ktime = $this->input->get('ktime',true);
  1055. $jtime = $this->input->get('jtime',true);
  1056. $ktime = strtotime($ktime);
  1057. $jtime = strtotime($jtime);
  1058. $where = "1=1";$gj = "";$ck = "";
  1059. if($number)
  1060. {
  1061. $where .= " and number like '%$number%'";
  1062. }
  1063. if($type != '')
  1064. {
  1065. $where .= " and type = '$type'";
  1066. }
  1067. if($sku)
  1068. {
  1069. $where .= " and sku like '%$sku%'";
  1070. }
  1071. if($title)
  1072. {
  1073. $where .= " and title like '%$title%'";
  1074. }
  1075. if($pm)
  1076. {
  1077. $where .= " and pm like '%$pm%'";
  1078. }
  1079. if($category)
  1080. {
  1081. $where .= " and shipremarks like '%-$category-%'";
  1082. }
  1083. if($size)
  1084. {
  1085. $where .= " and shipremarks like '%-$size-%'";
  1086. }
  1087. if($grade)
  1088. {
  1089. $where .= " and shipremarks like '%-$grade-%'";
  1090. }
  1091. if($color)
  1092. {
  1093. $where .= " and shipremarks like '%-$color-%'";
  1094. }
  1095. if($lowe)
  1096. {
  1097. $where .= " and shipremarks like '%-$lowe-%'";
  1098. }
  1099. if($state)
  1100. {
  1101. $where .= " and state = '$state'";
  1102. }
  1103. if($shipremarks)
  1104. {
  1105. $where .= " and shipremarks like '%$shipremarks%'";
  1106. }
  1107. $sidwhere = '';
  1108. if($sid)
  1109. {
  1110. $sd = "";
  1111. $s = explode(',',trim($sid,','));
  1112. foreach ($s as $value)
  1113. {
  1114. $sd .= " id = ".$value." or";
  1115. }
  1116. $sidwhere = " and (".rtrim($sd,'or').")";
  1117. }
  1118. //数据排序
  1119. $order_str = "time desc";
  1120. if(empty($page))
  1121. {
  1122. $start = 0;
  1123. $perpage = 1;
  1124. }
  1125. else
  1126. {
  1127. $start = ($page - 1)*$perpage;
  1128. }
  1129. //取得信息列表
  1130. /**
  1131. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  1132. $rows = array();$list = array();
  1133. foreach ($info_list as $key=>$value)
  1134. {
  1135. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  1136. }
  1137. **/
  1138. $warehouse = $this->warehouse->find_all();
  1139. $ck = array();
  1140. foreach ($warehouse as $v)
  1141. {
  1142. $ck[$v['id']] = $v['title'];
  1143. }
  1144. $list = array();
  1145. $rows = $this->whlabel_bh->find_all($where.$sidwhere,'state,orderinfo,number,jm,title,pm,shipremarks,bhnum,kcnum,num,rknum,dbnum,id,sctime,time');
  1146. foreach ($rows as $key=>$value)
  1147. {
  1148. if($value['state'] == 0)
  1149. {
  1150. $rows[$key]['state'] = "待生产/外购";
  1151. }
  1152. else if($value['state'] == 1)
  1153. {
  1154. $rows[$key]['state'] = "生产/外购中";
  1155. }
  1156. else if($value['state'] == 2)
  1157. {
  1158. $rows[$key]['state'] = "已完成";
  1159. }
  1160. $zd = $this->whlabel_bh_list->find_all("uid = '".$value['id']."'");
  1161. $zc = '';
  1162. foreach ($zd as $v)
  1163. {
  1164. $zc .= $ck[$v['warehouse']].'转入 - '.$v['num'].'<br>';
  1165. }
  1166. $rows[$key]['id'] = $zc;
  1167. $rows[$key]['dbnum'] = array_sum(array_column($zd,'num'));
  1168. $rows[$key]['sctime'] = ($value['sctime']>0)?date('Y-m-d',$value['sctime']):'未记录';
  1169. $rows[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  1170. }
  1171. $title = '备货详情';
  1172. $titlename = "<table border=1>
  1173. <tr align='center'>
  1174. <td>状态</td>
  1175. <td>标题</td>
  1176. <td>流水码</td>
  1177. <td>简码</td>
  1178. <td>英文</td>
  1179. <td>中文</td>
  1180. <td>备注</td>
  1181. <td>备货数量</td>
  1182. <td>库存数量</td>
  1183. <td>生产/外购数量</td>
  1184. <td>入库数量</td>
  1185. <td>调拨数量</td>
  1186. <td>调拨详情</td>>
  1187. <td>生产时间</td>>
  1188. <td>操作时间</td>>
  1189. </tr>
  1190. </table>";
  1191. $filename = $title.".xls";
  1192. $tail = "";
  1193. $this->excel->get_fz2($rows,$titlename,$filename,$tail);
  1194. }
  1195. }
  1196. public function _xxpl()
  1197. {
  1198. /* 订单加入键值-j */
  1199. $dir = '/data/excel/'.date('Ymd',time()).'/';
  1200. $config['upload_path'] = '.'.$dir ;
  1201. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  1202. $config['allowed_types'] = 'xls|xlsx|csv';
  1203. $config['max_size'] = 10240;
  1204. $this->load->library('upload', $config);
  1205. $this->upload->initialize($config);
  1206. if ($this->upload->do_upload('userfile'))
  1207. {
  1208. $full_path = $dir.$this->upload->data('file_name');
  1209. $fileName = '.' . $full_path;
  1210. if (!file_exists($fileName))
  1211. {
  1212. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  1213. }
  1214. else
  1215. {
  1216. require_once "./data/excel/PHPExcel/IOFactory.php";
  1217. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  1218. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  1219. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  1220. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  1221. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  1222. ++$column;//如果列数大于26行
  1223. $list = array();
  1224. for ($i = 2; $i <= $row; $i++) // 行数循环
  1225. {
  1226. $data = array();
  1227. for ($c = 'A'; $c != $column; $c++) // 列数循环
  1228. {
  1229. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  1230. }
  1231. $list[] = $data;
  1232. }
  1233. }
  1234. $tc = $this->typeclass->find_all();
  1235. $typeclass = array();
  1236. foreach ($tc as $v)
  1237. {
  1238. $typeclass[$v['jm']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm'],'bqsku'=>$v['bqsku']);
  1239. }
  1240. $i = 0;$j = 0;$ed = array();
  1241. $classid = $this->classid->sku();
  1242. foreach($list as $val)
  1243. {
  1244. $pm = $classid;
  1245. $jm = $classid;
  1246. $title = '';$features = '';$cs = array();
  1247. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'',46=>'');
  1248. $val = $val[1];
  1249. if($val == '')
  1250. {
  1251. continue;
  1252. }
  1253. $cfjm = explode('-',trim($val,'-'));
  1254. foreach($cfjm as $v)
  1255. {
  1256. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1257. {
  1258. if($typeclass[$v]['classid'] == '18')//头套
  1259. {
  1260. $bmpx[16] = '0103';
  1261. }
  1262. else if($typeclass[$v]['classid'] == '25' || $typeclass[$v]['classid'] == '26')//发块
  1263. {
  1264. $bmpx[16] = '0102';
  1265. }
  1266. else if($typeclass[$v]['classid'] == '33')//接发
  1267. {
  1268. $bmpx[16] = '0104';
  1269. }
  1270. else if($typeclass[$v]['classid'] == '35')//配件
  1271. {
  1272. $bmpx[16] = '0105';
  1273. }
  1274. else if($typeclass[$v]['classid'] == '41')//化纤头套
  1275. {
  1276. $bmpx[16] = '0201';
  1277. }
  1278. else if($typeclass[$v]['classid'] == '46')//化纤其它
  1279. {
  1280. $bmpx[16] = '0202';
  1281. }
  1282. else if($typeclass[$v]['classid'] == '49')//礼物
  1283. {
  1284. $bmpx[16] = '99';
  1285. }
  1286. else
  1287. {
  1288. $bmpx[16] = '0101';//发条
  1289. }
  1290. if($typeclass[$v]['bm'] != '')
  1291. {
  1292. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1293. }
  1294. }
  1295. if(isset($typeclass[$v]['title']))
  1296. {
  1297. $title .= $typeclass[$v]['title']." ";
  1298. }
  1299. if($v != 0)
  1300. {
  1301. if(isset($pm[$typeclass[$v]['classid']]))
  1302. {
  1303. if($typeclass[$v]['title'] == '9A')
  1304. {
  1305. $pm[$typeclass[$v]['classid']] = '9A';
  1306. }
  1307. else if($typeclass[$v]['title'] == '10A')
  1308. {
  1309. $pm[$typeclass[$v]['classid']] = '10A';
  1310. }
  1311. else
  1312. {
  1313. $clzh = $typeclass[$v]['zh'];
  1314. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1315. {
  1316. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1317. $clzh = $clzh[0];
  1318. }
  1319. $pm[$typeclass[$v]['classid']] = $clzh;
  1320. }
  1321. }
  1322. }
  1323. }
  1324. $jm = $val;
  1325. $pm = array_filter($pm);//去除空值
  1326. $pm = implode(" ",$pm);
  1327. $pm = preg_replace("/\r\n|\r|\n/",'',trim($pm,' '));
  1328. $title = trim($title,' ');
  1329. $bm = '03'.implode("",$bmpx);
  1330. $chuanshu = $this->_cslh($jm,$title,$pm,$bm);
  1331. if($chuanshu['x'] != 2)
  1332. {
  1333. $j++;
  1334. $ed[] = array($chuanshu['msg'],$jm,$bm);
  1335. }
  1336. }
  1337. if($j > 0)
  1338. {
  1339. $time = date('Ymd',time());
  1340. $title = '错误信息-'.$time;
  1341. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  1342. $tail = "\n";
  1343. $filename = $title.".xls";
  1344. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  1345. $dir = '/data/excel/'.$time.'/';
  1346. $file_name = 'error_'.$time.rand(1000,9999);
  1347. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  1348. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  1349. fwrite($myfile,$ecl);
  1350. fclose($myfile);
  1351. $error = $dir.$file_name.'.xls';
  1352. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  1353. }
  1354. else
  1355. {
  1356. echo json_encode(array('msg'=>'添加成功!'.$i,'error'=>1,'success'=>true));exit;
  1357. }
  1358. }
  1359. else
  1360. {
  1361. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  1362. }
  1363. }
  1364. public function _cslh($jm,$title,$pm,$bm)
  1365. {
  1366. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$title,'zh'=>$pm,'bm'=>$bm));
  1367. if(isset($lh['Data'][0]))
  1368. {
  1369. if($lh['Data'][0]['m_isSucess'] != 1)
  1370. {
  1371. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  1372. {
  1373. return array('msg'=>$lh['Data'][0]['m_errorMsg'],'x'=>1);exit;
  1374. }
  1375. }
  1376. }
  1377. else
  1378. {
  1379. return array('msg'=>'料号错误','x'=>1);exit;
  1380. }
  1381. return array('x'=>2);exit;
  1382. }
  1383. public function _bbprint()
  1384. {
  1385. $time = time();
  1386. $post = $this->input->post(NULL);
  1387. if(isset($post['d']))
  1388. {
  1389. $order = 0;$time = time();
  1390. $d = $this->input->post('d',true);
  1391. $n = $this->input->post('n',true);//打印数量
  1392. $data = $this->whlabel_bh->read($d);
  1393. if(!$data)
  1394. {
  1395. echo json_encode(array('msg'=>'未找到此备货信息,请刷新页面重试','success'=>false));exit;
  1396. }
  1397. $printnum = $this->whlabel_bh_transfer->find_all("number = '".$data['number']."'");
  1398. $printnum = array_sum(array_column($printnum,'ts'));
  1399. if($data['bhnum']-$printnum-$n < 0)
  1400. {
  1401. echo json_encode(array('msg'=>'打印数量不可超出备货数量!','success'=>false));exit;
  1402. }
  1403. $post['number'] = $data['number'];
  1404. $post['orderinfo'] = $data['orderinfo'];
  1405. $post['type'] = 0;//0生产 1外购
  1406. $post['features'] = $data['features'];
  1407. $post['jm'] = $data['jm'];
  1408. $post['bm'] = $data['bm'];
  1409. $post['pm'] = $data['pm'];
  1410. $post['sku'] = $data['sku'];
  1411. $post['features'] = $data['features'];
  1412. $post['number'] = $data['number'];
  1413. $post['title'] = $data['title'];
  1414. $post['printtime'] = $time;
  1415. $post['ts'] = $n;
  1416. $post['rk'] = "|15|";//默认订单中心 打印后直接入库
  1417. $post['rktime'] = "|".$time."|";
  1418. $post['ctime15'] = $time;
  1419. $post['time'] = $time;
  1420. $post['gtime'] = date('Yms',$time);
  1421. $rows = array();
  1422. $label = substr($time,1).rand(10,99);
  1423. $post['label'] = $label;
  1424. $rows[] = array('num'=>$post['label'],'title'=>$data['orderinfo'],'jm'=>$data['jm'],'n'=>$n);
  1425. if($this->whlabel_bh_transfer->insert($post))
  1426. {
  1427. echo json_encode(array('rows'=>($rows),'id'=>$d,'success'=>true));exit;
  1428. }
  1429. else
  1430. {
  1431. $this->db->trans_rollback();
  1432. echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  1433. }
  1434. }
  1435. }
  1436. public function _operate()
  1437. {
  1438. $post = $this->input->post(NULL, TRUE);
  1439. if(isset($post['page']))
  1440. {
  1441. $api = $this->input->post('api',true);
  1442. $page = $this->input->post('page',true);
  1443. $perpage = $this->input->post('perpage',true);
  1444. $orderinfo = $this->input->post('number',true);
  1445. $color = $this->input->post('color',true);
  1446. $pm = $this->input->post('pm',true);
  1447. $purchase = $this->input->post('purchase',true);
  1448. $transfer = $this->input->post('transfer',true);
  1449. $lx = $this->input->post('lx',true);
  1450. $timetk = $this->input->post('timetk',true);
  1451. $timetj = $this->input->post('timetj',true);
  1452. $timetk = strtotime($timetk);
  1453. $timetj = strtotime($timetj);
  1454. $where = "1=1";
  1455. if($transfer)
  1456. {
  1457. $ctime = 'ctime'.$transfer;
  1458. $where .= " and $ctime > '$timetk' and $ctime < '$timetj'";
  1459. }
  1460. else
  1461. {
  1462. $where .= " and time > '$timetk' and time < '$timetj'";
  1463. }
  1464. if($orderinfo)
  1465. {
  1466. $where .= " and orderinfo like '%$orderinfo%'";
  1467. }
  1468. if($transfer)
  1469. {
  1470. $where .= " and rk like '%|".$transfer."|%'";
  1471. }
  1472. if($purchase)
  1473. {
  1474. $where .= " and purchase = '$purchase'";
  1475. }
  1476. if($pm)
  1477. {
  1478. $where .= " and pm like '%$pm%'";
  1479. }
  1480. if($color)
  1481. {
  1482. $where .= " and fpdata like '%-".$color."-%'";
  1483. }
  1484. //数据排序
  1485. $order_str = "id desc";
  1486. if(empty($page))
  1487. {
  1488. $start = 0;
  1489. $perpage = 1;
  1490. }
  1491. else
  1492. {
  1493. $start = ($page - 1)*$perpage;
  1494. }
  1495. //取得信息列表
  1496. $info_list = $this->whlabel_bh_transfer->find_all($where,'id,orderinfo,pm,shipremarks,ts,printtime,time',$order_str,$start,$perpage);
  1497. $transfer = $this->transfer->find_all();
  1498. $t = array();$ot = array();
  1499. foreach ($transfer as $v)
  1500. {
  1501. $t[$v['id']] = $v['title'];
  1502. $ot[$v['id']] = ($v['orvertime']>0)?$v['orvertime']*24*3600:0;
  1503. }
  1504. //格式化数据
  1505. foreach ($info_list as $key=>$value)
  1506. {
  1507. $dd = $this->whlabel_bh_transfer->read($value['id']);
  1508. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1509. $rk = explode('|',trim($dd['rk'],'|'));
  1510. $rktime = explode('|',trim($dd['rktime'],'|'));
  1511. $ck = explode('|',trim($dd['ck'],'|'));
  1512. $cktime = explode('|',trim($dd['cktime'],'|'));
  1513. $info_list[$key]['time'] = '';
  1514. for($i=0;$i<count($rk);$i++)
  1515. {
  1516. if(count($rk)-1 == $i && $ot[$rk[$i]] > 0 && $rktime[$i] + $ot[$rk[$i]] < time())
  1517. {
  1518. $d = '<em style="color: #fc5454;">'.$t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').' 超</em><br>';
  1519. }
  1520. else
  1521. {
  1522. $d = $t[$rk[$i]].'入库 :'.((isset($rktime[$i]))?(date('Y-m-d H:i',$rktime[$i])):'').'<br>';
  1523. }
  1524. $info_list[$key]['time'] .= $d;
  1525. if(isset($ck[$i]) && $ck[$i] != '')
  1526. {
  1527. $info_list[$key]['time'] .= $t[$ck[$i]].'出库 :'.date('Y-m-d H:i',$cktime[$i]).'<br>';
  1528. }
  1529. }
  1530. $info_list[$key]['time'] = trim($info_list[$key]['time'],'<br>');
  1531. }
  1532. $total = $this->whlabel_bh_transfer->find_count($where);
  1533. $pagenum = ceil($total/$perpage);
  1534. $over = $total-($start+$perpage);
  1535. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  1536. echo json_encode($rows);exit;
  1537. }
  1538. if(isset($_SESSION['api']))
  1539. {
  1540. $user = $this->user->get_api($_SESSION['api']);
  1541. $usp = $user;
  1542. $pid = "";$tid="";$sid="";$wid="";
  1543. $purchase = explode('|',trim($user['purchase'],'|'));
  1544. $transfer = explode('|',trim($user['transfer'],'|'));
  1545. $warehouse = explode('|',trim($user['warehouse'],'|'));
  1546. foreach ($purchase as $value)
  1547. {
  1548. $pid .= " id = ".$value." or";
  1549. }
  1550. foreach ($transfer as $value)
  1551. {
  1552. $tid .= " id = ".$value." or";
  1553. }
  1554. foreach ($warehouse as $value)
  1555. {
  1556. $wid .= " id = ".$value." or";
  1557. }
  1558. }
  1559. else
  1560. {
  1561. header('Location: /');exit;
  1562. }
  1563. $kx = '';$zjtab = '';
  1564. $warehouse = $this->warehouse->find_all('1=1 and '.rtrim($wid,'or'),"*","px asc");
  1565. $this->data['warehouse'] = $warehouse;
  1566. $purchase = $this->purchase->find_all("yyid != ''");
  1567. $this->data['purchase'] = $purchase;
  1568. $transfer = $this->transfer->find_all('1=1 and '.rtrim($tid,'or'));
  1569. $this->data['transfer'] = $transfer;
  1570. $this->data['vip'] = $user['vip'];
  1571. $this->_Template('whlabel_bh_operate',$this->data);
  1572. }
  1573. public function _out()
  1574. {
  1575. $post = $this->input->post(NULL, TRUE);
  1576. if(isset($post['label']))
  1577. {
  1578. $time = time();
  1579. $label = $this->input->post('label',true);
  1580. $cz = $this->input->post('cz',true);
  1581. $transfer = $this->input->post('transfer',true);
  1582. if(!$label)
  1583. {
  1584. echo json_encode(array('msg'=>'未扫入数据!','success'=>false));exit;
  1585. }
  1586. if(!$transfer)
  1587. {
  1588. echo json_encode(array('msg'=>'请选择需对应的部门!','success'=>false));exit;
  1589. }
  1590. $lb = $this->whlabel_bh_transfer->get_label($label);
  1591. if(!$lb)
  1592. {
  1593. echo json_encode(array('msg'=>'错误!未找到此条码','success'=>false));exit;
  1594. }
  1595. $lbrk = array_reverse(explode('|',trim($lb['rk'],'|')));
  1596. $lbck = array_reverse(explode('|',trim($lb['ck'],'|')));
  1597. if($cz == 1)
  1598. {
  1599. $lb['rk'] .= $transfer.'|';
  1600. $lb['rktime'] .= $time.'|';
  1601. if($lbrk[0] == $transfer)
  1602. {
  1603. echo json_encode(array('msg'=>'已有入库记录,不可连续重复录入!','success'=>false));exit;
  1604. }
  1605. }
  1606. else if($cz == 2)
  1607. {
  1608. $lb['ck'] .= $transfer.'|';
  1609. $lb['cktime'] .= $time.'|';
  1610. if($lbck[0] == $transfer)
  1611. {
  1612. echo json_encode(array('msg'=>'已有出库记录,不可连续重复录入!','success'=>false));exit;
  1613. }
  1614. }
  1615. $cztime = 'ctime'.$transfer;
  1616. //if(($transfer == 3 && $lb['dbapi'] < 99 && $cz == 2) || ($transfer == 13 && $lb['dbapi'] < 99 && $cz == 1))//出入库用这个
  1617. if($transfer == 11 && stripos($lb['rk'],'|8|') === false && stripos($lb['ck'],'|3|') === false && stripos($lb['rk'],'|13|') === false)//改出入库 需要调整8为3 由完成出库检测
  1618. {
  1619. echo json_encode(array('msg'=>'工厂未出库,请退回工厂!','success'=>false));exit;
  1620. }
  1621. 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']))
  1622. {
  1623. echo json_encode(array('music'=>'1','success'=>true));exit;
  1624. }
  1625. else
  1626. {
  1627. echo json_encode(array('msg'=>'数据写入失败,请重试!','success'=>false));exit;
  1628. }
  1629. }
  1630. }
  1631. public function _bdbb()
  1632. {
  1633. $post = $this->input->post(NULL, TRUE);
  1634. if(isset($post['s']))
  1635. {
  1636. $id_arr = $this->input->post('s');
  1637. $id_arr = explode(',',trim($id_arr,','));
  1638. if(!$id_arr)
  1639. {
  1640. echo json_encode(array('msg'=>$v.' - 未查询到需要补打信息!','success'=>false));exit;
  1641. }
  1642. //循环删除记录
  1643. foreach ($id_arr as $v)
  1644. {
  1645. $t = $this->whlabel_bh_transfer->read($v);
  1646. if(!isset($t['number']))
  1647. {
  1648. echo json_encode(array('msg'=>$v.' - 补打信息已被删除!','success'=>false));exit;
  1649. }
  1650. $rows[] = array('num'=>$t['label'],'title'=>'补:'.$t['orderinfo'],'jm'=>$t['jm'],'n'=>$t['ts']);
  1651. }
  1652. echo json_encode(array('rows'=>($rows),'success'=>true));exit;
  1653. }
  1654. }
  1655. }