Whlabel_bh.php 56 KB

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