Whlabel_bh.php 80 KB

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