Whlabel_bh.php 94 KB

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