Whlabel_bh.php 67 KB

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