Whlabel_bh.php 56 KB

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