Whlabel_bh.php 110 KB

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