Whlabel.php 341 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. $this->load->_model("Model_whlabelscbf","whlabelscbf");
  49. }
  50. //定义方法的调用规则 获取URI第二段值
  51. public function _remap($arg, $arg_array)
  52. {
  53. if ($arg == 'existence') //在库标签
  54. {
  55. $this->_existence();
  56. } else if ($arg == 'cpbqdc') //在库标签
  57. {
  58. $this->_cpbqdc();
  59. } else if ($arg == 'type') //进销存浏览
  60. {
  61. $this->_type();
  62. }else if ($arg == 'typev1') //进销存浏览
  63. {
  64. $this->_typev1();
  65. } else if ($arg == 'typedy') //进销存浏览店员页面
  66. {
  67. $this->_typedy($arg_array);
  68. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  69. {
  70. $this->_typedy_ck($arg_array);
  71. } else if ($arg == 'typeck') {
  72. $this->_typeck($arg_array);
  73. } else if ($arg == 'whlabeckdc') {
  74. $this->_whlabeckdc($arg_array);
  75. } else if ($arg == 'usatype') //美仓进销存浏览
  76. {
  77. $this->_usatype();
  78. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  79. {
  80. $this->_usatypeapp();
  81. } else if ($arg == 'enteradd') //入库操作
  82. {
  83. $this->_enteradd();
  84. } else if ($arg == 'enteredit') //修改
  85. {
  86. $this->_enteredit($arg_array);
  87. } else if ($arg == 'enter') //入库浏览
  88. {
  89. $this->_enter();
  90. } else if ($arg == 'out') //出库浏览
  91. {
  92. $this->_out();
  93. } else if ($arg == 'label') //出库标签浏览
  94. {
  95. $this->_label();
  96. } else if ($arg == 'outorder') //独立站出库订单
  97. {
  98. $this->_outorder();
  99. } else if ($arg == 'soutorder') //速卖通出库订单
  100. {
  101. $this->_soutorder();
  102. } else if ($arg == 'toutorder') //TT出库订单
  103. {
  104. $this->_toutorder();
  105. }else if ($arg == 'aoutorder') //amz出库订单
  106. {
  107. $this->_aoutorder();
  108. } else if ($arg == 'retreat') //退库订单
  109. {
  110. $this->_retreat();
  111. } else if ($arg == 'retreatlk') //退库订单
  112. {
  113. $this->_retreatlk();
  114. } else if ($arg == 'change') //更换标签
  115. {
  116. $this->_change();
  117. } else if ($arg == 'del') //删除
  118. {
  119. $this->_del();
  120. } else if ($arg == 'exceljxc') //进销存信息导出
  121. {
  122. $this->_exceljxc();
  123. } else if ($arg == 'excelr') //入库信息导出
  124. {
  125. $this->_excelr();
  126. } else if ($arg == 'excelct') //出库、退库信息导出
  127. {
  128. $this->_excelct();
  129. } else if ($arg == 'dccrtype') //根据出入库类型导出
  130. {
  131. $this->_dccrtype();
  132. } else if ($arg == 'excelcr') //出库、退库信息导出
  133. {
  134. $this->_excelcr();
  135. } else if ($arg == 'kcyz') //库存验证
  136. {
  137. $this->_kcyz();
  138. } else if ($arg == 'kj') //库存扣减
  139. {
  140. $this->_kj($arg_array);
  141. } else if ($arg == 'presetout') //预设库存导入
  142. {
  143. $this->_presetout($arg_array);
  144. } else if ($arg == 'presetedit') //预设库存导入
  145. {
  146. $this->_presetedit($arg_array);
  147. }else if ($arg == 'presetedittwo') //预设库存导入
  148. {
  149. $this->_presetedittwo($arg_array);
  150. } else if ($arg == 'summary') //汇总导出
  151. {
  152. $this->_summary($arg_array);
  153. } else if ($arg == 'manifest') //usps发货清单
  154. {
  155. $this->_manifest();
  156. } else if ($arg == 'abnormal') //占单异常
  157. {
  158. $this->_abnormal();
  159. } else if ($arg == 'error') //0库存SKU
  160. {
  161. $this->_error();
  162. } else if ($arg == 'errorexcel') //0库存SKU导出
  163. {
  164. $this->_errorexcel();
  165. } else if ($arg == 'db') {
  166. $this->_db();
  167. } else if ($arg == 'dbrk') {
  168. $this->_dbrk();
  169. } else if ($arg == 'whlabelczdc') {
  170. $this->_whlabelczdc();
  171. } else if ($arg == 'print') {
  172. $this->_print($arg_array);
  173. } else if ($arg == 'usaprint') {
  174. $this->_usaprint($arg_array);
  175. } else if ($arg == 'printck') {
  176. $this->_printck($arg_array);
  177. } else if ($arg == 'printrk') {
  178. $this->_printrk($arg_array);
  179. } else if ($arg == 'printxzrk') {
  180. $this->_printxzrk($arg_array);
  181. } else if ($arg == 'printexcel') {
  182. $this->_printexcel($arg_array);
  183. } else if ($arg == 'uck') {
  184. $this->_uck();
  185. } else if ($arg == 'whlabelexcelzh') {
  186. $this->_whlabelexcelzh();
  187. } else if ($arg == 'fc') {
  188. $this->_fc();
  189. } else if ($arg == 'fcmb') {
  190. $this->_fcmb();
  191. } else if ($arg == 'fcexcel') {
  192. $this->_fcexcel();
  193. } else if ($arg == 'fcjxc') {
  194. $this->_fcjxc($arg_array);
  195. } else if ($arg == '0kcdel') {
  196. $this->_0kcdel(); //导表删除0库存
  197. } else if ($arg == 'gbhtype') {
  198. $this->_gbhtype(); //更改备货状态
  199. } else if($arg == 'excelrjs'){
  200. $this->_excelrjs();
  201. } else if($arg == 'excelctjs'){
  202. $this->_excelctjs();
  203. }else if ($arg == 'exceljxcjs') //进销存信息导出
  204. {
  205. $this->_exceljxcjs();
  206. } else if ($arg == 'summaryjs') //汇总导出
  207. {
  208. $this->_summaryjs($arg_array);
  209. }else if($arg == 'uckjs'){
  210. $this->_uckjs();
  211. }else if ($arg == 'whlabelexcelzhjs') {
  212. $this->_whlabelexcelzhjs();
  213. }else if($arg == 'dccrtypejs'){
  214. $this->_dccrtypejs();
  215. }else if($arg == 'errorexceljs'){
  216. $this->_errorexceljs();
  217. }else if($arg == "w_t_cs"){
  218. $this->_w_t_cs(); //首页
  219. }else {
  220. $this->_index();
  221. }
  222. }
  223. public function _w_t_cs(){
  224. $vip = 0;
  225. if (isset($_SESSION['api'])) {
  226. $user = $this->user->get_api($_SESSION['api']);
  227. $fgshop = "";
  228. $sid = "";
  229. $usersp = explode('|', trim($user['shop'], '|'));
  230. foreach ($usersp as $value) {
  231. $fgshop .= " shop = " . $value . " or";
  232. $sid .= " id = " . $value . " or";
  233. }
  234. if ($user['vip'] == 1) {
  235. $vip = 1;
  236. }
  237. } else {
  238. header('Location: /');
  239. exit;
  240. }
  241. $prc = array();
  242. $purchase = $this->purchase->find_all();
  243. foreach ($purchase as $k => $v) {
  244. $prc[$v['id']] = $v['title'];
  245. }
  246. $company = array();
  247. $ct = $this->company->find_all();
  248. foreach ($ct as $k => $v) {
  249. $company[$v['id']] = $v['title'];
  250. }
  251. $sp = array();
  252. $s = $this->shop->find_all('1=1', 'id,shopname');
  253. foreach ($s as $v) {
  254. $sp[$v['id']] = $v['shopname'];
  255. }
  256. $wh = array();
  257. $w = $this->warehouse->find_all('1=1', 'id,title');
  258. foreach ($w as $v) {
  259. $wh[$v['id']] = $v['title'];
  260. }
  261. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  262. $this->data['shop'] = $wlshop;
  263. $this->data['vip'] = $vip;
  264. $this->_Template('whlabel_typejs', $this->data);
  265. }
  266. //管理
  267. public function _index()
  268. {
  269. $post = $this->input->post(NULL, TRUE);
  270. if (isset($post['page'])) {
  271. $page = $this->input->post('page', true);
  272. $perpage = $this->input->post('perpage', true);
  273. $sku = $this->input->post('sku', true);
  274. $number = $this->input->post('number', true);
  275. $warehouse = $this->input->post('warehouse', true);
  276. $purchase = $this->input->post('purchase', true);
  277. $orderinfo = $this->input->post('orderinfo', true);
  278. $waybill = $this->input->post('waybill', true);
  279. $category = $this->input->post('category', true);
  280. $size = $this->input->post('size', true);
  281. $grade = $this->input->post('grade', true);
  282. $color = $this->input->post('color', true);
  283. $lowe = $this->input->post('lowe', true);
  284. $state = $this->input->post('state', true);
  285. $label = $this->input->post('label', true);
  286. $timetk = $this->input->post('timetkk', true);
  287. $timetj = $this->input->post('timetjj', true);
  288. $timetk = strtotime($timetk);
  289. $timetj = strtotime($timetj);
  290. $where = "1=1 ";
  291. if ($timetk && $timetj) {
  292. $where .= " and time > '$timetk' and time < '$timetj'";
  293. }
  294. if ($sku) {
  295. $where .= " and sku = '$sku'";
  296. }
  297. if ($number) {
  298. $where .= " and number = '$number'";
  299. }
  300. if ($warehouse) {
  301. $where .= " and warehouse = '$warehouse'";
  302. }
  303. if ($purchase) {
  304. $where .= " and purchase = '$purchase'";
  305. }
  306. if ($orderinfo) {
  307. $where .= " and orderinfo = '$orderinfo'";
  308. }
  309. if ($waybill) {
  310. $where .= " and waybill = '$waybill'";
  311. }
  312. if ($category) {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if ($size) {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if ($grade) {
  319. $where .= " and features like '%-$grade-%'";
  320. }
  321. if ($color) {
  322. $where .= " and features like '%-$color-%'";
  323. }
  324. if ($lowe) {
  325. $where .= " and features like '%-$lowe-%'";
  326. }
  327. if ($label) {
  328. $where .= " and label = '$label'";
  329. }
  330. if ($state != '') {
  331. $where .= " and state = '$state'";
  332. }
  333. //数据排序
  334. $order_str = "time desc";
  335. if (empty($page)) {
  336. $start = 0;
  337. $perpage = 1;
  338. } else {
  339. $start = ($page - 1) * $perpage;
  340. }
  341. //取得信息列表
  342. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  343. foreach ($info_list as $key => $value) {
  344. $warehouse = $this->warehouse->read($value['warehouse']);
  345. $info_list[$key]['warehouse'] = $warehouse['title'];
  346. $purchase = $this->purchase->read($value['purchase']);
  347. $info_list[$key]['purchase'] = $purchase['title'];
  348. if ($value['enter'] != 0) {
  349. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  350. } else {
  351. $info_list[$key]['enter'] = "";
  352. }
  353. if ($value['outk'] != 0) {
  354. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  355. } else {
  356. $info_list[$key]['outk'] = "";
  357. }
  358. if ($value['printing'] != 0) {
  359. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  360. } else {
  361. $info_list[$key]['printing'] = "";
  362. }
  363. if ($value['orderinfo'] == 0) {
  364. $info_list[$key]['orderinfo'] = "";
  365. }
  366. if ($value['waybill'] == 0) {
  367. $info_list[$key]['waybill'] = "";
  368. }
  369. if ($value['state'] == 0) {
  370. $info_list[$key]['state'] = "在库";
  371. } else if ($value['state'] == 1) {
  372. $info_list[$key]['state'] = "出库";
  373. } else if ($value['state'] == 2) {
  374. $info_list[$key]['state'] = "退库";
  375. } else if ($value['state'] == 3) {
  376. $info_list[$key]['state'] = "调拨中";
  377. } else if ($value['state'] == 4) {
  378. $info_list[$key]['state'] = "再加工";
  379. } else if ($value['state'] == 5) {
  380. $info_list[$key]['state'] = "维修中";
  381. } else if ($value['state'] == 6) {
  382. $info_list[$key]['state'] = "盘亏";
  383. } else if ($value['state'] == 7) {
  384. $info_list[$key]['state'] = "更换标签";
  385. } else if ($value['state'] == 8) {
  386. $info_list[$key]['state'] = "其它";
  387. } else if ($value['state'] == 9) {
  388. $info_list[$key]['state'] = "预设";
  389. } else if ($value['state'] == 10) {
  390. $info_list[$key]['state'] = "美店零售";
  391. }
  392. if ($value['text'] == "") {
  393. $info_list[$key]['text'] = "";
  394. }
  395. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  396. }
  397. $total = $this->whlabel->find_count($where);
  398. $pagenum = ceil($total / $perpage);
  399. $over = $total - ($start + $perpage);
  400. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  401. echo json_encode($rows);
  402. exit;
  403. }
  404. if (isset($post['outsku'])) {
  405. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  406. $cz = $this->input->post('cz', true);
  407. if ($cz == '1') {
  408. $sku = $this->input->post('outsku', true);
  409. if ($sku) {
  410. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  411. if (count($data) < 1) {
  412. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  413. exit;
  414. }
  415. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  416. echo json_encode(array('success' => true));
  417. exit;
  418. }
  419. } else {
  420. $sku = $this->input->post('outsku', true);
  421. if ($sku) {
  422. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  423. if (count($data) < 1) {
  424. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  425. exit;
  426. }
  427. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  428. echo json_encode(array('success' => true));
  429. exit;
  430. }
  431. }
  432. }
  433. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  434. $this->_Template('whlabel', $this->data);
  435. }
  436. //在库标签
  437. public function _existence()
  438. {
  439. $post = $this->input->post(NULL, TRUE);
  440. if (isset($post['s'])) {
  441. $id_arr = $this->input->post('s');
  442. $id_arr = explode(',', $id_arr);
  443. if (!$id_arr) {
  444. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  445. exit;
  446. }
  447. //循环删除记录
  448. foreach ($id_arr as $v) {
  449. $sid = $this->whlabel->read($v);
  450. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  451. if ($count > 0) {
  452. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  453. exit;
  454. }
  455. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  456. if (count($zt) > 0) {
  457. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  458. exit;
  459. }
  460. $this->whlabel->remove($v);
  461. }
  462. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  463. exit;
  464. }
  465. if (isset($post['page'])) {
  466. $page = $this->input->post('page', true);
  467. $perpage = $this->input->post('perpage', true);
  468. $warehouse = $this->input->post('warehouse', true);
  469. $label = $this->input->post('label', true);
  470. $where = "1=1 and state = 0";
  471. if ($warehouse) {
  472. $where .= " and warehouse = '$warehouse'";
  473. }
  474. if ($label) {
  475. $where .= " and label = '$label'";
  476. }
  477. //数据排序
  478. $order_str = "time asc";
  479. if (empty($page)) {
  480. $start = 0;
  481. $perpage = 1;
  482. } else {
  483. $start = ($page - 1) * $perpage;
  484. }
  485. //取得信息列表
  486. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  487. foreach ($info_list as $key => $value) {
  488. if ($value['enter'] != 0) {
  489. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  490. } else {
  491. $info_list[$key]['enter'] = "";
  492. }
  493. if ($value['printing'] != 0) {
  494. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  495. } else {
  496. $info_list[$key]['printing'] = "";
  497. }
  498. }
  499. $total = $this->whlabel->find_count($where);
  500. $pagenum = ceil($total / $perpage);
  501. $over = $total - ($start + $perpage);
  502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  503. echo json_encode($rows);
  504. exit;
  505. }
  506. $this->_Template('whlabel_existence', $this->data);
  507. }
  508. //进销存浏览
  509. public function _typedy($arg_array)
  510. {
  511. $prc = array();
  512. $purchase = $this->purchase->find_all();
  513. foreach ($purchase as $k => $v) {
  514. $prc[$v['id']] = $v['title'];
  515. }
  516. $post = $this->input->post(NULL, TRUE);
  517. if (isset($post['page'])) {
  518. $page = $this->input->post('page', true);
  519. $perpage = $this->input->post('perpage', true);
  520. $category = $this->input->post('category', true);
  521. $size = $this->input->post('size', true);
  522. $grade = $this->input->post('grade', true);
  523. $color = $this->input->post('color', true);
  524. $lowe = $this->input->post('lowe', true);
  525. $sku = $this->input->post('sku');
  526. $title = $this->input->post('title');
  527. $warehouse = $this->input->post('warehouse', true);
  528. $usa = $this->input->post('usa', true);
  529. $purchase = $this->input->post('purchase', true);
  530. $lacetype = $this->input->post('lacetype', true);
  531. $haircap = $this->input->post('haircap', true);
  532. $density = $this->input->post('density', true);
  533. $details = $this->input->post('details', true);
  534. $state = $this->input->post('state', true);
  535. $lacecolor = $this->input->post('lacecolor', true);
  536. $hairnumber = $this->input->post('hairnumber', true);
  537. $cklx = $this->input->post('cklx', true);
  538. $ktime = $this->input->post('ktime', true);
  539. $jtime = $this->input->post('jtime', true);
  540. $sm = $this->input->post('sm', true);
  541. $cpbz = $this->input->post('cpbz', true);
  542. $type = $this->input->post('type', true);
  543. $ktime = strtotime($ktime);
  544. $jtime = strtotime($jtime);
  545. $where = "1=1";
  546. $gj = "";
  547. $ck = "";
  548. if ($usa) {
  549. if (!$warehouse) {
  550. $where .= " and (warehouse = '5' or warehouse = '8')";
  551. }
  552. }
  553. if ($warehouse) {
  554. $where .= " and warehouse = '$warehouse'";
  555. }
  556. if ($details) {
  557. $where .= " and details = '$details'";
  558. }
  559. if ($purchase) {
  560. $where .= " and purchase = '$purchase'";
  561. }
  562. if (isset($state)) {
  563. if($state >-1){
  564. $where .= " and state = '$state'";
  565. }
  566. }
  567. if ($lacetype) {
  568. $where .= " and features like '%-$lacetype-%'";
  569. }
  570. if ($category) {
  571. $where .= " and features like '%-$category-%'";
  572. }
  573. if ($size) {
  574. $where .= " and features like '%-$size-%'";
  575. }
  576. if ($grade) {
  577. $where .= " and features like '%-$grade-%'";
  578. }
  579. if ($color) {
  580. $where .= " and features like '%-$color-%'";
  581. }
  582. if ($lowe) {
  583. $where .= " and features like '%-$lowe-%'";
  584. }
  585. if ($haircap) {
  586. $where .= " and features like '%-$haircap-%'";
  587. }
  588. if ($density) {
  589. $where .= " and features like '%-$density-%'";
  590. }
  591. if ($lacecolor) {
  592. $where .= " and features like '%-$lacecolor-%'";
  593. }
  594. if($sm){
  595. $where .= " and sm like '%".$sm."%'";
  596. }
  597. if($cpbz){
  598. $where .= " and cpbz like '%".$cpbz."%'";
  599. }
  600. if($type){
  601. $where .= " and type = ".$type."";
  602. }
  603. if (!empty($hairnumber)) {
  604. $where .= " and features like '%-128-%' ";
  605. if ($hairnumber < 0) {
  606. $class_list = $this->typeclass->find_all('classid = 43');
  607. foreach ($class_list as $v) {
  608. $where .= " and features not like '%-" . $v['id'] . "-%'";
  609. }
  610. } else {
  611. $where .= " and features like '%-$hairnumber-%'";
  612. }
  613. }
  614. $where_add = '';
  615. if ($cklx) {
  616. $shop = $this->shop->read($cklx);
  617. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  618. }
  619. if ($ktime && $jtime) {
  620. $gj = " and enter > '$ktime' and enter < '$jtime'";
  621. $ck = " and outk > '$ktime' and outk < '$jtime'";
  622. }
  623. //数据排序
  624. $order_str = "id desc";
  625. if (empty($page)) {
  626. $start = 0;
  627. $perpage = 1;
  628. } else {
  629. $start = ($page - 1) * $perpage;
  630. }
  631. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  632. if ($sku) {
  633. $sku = trim($sku, ' ');
  634. $sku = trim($sku, ' ');
  635. $where .= " and sku like '%$sku%'";
  636. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  637. } else if ($title) {
  638. $title = trim($title, ' ');
  639. $title = trim($title, ' ');
  640. $where .= " and title like '%$title%'";
  641. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  642. } else {
  643. //$where .= " and time > '$ktime' and time < '$jtime'";
  644. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  645. }
  646. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  647. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  648. foreach ($info_list as $k => $v) {
  649. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  650. unset($info_list[$k]['pm']);
  651. unset($info_list[$k]['jm']);
  652. unset($info_list[$k]['bm']);
  653. }
  654. //取得信息列表
  655. $rows = array();
  656. $list = array();
  657. foreach ($info_list as $key => $value) {
  658. $warehouse = $this->warehouse->read($value['warehouse']);
  659. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  660. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  661. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  662. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  663. $info_list[$key]['label'] = $value['sm'];
  664. $number = $value['number'];
  665. $ftime = time() - 15 * 24 * 3600;
  666. $info_list[$key]['warehouse'] = $warehouse['title'];
  667. $info_list[$key]['features'] = count($c);
  668. $z = count($z); //查看订单号
  669. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  670. $ztdata = '';
  671. if (count($zt) > 0) {
  672. foreach ($zt as $vv) {
  673. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  674. }
  675. }
  676. $info_list[$key]['number'] = $ztdata;
  677. $info_list[$key]['sm'] = $z;
  678. $details = array();
  679. $cpid = array();
  680. foreach ($c as $k => $v) {
  681. $details[$v['details']] = $v['details'];
  682. if ($v['cpid'] != 0) {
  683. $cpid[$v['cpid']] = $v['cpid'];
  684. }
  685. }
  686. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  687. if ($value['shop'] != '') {
  688. $shop = explode(',', trim($value['shop'], ','));
  689. $shop = $this->shop->read($shop[0]);
  690. $info_list[$key]['shop'] = $shop['shopname'];
  691. }
  692. }
  693. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  694. $pagenum = ceil($total / $perpage);
  695. $over = $total - ($start + $perpage);
  696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  697. echo json_encode($rows);
  698. exit;
  699. }
  700. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  701. $this->_Template('whlabel_typedy', $this->data);
  702. }
  703. //进销存浏览
  704. public function _typedy_ck($arg_array)
  705. {
  706. $prc = array();
  707. $purchase = $this->purchase->find_all();
  708. foreach ($purchase as $k => $v) {
  709. $prc[$v['id']] = $v['title'];
  710. }
  711. $post = $this->input->post(NULL, TRUE);
  712. if (isset($post['page'])) {
  713. $page = $this->input->post('page', true);
  714. $perpage = $this->input->post('perpage', true);
  715. $category = $this->input->post('category', true);
  716. $size = $this->input->post('size', true);
  717. $grade = $this->input->post('grade', true);
  718. $color = $this->input->post('color', true);
  719. $lowe = $this->input->post('lowe', true);
  720. $sku = $this->input->post('sku');
  721. $title = $this->input->post('title');
  722. $warehouse = $this->input->post('warehouse', true);
  723. $usa = $this->input->post('usa', true);
  724. $purchase = $this->input->post('purchase', true);
  725. $lacetype = $this->input->post('lacetype', true);
  726. $haircap = $this->input->post('haircap', true);
  727. $density = $this->input->post('density', true);
  728. $details = $this->input->post('details', true);
  729. $state = $this->input->post('state', true);
  730. $lacecolor = $this->input->post('lacecolor', true);
  731. $cklx = $this->input->post('cklx', true);
  732. $ktime = $this->input->post('ktime', true);
  733. $jtime = $this->input->post('jtime', true);
  734. $ktime = strtotime($ktime);
  735. $jtime = strtotime($jtime);
  736. $where = "1=1";
  737. $gj = "";
  738. $ck = "";
  739. if ($lacetype) {
  740. $where .= " and features like '%-$lacetype-%'";
  741. }
  742. if ($category) {
  743. $where .= " and features like '%-$category-%'";
  744. }
  745. if ($size) {
  746. $where .= " and features like '%-$size-%'";
  747. }
  748. if ($grade) {
  749. $where .= " and features like '%-$grade-%'";
  750. }
  751. if ($color) {
  752. $where .= " and features like '%-$color-%'";
  753. }
  754. if ($lowe) {
  755. $where .= " and features like '%-$lowe-%'";
  756. }
  757. if ($haircap) {
  758. $where .= " and features like '%-$haircap-%'";
  759. }
  760. if ($density) {
  761. $where .= " and features like '%-$density-%'";
  762. }
  763. if ($lacecolor) {
  764. $where .= " and features like '%-$lacecolor-%'";
  765. }
  766. if ($usa) {
  767. if (!$warehouse) {
  768. $where .= " and (warehouse = '5' or warehouse = '8')";
  769. }
  770. }
  771. if ($warehouse) {
  772. $where .= " and warehouse = '$warehouse'";
  773. }
  774. if ($details) {
  775. $where .= " and details = '$details'";
  776. }
  777. if ($purchase) {
  778. $where .= " and purchase = '$purchase'";
  779. }
  780. if ($state) {
  781. $where .= " and state = '$state'";
  782. }
  783. $where_add = '';
  784. if ($cklx) {
  785. $shop = $this->shop->read($cklx);
  786. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  787. }
  788. if ($ktime && $jtime) {
  789. $gj = " and enter > '$ktime' and enter < '$jtime'";
  790. $ck = " and outk > '$ktime' and outk < '$jtime'";
  791. }
  792. //数据排序
  793. $order_str = "id desc";
  794. if (empty($page)) {
  795. $start = 0;
  796. $perpage = 1;
  797. } else {
  798. $start = ($page - 1) * $perpage;
  799. }
  800. if ($sku) {
  801. $sku = trim($sku, ' ');
  802. $sku = trim($sku, ' ');
  803. $where .= " and sku like '%$sku%'";
  804. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  805. } else if ($title) {
  806. $title = trim($title, ' ');
  807. $title = trim($title, ' ');
  808. $where .= " and title like '%$title%'";
  809. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  810. } else {
  811. //$where .= " and time > '$ktime' and time < '$jtime'";
  812. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  813. }
  814. //取得信息列表
  815. $rows = array();
  816. $list = array();
  817. foreach ($info_list as $key => $value) {
  818. $warehouse = $this->warehouse->read($value['warehouse']);
  819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  820. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  821. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  822. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  823. $ftime = time() - 15 * 24 * 3600;
  824. $info_list[$key]['warehouse'] = $warehouse['title'];
  825. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  826. //$z = count($z);//查看订单号
  827. //$info_list[$key]['zd'] = $z;
  828. $details = array();
  829. $cpid = array();
  830. foreach ($c as $k => $v) {
  831. $details[$v['details']] = $v['details'];
  832. if ($v['cpid'] != 0) {
  833. $cpid[$v['cpid']] = $v['cpid'];
  834. }
  835. }
  836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  837. if ($value['shop'] != '') {
  838. $shop = explode(',', trim($value['shop'], ','));
  839. $shop = $this->shop->read($shop[0]);
  840. $info_list[$key]['shop'] = $shop['shopname'];
  841. }
  842. }
  843. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  844. $pagenum = ceil($total / $perpage);
  845. $over = $total - ($start + $perpage);
  846. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  847. echo json_encode($rows);
  848. exit;
  849. }
  850. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  851. $this->_Template('whlabel_typedy_ck', $this->data);
  852. }
  853. public function _typeck($arg_array)
  854. {
  855. $prc = array();
  856. $purchase = $this->purchase->find_all();
  857. foreach ($purchase as $k => $v) {
  858. $prc[$v['id']] = $v['title'];
  859. }
  860. $post = $this->input->post(NULL, TRUE);
  861. if (isset($post['page'])) {
  862. $page = $this->input->post('page', true);
  863. $perpage = $this->input->post('perpage', true);
  864. $category = $this->input->post('category', true);
  865. $size = $this->input->post('size', true);
  866. $grade = $this->input->post('grade', true);
  867. $color = $this->input->post('color', true);
  868. $lacecolor = $this->input->post('lacecolor', true);
  869. $lowe = $this->input->post('lowe', true);
  870. $sku = $this->input->post('sku');
  871. $title = $this->input->post('title');
  872. $warehouse = 13;
  873. $usa = $this->input->post('usa', true);
  874. $purchase = $this->input->post('purchase', true);
  875. $lacetype = $this->input->post('lacetype', true);
  876. $haircap = $this->input->post('haircap', true);
  877. $density = $this->input->post('density', true);
  878. $details = $this->input->post('details', true);
  879. $state = $this->input->post('state', true);
  880. $ktime = $this->input->post('ktime', true);
  881. $jtime = $this->input->post('jtime', true);
  882. $ktime = strtotime($ktime);
  883. $jtime = strtotime($jtime);
  884. $where = "1=1";
  885. $gj = "";
  886. $ck = "";
  887. if ($lacetype) {
  888. $where .= " and features like '%-$lacetype-%'";
  889. }
  890. if ($category) {
  891. $where .= " and features like '%-$category-%'";
  892. }
  893. if ($size) {
  894. $where .= " and features like '%-$size-%'";
  895. }
  896. if ($grade) {
  897. $where .= " and features like '%-$grade-%'";
  898. }
  899. if ($color) {
  900. $where .= " and features like '%-$color-%'";
  901. }
  902. if ($lacecolor) {
  903. $where .= " and features like '%-$lacecolor-%'";
  904. }
  905. if ($lowe) {
  906. $where .= " and features like '%-$lowe-%'";
  907. }
  908. if ($haircap) {
  909. $where .= " and features like '%-$haircap-%'";
  910. }
  911. if ($density) {
  912. $where .= " and features like '%-$density-%'";
  913. }
  914. if ($warehouse) {
  915. $where .= " and warehouse = '$warehouse'";
  916. }
  917. if ($details) {
  918. $where .= " and details = '$details'";
  919. }
  920. if ($purchase) {
  921. $where .= " and purchase = '$purchase'";
  922. }
  923. if ($state) {
  924. $where .= " and state = '$state'";
  925. }
  926. if ($ktime && $jtime) {
  927. $gj = " and enter > '$ktime' and enter < '$jtime'";
  928. $ck = " and outk > '$ktime' and outk < '$jtime'";
  929. }
  930. //数据排序
  931. $order_str = "id desc";
  932. if (empty($page)) {
  933. $start = 0;
  934. $perpage = 1;
  935. } else {
  936. $start = ($page - 1) * $perpage;
  937. }
  938. if ($sku) {
  939. $sku = trim($sku, ' ');
  940. $sku = trim($sku, ' ');
  941. $where .= " and sku like '%$sku%'";
  942. } else if ($title) {
  943. $title = trim($title, ' ');
  944. $title = trim($title, ' ');
  945. $where .= " and title like '%$title%'";
  946. }
  947. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  948. //取得信息列表
  949. $t = array();
  950. $typeclass = $this->typeclass->find_all();
  951. foreach ($typeclass as $v) {
  952. $t[$v['id']] = $v;
  953. }
  954. $rows = array();
  955. $list = array();
  956. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  957. foreach ($info_list as $key => $value) {
  958. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  959. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  960. $warehouse = $this->warehouse->read($value['warehouse']);
  961. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  962. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  963. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  964. $number = $value['number'];
  965. $ftime = time() - 15 * 24 * 3600;
  966. $z = count($z); //查看订单号
  967. $info_list[$key]['warehouse'] = $warehouse['title'];
  968. $info_list[$key]['features'] = count($c);
  969. $info_list[$key]['number'] = $z;
  970. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  971. $details = array();
  972. $cpid = array();
  973. foreach ($c as $k => $v) {
  974. $details[$v['details']] = $v['details'];
  975. if ($v['cpid'] != 0) {
  976. $cpid[$v['cpid']] = $v['cpid'];
  977. }
  978. }
  979. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  980. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  981. unset($info_list[$key]['pm']);
  982. unset($info_list[$key]['jm']);
  983. unset($info_list[$key]['bm']);
  984. }
  985. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  986. $pagenum = ceil($total / $perpage);
  987. $over = $total - ($start + $perpage);
  988. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  989. echo json_encode($rows);
  990. exit;
  991. }
  992. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  993. $this->_Template('whlabel_typeck', $this->data);
  994. }
  995. //进销存导出
  996. public function _whlabeckdc()
  997. {
  998. $prc = array();
  999. $purchase = $this->purchase->find_all();
  1000. foreach ($purchase as $k => $v) {
  1001. $prc[$v['id']] = $v['title'];
  1002. }
  1003. if (isset($_GET['excel'])) {
  1004. $where = "sku != 'Preset'";
  1005. //数据排序
  1006. $order_str = "id desc";
  1007. if (empty($page)) {
  1008. $start = 0;
  1009. $perpage = 1;
  1010. } else {
  1011. $start = ($page - 1) * $perpage;
  1012. }
  1013. $category = $this->input->get('category', true);
  1014. $color = $this->input->get('color', true);
  1015. $lowe = $this->input->get('lowe', true);
  1016. $lacetype = $this->input->get('lacetype', true);
  1017. $size = $this->input->get('size', true);
  1018. $density = $this->input->get('density', true);
  1019. $haircap = $this->input->get('haircap', true);
  1020. $sku = $this->input->get('sku', true);
  1021. $details = $this->input->get('details', true);
  1022. $warehouse = 13;
  1023. $excelid = $this->input->get('sid', true);
  1024. if ($category) {
  1025. $where .= " and features like '%-$category-%'";
  1026. }
  1027. if ($color) {
  1028. $where .= " and features like '%-$color-%'";
  1029. }
  1030. if ($lowe) {
  1031. $where .= " and features like '%-$lowe-%'";
  1032. }
  1033. if ($lacetype) {
  1034. $where .= " and features like '%-$lacetype-%'";
  1035. }
  1036. if ($size) {
  1037. $where .= " and features like '%-$size-%'";
  1038. }
  1039. if ($density) {
  1040. $where .= " and features like '%-$density-%'";
  1041. }
  1042. if ($haircap) {
  1043. $where .= " and features like '%-$haircap-%'";
  1044. }
  1045. if ($warehouse) {
  1046. $where .= " and warehouse = '$warehouse'";
  1047. }
  1048. if ($sku) {
  1049. $where .= " and sku like '%$sku%'";
  1050. }
  1051. if ($details) {
  1052. $where .= " and details = '$details'";
  1053. }
  1054. $xzid = '';
  1055. if ($excelid) {
  1056. $excelid = explode(',', trim($excelid, ','));
  1057. foreach ($excelid as $key => $value) {
  1058. $xzid .= " id = " . $value . " or";
  1059. }
  1060. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1061. }
  1062. //取得信息列表
  1063. /**
  1064. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1065. $rows = array();$list = array();
  1066. foreach ($info_list as $key=>$value)
  1067. {
  1068. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1069. }
  1070. **/
  1071. $wh = array();
  1072. $w = $this->warehouse->find_all('1=1', 'id,title');
  1073. foreach ($w as $v) {
  1074. $wh[$v['id']] = $v['title'];
  1075. }
  1076. $tc = array();
  1077. $tcdata = array();
  1078. $list = array();
  1079. $classid = $this->classid->sku();
  1080. $tcall = $this->typeclass->find_all();
  1081. $typeclass = array();
  1082. foreach ($tcall as $v)
  1083. {
  1084. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1085. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1086. }
  1087. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1088. foreach ($rows as $key => $value) {
  1089. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1090. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1091. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1092. $rows[$key]['cpbz'] = $u9_info['bm'];
  1093. $rows[$key]['cs'] = $u9_info['jm'];
  1094. if(empty($value['details'])){
  1095. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1096. }else{
  1097. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1098. }
  1099. $details = array();
  1100. $cpid = array();
  1101. $cpbz = array();
  1102. $c = 0;
  1103. $g = 0;
  1104. $x = 0;
  1105. $t = 0;
  1106. $s = 0;
  1107. $q = 0;
  1108. foreach ($sd as $k => $v) {
  1109. if ($v['state'] == 0) {
  1110. $c++;
  1111. }
  1112. if ($v['state'] != 9) {
  1113. $g++;
  1114. }
  1115. if ($v['state'] == 1) {
  1116. $x++;
  1117. }
  1118. if ($v['state'] == 2) {
  1119. $t++;
  1120. }
  1121. if ($v['state'] == 8) {
  1122. $s++;
  1123. }
  1124. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1125. $q++;
  1126. }
  1127. $details[$v['details']] = $v['details'];
  1128. if ($v['cpid'] != 0) {
  1129. $cpid[$v['cpid']] = $v['cpid'];
  1130. }
  1131. if ($v['cpbz'] != '') {
  1132. $cpbz[$v['cpbz']] = $v['cpbz'];
  1133. }
  1134. }
  1135. $rows[$key]['details'] = implode("、", $details);
  1136. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1137. $number = $value['number'];
  1138. $ftime = time() - 15 * 24 * 3600;
  1139. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1140. $rows[$key]['number'] = $g;
  1141. $rows[$key]['features'] = $c;
  1142. $rows[$key]['x'] = $x;
  1143. $rows[$key]['t'] = $t;
  1144. $rows[$key]['s'] = $s;
  1145. $rows[$key]['q'] = $q;
  1146. $rows[$key]['wzsl'] = count($details);
  1147. //cpbzs
  1148. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1149. $unique_arr = array_unique($tmp_cpbzs);
  1150. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1151. }
  1152. $title = "进销存统计表" . date('Y-m-d', time());
  1153. $titlename = "<table border=1>
  1154. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1155. <tr align='center'>
  1156. <td>仓库</td>
  1157. <td>供应商</td>
  1158. <td>位置</td>
  1159. <td>库存编码</td>
  1160. <td>SKU</td>
  1161. <td>用友编码</td>
  1162. <td>用友料号</td>
  1163. <td>产品英文名</td>
  1164. <td>产品中文名</td>
  1165. <td>备注</td>
  1166. <td>入库总量</td>
  1167. <td>库存数量</td>
  1168. <td>销售数量</td>
  1169. <td>退货数量</td>
  1170. <td>删除数量</td>
  1171. <td>其它操作</td>
  1172. <td>位置数量</td>
  1173. </tr>
  1174. </table>";
  1175. $filename = $title . ".xls";
  1176. $tail = "";
  1177. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1178. }
  1179. }
  1180. public function _type()
  1181. {
  1182. $vip = 0;
  1183. if (isset($_SESSION['api'])) {
  1184. $user = $this->user->get_api($_SESSION['api']);
  1185. $fgshop = "";
  1186. $sid = "";
  1187. $usersp = explode('|', trim($user['shop'], '|'));
  1188. foreach ($usersp as $value) {
  1189. $fgshop .= " shop = " . $value . " or";
  1190. $sid .= " id = " . $value . " or";
  1191. }
  1192. if ($user['vip'] == 1) {
  1193. $vip = 1;
  1194. }
  1195. } else {
  1196. header('Location: /');
  1197. exit;
  1198. }
  1199. $prc = array();
  1200. $purchase = $this->purchase->find_all();
  1201. foreach ($purchase as $k => $v) {
  1202. $prc[$v['id']] = $v['title'];
  1203. }
  1204. $company = array();
  1205. $ct = $this->company->find_all();
  1206. foreach ($ct as $k => $v) {
  1207. $company[$v['id']] = $v['title'];
  1208. }
  1209. $sp = array();
  1210. $s = $this->shop->find_all('1=1', 'id,shopname');
  1211. foreach ($s as $v) {
  1212. $sp[$v['id']] = $v['shopname'];
  1213. }
  1214. $wh = array();
  1215. $w = $this->warehouse->find_all('1=1', 'id,title');
  1216. foreach ($w as $v) {
  1217. $wh[$v['id']] = $v['title'];
  1218. }
  1219. $post = $this->input->post(NULL, TRUE);
  1220. if (isset($post['page'])) {
  1221. $page = $this->input->post('page', true);
  1222. $perpage = $this->input->post('perpage', true);
  1223. $category = $this->input->post('category', true);
  1224. $size = $this->input->post('size', true);
  1225. $grade = $this->input->post('grade', true);
  1226. $color = $this->input->post('color', true);
  1227. $lowe = $this->input->post('lowe', true);
  1228. $sku = $this->input->post('sku');
  1229. $title = $this->input->post('title');
  1230. $warehouse = $this->input->post('warehouse', true);
  1231. $usa = $this->input->post('usa', true);
  1232. $purchase = $this->input->post('purchase', true);
  1233. $lacetype = $this->input->post('lacetype', true);
  1234. $haircap = $this->input->post('haircap', true);
  1235. $density = $this->input->post('density', true);
  1236. $details = $this->input->post('details', true);
  1237. $state = $this->input->post('state', true);
  1238. $shop = $this->input->post('shop', true);
  1239. $lacecolor = $this->input->post('lacecolor', true);
  1240. $hairnumber = $this->input->post('hairnumber', true);
  1241. $type = $this->input->post('type', true);
  1242. $ktime = $this->input->post('ktime', true);
  1243. $jtime = $this->input->post('jtime', true);
  1244. $ktime = strtotime($ktime);
  1245. $jtime = strtotime($jtime);
  1246. $cpbz = $this->input->post('cpbz', true);
  1247. $sm = $this->input->post('sm', true);
  1248. $where = "1=1";
  1249. $gj = "";
  1250. $ck = "";
  1251. if ($usa) {
  1252. if (!$warehouse) {
  1253. $where .= " and (warehouse = '5' or warehouse = '8')";
  1254. }
  1255. }
  1256. if ($warehouse) {
  1257. $where .= " and warehouse = '$warehouse'";
  1258. }
  1259. if ($details) {
  1260. $where .= " and details = '$details'";
  1261. }
  1262. if ($purchase) {
  1263. $where .= " and purchase = '$purchase'";
  1264. }
  1265. if ($state) {
  1266. $where .= " and state = '$state'";
  1267. }
  1268. if ($shop) {
  1269. $where .= " and shop like '%$shop%'";
  1270. }
  1271. if ($type) {
  1272. $where .= " and type = '$type'";
  1273. }
  1274. if ($ktime && $jtime) {
  1275. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1276. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1277. }
  1278. if ($cpbz) {
  1279. $where .= " and cpbz like '%$cpbz%' ";
  1280. }
  1281. if ($sm) {
  1282. $where .= " and sm like '%$sm%' ";
  1283. }
  1284. if ($lacecolor) {
  1285. $where .= " and features like '%-$lacecolor-%'";
  1286. }
  1287. if ($lacetype) {
  1288. $where .= " and features like '%-$lacetype-%'";
  1289. }
  1290. if ($category) {
  1291. $where .= " and features like '%-$category-%'";
  1292. }
  1293. if ($size) {
  1294. $where .= " and features like '%-$size-%'";
  1295. }
  1296. if ($grade) {
  1297. $where .= " and features like '%-$grade-%'";
  1298. }
  1299. if ($color) {
  1300. $where .= " and features like '%-$color-%'";
  1301. }
  1302. if ($lowe) {
  1303. $where .= " and features like '%-$lowe-%'";
  1304. }
  1305. if ($haircap) {
  1306. $where .= " and features like '%-$haircap-%'";
  1307. }
  1308. if ($density) {
  1309. $where .= " and features like '%-$density-%'";
  1310. }
  1311. if (!empty($hairnumber)) {
  1312. $where .= " and features like '%-128-%' ";
  1313. if ($hairnumber < 0) {
  1314. $class_list = $this->typeclass->find_all('classid = 43');
  1315. foreach ($class_list as $v) {
  1316. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1317. }
  1318. } else {
  1319. $where .= " and features like '%-$hairnumber-%'";
  1320. }
  1321. }
  1322. //数据排序
  1323. $order_str = "id desc";
  1324. if (empty($page)) {
  1325. $start = 0;
  1326. $perpage = 1;
  1327. } else {
  1328. $start = ($page - 1) * $perpage;
  1329. }
  1330. $fjnr = '';
  1331. if ($sku) {
  1332. $sku = trim($sku, ' ');
  1333. $sku = trim($sku, ' ');
  1334. $fjnr .= " and sku like '%$sku%'";
  1335. }
  1336. if ($title) {
  1337. $title = trim($title, ' ');
  1338. $title = trim($title, ' ');
  1339. $fjnr .= " and title like '%$title%'";
  1340. }
  1341. $wt = array();
  1342. $whlabel_type = $this->whlabel_type->find_all();
  1343. foreach ($whlabel_type as $v) {
  1344. $wt[$v['id']] = $v['title'];
  1345. }
  1346. //$where .= " and time > '$ktime' and time < '$jtime'";
  1347. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1348. //取得信息列表
  1349. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1350. $rows = array();
  1351. $list = array();
  1352. foreach ($info_list as $key => $value) {
  1353. if (isset($wt[$value['type']])) {
  1354. $info_list[$key]['type'] = $wt[$value['type']];
  1355. } else {
  1356. $info_list[$key]['type'] = '未设置';
  1357. }
  1358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1359. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1360. $ztdata = '';
  1361. if (count($zt) > 0) {
  1362. foreach ($zt as $vv) {
  1363. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1364. }
  1365. }
  1366. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1367. $cdata = array_filter($qbdata, function ($item) {
  1368. return $item['state'] < 1;
  1369. });
  1370. $c = array_sum(array_column($cdata, 'jnum'));
  1371. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1373. });
  1374. $g = array_sum(array_column($gdata, 'jnum'));
  1375. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $x = array_sum(array_column($xdata, 'jnum'));
  1379. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1380. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1381. });
  1382. $t = array_sum(array_column($tdata, 'jnum'));
  1383. // $zdata = array_filter($qbdata, function ($item) {
  1384. // return $item['zd'] != "" && $item['state'] < 1;
  1385. // });
  1386. // $z = array_sum(array_column($zdata, 'jnum'));
  1387. $zdata = array_filter($qbdata, function ($item) {
  1388. return $item['zd'] != "" && $item['state'] < 1;
  1389. });
  1390. $z = array_sum(array_column($zdata, 'jnum'));
  1391. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1392. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1393. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1394. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1395. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1396. $details = array();
  1397. $cpid = array();
  1398. $od = array();
  1399. $odid = '';
  1400. $companytitle = '';
  1401. $shop_list = [];
  1402. foreach ($qbdata as $v) {
  1403. if ($v['zd'] != "" && $v['state'] < 1) {
  1404. if (!isset($od[$v['zd']])) {
  1405. $od[$v['zd']] = 1; //所有数据sku
  1406. } else {
  1407. $od[$v['zd']] = $od[$v['zd']] + 1;
  1408. }
  1409. }
  1410. if($v['state'] == 0){
  1411. $details[$v['details']] = $v['details'];
  1412. }
  1413. if ($v['state'] < 1) {
  1414. //$details[$v['details']] = $v['details'];
  1415. if ($v['cpid'] != 0) {
  1416. $cpid[$v['cpid']] = $v['cpid'];
  1417. }
  1418. }
  1419. if($v['state'] == 0){
  1420. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1421. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1422. }
  1423. if ($v['shop'] != '') {
  1424. $shop = explode(',', trim($v['shop'], ','));
  1425. foreach ($shop as $vv) {
  1426. if (!in_array($vv, $shop_list)) {
  1427. $shop_list[] = $vv;
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. foreach ($od as $k => $vv) {
  1434. $odid .= $k . '数量' . $vv;
  1435. }
  1436. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1437. $info_list[$key]['label'] = $value['sm'];
  1438. $number = $value['number'];
  1439. $ftime = time() - 15 * 24 * 3600;
  1440. $z = $z . '(' . $odid . ')'; //查看订单号
  1441. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1442. $info_list[$key]['features'] = $c;
  1443. $info_list[$key]['number'] = $ztdata;
  1444. $info_list[$key]['sm'] = $g;
  1445. $info_list[$key]['x'] = $x;
  1446. $info_list[$key]['t'] = $t;
  1447. $info_list[$key]['z'] = $z;
  1448. /**
  1449. foreach ($cdata as $k=>$v)
  1450. {
  1451. $details[$v['details']] = $v['details'];
  1452. if($v['cpid'] != 0)
  1453. {
  1454. $cpid[$v['cpid']] = $v['cpid'];
  1455. }
  1456. }
  1457. **/
  1458. $info_list[$key]['shop'] = '';
  1459. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1460. // if ($value['shop'] != '') {
  1461. // $shop = explode(',', trim($value['shop'], ','));
  1462. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1463. // }
  1464. $shop_list = array_unique($shop_list);
  1465. $shop_str = '';
  1466. foreach ($shop_list as $v) {
  1467. if(isset($sp[$v])){
  1468. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1469. }
  1470. }
  1471. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1472. /**
  1473. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1474. if(isset($companytitle[0]))
  1475. {
  1476. foreach ($companytitle as $k=>$v)
  1477. {
  1478. if($v['companytitle'] != '')
  1479. {
  1480. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1481. }
  1482. }
  1483. }
  1484. **/
  1485. }
  1486. $final_all_list = [];
  1487. foreach ($info_list as $k => $v) {
  1488. $final_all_list[] = [
  1489. 'id' => $v['id'],
  1490. "warehouse" => $v["warehouse"],
  1491. "purchase" => $v["purchase"],
  1492. "sku" => $v["sku"],
  1493. "title" => $v["title"] . "<br/>" . $v["pm"],
  1494. "details" => $v["details"],
  1495. "shop" => $v["shop"],
  1496. "cpbz" => $v["cpbz"],
  1497. 'label' => $v['label'],
  1498. "type" => $v["type"],
  1499. "features" => $v["features"],
  1500. "number" => $v["number"],
  1501. "sm" => $v["sm"],
  1502. "x" => $v["x"],
  1503. "t" => $v["t"],
  1504. "z" => $v["z"]
  1505. ];
  1506. }
  1507. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1508. $pagenum = ceil($total / $perpage);
  1509. $over = $total - ($start + $perpage);
  1510. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1511. echo json_encode($rows);
  1512. exit;
  1513. }
  1514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1515. $this->data['shop'] = $wlshop;
  1516. $this->data['vip'] = $vip;
  1517. $this->_Template('whlabel_type', $this->data);
  1518. }
  1519. /**
  1520. * _type 优化版 v1
  1521. * 优化点:
  1522. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1523. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1524. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1525. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1526. */
  1527. public function _typev1()
  1528. {
  1529. $vip = 0;
  1530. if (isset($_SESSION['api'])) {
  1531. $user = $this->user->get_api($_SESSION['api']);
  1532. $fgshop = "";
  1533. $sid = "";
  1534. $usersp = explode('|', trim($user['shop'], '|'));
  1535. foreach ($usersp as $value) {
  1536. $fgshop .= " shop = " . $value . " or";
  1537. $sid .= " id = " . $value . " or";
  1538. }
  1539. if ($user['vip'] == 1) {
  1540. $vip = 1;
  1541. }
  1542. } else {
  1543. header('Location: /');
  1544. exit;
  1545. }
  1546. $prc = array();
  1547. $purchase = $this->purchase->find_all();
  1548. foreach ($purchase as $k => $v) {
  1549. $prc[$v['id']] = $v['title'];
  1550. }
  1551. $company = array();
  1552. $ct = $this->company->find_all();
  1553. foreach ($ct as $k => $v) {
  1554. $company[$v['id']] = $v['title'];
  1555. }
  1556. $sp = array();
  1557. $s = $this->shop->find_all('1=1', 'id,shopname');
  1558. foreach ($s as $v) {
  1559. $sp[$v['id']] = $v['shopname'];
  1560. }
  1561. $wh = array();
  1562. $w = $this->warehouse->find_all('1=1', 'id,title');
  1563. foreach ($w as $v) {
  1564. $wh[$v['id']] = $v['title'];
  1565. }
  1566. $post = $this->input->post(NULL, TRUE);
  1567. if (isset($post['page'])) {
  1568. $page = $this->input->post('page', true);
  1569. $perpage = $this->input->post('perpage', true);
  1570. $category = $this->input->post('category', true);
  1571. $size = $this->input->post('size', true);
  1572. $grade = $this->input->post('grade', true);
  1573. $color = $this->input->post('color', true);
  1574. $lowe = $this->input->post('lowe', true);
  1575. $sku = $this->input->post('sku');
  1576. $title = $this->input->post('title');
  1577. $warehouse = $this->input->post('warehouse', true);
  1578. $usa = $this->input->post('usa', true);
  1579. $purchase = $this->input->post('purchase', true);
  1580. $lacetype = $this->input->post('lacetype', true);
  1581. $haircap = $this->input->post('haircap', true);
  1582. $density = $this->input->post('density', true);
  1583. $details = $this->input->post('details', true);
  1584. $state = $this->input->post('state', true);
  1585. $shop = $this->input->post('shop', true);
  1586. $lacecolor = $this->input->post('lacecolor', true);
  1587. $hairnumber = $this->input->post('hairnumber', true);
  1588. $type = $this->input->post('type', true);
  1589. $ktime = $this->input->post('ktime', true);
  1590. $jtime = $this->input->post('jtime', true);
  1591. $ktime = strtotime($ktime);
  1592. $jtime = strtotime($jtime);
  1593. $cpbz = $this->input->post('cpbz', true);
  1594. $sm = $this->input->post('sm', true);
  1595. $where = "1=1";
  1596. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1597. $where_no_features = "1=1";
  1598. if ($usa) {
  1599. if (!$warehouse) {
  1600. $where .= " and (warehouse = '5' or warehouse = '8')";
  1601. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1602. }
  1603. }
  1604. if ($warehouse) {
  1605. $where .= " and warehouse = '$warehouse'";
  1606. $where_no_features .= " and warehouse = '$warehouse'";
  1607. }
  1608. if ($details) {
  1609. $where .= " and details = '$details'";
  1610. $where_no_features .= " and details = '$details'";
  1611. }
  1612. if ($purchase) {
  1613. $where .= " and purchase = '$purchase'";
  1614. $where_no_features .= " and purchase = '$purchase'";
  1615. }
  1616. if ($state) {
  1617. $where .= " and state = '$state'";
  1618. $where_no_features .= " and state = '$state'";
  1619. }
  1620. if ($shop) {
  1621. $where .= " and shop like '%$shop%'";
  1622. $where_no_features .= " and shop like '%$shop%'";
  1623. }
  1624. if ($type) {
  1625. $where .= " and type = '$type'";
  1626. $where_no_features .= " and type = '$type'";
  1627. }
  1628. if ($cpbz) {
  1629. $where .= " and cpbz like '%$cpbz%' ";
  1630. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1631. }
  1632. if ($sm) {
  1633. $where .= " and sm like '%$sm%' ";
  1634. $where_no_features .= " and sm like '%$sm%' ";
  1635. }
  1636. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1637. if ($lacecolor) {
  1638. $where .= " and features like '%-$lacecolor-%'";
  1639. }
  1640. if ($lacetype) {
  1641. $where .= " and features like '%-$lacetype-%'";
  1642. }
  1643. if ($category) {
  1644. $where .= " and features like '%-$category-%'";
  1645. }
  1646. if ($size) {
  1647. $where .= " and features like '%-$size-%'";
  1648. }
  1649. if ($grade) {
  1650. $where .= " and features like '%-$grade-%'";
  1651. }
  1652. if ($color) {
  1653. $where .= " and features like '%-$color-%'";
  1654. }
  1655. if ($lowe) {
  1656. $where .= " and features like '%-$lowe-%'";
  1657. }
  1658. if ($haircap) {
  1659. $where .= " and features like '%-$haircap-%'";
  1660. }
  1661. if ($density) {
  1662. $where .= " and features like '%-$density-%'";
  1663. }
  1664. if (!empty($hairnumber)) {
  1665. $where .= " and features like '%-128-%' ";
  1666. if ($hairnumber < 0) {
  1667. $class_list = $this->typeclass->find_all('classid = 43');
  1668. foreach ($class_list as $v) {
  1669. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1670. }
  1671. } else {
  1672. $where .= " and features like '%-$hairnumber-%'";
  1673. }
  1674. }
  1675. //数据排序
  1676. $order_str = "id desc";
  1677. if (empty($page)) {
  1678. $start = 0;
  1679. $perpage = 1;
  1680. } else {
  1681. $start = ($page - 1) * $perpage;
  1682. }
  1683. $fjnr = '';
  1684. if ($sku) {
  1685. $sku = trim($sku, ' ');
  1686. $sku = trim($sku, ' ');
  1687. $fjnr .= " and sku like '%$sku%'";
  1688. }
  1689. if ($title) {
  1690. $title = trim($title, ' ');
  1691. $title = trim($title, ' ');
  1692. $fjnr .= " and title like '%$title%'";
  1693. }
  1694. $wt = array();
  1695. $whlabel_type = $this->whlabel_type->find_all();
  1696. foreach ($whlabel_type as $v) {
  1697. $wt[$v['id']] = $v['title'];
  1698. }
  1699. // 列表分组(与原来完全一致)
  1700. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1701. //取得信息列表
  1702. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1703. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1704. $keys = array();
  1705. foreach ($info_list as $v) {
  1706. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1707. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1708. }
  1709. // 组合键函数,用于 PHP 端按分组索引
  1710. $comboKey = function ($r) {
  1711. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1712. };
  1713. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1714. $all_qb = array();
  1715. if (!empty($keys)) {
  1716. $keyInSql = implode(',', $keys);
  1717. $qbAll = $this->whlabel->find_all(
  1718. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1719. );
  1720. foreach ($qbAll as $r) {
  1721. $all_qb[$comboKey($r)][] = $r;
  1722. }
  1723. }
  1724. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1725. $all_zt = array();
  1726. if (!empty($info_list)) {
  1727. $ztKeys = array();
  1728. foreach ($info_list as $v) {
  1729. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1730. . addslashes($v['warehouse']) . "','"
  1731. . addslashes($v['features']) . "')";
  1732. }
  1733. $ztInSql = implode(',', $ztKeys);
  1734. $ztAll = $this->whlabeltransport->find_all(
  1735. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1736. '*',
  1737. 'stime'
  1738. );
  1739. foreach ($ztAll as $r) {
  1740. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1741. $all_zt[$ck][] = $r;
  1742. }
  1743. }
  1744. $rows = array();
  1745. $list = array();
  1746. foreach ($info_list as $key => $value) {
  1747. if (isset($wt[$value['type']])) {
  1748. $info_list[$key]['type'] = $wt[$value['type']];
  1749. } else {
  1750. $info_list[$key]['type'] = '未设置';
  1751. }
  1752. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1753. // transport 在途数据:从预取数组中取
  1754. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1755. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1756. $ztdata = '';
  1757. if (count($zt) > 0) {
  1758. foreach ($zt as $vv) {
  1759. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1760. }
  1761. }
  1762. // whlabel 组数据:从预取数组中取
  1763. $qbCk = $comboKey($value);
  1764. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1765. $cdata = array_filter($qbdata, function ($item) {
  1766. return $item['state'] < 1;
  1767. });
  1768. $c = array_sum(array_column($cdata, 'jnum'));
  1769. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1770. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1771. });
  1772. $g = array_sum(array_column($gdata, 'jnum'));
  1773. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1774. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1775. });
  1776. $x = array_sum(array_column($xdata, 'jnum'));
  1777. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1778. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1779. });
  1780. $t = array_sum(array_column($tdata, 'jnum'));
  1781. $zdata = array_filter($qbdata, function ($item) {
  1782. return $item['zd'] != "" && $item['state'] < 1;
  1783. });
  1784. $z = array_sum(array_column($zdata, 'jnum'));
  1785. $detailsArr = array();
  1786. $cpid = array();
  1787. $od = array();
  1788. $odid = '';
  1789. $companytitle = '';
  1790. $shop_list = [];
  1791. foreach ($qbdata as $v) {
  1792. if ($v['zd'] != "" && $v['state'] < 1) {
  1793. if (!isset($od[$v['zd']])) {
  1794. $od[$v['zd']] = 1;
  1795. } else {
  1796. $od[$v['zd']] = $od[$v['zd']] + 1;
  1797. }
  1798. }
  1799. if ($v['state'] == 0) {
  1800. $detailsArr[$v['details']] = $v['details'];
  1801. }
  1802. if ($v['state'] < 1) {
  1803. if ($v['cpid'] != 0) {
  1804. $cpid[$v['cpid']] = $v['cpid'];
  1805. }
  1806. }
  1807. if ($v['state'] == 0) {
  1808. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1809. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1810. }
  1811. if ($v['shop'] != '') {
  1812. $shopArr = explode(',', trim($v['shop'], ','));
  1813. foreach ($shopArr as $vv) {
  1814. if (!in_array($vv, $shop_list)) {
  1815. $shop_list[] = $vv;
  1816. }
  1817. }
  1818. }
  1819. }
  1820. }
  1821. foreach ($od as $k => $vv) {
  1822. $odid .= $k . '数量' . $vv;
  1823. }
  1824. $info_list[$key]['cpbz'] = $value['cpbz'];
  1825. $info_list[$key]['label'] = $value['sm'];
  1826. $number = $value['number'];
  1827. $z = $z . '(' . $odid . ')';
  1828. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1829. $info_list[$key]['features'] = $c;
  1830. $info_list[$key]['number'] = $ztdata;
  1831. $info_list[$key]['sm'] = $g;
  1832. $info_list[$key]['x'] = $x;
  1833. $info_list[$key]['t'] = $t;
  1834. $info_list[$key]['z'] = $z;
  1835. $info_list[$key]['shop'] = '';
  1836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1837. $shop_list = array_unique($shop_list);
  1838. $shop_str = '';
  1839. foreach ($shop_list as $v) {
  1840. if (isset($sp[$v])) {
  1841. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1842. }
  1843. }
  1844. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1845. }
  1846. $final_all_list = [];
  1847. foreach ($info_list as $k => $v) {
  1848. $final_all_list[] = [
  1849. 'id' => $v['id'],
  1850. "warehouse" => $v["warehouse"],
  1851. "purchase" => $v["purchase"],
  1852. "sku" => $v["sku"],
  1853. "title" => $v["title"] . "<br/>" . $v["pm"],
  1854. "details" => $v["details"],
  1855. "shop" => $v["shop"],
  1856. "cpbz" => $v["cpbz"],
  1857. 'label' => $v['label'],
  1858. "type" => $v["type"],
  1859. "features" => $v["features"],
  1860. "number" => $v["number"],
  1861. "sm" => $v["sm"],
  1862. "x" => $v["x"],
  1863. "t" => $v["t"],
  1864. "z" => $v["z"]
  1865. ];
  1866. }
  1867. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1868. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1869. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1870. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1871. $countResult = $this->whlabel->query($countSql)->result_array();
  1872. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1873. $pagenum = ceil($total / $perpage);
  1874. $over = $total - ($start + $perpage);
  1875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1876. echo json_encode($rows);
  1877. exit;
  1878. }
  1879. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1880. $this->data['shop'] = $wlshop;
  1881. $this->data['vip'] = $vip;
  1882. $this->_Template('whlabel_typev1', $this->data);
  1883. }
  1884. //美仓进销存浏览
  1885. public function _usatype()
  1886. {
  1887. if (isset($_SESSION['api'])) {
  1888. $user = $this->user->get_api($_SESSION['api']);
  1889. $usp = $user;
  1890. $fgshop = "";
  1891. $sid = "";
  1892. $wid = "";
  1893. $wtype = "";
  1894. $userwh = explode('|', trim($user['warehouse'], '|'));
  1895. foreach ($userwh as $value) {
  1896. $wid .= " id = " . $value . " or";
  1897. $wtype .= " type = " . $value . " or";
  1898. }
  1899. }
  1900. $prc = array();
  1901. $purchase = $this->purchase->find_all();
  1902. foreach ($purchase as $k => $v) {
  1903. $prc[$v['id']] = $v['title'];
  1904. }
  1905. $post = $this->input->post(NULL, TRUE);
  1906. if (isset($post['page'])) {
  1907. $page = $this->input->post('page', true);
  1908. $perpage = $this->input->post('perpage', true);
  1909. $category = $this->input->post('category', true);
  1910. $size = $this->input->post('size', true);
  1911. $grade = $this->input->post('grade', true);
  1912. $color = $this->input->post('color', true);
  1913. $lowe = $this->input->post('lowe', true);
  1914. $sku = $this->input->post('sku');
  1915. $title = $this->input->post('title');
  1916. $warehouse = $this->input->post('warehouse', true);
  1917. $usa = $this->input->post('usa', true);
  1918. $purchase = $this->input->post('purchase', true);
  1919. $lacetype = $this->input->post('lacetype', true);
  1920. $haircap = $this->input->post('haircap', true);
  1921. $density = $this->input->post('density', true);
  1922. $details = $this->input->post('details', true);
  1923. $state = $this->input->post('state', true);
  1924. $lacecolor = $this->input->post('lacecolor', true);
  1925. $cklx = $this->input->post('cklx', true);
  1926. $ktime = $this->input->post('ktime', true);
  1927. $jtime = $this->input->post('jtime', true);
  1928. $ktime = strtotime($ktime);
  1929. $jtime = strtotime($jtime);
  1930. $where = "1=1";
  1931. $gj = "";
  1932. $ck = "";
  1933. if ($lacetype) {
  1934. $where .= " and features like '%-$lacetype-%'";
  1935. }
  1936. if ($category) {
  1937. $where .= " and features like '%-$category-%'";
  1938. }
  1939. if ($size) {
  1940. $where .= " and features like '%-$size-%'";
  1941. }
  1942. if ($grade) {
  1943. $where .= " and features like '%-$grade-%'";
  1944. }
  1945. if ($color) {
  1946. $where .= " and features like '%-$color-%'";
  1947. }
  1948. if ($lowe) {
  1949. $where .= " and features like '%-$lowe-%'";
  1950. }
  1951. if ($haircap) {
  1952. $where .= " and features like '%-$haircap-%'";
  1953. }
  1954. if ($density) {
  1955. $where .= " and features like '%-$density-%'";
  1956. }
  1957. if ($lacecolor) {
  1958. $where .= " and features like '%-$lacecolor-%'";
  1959. }
  1960. if ($usa) {
  1961. if (!$warehouse) {
  1962. $where .= " and (warehouse = '5' or warehouse = '8')";
  1963. }
  1964. }
  1965. if ($warehouse) {
  1966. $where .= " and warehouse = '$warehouse'";
  1967. }
  1968. if ($details) {
  1969. $where .= " and details = '$details'";
  1970. }
  1971. if ($purchase) {
  1972. $where .= " and purchase = '$purchase'";
  1973. }
  1974. if ($state) {
  1975. $where .= " and state = '$state'";
  1976. }
  1977. $where_add = '';
  1978. if ($cklx) {
  1979. $shop = $this->shop->read($cklx);
  1980. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1981. }
  1982. if ($ktime && $jtime) {
  1983. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1984. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1985. }
  1986. //数据排序
  1987. $order_str = "id desc";
  1988. if (empty($page)) {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. } else {
  1992. $start = ($page - 1) * $perpage;
  1993. }
  1994. if ($sku) {
  1995. $sku = trim($sku, ' ');
  1996. $sku = trim($sku, ' ');
  1997. $where .= " and sku like '%$sku%'";
  1998. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1999. } else if ($title) {
  2000. $title = trim($title, ' ');
  2001. $title = trim($title, ' ');
  2002. $where .= " and title like '%$title%'";
  2003. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2004. } else {
  2005. //$where .= " and time > '$ktime' and time < '$jtime'";
  2006. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2007. }
  2008. //取得信息列表
  2009. $rows = array();
  2010. $list = array();
  2011. foreach ($info_list as $key => $value) {
  2012. $warehouse = $this->warehouse->read($value['warehouse']);
  2013. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2016. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2017. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2018. $od = array();
  2019. $odid = '';
  2020. foreach ($z as $v) {
  2021. if (!isset($od[$v['zd']])) {
  2022. $od[$v['zd']] = 1; //所有数据sku
  2023. } else {
  2024. $od[$v['zd']] = $od[$v['zd']] + 1;
  2025. }
  2026. }
  2027. foreach ($od as $k => $vv) {
  2028. $odid .= $k . '数量' . $vv . ' ';
  2029. }
  2030. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2031. $info_list[$key]['features'] = $c;
  2032. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2033. $ztdata = '';
  2034. if (count($zt) > 0) {
  2035. foreach ($zt as $vv) {
  2036. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2037. }
  2038. }
  2039. $info_list[$key]['warehouse'] = $ztdata;
  2040. $info_list[$key]['g'] = $g;
  2041. $info_list[$key]['x'] = $x;
  2042. $info_list[$key]['t'] = $t;
  2043. $info_list[$key]['z'] = $z;
  2044. }
  2045. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2046. $pagenum = ceil($total / $perpage);
  2047. $over = $total - ($start + $perpage);
  2048. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2049. echo json_encode($rows);
  2050. exit;
  2051. }
  2052. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2053. $this->data['warehouse'] = $warehouse;
  2054. $this->_Template('whlabel_typeusa', $this->data);
  2055. }
  2056. //美仓进销存浏览
  2057. public function _usatypeapp()
  2058. {
  2059. $post = $this->input->post(NULL, TRUE);
  2060. if (isset($post['page'])) {
  2061. $page = $this->input->post('page', true);
  2062. $perpage = $this->input->post('perpage', true);
  2063. $sku = $this->input->post('sku', true);
  2064. $warehouse = 5;
  2065. $title = $this->input->post('title', true);
  2066. $state = $this->input->post('state', true);
  2067. $ktime = $this->input->post('ktime', true);
  2068. $jtime = $this->input->post('jtime', true);
  2069. $ktime = strtotime($ktime);
  2070. $jtime = strtotime($jtime);
  2071. $where = "1=1";
  2072. $gj = "";
  2073. $ck = "";
  2074. if ($title) {
  2075. $st = explode(' ', trim($title, ' '));
  2076. foreach ($st as $v) {
  2077. $where .= " and title like '%$v%'";
  2078. }
  2079. }
  2080. if ($warehouse) {
  2081. $where .= " and warehouse = '$warehouse'";
  2082. }
  2083. if ($state) {
  2084. $where .= " and state = '$state'";
  2085. }
  2086. if ($sku) {
  2087. $where .= " and sku like '%$sku%'";
  2088. }
  2089. if ($ktime && $jtime) {
  2090. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2091. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2092. }
  2093. //数据排序
  2094. $order_str = "id desc";
  2095. if (empty($page)) {
  2096. $start = 0;
  2097. $perpage = 1;
  2098. } else {
  2099. $start = ($page - 1) * $perpage;
  2100. }
  2101. //取得信息列表
  2102. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2103. $rows = array();
  2104. $list = array();
  2105. foreach ($info_list as $key => $value) {
  2106. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2107. }
  2108. $rowsdq = array_slice($rows, $start, $perpage);
  2109. foreach ($rowsdq as $value) {
  2110. $warehouse = $this->warehouse->read($value['warehouse']);
  2111. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2112. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2113. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2114. $od = array();
  2115. $odid = '';
  2116. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2117. }
  2118. $total = count($rows);
  2119. $pagenum = ceil($total / $perpage);
  2120. $over = $total - ($start + $perpage);
  2121. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2122. echo json_encode($rows);
  2123. exit;
  2124. }
  2125. $this->_Template('phone/p_usatypeapp', $this->data);
  2126. }
  2127. //入库操作
  2128. public function _enteradd()
  2129. {
  2130. $dt = 0;
  2131. if (isset($_SESSION['api'])) {
  2132. $user = $this->user->get_api($_SESSION['api']);
  2133. $usp = $user;
  2134. $fgshop = "";
  2135. $sid = "";
  2136. $user = explode('|', trim($user['shop'], '|'));
  2137. foreach ($user as $value) {
  2138. $fgshop .= " shop = " . $value . " or";
  2139. $sid .= " id = " . $value . " or";
  2140. }
  2141. }
  2142. $tc = $this->typeclass->find_all();
  2143. $typeclass = array();
  2144. foreach ($tc as $v) {
  2145. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2146. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2147. }
  2148. $post = $this->input->post(NULL, TRUE);
  2149. if (isset($post['sku'])) {
  2150. $list = array();
  2151. $num = "";
  2152. $title = "";
  2153. $features = "";
  2154. $order = $this->input->post('order', true);
  2155. $shop = $this->input->post('shop', true);
  2156. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2157. $sku = $this->input->post('sku', true);
  2158. $post['sm'] = $this->input->post('sm', true);
  2159. $post['warehouse'] = $this->input->post('warehouse', true);
  2160. $post['purchase'] = $this->input->post('purchase', true);
  2161. $post['retreatwarehouse'] = $post['warehouse'];
  2162. $post['state'] = $this->input->post('state', true);
  2163. $post['rktype'] = $this->input->post('rktype', true);
  2164. $post['text'] = $this->input->post('text', true);
  2165. $category = $this->input->post('category', true);
  2166. $list['category'] = $category;
  2167. $list['hairtype'] = $this->input->post('hairtype', true);
  2168. $list['grade'] = $this->input->post('grade', true);
  2169. $size = $this->input->post('size', true);
  2170. $xzsku = $this->input->post('xzsku', true);
  2171. $list['size'] = rtrim($size, ',');
  2172. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2173. $list['extension'] = $this->input->post('extension', true);
  2174. if ($category == 1297) {
  2175. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2176. }
  2177. if ($category == 1702) {
  2178. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2179. $list['syother'] = $this->input->post('syother', true);
  2180. }
  2181. if ($category == 133) {
  2182. $list['fittype'] = $this->input->post('fittype', true);
  2183. $list['acother'] = $this->input->post('acother', true);
  2184. }
  2185. $list['color'] = $this->input->post('color', true);
  2186. $list['lowe'] = $this->input->post('lowe', true);
  2187. if (!$post['purchase']) {
  2188. $post['purchase'] = 1;
  2189. }
  2190. if ($category == 127) {
  2191. $list['type'] = $this->input->post('type', true);
  2192. $list['headroad'] = $this->input->post('headroad', true);
  2193. $list['density'] = $this->input->post('density', true);
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2196. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2197. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. if($k == 'hairtype'){
  2243. if(!in_array($v,[163,164,165,166])){
  2244. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2245. }
  2246. }else{
  2247. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2248. }
  2249. if ($k != 'size') {
  2250. $title .= $typeclass[$v]['title'] . " ";
  2251. }
  2252. if (isset($pm[$typeclass[$v]['classid']])) {
  2253. if ($typeclass[$v]['title'] == '9A') {
  2254. $pm[$typeclass[$v]['classid']] = '9A';
  2255. } else if ($typeclass[$v]['title'] == '10A') {
  2256. $pm[$typeclass[$v]['classid']] = '10A';
  2257. } else {
  2258. $clzh = $typeclass[$v]['zh'];
  2259. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2260. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2261. $clzh = $clzh[0];
  2262. }
  2263. if($k == 'hairtype'){
  2264. if(!in_array($v,[163,164,165,166])){
  2265. $pm[$typeclass[$v]['classid']] = $clzh;
  2266. }
  2267. }else{
  2268. $pm[$typeclass[$v]['classid']] = $clzh;
  2269. }
  2270. }
  2271. }
  2272. }
  2273. }
  2274. $zh = implode(" ", $pm);
  2275. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2276. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2277. if ($list['size']) {
  2278. $typeclass = $this->typeclass->read($list['size']);
  2279. $title .= $typeclass['title'];
  2280. }
  2281. $time = time();
  2282. if ($xzsku) {
  2283. $scsku = implode("-", $scsku);
  2284. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2285. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2286. $post['sku'] = trim($scsku, ' ');
  2287. } else {
  2288. $post['sku'] = $sku;
  2289. }
  2290. //$post['sku'] = trim($sku,' ');
  2291. $post['title'] = rtrim($title, ' ');
  2292. $post['number'] = $num;
  2293. $post['features'] = '-' . $features;
  2294. $post['enter'] = $time;
  2295. $post['time'] = $time; //操作时间
  2296. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2297. if ($yza) {
  2298. if ($post['features'] != $yza[0]['features']) {
  2299. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2300. exit;
  2301. }
  2302. }
  2303. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2304. if ($yzb) {
  2305. if ($post['sku'] != $yzb[0]['sku']) {
  2306. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2307. exit;
  2308. }
  2309. }
  2310. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2311. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2312. exit;
  2313. }
  2314. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2315. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2316. exit;
  2317. }
  2318. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2319. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2320. exit;
  2321. }
  2322. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2323. if (isset($yz[0]['type'])) {
  2324. $post['type'] = $yz[0]['type'];
  2325. }
  2326. if ($post['state'] == 9) //如果选择预设库存
  2327. {
  2328. $this->whlabel->insert($post);
  2329. } else {
  2330. /**
  2331. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2332. if($ljg == 1)
  2333. {
  2334. for($i=0;$i<$order;$i++)
  2335. {
  2336. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2337. $this->whlabel->insert($post);
  2338. }
  2339. }
  2340. **/
  2341. //if($post['warehouse'] == '5')
  2342. //{
  2343. //}
  2344. $yydata = $post;
  2345. $yydata['zh'] = $zh;
  2346. /**
  2347. $wl = $this->apiyy->get_cjlp($yydata);
  2348. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2349. {
  2350. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2351. }
  2352. if($wl['Data'][0]['m_isSucess'] != 1)
  2353. {
  2354. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2355. }
  2356. **/
  2357. for ($i = 0; $i < $order; $i++) {
  2358. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2359. $this->whlabel->insert($post);
  2360. }
  2361. }
  2362. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2363. exit;
  2364. }
  2365. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2366. $this->data['wlshop'] = $wlshop;
  2367. $this->_Template('whlabel_enteradd', $this->data);
  2368. }
  2369. //修改产品
  2370. public function _enteredit($arg_array)
  2371. {
  2372. $dt = 0;
  2373. if (isset($_SESSION['api'])) {
  2374. $user = $this->user->get_api($_SESSION['api']);
  2375. $usp = $user;
  2376. $fgshop = "";
  2377. $sid = "";
  2378. $user = explode('|', trim($user['shop'], '|'));
  2379. foreach ($user as $value) {
  2380. $fgshop .= " shop = " . $value . " or";
  2381. $sid .= " id = " . $value . " or";
  2382. }
  2383. }
  2384. $post = $this->input->post(NULL, TRUE);
  2385. if (isset($post['sku'])) {
  2386. $list = array();
  2387. $num = "";
  2388. $title = "";
  2389. $features = "";
  2390. $id = $this->input->post('id', true);
  2391. $order = $this->input->post('order', true);
  2392. $shop = $this->input->post('shop', true);
  2393. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2394. $post['sku'] = $this->input->post('sku', true);
  2395. $post['sm'] = $this->input->post('sm', true);
  2396. $post['warehouse'] = $this->input->post('warehouse', true);
  2397. $post['purchase'] = $this->input->post('purchase', true);
  2398. $post['retreatwarehouse'] = $post['warehouse'];
  2399. $category = $this->input->post('category', true);
  2400. $list['category'] = $category;
  2401. $list['hairtype'] = $this->input->post('hairtype', true);
  2402. $list['grade'] = $this->input->post('grade', true);
  2403. $size = $this->input->post('size', true);
  2404. $list['size'] = rtrim($size, ',');
  2405. $post['rktype'] = $this->input->post('rktype', true);
  2406. $post['text'] = $this->input->post('text', true);
  2407. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2408. $list['extension'] = $this->input->post('extension', true);
  2409. if ($category == 1297) {
  2410. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2411. }
  2412. if ($category == 1702) {
  2413. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2414. $list['syother'] = $this->input->post('syother', true);
  2415. }
  2416. if ($category == 133) {
  2417. $list['fittype'] = $this->input->post('fittype', true);
  2418. $list['acother'] = $this->input->post('acother', true);
  2419. }
  2420. $list['color'] = $this->input->post('color', true);
  2421. $list['lowe'] = $this->input->post('lowe', true);
  2422. if (!$post['purchase']) {
  2423. $post['purchase'] = 1;
  2424. }
  2425. if ($category == 127) {
  2426. $list['type'] = $this->input->post('type', true);
  2427. $list['headroad'] = $this->input->post('headroad', true);
  2428. $list['density'] = $this->input->post('density', true);
  2429. $list['lacesize'] = $this->input->post('lacesize', true);
  2430. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2431. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2432. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  2433. }
  2434. if ($category == 128) {
  2435. $list['lacetype'] = $this->input->post('lacetype', true);
  2436. $list['haircap'] = $this->input->post('haircap', true);
  2437. $list['density'] = $this->input->post('density', true);
  2438. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2439. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2440. $list['wigother'] = $this->input->post('wigother', true);
  2441. $list['wigother1'] = $this->input->post('wigother1', true);
  2442. $list['wigother2'] = $this->input->post('wigother2', true);
  2443. $list['product_related'] = $this->input->post('product_related', true);
  2444. }
  2445. if ($category == 129) {
  2446. $list['wide'] = $this->input->post('wide', true);
  2447. }
  2448. if ($category == 131) {
  2449. $list['gifttype'] = $this->input->post('gifttype', true);
  2450. $list['giftother'] = $this->input->post('giftother', true);
  2451. }
  2452. if ($category == 134) {
  2453. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2454. }
  2455. if ($category == 1297) {
  2456. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2457. $list['sywigother'] = $this->input->post('sywigother', true);
  2458. }
  2459. if ($category == 130 || $category == 133 || $category == 1702) {
  2460. $list['items'] = $this->input->post('items', true);
  2461. $list['weight'] = $this->input->post('weight', true);
  2462. }
  2463. if($category == 130){
  2464. $list['jfother'] = $this->input->post('jfother', true);
  2465. }
  2466. if ($category == 1702) {
  2467. $list['syhairther'] = $this->input->post('syhairther', true);
  2468. }
  2469. foreach ($list as $k => $v) {
  2470. if ($v != 0) {
  2471. $num .= $v;
  2472. $features .= $v . '-';
  2473. $typeclass = $this->typeclass->read($v);
  2474. if ($k != 'size') {
  2475. $title .= $typeclass['title'] . " ";
  2476. }
  2477. }
  2478. }
  2479. $typeclass = $this->typeclass->read($list['size']);
  2480. $title .= $typeclass['title'];
  2481. $time = time();
  2482. $post['title'] = rtrim($title, ' ');
  2483. $post['number'] = $num;
  2484. $post['features'] = '-' . $features;
  2485. $post['time'] = $time; //操作时间
  2486. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2487. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2488. exit;
  2489. }
  2490. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2491. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2492. exit;
  2493. }
  2494. $uid = $this->whlabel->read($id);
  2495. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2496. if ($datanum > 0) {
  2497. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2498. exit;
  2499. }
  2500. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2501. {
  2502. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2503. if ($yza) {
  2504. if ($post['features'] != $yza[0]['features']) {
  2505. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2506. exit;
  2507. }
  2508. }
  2509. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2510. if ($yzb) {
  2511. if ($post['sku'] != $yzb[0]['sku']) {
  2512. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2513. exit;
  2514. }
  2515. }
  2516. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2517. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2518. exit;
  2519. }
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. } else {
  2526. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2527. if ($data > 0) {
  2528. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2529. exit;
  2530. } else {
  2531. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2532. foreach ($data as $v) {
  2533. $post['id'] = $v['id'];
  2534. $this->whlabel->save($post, $v['id']);
  2535. }
  2536. }
  2537. }
  2538. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2539. exit;
  2540. }
  2541. $uid = $this->whlabel->read($arg_array[0]);
  2542. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2543. $this->data['enter'] = $uid;
  2544. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2545. $this->data['wlshop'] = $wlshop;
  2546. $this->_Template('whlabel_enteredit', $this->data);
  2547. }
  2548. //入库浏览
  2549. public function _enter()
  2550. {
  2551. $post = $this->input->post(NULL, TRUE);
  2552. if (isset($post['s'])) {
  2553. $id_arr = $this->input->post('s');
  2554. $id_arr = explode(',', $id_arr);
  2555. if (!$id_arr) {
  2556. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2557. exit;
  2558. }
  2559. //循环删除记录
  2560. foreach ($id_arr as $v) {
  2561. $sid = $this->whlabel->read($v);
  2562. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2563. if ($count > 0) {
  2564. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2565. exit;
  2566. }
  2567. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2568. foreach ($info_list as $va) {
  2569. $this->whlabel->remove($va['id']);
  2570. }
  2571. }
  2572. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2573. exit;
  2574. }
  2575. $sp = array();
  2576. $s = $this->shop->find_all('1=1', 'id,shopname');
  2577. foreach ($s as $v) {
  2578. $sp[$v['id']] = $v['shopname'];
  2579. }
  2580. $wh = array();
  2581. $w = $this->warehouse->find_all('1=1', 'id,title');
  2582. foreach ($w as $v) {
  2583. $wh[$v['id']] = $v['title'];
  2584. }
  2585. if (isset($post['page'])) {
  2586. $page = $this->input->post('page', true);
  2587. $perpage = $this->input->post('perpage', true);
  2588. $category = $this->input->post('category', true);
  2589. $size = $this->input->post('size', true);
  2590. $grade = $this->input->post('grade', true);
  2591. $color = $this->input->post('color', true);
  2592. $lowe = $this->input->post('lowe', true);
  2593. $sku = $this->input->post('sku', true);
  2594. $warehouse = $this->input->post('warehouse', true);
  2595. $purchase = $this->input->post('purchase', true);
  2596. $ktime = $this->input->post('ktime', true);
  2597. $jtime = $this->input->post('jtime', true);
  2598. $ktime = strtotime($ktime);
  2599. $jtime = strtotime($jtime);
  2600. $where = "1=1";
  2601. $gj = "";
  2602. $ck = "";
  2603. if ($category) {
  2604. $where .= " and features like '%-$category-%'";
  2605. }
  2606. if ($size) {
  2607. $where .= " and features like '%-$size-%'";
  2608. }
  2609. if ($grade) {
  2610. $where .= " and features like '%-$grade-%'";
  2611. }
  2612. if ($color) {
  2613. $where .= " and features like '%-$color-%'";
  2614. }
  2615. if ($lowe) {
  2616. $where .= " and features like '%-$lowe-%'";
  2617. }
  2618. if ($warehouse) {
  2619. $where .= " and warehouse = '$warehouse'";
  2620. }
  2621. if ($purchase) {
  2622. $where .= " and purchase = '$purchase'";
  2623. }
  2624. if ($sku) {
  2625. $where .= " and sku like '%$sku%'";
  2626. }
  2627. if ($ktime && $jtime) {
  2628. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2629. }
  2630. //数据排序
  2631. $order_str = "enter desc";
  2632. if (empty($page)) {
  2633. $start = 0;
  2634. $perpage = 1;
  2635. } else {
  2636. $start = ($page - 1) * $perpage;
  2637. }
  2638. //取得信息列表
  2639. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2640. foreach ($info_list as $k => $v) {
  2641. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2642. if ($v['shop'] == '') {
  2643. $s = '通用';
  2644. } else {
  2645. $info_list[$k]['shop'] = '';
  2646. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2647. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2648. }
  2649. }
  2650. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2651. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2652. $info_list[$k]['g'] = $g;
  2653. }
  2654. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2655. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2656. $pagenum = ceil($total / $perpage);
  2657. $over = $total - ($start + $perpage);
  2658. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2659. echo json_encode($rows);
  2660. exit;
  2661. }
  2662. $this->_Template('whlabel_enter', $this->data);
  2663. }
  2664. //出库浏览
  2665. public function _out()
  2666. {
  2667. $post = $this->input->post(NULL, TRUE);
  2668. if (isset($post['page'])) {
  2669. $page = $this->input->post('page', true);
  2670. $perpage = $this->input->post('perpage', true);
  2671. $category = $this->input->post('category', true);
  2672. $size = $this->input->post('size', true);
  2673. $grade = $this->input->post('grade', true);
  2674. $color = $this->input->post('color', true);
  2675. $lowe = $this->input->post('lowe', true);
  2676. $sku = $this->input->post('sku', true);
  2677. $warehouse = $this->input->post('warehouse', true);
  2678. $purchase = $this->input->post('purchase', true);
  2679. $state = $this->input->post('state', true);
  2680. $ktime = $this->input->post('ktime', true);
  2681. $jtime = $this->input->post('jtime', true);
  2682. $ktime = strtotime($ktime);
  2683. $jtime = strtotime($jtime);
  2684. $where = "state=3";
  2685. $gj = "";
  2686. $ck = "";
  2687. if ($category) {
  2688. $where .= " and features like '%-$category-%'";
  2689. }
  2690. if ($size) {
  2691. $where .= " and features like '%-$size-%'";
  2692. }
  2693. if ($grade) {
  2694. $where .= " and features like '%-$grade-%'";
  2695. }
  2696. if ($color) {
  2697. $where .= " and features like '%-$color-%'";
  2698. }
  2699. if ($lowe) {
  2700. $where .= " and features like '%-$lowe-%'";
  2701. }
  2702. if ($state) {
  2703. $where .= " and state = '$state'";
  2704. }
  2705. if ($warehouse) {
  2706. $where .= " and warehouse = '$warehouse'";
  2707. }
  2708. if ($purchase) {
  2709. $where .= " and purchase = '$purchase'";
  2710. }
  2711. if ($sku) {
  2712. $where .= " and sku = '$sku'";
  2713. }
  2714. if ($ktime && $jtime) {
  2715. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2716. }
  2717. //数据排序
  2718. $order_str = "id desc";
  2719. if (empty($page)) {
  2720. $start = 0;
  2721. $perpage = 1;
  2722. } else {
  2723. $start = ($page - 1) * $perpage;
  2724. }
  2725. //取得信息列表
  2726. $info_list = $this->whlabel->find_all($where, 'sku');
  2727. $rows = array();
  2728. $list = array();
  2729. foreach ($info_list as $key => $value) {
  2730. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2731. }
  2732. $rows = array_unique($rows); //删除重复记录
  2733. foreach ($rows as $key => $value) {
  2734. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2735. $ck = $this->warehouse->read($data['warehouse']);
  2736. $warehouse = $ck['title'];
  2737. $gy = $this->purchase->read($data['purchase']);
  2738. $purchase = $gy['purchase'];
  2739. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2740. $list[] = array('id' => $data['id'], 'warehouse' => $warehouse, 'purchase' => $purchase, 'sku' => $data['sku'], 'title' => $data['title'], 'time' => date('Y-m-d H:i:s', $data['enter']), 'number' => $g);
  2741. }
  2742. $total = count($list);
  2743. $pagenum = ceil($total / $perpage);
  2744. $over = $total - ($start + $perpage);
  2745. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2747. echo json_encode($rows);
  2748. exit;
  2749. }
  2750. $this->_Template('whlabel_out', $this->data);
  2751. }
  2752. //出库标签浏览
  2753. public function _label()
  2754. {
  2755. $post = $this->input->post(NULL, TRUE);
  2756. if (isset($post['page'])) {
  2757. $page = $this->input->post('page', true);
  2758. $perpage = $this->input->post('perpage', true);
  2759. $sku = $this->input->post('sku', true);
  2760. $warehouse = $this->input->post('warehouse', true);
  2761. $purchase = $this->input->post('purchase', true);
  2762. $orderinfo = $this->input->post('orderinfo', true);
  2763. $waybill = $this->input->post('waybill', true);
  2764. $category = $this->input->post('category', true);
  2765. $size = $this->input->post('size', true);
  2766. $grade = $this->input->post('grade', true);
  2767. $color = $this->input->post('color', true);
  2768. $lowe = $this->input->post('lowe', true);
  2769. $where = "state=1";
  2770. if ($sku) {
  2771. $where .= " and sku = '$sku'";
  2772. }
  2773. if ($warehouse) {
  2774. $where .= " and warehouse = '$warehouse'";
  2775. }
  2776. if ($purchase) {
  2777. $where .= " and purchase = '$purchase'";
  2778. }
  2779. if ($orderinfo) {
  2780. $where .= " and orderinfo = '$orderinfo'";
  2781. }
  2782. if ($waybill) {
  2783. $where .= " and waybill = '$waybill'";
  2784. }
  2785. if ($category) {
  2786. $where .= " and features like '%-$category-%'";
  2787. }
  2788. if ($size) {
  2789. $where .= " and features like '%-$size-%'";
  2790. }
  2791. if ($grade) {
  2792. $where .= " and features like '%-$grade-%'";
  2793. }
  2794. if ($color) {
  2795. $where .= " and features like '%-$color-%'";
  2796. }
  2797. if ($lowe) {
  2798. $where .= " and features like '%-$lowe-%'";
  2799. }
  2800. //数据排序
  2801. $order_str = "outk desc";
  2802. if (empty($page)) {
  2803. $start = 0;
  2804. $perpage = 1;
  2805. } else {
  2806. $start = ($page - 1) * $perpage;
  2807. }
  2808. //取得信息列表
  2809. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2810. foreach ($info_list as $key => $value) {
  2811. $warehouse = $this->warehouse->read($value['warehouse']);
  2812. $info_list[$key]['warehouse'] = $warehouse['title'];
  2813. $purchase = $this->purchase->read($value['purchase']);
  2814. $info_list[$key]['purchase'] = $purchase['title'];
  2815. if ($value['outk'] != 0) {
  2816. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2817. } else {
  2818. $info_list[$key]['outk'] = "";
  2819. }
  2820. if ($value['orderinfo'] == 0) {
  2821. $info_list[$key]['orderinfo'] = "";
  2822. }
  2823. if ($value['waybill'] == 0) {
  2824. $info_list[$key]['waybill'] = "";
  2825. }
  2826. }
  2827. $total = $this->whlabel->find_count($where);
  2828. $pagenum = ceil($total / $perpage);
  2829. $over = $total - ($start + $perpage);
  2830. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2831. echo json_encode($rows);
  2832. exit;
  2833. }
  2834. $this->_Template('whlabel_label', $this->data);
  2835. }
  2836. //独立站出库订单
  2837. public function _outorder()
  2838. {
  2839. if (isset($_SESSION['api'])) {
  2840. $user = $this->user->get_api($_SESSION['api']);
  2841. $usp = $user;
  2842. $fgshop = "";
  2843. $sid = "";
  2844. $user = explode('|', trim($user['shop'], '|'));
  2845. foreach ($user as $value) {
  2846. $fgshop .= " shop = " . $value . " or";
  2847. $sid .= " id = " . $value . " or";
  2848. }
  2849. } else {
  2850. echo "请重新登录";
  2851. }
  2852. $post = $this->input->post(NULL, TRUE);
  2853. if (isset($post['page'])) {
  2854. $page = $this->input->post('page', true);
  2855. $perpage = $this->input->post('perpage', true);
  2856. $warehouse = $this->input->post('warehouse', true);
  2857. $xztime = $this->input->post('xztime', true);
  2858. $timetk = $this->input->post('timetkk', true);
  2859. $timetj = $this->input->post('timetjj', true);
  2860. $shop = $this->input->post('shop', true);
  2861. $source = $this->input->post('source', true);
  2862. $orderinfo = $this->input->post('orderinfo', true);
  2863. $number = $this->input->post('number', true);
  2864. $sfxh = $this->input->post('sfxh', true);
  2865. $express = $this->input->post('express', true);
  2866. $waybill = $this->input->post('waybill', true);
  2867. $library = $this->input->post('library', true);
  2868. $country = $this->input->post('country', true);
  2869. $so = $this->input->post('so', true);
  2870. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2871. $print = $this->input->post('print', true);
  2872. $state = $this->input->post('state', true);
  2873. $orderurl = $this->input->post('orderurl', true);
  2874. $productid = $this->input->post('productid', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullorder";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($country) {
  2924. $where .= " and country = '$country'";
  2925. }
  2926. if ($sfxh != '') {
  2927. $where .= " and sfxh = '$sfxh'";
  2928. }
  2929. if ($so) {
  2930. $where .= " and shipremarks like '%$so%'";
  2931. }
  2932. if ($source) {
  2933. if ($source == '2d') {
  2934. $where .= " and source >= '2'";
  2935. } else {
  2936. $where .= " and source = '$source'";
  2937. }
  2938. }
  2939. if (isset($_SESSION['api'])) {
  2940. foreach ($user as $value) {
  2941. $fgshop .= " shop = " . $value . " or";
  2942. }
  2943. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2944. }
  2945. if ($orderurl) {
  2946. $url = $this->orderurl->read($orderurl);
  2947. $where .= " and link like '%" . $url['url'] . "%'";
  2948. }
  2949. if($productid){
  2950. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2951. }
  2952. //数据排序
  2953. $order_str = "librarytime desc";
  2954. if (empty($page)) {
  2955. $start = 0;
  2956. $perpage = 1;
  2957. } else {
  2958. $start = ($page - 1) * $perpage;
  2959. }
  2960. //取得信息列表
  2961. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2962. //格式化数据
  2963. foreach ($info_list as $key => $value) {
  2964. $shop = $this->shop->read($value['shop']);
  2965. $info_list[$key]['shop'] = $shop['shopname'];
  2966. $express = $this->express->read($value['express']);
  2967. $info_list[$key]['express'] = $express['servicename'];
  2968. $warehouse = $this->warehouse->read($value['type']);
  2969. $info_list[$key]['type'] = $warehouse['title'];
  2970. if ($value['librarytime'] == '0') {
  2971. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2972. } else {
  2973. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2974. }
  2975. }
  2976. $total = $this->$sj->find_count($where);
  2977. $pagenum = ceil($total / $perpage);
  2978. $over = $total - ($start + $perpage);
  2979. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2980. echo json_encode($rows);
  2981. exit;
  2982. }
  2983. $this->data['express'] = $this->express->find_all();
  2984. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2985. $this->data['wlshop'] = $wlshop;
  2986. $user = $this->user->get_api($_SESSION['api']);
  2987. $powerid = $this->power->read($user['power']);
  2988. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2989. $pid = '';
  2990. foreach ($powertext as $v) {
  2991. $pid .= " id = " . $v . " or";
  2992. }
  2993. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2994. $this->data['fullorderexcel'] = $fullorderexcel;
  2995. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2996. $this->data['orderurl'] = $orderurl;
  2997. $this->_Template('whlabel_outorder', $this->data);
  2998. }
  2999. //tt出库
  3000. public function _toutorder()
  3001. {
  3002. $fgshop = "";
  3003. $sid = "";
  3004. if (isset($_SESSION['api'])) {
  3005. $user = $this->user->get_api($_SESSION['api']);
  3006. $usp = $user;
  3007. $user = explode('|', trim($user['shop'], '|'));
  3008. foreach ($user as $value) {
  3009. $fgshop .= " shop = " . $value . " or";
  3010. $sid .= " id = " . $value . " or";
  3011. }
  3012. } else {
  3013. echo "请重新登录";
  3014. die;
  3015. }
  3016. $post = $this->input->post(NULL, TRUE);
  3017. if (isset($post['page'])) {
  3018. $page = $this->input->post('page', true);
  3019. $perpage = $this->input->post('perpage', true);
  3020. $warehouse = $this->input->post('warehouse', true);
  3021. $xztime = $this->input->post('xztime', true);
  3022. $timetk = $this->input->post('timetkk', true);
  3023. $timetj = $this->input->post('timetjj', true);
  3024. $shop = $this->input->post('shop', true);
  3025. $source = $this->input->post('source', true);
  3026. $orderinfo = $this->input->post('orderinfo', true);
  3027. $number = $this->input->post('number', true);
  3028. $sfxh = $this->input->post('sfxh', true);
  3029. $express = $this->input->post('express', true);
  3030. $waybill = $this->input->post('waybill', true);
  3031. $library = $this->input->post('library', true);
  3032. $country = $this->input->post('country', true);
  3033. $so = $this->input->post('so', true);
  3034. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3035. $print = $this->input->post('print', true);
  3036. $state = $this->input->post('state', true);
  3037. $orderurl = $this->input->post('orderurl', true);
  3038. $timetk = strtotime($timetk);
  3039. $timetj = strtotime($timetj);
  3040. /**
  3041. $sj = $this->input->post('sj',true);
  3042. if($sj)
  3043. {
  3044. $sj = $this->input->post('sj',true);
  3045. }
  3046. else
  3047. {
  3048. $sj = "fullorder";
  3049. }
  3050. **/
  3051. $sj = "fullordertt";
  3052. $where = "1=1";
  3053. if ($warehouse) {
  3054. $where .= " and type = '$warehouse'";
  3055. }
  3056. if ($timetk && $timetj) {
  3057. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3058. }
  3059. if ($orderinfo) {
  3060. $where .= " and orderinfo = '$orderinfo'";
  3061. }
  3062. if ($number) {
  3063. $where .= " and number = '$number'";
  3064. }
  3065. if ($express) {
  3066. $where .= " and express = '$express'";
  3067. }
  3068. if ($waybill) {
  3069. $where .= " and waybill = '$waybill'";
  3070. }
  3071. if ($library) {
  3072. $where .= " and library = '$library'";
  3073. }
  3074. if ($print) {
  3075. $where .= " and print = '$print'";
  3076. }
  3077. if ($libraryconfirm) {
  3078. $where .= " and libraryconfirm = '$libraryconfirm'";
  3079. }
  3080. if ($state) {
  3081. $where .= " and state = '$state'";
  3082. }
  3083. if ($shop) {
  3084. $where .= " and shop = '$shop'";
  3085. }
  3086. if ($country) {
  3087. $where .= " and country = '$country'";
  3088. }
  3089. if ($sfxh != '') {
  3090. $where .= " and sfxh = '$sfxh'";
  3091. }
  3092. if ($so) {
  3093. $where .= " and shipremarks like '%$so%'";
  3094. }
  3095. if ($source) {
  3096. if ($source == '2d') {
  3097. $where .= " and source >= '2'";
  3098. } else {
  3099. $where .= " and source = '$source'";
  3100. }
  3101. }
  3102. if (isset($_SESSION['api'])) {
  3103. foreach ($user as $value) {
  3104. $fgshop .= " shop = " . $value . " or";
  3105. }
  3106. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3107. }
  3108. if ($orderurl) {
  3109. $url = $this->orderurl->read($orderurl);
  3110. $where .= " and link like '%" . $url['url'] . "%'";
  3111. }
  3112. //数据排序
  3113. $order_str = "librarytime desc";
  3114. if (empty($page)) {
  3115. $start = 0;
  3116. $perpage = 1;
  3117. } else {
  3118. $start = ($page - 1) * $perpage;
  3119. }
  3120. //取得信息列表
  3121. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3122. //格式化数据
  3123. foreach ($info_list as $key => $value) {
  3124. $shop = $this->shop->read($value['shop']);
  3125. $info_list[$key]['shop'] = $shop['shopname'];
  3126. $express = $this->express->read($value['express']);
  3127. $info_list[$key]['express'] = $express['servicename'];
  3128. $warehouse = $this->warehouse->read($value['type']);
  3129. $info_list[$key]['type'] = $warehouse['title'];
  3130. if ($value['librarytime'] == '0') {
  3131. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3132. } else {
  3133. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3134. }
  3135. }
  3136. $total = $this->$sj->find_count($where);
  3137. $pagenum = ceil($total / $perpage);
  3138. $over = $total - ($start + $perpage);
  3139. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3140. echo json_encode($rows);
  3141. exit;
  3142. }
  3143. $this->data['express'] = $this->express->find_all();
  3144. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3145. $this->data['wlshop'] = $wlshop;
  3146. $user = $this->user->get_api($_SESSION['api']);
  3147. $powerid = $this->power->read($user['power']);
  3148. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3149. $pid = '';
  3150. foreach ($powertext as $v) {
  3151. $pid .= " id = " . $v . " or";
  3152. }
  3153. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3154. $this->data['fullorderexcel'] = $fullorderexcel;
  3155. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3156. $this->data['orderurl'] = $orderurl;
  3157. $this->_Template('whlabel_toutorder', $this->data);
  3158. }
  3159. //tt出库
  3160. public function _aoutorder()
  3161. {
  3162. if (isset($_SESSION['api'])) {
  3163. $user = $this->user->get_api($_SESSION['api']);
  3164. $usp = $user;
  3165. $fgshop = "";
  3166. $sid = "";
  3167. $user = explode('|', trim($user['shop'], '|'));
  3168. foreach ($user as $value) {
  3169. $fgshop .= " shop = " . $value . " or";
  3170. $sid .= " id = " . $value . " or";
  3171. }
  3172. } else {
  3173. echo "请重新登录";
  3174. }
  3175. $post = $this->input->post(NULL, TRUE);
  3176. if (isset($post['page'])) {
  3177. $page = $this->input->post('page', true);
  3178. $perpage = $this->input->post('perpage', true);
  3179. $warehouse = $this->input->post('warehouse', true);
  3180. $xztime = $this->input->post('xztime', true);
  3181. $timetk = $this->input->post('timetkk', true);
  3182. $timetj = $this->input->post('timetjj', true);
  3183. $shop = $this->input->post('shop', true);
  3184. $source = $this->input->post('source', true);
  3185. $orderinfo = $this->input->post('orderinfo', true);
  3186. $number = $this->input->post('number', true);
  3187. $sfxh = $this->input->post('sfxh', true);
  3188. $express = $this->input->post('express', true);
  3189. $waybill = $this->input->post('waybill', true);
  3190. $library = $this->input->post('library', true);
  3191. $country = $this->input->post('country', true);
  3192. $so = $this->input->post('so', true);
  3193. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3194. $print = $this->input->post('print', true);
  3195. $state = $this->input->post('state', true);
  3196. $orderurl = $this->input->post('orderurl', true);
  3197. $timetk = strtotime($timetk);
  3198. $timetj = strtotime($timetj);
  3199. /**
  3200. $sj = $this->input->post('sj',true);
  3201. if($sj)
  3202. {
  3203. $sj = $this->input->post('sj',true);
  3204. }
  3205. else
  3206. {
  3207. $sj = "fullorder";
  3208. }
  3209. **/
  3210. $sj = "fullorderamz";
  3211. $where = "1=1";
  3212. if ($warehouse) {
  3213. $where .= " and type = '$warehouse'";
  3214. }
  3215. if ($timetk && $timetj) {
  3216. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3217. }
  3218. if ($orderinfo) {
  3219. $where .= " and orderinfo = '$orderinfo'";
  3220. }
  3221. if ($number) {
  3222. $where .= " and number = '$number'";
  3223. }
  3224. if ($express) {
  3225. $where .= " and express = '$express'";
  3226. }
  3227. if ($waybill) {
  3228. $where .= " and waybill = '$waybill'";
  3229. }
  3230. if ($library) {
  3231. $where .= " and library = '$library'";
  3232. }
  3233. if ($print) {
  3234. $where .= " and print = '$print'";
  3235. }
  3236. if ($libraryconfirm) {
  3237. $where .= " and libraryconfirm = '$libraryconfirm'";
  3238. }
  3239. if ($state) {
  3240. $where .= " and state = '$state'";
  3241. }
  3242. if ($shop) {
  3243. $where .= " and shop = '$shop'";
  3244. }
  3245. if ($country) {
  3246. $where .= " and country = '$country'";
  3247. }
  3248. if ($sfxh != '') {
  3249. $where .= " and sfxh = '$sfxh'";
  3250. }
  3251. if ($so) {
  3252. $where .= " and shipremarks like '%$so%'";
  3253. }
  3254. if ($source) {
  3255. if ($source == '2d') {
  3256. $where .= " and source >= '2'";
  3257. } else {
  3258. $where .= " and source = '$source'";
  3259. }
  3260. }
  3261. if (isset($_SESSION['api'])) {
  3262. foreach ($user as $value) {
  3263. $fgshop .= " shop = " . $value . " or";
  3264. }
  3265. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3266. }
  3267. if ($orderurl) {
  3268. $url = $this->orderurl->read($orderurl);
  3269. $where .= " and link like '%" . $url['url'] . "%'";
  3270. }
  3271. //数据排序
  3272. $order_str = "librarytime desc";
  3273. if (empty($page)) {
  3274. $start = 0;
  3275. $perpage = 1;
  3276. } else {
  3277. $start = ($page - 1) * $perpage;
  3278. }
  3279. //取得信息列表
  3280. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3281. //格式化数据
  3282. foreach ($info_list as $key => $value) {
  3283. $shop = $this->shop->read($value['shop']);
  3284. $info_list[$key]['shop'] = $shop['shopname'];
  3285. $express = $this->express->read($value['express']);
  3286. $info_list[$key]['express'] = $express['servicename'];
  3287. $warehouse = $this->warehouse->read($value['type']);
  3288. $info_list[$key]['type'] = $warehouse['title'];
  3289. if ($value['librarytime'] == '0') {
  3290. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3291. } else {
  3292. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3293. }
  3294. }
  3295. $total = $this->$sj->find_count($where);
  3296. $pagenum = ceil($total / $perpage);
  3297. $over = $total - ($start + $perpage);
  3298. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3299. echo json_encode($rows);
  3300. exit;
  3301. }
  3302. $this->data['express'] = $this->express->find_all();
  3303. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3304. $this->data['wlshop'] = $wlshop;
  3305. $user = $this->user->get_api($_SESSION['api']);
  3306. $powerid = $this->power->read($user['power']);
  3307. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3308. $pid = '';
  3309. foreach ($powertext as $v) {
  3310. $pid .= " id = " . $v . " or";
  3311. }
  3312. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3313. $this->data['fullorderexcel'] = $fullorderexcel;
  3314. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3315. $this->data['orderurl'] = $orderurl;
  3316. $this->_Template('whlabel_aoutorder', $this->data);
  3317. }
  3318. //速卖通出库订单
  3319. public function _soutorder()
  3320. {
  3321. if (isset($_SESSION['api'])) {
  3322. $user = $this->user->get_api($_SESSION['api']);
  3323. $usp = $user;
  3324. $fgshop = "";
  3325. $sid = "";
  3326. $user = explode('|', trim($user['shop'], '|'));
  3327. foreach ($user as $value) {
  3328. $sid .= " id = " . $value . " or";
  3329. }
  3330. }
  3331. $post = $this->input->post(NULL, TRUE);
  3332. if (isset($post['page'])) {
  3333. $page = $this->input->post('page', true);
  3334. $perpage = $this->input->post('perpage', true);
  3335. $warehouse = $this->input->post('warehouse', true);
  3336. $xztime = $this->input->post('xztime', true);
  3337. $timetk = $this->input->post('timetkk', true);
  3338. $timetj = $this->input->post('timetjj', true);
  3339. $shop = $this->input->post('shop', true);
  3340. $source = $this->input->post('source', true);
  3341. $orderinfo = $this->input->post('orderinfo', true);
  3342. $number = $this->input->post('number', true);
  3343. $express = $this->input->post('express', true);
  3344. $waybill = $this->input->post('waybill', true);
  3345. $library = $this->input->post('library', true);
  3346. $country = $this->input->post('country', true);
  3347. $sfxh = $this->input->post('sfxh', true);
  3348. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3349. $print = $this->input->post('print', true);
  3350. $state = $this->input->post('state', true);
  3351. $so = $this->input->post('so', true);
  3352. $timetk = strtotime($timetk);
  3353. $timetj = strtotime($timetj);
  3354. /**
  3355. $sj = $this->input->post('sj',true);
  3356. if($sj)
  3357. {
  3358. $sj = $this->input->post('sj',true);
  3359. }
  3360. else
  3361. {
  3362. $sj = "fullorder";
  3363. }
  3364. **/
  3365. $sj = "fullordersmt";
  3366. $where = "1=1";
  3367. if ($warehouse) {
  3368. $where .= " and type = '$warehouse'";
  3369. }
  3370. if ($timetk && $timetj) {
  3371. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3372. }
  3373. if ($orderinfo) {
  3374. $where .= " and orderinfo = '$orderinfo'";
  3375. }
  3376. if ($number) {
  3377. $where .= " and number = '$number'";
  3378. }
  3379. if ($express) {
  3380. $where .= " and express = '$express'";
  3381. }
  3382. if ($waybill) {
  3383. $where .= " and waybill = '$waybill'";
  3384. }
  3385. if ($library) {
  3386. $where .= " and library = '$library'";
  3387. }
  3388. if ($print) {
  3389. $where .= " and print = '$print'";
  3390. }
  3391. if ($libraryconfirm) {
  3392. $where .= " and libraryconfirm = '$libraryconfirm'";
  3393. }
  3394. if ($state) {
  3395. $where .= " and state = '$state'";
  3396. }
  3397. if ($shop) {
  3398. $where .= " and shop = '$shop'";
  3399. }
  3400. if ($sfxh != '') {
  3401. $where .= " and sfxh = '$sfxh'";
  3402. }
  3403. if ($so) {
  3404. $where .= " and shipremarks like '%$so%'";
  3405. }
  3406. if ($source) {
  3407. $where .= " and source = '$source'";
  3408. }
  3409. if ($country) {
  3410. $where .= " and country = '$country'";
  3411. } else {
  3412. if (isset($_SESSION['api'])) {
  3413. foreach ($user as $value) {
  3414. $fgshop .= " shop = " . $value . " or";
  3415. }
  3416. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3417. }
  3418. }
  3419. //数据排序
  3420. $order_str = "librarytime desc";
  3421. if (empty($page)) {
  3422. $start = 0;
  3423. $perpage = 1;
  3424. } else {
  3425. $start = ($page - 1) * $perpage;
  3426. }
  3427. //取得信息列表
  3428. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3429. //格式化数据
  3430. foreach ($info_list as $key => $value) {
  3431. $shop = $this->shop->read($value['shop']);
  3432. $info_list[$key]['shop'] = $shop['shopname'];
  3433. $express = $this->express->read($value['express']);
  3434. $info_list[$key]['express'] = $express['servicename'];
  3435. $warehouse = $this->warehouse->read($value['type']);
  3436. $info_list[$key]['type'] = $warehouse['title'];
  3437. if ($value['librarytime'] == '0') {
  3438. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3439. } else {
  3440. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3441. }
  3442. }
  3443. $total = $this->$sj->find_count($where);
  3444. $pagenum = ceil($total / $perpage);
  3445. $over = $total - ($start + $perpage);
  3446. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3447. echo json_encode($rows);
  3448. exit;
  3449. }
  3450. $this->data['express'] = $this->express->find_all();
  3451. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3452. $this->data['wlshop'] = $wlshop;
  3453. $user = $this->user->get_api($_SESSION['api']);
  3454. $powerid = $this->power->read($user['power']);
  3455. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3456. $pid = '';
  3457. foreach ($powertext as $v) {
  3458. $pid .= " id = " . $v . " or";
  3459. }
  3460. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3461. $this->data['fullorderexcel'] = $fullorderexcel;
  3462. $this->_Template('whlabel_soutorder', $this->data);
  3463. }
  3464. //订单退库
  3465. public function _retreat()
  3466. {
  3467. $post = $this->input->post(NULL, TRUE);
  3468. if (isset($post['page'])) {
  3469. $page = $this->input->post('page', true);
  3470. $perpage = $this->input->post('perpage', true);
  3471. $warehouse = $this->input->post('warehouse', true);
  3472. $timetk = $this->input->post('timetk', true);
  3473. $timetj = $this->input->post('timetj', true);
  3474. $shop = $this->input->post('shop', true);
  3475. $source = $this->input->post('source', true);
  3476. $state = $this->input->post('state', true);
  3477. $review = $this->input->post('review', true);
  3478. $state = $this->input->post('state', true);
  3479. $express = $this->input->post('express', true);
  3480. $orderinfo = $this->input->post('orderinfo', true);
  3481. $user = $this->input->post('user', true);
  3482. $name = $this->input->post('name', true);
  3483. $waybill = $this->input->post('waybill', true);
  3484. $timetk = strtotime($timetk);
  3485. $timetj = strtotime($timetj);
  3486. $where = "(state=206 or state=210) and mergeid = 0";
  3487. if ($warehouse) {
  3488. $where .= " and state = '$warehouse'";
  3489. }
  3490. if ($timetk && $timetj) {
  3491. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3492. }
  3493. if ($shop) {
  3494. $where .= " and shop = '$shop'";
  3495. }
  3496. if ($source) {
  3497. $where .= " and source = '$source'";
  3498. }
  3499. if ($state) {
  3500. $where .= " and state = '$state'";
  3501. }
  3502. if ($review) {
  3503. $where .= " and review = '$review'";
  3504. }
  3505. if ($state) {
  3506. $where .= " and state = '$state'";
  3507. }
  3508. if ($express) {
  3509. $where .= " and express = '$express'";
  3510. }
  3511. if ($orderinfo) {
  3512. $where .= " and orderinfo = '$orderinfo'";
  3513. }
  3514. if ($user) {
  3515. $where .= " and user = '$user'";
  3516. }
  3517. if ($name) {
  3518. $where .= " and name = '$name'";
  3519. }
  3520. if ($waybill) {
  3521. $where .= " and waybill = '$waybill'";
  3522. }
  3523. //数据排序
  3524. $order_str = "id desc";
  3525. if (empty($page)) {
  3526. $start = 0;
  3527. $perpage = 1;
  3528. } else {
  3529. $start = ($page - 1) * $perpage;
  3530. }
  3531. //取得信息列表
  3532. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3533. //格式化数据
  3534. foreach ($info_list as $key => $value) {
  3535. $shop = $this->shop->read($value['shop']);
  3536. $info_list[$key]['shop'] = $shop['shopname'];
  3537. $warehouse = $this->warehouse->read($value['warehouse']);
  3538. $info_list[$key]['warehouse'] = $warehouse['title'];
  3539. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3540. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3541. if ($value['waybill'] == 0) {
  3542. $info_list[$key]['waybill'] = "";
  3543. }
  3544. $express = $this->express->read($value['express']);
  3545. $info_list[$key]['express'] = $express['title'];
  3546. $typeclass = $this->typeclass->read($value['state']);
  3547. $info_list[$key]['state'] = $typeclass['title'];
  3548. }
  3549. $total = $this->fullorder->find_count($where);
  3550. $pagenum = ceil($total / $perpage);
  3551. $over = $total - ($start + $perpage);
  3552. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3553. echo json_encode($rows);
  3554. exit;
  3555. }
  3556. $this->data['express'] = $this->express->find_all();
  3557. $this->_Template('whlabel_retreat', $this->data);
  3558. }
  3559. //退库标签浏览
  3560. public function _retreatlk()
  3561. {
  3562. $post = $this->input->post(NULL, TRUE);
  3563. if (isset($post['page'])) {
  3564. $page = $this->input->post('page', true);
  3565. $perpage = $this->input->post('perpage', true);
  3566. $timetk = $this->input->post('timetk', true);
  3567. $timetj = $this->input->post('timetj', true);
  3568. $sku = $this->input->post('sku', true);
  3569. $warehouse = $this->input->post('warehouse', true);
  3570. $purchase = $this->input->post('purchase', true);
  3571. $orderinfo = $this->input->post('orderinfo', true);
  3572. $waybill = $this->input->post('waybill', true);
  3573. $category = $this->input->post('category', true);
  3574. $size = $this->input->post('size', true);
  3575. $grade = $this->input->post('grade', true);
  3576. $color = $this->input->post('color', true);
  3577. $lowe = $this->input->post('lowe', true);
  3578. $state = $this->input->post('state', true);
  3579. $timetk = strtotime($timetk);
  3580. $timetj = strtotime($timetj);
  3581. $where = "state=2";
  3582. if ($timetk && $timetj) {
  3583. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3584. }
  3585. if ($sku) {
  3586. $where .= " and sku = '$sku'";
  3587. }
  3588. if ($warehouse) {
  3589. $where .= " and warehouse = '$warehouse'";
  3590. }
  3591. if ($purchase) {
  3592. $where .= " and purchase = '$purchase'";
  3593. }
  3594. if ($orderinfo) {
  3595. $where .= " and orderinfo = '$orderinfo'";
  3596. }
  3597. if ($waybill) {
  3598. $where .= " and waybill = '$waybill'";
  3599. }
  3600. if ($category) {
  3601. $where .= " and features like '%-$category-%'";
  3602. }
  3603. if ($size) {
  3604. $where .= " and features like '%-$size-%'";
  3605. }
  3606. if ($grade) {
  3607. $where .= " and features like '%-$grade-%'";
  3608. }
  3609. if ($color) {
  3610. $where .= " and features like '%-$color-%'";
  3611. }
  3612. if ($lowe) {
  3613. $where .= " and features like '%-$lowe-%'";
  3614. }
  3615. //数据排序
  3616. $order_str = "time desc";
  3617. if (empty($page)) {
  3618. $start = 0;
  3619. $perpage = 1;
  3620. } else {
  3621. $start = ($page - 1) * $perpage;
  3622. }
  3623. //取得信息列表
  3624. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3625. foreach ($info_list as $key => $value) {
  3626. $warehouse = $this->warehouse->read($value['warehouse']);
  3627. $info_list[$key]['warehouse'] = $warehouse['title'];
  3628. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3629. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3630. $purchase = $this->purchase->read($value['purchase']);
  3631. $info_list[$key]['purchase'] = $purchase['title'];
  3632. if ($value['outk'] != 0) {
  3633. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3634. } else {
  3635. $info_list[$key]['outk'] = "";
  3636. }
  3637. if ($value['retreat'] != 0) {
  3638. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3639. } else {
  3640. $info_list[$key]['retreat'] = "";
  3641. }
  3642. if ($value['orderinfo'] == 0) {
  3643. $info_list[$key]['orderinfo'] = "";
  3644. }
  3645. if ($value['waybill'] == 0) {
  3646. $info_list[$key]['waybill'] = "";
  3647. }
  3648. }
  3649. $total = $this->whlabel->find_count($where);
  3650. $pagenum = ceil($total / $perpage);
  3651. $over = $total - ($start + $perpage);
  3652. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3653. echo json_encode($rows);
  3654. exit;
  3655. }
  3656. $this->_Template('whlabel_retreatlk', $this->data);
  3657. }
  3658. //更换标签及浏览
  3659. public function _change()
  3660. {
  3661. $post = $this->input->post(NULL, TRUE);
  3662. if (isset($post['page'])) {
  3663. $page = $this->input->post('page', true);
  3664. $perpage = $this->input->post('perpage', true);
  3665. $timetk = $this->input->post('timetk', true);
  3666. $timetj = $this->input->post('timetj', true);
  3667. $label = $this->input->post('label', true);
  3668. $oldlabel = $this->input->post('oldlabel', true);
  3669. $timetk = strtotime($timetk);
  3670. $timetj = strtotime($timetj);
  3671. $where = "state=10 ";
  3672. if ($timetk && $timetj) {
  3673. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3674. }
  3675. if ($label) {
  3676. $where .= " and label = '$label'";
  3677. }
  3678. if ($oldlabel) {
  3679. $where .= " and oldlabel = '$oldlabel'";
  3680. }
  3681. //数据排序
  3682. $order_str = "time asc";
  3683. if (empty($page)) {
  3684. $start = 0;
  3685. $perpage = 1;
  3686. } else {
  3687. $start = ($page - 1) * $perpage;
  3688. }
  3689. //取得信息列表
  3690. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3691. foreach ($info_list as $key => $value) {
  3692. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3693. }
  3694. $total = $this->whlabel->find_count($where);
  3695. $pagenum = ceil($total / $perpage);
  3696. $over = $total - ($start + $perpage);
  3697. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3698. echo json_encode($rows);
  3699. exit;
  3700. }
  3701. $this->_Template('whlabel_change', $this->data);
  3702. }
  3703. //产品标签
  3704. public function _cpbqdc()
  3705. {
  3706. if (isset($_GET['excel'])) {
  3707. $where = "1=1";
  3708. //数据排序
  3709. $order_str = "id desc";
  3710. if (empty($page)) {
  3711. $start = 0;
  3712. $perpage = 1;
  3713. } else {
  3714. $start = ($page - 1) * $perpage;
  3715. }
  3716. $warehouse = $this->input->get('warehouse', true);
  3717. $state = $this->input->get('state', true);
  3718. $timetk = $this->input->get('timetkk', true);
  3719. $timetj = $this->input->get('timetjj', true);
  3720. $timetk = strtotime($timetk);
  3721. $timetj = strtotime($timetj);
  3722. if ($warehouse) {
  3723. $where .= " and warehouse = '$warehouse'";
  3724. }
  3725. if ($state || $state == 0) {
  3726. $where .= " and state = '$state'";
  3727. }
  3728. if ($timetk && $timetj) {
  3729. $where .= " and time > '$timetk' and time < '$timetj'";
  3730. }
  3731. //取得信息列表
  3732. $info_list = $this->whlabel->find_all($where, '*');
  3733. $rows = array();
  3734. $list = array();
  3735. foreach ($info_list as $key => $value) {
  3736. $rows[$value['time']] = $value; //所有数据sku
  3737. }
  3738. foreach ($rows as $value) {
  3739. $warehouse = $this->warehouse->read($value['warehouse']);
  3740. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3741. $list[] = array($warehouse['title'], $value['sku'], $value['title'], date('Y-m-d H:i:s', $value['enter']), date('Y-m-d H:i:s', $value['time']), $value['text'], $s);
  3742. }
  3743. $title = "产品标签统计表";
  3744. $titlename = "<table border=1>
  3745. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3746. <tr align='center'>
  3747. <td>仓库</td>
  3748. <td>SKU</td>
  3749. <td>产品</td>
  3750. <td>入库时间</td>
  3751. <td>操作时间</td>
  3752. <td>备注</td>
  3753. <td>数量</td>
  3754. </tr>
  3755. </table>";
  3756. $filename = $title . ".xls";
  3757. $tail = "";
  3758. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3759. }
  3760. }
  3761. //进销存导出
  3762. public function _exceljxc()
  3763. {
  3764. $classid = $this->classid->sku();
  3765. $pm = $classid;
  3766. $typeclass = array();
  3767. $tc = $this->typeclass->find_all();
  3768. foreach ($tc as $v) {
  3769. $typeclass[$v['id']] = $v;
  3770. }
  3771. $prc = array();
  3772. $purchase = $this->purchase->find_all();
  3773. foreach ($purchase as $k => $v) {
  3774. $prc[$v['id']] = $v['title'];
  3775. }
  3776. if (isset($_GET['excel'])) {
  3777. $where = "sku != 'Preset'";
  3778. //数据排序
  3779. $order_str = "id desc";
  3780. if (empty($page)) {
  3781. $start = 0;
  3782. $perpage = 1;
  3783. } else {
  3784. $start = ($page - 1) * $perpage;
  3785. }
  3786. $category = $this->input->get('category', true);
  3787. $warehouse = $this->input->get('warehouse', true);
  3788. $excelid = $this->input->get('sid', true);
  3789. if ($category) {
  3790. $where .= " and features like '%-$category-%'";
  3791. }
  3792. if ($warehouse) {
  3793. $where .= " and warehouse = '$warehouse'";
  3794. }
  3795. $xzid = '';
  3796. if ($excelid) {
  3797. $excelid = explode(',', trim($excelid, ','));
  3798. foreach ($excelid as $key => $value) {
  3799. $xzid .= " id = " . $value . " or";
  3800. }
  3801. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3802. }
  3803. //取得信息列表
  3804. /**
  3805. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3806. $rows = array();$list = array();
  3807. foreach ($info_list as $key=>$value)
  3808. {
  3809. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3810. }
  3811. **/
  3812. $wt = array();
  3813. $whlabel_type = $this->whlabel_type->find_all();
  3814. foreach ($whlabel_type as $v) {
  3815. $wt[$v['id']] = $v['title'];
  3816. }
  3817. $wh = array();
  3818. $w = $this->warehouse->find_all('1=1', 'id,title');
  3819. foreach ($w as $v) {
  3820. $wh[$v['id']] = $v['title'];
  3821. }
  3822. $list = array();
  3823. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3824. foreach ($rows as $key => $value) {
  3825. if (isset($wt[$value['type']])) {
  3826. $rows[$key]['type'] = $wt[$value['type']];
  3827. } else {
  3828. $rows[$key]['type'] = '未设置';
  3829. }
  3830. $bm = '03';
  3831. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3832. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3833. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3834. $details = array();
  3835. $cpid = array();
  3836. $cpbz = array();
  3837. $c = 0;
  3838. $g = 0;
  3839. $x = 0;
  3840. $t = 0;
  3841. $s = 0;
  3842. $q = 0;
  3843. foreach ($sd as $k => $v) {
  3844. if ($v['state'] == 0) {
  3845. $c++;
  3846. if ($v['cpid'] != 0) {
  3847. $cpid[$v['cpid']] = $v['cpid'];
  3848. }
  3849. if ($v['cpbz'] != '') {
  3850. $cpbz[$v['cpbz']] = $v['cpbz'];
  3851. }
  3852. }
  3853. if ($v['state'] != 9) {
  3854. $g++;
  3855. }
  3856. if ($v['state'] == 1) {
  3857. $x++;
  3858. }
  3859. if ($v['state'] == 2) {
  3860. $t++;
  3861. }
  3862. if ($v['state'] == 8) {
  3863. $s++;
  3864. }
  3865. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3866. $q++;
  3867. }
  3868. $details[$v['details']] = $v['details'];
  3869. }
  3870. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3871. $rows[$key]['details'] = implode("、", $details);
  3872. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3873. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3874. $number = $value['number'];
  3875. $ftime = time() - 15 * 24 * 3600;
  3876. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3877. $rows[$key]['number'] = $g;
  3878. $rows[$key]['c'] = $c;
  3879. $rows[$key]['x'] = $x;
  3880. $rows[$key]['t'] = $t;
  3881. $rows[$key]['s'] = $s;
  3882. $rows[$key]['q'] = $q;
  3883. $rows[$key]['z'] = $z;
  3884. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3885. $features = explode('-', trim($features, '-'));
  3886. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3887. // $pm = $classid;
  3888. // $jm = $classid;
  3889. // foreach($features as $k=>$v)
  3890. // {
  3891. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3892. // {
  3893. // if($typeclass[$v]['bm'] != '')
  3894. // {
  3895. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3896. // }
  3897. // }
  3898. // if($v != 0)
  3899. // {
  3900. // if(!isset($typeclass[$v]))
  3901. // {
  3902. // continue;
  3903. // }
  3904. // if(isset($pm[$typeclass[$v]['classid']]))
  3905. // {
  3906. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3907. // {
  3908. // $tz = explode('|',$typeclass[$v]['zh']);
  3909. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3910. // }
  3911. // else
  3912. // {
  3913. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3914. // }
  3915. // }
  3916. // if(isset($jm[$typeclass[$v]['classid']]))
  3917. // {
  3918. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3919. // }
  3920. // }
  3921. // }
  3922. // $jm = array_filter($jm);
  3923. // $rows[$key]['bs'] = implode("-",$jm);
  3924. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3925. // $zh = implode(" ",$pm);
  3926. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3927. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3928. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3929. // $rows[$key]['features'] = $zh;
  3930. }
  3931. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3932. $final_list = [];
  3933. foreach ($list as $k => $v) {
  3934. if (empty($v['sku'])) {
  3935. continue;
  3936. }
  3937. $final_list[] = [
  3938. "warehouse" => $v["warehouse"],
  3939. "purchase" => $v["purchase"],
  3940. "details" => $v["details"],
  3941. "cpid" => $v["cpid"],
  3942. "dbcontent" => $v["dbcontent"],
  3943. "sku" => $v["sku"],
  3944. "cs" => $v["bm"],
  3945. "bs" => $v["jm"],
  3946. "title" => $v["title"],
  3947. "features" => $v["pm"],
  3948. "cpbz" => $v["cpbz"],
  3949. "sm" => $v["sm"],
  3950. "type" => $v["type"],
  3951. "number" => $v["number"],
  3952. "c" => $v["c"],
  3953. "x" => $v["x"],
  3954. "t" => $v["t"],
  3955. "s" => $v["s"],
  3956. "q" => $v["q"],
  3957. "z" => $v["z"],
  3958. "weight" => $v['weight'],
  3959. ];
  3960. }
  3961. $title = "总进销存统计表";
  3962. $titlename = "<table border=1>
  3963. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3964. <tr align='center'>
  3965. <td>仓库</td>
  3966. <td>供应商</td>
  3967. <td>位置</td>
  3968. <td>库存编码</td>
  3969. <td>类目</td>
  3970. <td>SKU</td>
  3971. <td>用友编码</td>
  3972. <td>用友料号</td>
  3973. <td>商品名称</td>
  3974. <td>商品中文</td>
  3975. <td>产品备注</td>
  3976. <td>库位负责人</td>
  3977. <td>类型</td>
  3978. <td>入库总量</td>
  3979. <td>库存数量</td>
  3980. <td>销售数量</td>
  3981. <td>退货数量</td>
  3982. <td>删除数量</td>
  3983. <td>其它操作</td>
  3984. <td>占单数量</td>
  3985. <td>重量(g)</td>
  3986. </tr>
  3987. </table>";
  3988. $filename = $title . ".xls";
  3989. $tail = "";
  3990. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3991. }
  3992. }
  3993. //入库导出
  3994. public function _excelr()
  3995. {
  3996. if (isset($_GET['excel'])) {
  3997. $category = $this->input->get('category', true);
  3998. $size = $this->input->get('size', true);
  3999. $grade = $this->input->get('grade', true);
  4000. $color = $this->input->get('color', true);
  4001. $lowe = $this->input->get('lowe', true);
  4002. $sku = $this->input->get('sku', true);
  4003. $warehouse = $this->input->get('warehouse', true);
  4004. $purchase = $this->input->get('purchase', true);
  4005. $ktime = $this->input->get('ktime', true);
  4006. $jtime = $this->input->get('jtime', true);
  4007. $rktype = $this->input->get('rktype',true);
  4008. $ktime = strtotime($ktime);
  4009. $jtime = strtotime($jtime);
  4010. $where = "1=1";
  4011. $gj = "";
  4012. $ck = "";
  4013. if ($category) {
  4014. $where .= " and features like '%-$category-%'";
  4015. }
  4016. if ($size) {
  4017. $where .= " and features like '%-$size-%'";
  4018. }
  4019. if ($grade) {
  4020. $where .= " and features like '%-$grade-%'";
  4021. }
  4022. if ($color) {
  4023. $where .= " and features like '%-$color-%'";
  4024. }
  4025. if ($lowe) {
  4026. $where .= " and features like '%-$lowe-%'";
  4027. }
  4028. if ($warehouse) {
  4029. $where .= " and warehouse = '$warehouse'";
  4030. }
  4031. if ($purchase) {
  4032. $where .= " and purchase = '$purchase'";
  4033. }
  4034. if ($sku) {
  4035. $where .= " and sku = '$sku'";
  4036. }
  4037. if($rktype){
  4038. $where .= " and rktype = '$rktype' ";
  4039. }
  4040. if ($ktime && $jtime) {
  4041. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4042. }
  4043. //数据排序
  4044. $order_str = "id desc";
  4045. if (empty($page)) {
  4046. $start = 0;
  4047. $perpage = 1;
  4048. } else {
  4049. $start = ($page - 1) * $perpage;
  4050. }
  4051. $list = array();
  4052. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4053. $three_month = strtotime('-3 months');
  4054. $rows_d = $this->whlabelscbf->find_pc($where." and del_time > ".$three_month, 'enter,sku,warehouse', '*', $order_str);
  4055. $rows_d = array_map(function ($item) {
  4056. unset($item['del_time']); // 删除 age 字段
  4057. return $item;
  4058. }, $rows_d);
  4059. $rows = array_merge($rows, $rows_d);
  4060. foreach ($rows as $value) {
  4061. $ck = $this->warehouse->read($value['warehouse']);
  4062. $warehouse = $ck['title'];
  4063. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4064. $retreatwarehouse = $tkck['title'];
  4065. $gy = $this->purchase->read($value['purchase']);
  4066. $purchase = $gy['title'];
  4067. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4068. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4069. }
  4070. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4071. $titlename = "<table border=1>
  4072. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4073. <tr align='center'>
  4074. <td>仓库</td>
  4075. <td>SKU</td>
  4076. <td>产品</td>
  4077. <td>时间</td>
  4078. <td>数量</td>
  4079. </tr>
  4080. </table>";
  4081. $filename = $title . ".xls";
  4082. $tail = "";
  4083. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4084. }
  4085. }
  4086. //出库、退库导出
  4087. public function _excelct()
  4088. {
  4089. $classid = $this->classid->sku();
  4090. $pm = $classid;
  4091. $typeclass = array();
  4092. $tc = $this->typeclass->find_all();
  4093. foreach ($tc as $v) {
  4094. $typeclass[$v['id']] = $v;
  4095. }
  4096. $prc = array();
  4097. $purchase = $this->purchase->find_all();
  4098. foreach ($purchase as $k => $v) {
  4099. $prc[$v['id']] = $v['title'];
  4100. }
  4101. if (isset($_GET['excel'])) {
  4102. $wh = array();
  4103. $w = $this->warehouse->find_all('1=1', 'id,title');
  4104. foreach ($w as $v) {
  4105. $wh[$v['id']] = $v['title'];
  4106. }
  4107. $type = $this->input->get('excel', true);
  4108. $category = $this->input->get('category', true);
  4109. $size = $this->input->get('size', true);
  4110. $grade = $this->input->get('grade', true);
  4111. $color = $this->input->get('color', true);
  4112. $lowe = $this->input->get('lowe', true);
  4113. $sku = $this->input->get('sku', true);
  4114. $title = $this->input->get('title', true);
  4115. $warehouse = $this->input->get('warehouse', true);
  4116. $purchase = $this->input->get('purchase', true);
  4117. $lacetype = $this->input->get('lacetype', true);
  4118. $haircap = $this->input->get('haircap', true);
  4119. $lacecolor = $this->input->get('lacecolor', true);
  4120. $density = $this->input->get('density', true);
  4121. $details = $this->input->get('details', true);
  4122. $state = $this->input->get('state', true);
  4123. $shop = $this->input->get('shop', true);
  4124. $hairnumber = $this->input->get('hairnumber', true);
  4125. $type_leixi = $this->input->get('type', true);
  4126. $cpbz = $this->input->get('cpbz', true);
  4127. $sm = $this->input->get('sm', true);
  4128. $sid = $this->input->get('sid', true);
  4129. $ktime = $this->input->get('ktime', true);
  4130. $jtime = $this->input->get('jtime', true);
  4131. $ktime = strtotime($ktime);
  4132. $jtime = strtotime($jtime);
  4133. //$where = " 1=1 ";
  4134. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4135. $where = " sku != '' ";
  4136. $gj = "";
  4137. $ck = "";
  4138. if ($category) {
  4139. $where .= " and features like '%-$category-%'";
  4140. }
  4141. if ($size) {
  4142. $where .= " and features like '%-$size-%'";
  4143. }
  4144. if ($grade) {
  4145. $where .= " and features like '%-$grade-%'";
  4146. }
  4147. if ($color) {
  4148. $where .= " and features like '%-$color-%'";
  4149. }
  4150. if ($lowe) {
  4151. $where .= " and features like '%-$lowe-%'";
  4152. }
  4153. if ($warehouse) {
  4154. $where .= " and warehouse = '$warehouse'";
  4155. }
  4156. if ($purchase) {
  4157. $where .= " and purchase = '$purchase'";
  4158. }
  4159. if ($state) {
  4160. $where .= " and state = '$state'";
  4161. }
  4162. if ($lacetype) {
  4163. $where .= " and features like '%-$lacetype-%'";
  4164. }
  4165. if ($lacecolor) {
  4166. $where .= " and features like '%-$lacecolor-%'";
  4167. }
  4168. if ($density) {
  4169. $where .= " and features like '%-$density-%'";
  4170. }
  4171. if ($haircap) {
  4172. $where .= " and features like '%-$haircap-%'";
  4173. }
  4174. if ($details) {
  4175. $where .= " and details = '$details'";
  4176. }
  4177. if ($shop) {
  4178. $where .= " and shop like '%$shop%'";
  4179. }
  4180. if ($title) {
  4181. $title = trim($title, ' ');
  4182. $title = trim($title, ' ');
  4183. $where .= " and title like '%$title%'";
  4184. }
  4185. if (!empty($hairnumber)) {
  4186. $where .= " and features like '%-128-%' ";
  4187. if ($hairnumber < 0) {
  4188. $class_list = $this->typeclass->find_all('classid = 43');
  4189. foreach ($class_list as $v) {
  4190. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4191. }
  4192. } else {
  4193. $where .= " and features like '%-$hairnumber-%'";
  4194. }
  4195. }
  4196. if ($type_leixi) {
  4197. $where .= " and type = '$type_leixi'";
  4198. }
  4199. if ($cpbz) {
  4200. $where .= " and cpbz like '%$cpbz%' ";
  4201. }
  4202. if ($sm) {
  4203. $where .= " and sm like '%$sm%' ";
  4204. }
  4205. if ($sku) {
  4206. $sku = trim($sku, ' ');
  4207. $sku = trim($sku, ' ');
  4208. $where .= " and sku like '%$sku%'";
  4209. }
  4210. if ($ktime && $jtime) {
  4211. if ($type == 1) {
  4212. $tl = '出库';
  4213. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4214. } else if ($type == 2) {
  4215. $tl = '退库';
  4216. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4217. } else if ($type == 3) {
  4218. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4219. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4220. } else if ($type == 4) {
  4221. $tl = '出库+零售';
  4222. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4223. } else if ($type == 5) {
  4224. $tl = '零售';
  4225. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4226. }
  4227. }
  4228. $sidwhere = '';
  4229. if ($sid) {
  4230. $sd = "";
  4231. $s = explode(',', trim($sid, ','));
  4232. foreach ($s as $value) {
  4233. $sd .= " id = " . $value . " or";
  4234. }
  4235. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4236. }
  4237. //数据排序
  4238. $order_str = "time desc";
  4239. if (empty($page)) {
  4240. $start = 0;
  4241. $perpage = 1;
  4242. } else {
  4243. $start = ($page - 1) * $perpage;
  4244. }
  4245. //取得信息列表
  4246. if ($type != 3 && $type != 5) {
  4247. if ($type == 1 || $type == 4) {
  4248. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4249. $three_month = strtotime('-3 months');
  4250. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4251. $info_list_d = array_map(function ($item) {
  4252. unset($item['del_time']); // 删除 age 字段
  4253. return $item;
  4254. }, $info_list_d);
  4255. $info_list = array_merge($info_list, $info_list_d);
  4256. foreach ($info_list as $key => $value) {
  4257. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4258. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4259. $warehouse = $this->warehouse->read($value['warehouse']);
  4260. $info_list[$key]['warehouse'] = $warehouse['title'];
  4261. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4262. $features = explode('-', trim($features, '-'));
  4263. $pm = $classid;
  4264. foreach ($features as $k => $v) {
  4265. if ($v != 0) {
  4266. if (!isset($typeclass[$v])) {
  4267. continue;
  4268. }
  4269. if (isset($pm[$typeclass[$v]['classid']])) {
  4270. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4271. $tz = explode('|', $typeclass[$v]['zh']);
  4272. $pm[$typeclass[$v]['classid']] = $tz[0];
  4273. } else {
  4274. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $zh = implode(" ", $pm);
  4280. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4281. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4282. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4283. $info_list[$key]['features'] = $zh;
  4284. }
  4285. $final_list = [];
  4286. foreach($info_list as $k=>$v){
  4287. $number = "";
  4288. if(!empty($v['orderinfo'])){
  4289. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4290. if(!empty($tmp_info['number'])){
  4291. $number = $tmp_info['number'];
  4292. }
  4293. }
  4294. $final_list[] = [
  4295. 'warehouse'=>$v['warehouse'],
  4296. 'purchase'=>$v['purchase'],
  4297. 'sku'=>$v['sku'],
  4298. 'title'=>$v['title'],
  4299. 'features'=>$v['features'],
  4300. 'label'=>$v['label'],
  4301. 'orderinfo'=>$v['orderinfo'],
  4302. 'number'=>$number,
  4303. 'waybill'=>$v['waybill'],
  4304. 'outk'=>$v['outk'],
  4305. ];
  4306. }
  4307. } else {
  4308. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4309. foreach ($info_list as $key => $value) {
  4310. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4311. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4312. $warehouse = $this->warehouse->read($value['warehouse']);
  4313. $info_list[$key]['warehouse'] = $warehouse['title'];
  4314. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4315. $features = explode('-', trim($features, '-'));
  4316. $pm = $classid;
  4317. foreach ($features as $k => $v) {
  4318. if ($v != 0) {
  4319. if (!isset($typeclass[$v])) {
  4320. continue;
  4321. }
  4322. if (isset($pm[$typeclass[$v]['classid']])) {
  4323. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4324. $tz = explode('|', $typeclass[$v]['zh']);
  4325. $pm[$typeclass[$v]['classid']] = $tz[0];
  4326. } else {
  4327. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4328. }
  4329. }
  4330. }
  4331. }
  4332. $zh = implode(" ", $pm);
  4333. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4334. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4335. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4336. $info_list[$key]['features'] = $zh;
  4337. }
  4338. $final_list = [];
  4339. foreach($info_list as $k=>$v){
  4340. $number = "";
  4341. if(!empty($v['orderinfo'])){
  4342. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4343. if(!empty($tmp_info['number'])){
  4344. $number = $tmp_info['number'];
  4345. }
  4346. }
  4347. $final_list[] = [
  4348. 'warehouse'=>$v['warehouse'],
  4349. 'purchase'=>$v['purchase'],
  4350. 'sku'=>$v['sku'],
  4351. 'title'=>$v['title'],
  4352. 'features'=>$v['features'],
  4353. 'label'=>$v['label'],
  4354. 'orderinfo'=>$v['orderinfo'],
  4355. 'number'=>$number,
  4356. 'waybill'=>$v['waybill'],
  4357. 'retreat'=>$v['retreat'],
  4358. ];
  4359. }
  4360. }
  4361. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4362. $titlename = "<table border=1>
  4363. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4364. <tr align='center'>
  4365. <td>仓库</td>
  4366. <td>供应商</td>
  4367. <td>SKU</td>
  4368. <td>商品名称</td>
  4369. <td>商品中文</td>
  4370. <td>标签</td>
  4371. <td>订单号</td>
  4372. <td>订单编码</td>
  4373. <td>运单号</td>
  4374. <td>" . $tl . "时间(中国时间)</td>
  4375. </tr>
  4376. </table>";
  4377. $filename = $title . ".xls";
  4378. $tail = "";
  4379. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4380. } else if ($type == 5) {
  4381. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4382. $three_month = strtotime('-3 months');
  4383. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4384. $info_list_d = array_map(function ($item) {
  4385. unset($item['del_time']); // 删除 age 字段
  4386. return $item;
  4387. }, $info_list_d);
  4388. $info_list = array_merge($info_list, $info_list_d);
  4389. foreach ($info_list as $key => $value) {
  4390. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4391. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4392. $warehouse = $this->warehouse->read($value['warehouse']);
  4393. $info_list[$key]['warehouse'] = $warehouse['title'];
  4394. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4395. $features = explode('-', trim($features, '-'));
  4396. $pm = $classid;
  4397. foreach ($features as $k => $v) {
  4398. if ($v != 0) {
  4399. if (!isset($typeclass[$v])) {
  4400. continue;
  4401. }
  4402. if (isset($pm[$typeclass[$v]['classid']])) {
  4403. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4404. $tz = explode('|', $typeclass[$v]['zh']);
  4405. $pm[$typeclass[$v]['classid']] = $tz[0];
  4406. } else {
  4407. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4408. }
  4409. }
  4410. }
  4411. }
  4412. $zh = implode(" ", $pm);
  4413. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4414. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4415. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4416. $info_list[$key]['features'] = $zh;
  4417. }
  4418. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4419. $titlename = "<table border=1>
  4420. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4421. <tr align='center'>
  4422. <td>仓库</td>
  4423. <td>供应商</td>
  4424. <td>SKU</td>
  4425. <td>商品名称</td>
  4426. <td>商品中文</td>
  4427. <td>标签</td>
  4428. <td>" . $tl . "时间(中国时间)</td>
  4429. </tr>
  4430. </table>";
  4431. $filename = $title . ".xls";
  4432. $tail = "";
  4433. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4434. } else {
  4435. /**
  4436. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4437. $rows = array();$list = array();
  4438. foreach ($info_list as $key=>$value)
  4439. {
  4440. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4441. }
  4442. **/
  4443. $wh = array();
  4444. $w = $this->warehouse->find_all('1=1', 'id,title');
  4445. foreach ($w as $v) {
  4446. $wh[$v['id']] = $v['title'];
  4447. }
  4448. $wt = array();
  4449. $whlabel_type = $this->whlabel_type->find_all();
  4450. foreach ($whlabel_type as $v) {
  4451. $wt[$v['id']] = $v['title'];
  4452. }
  4453. $classid = $this->classid->sku();
  4454. $list = array();
  4455. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4456. foreach ($rows as $key => $value) {
  4457. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4458. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4459. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  4460. $details = array();
  4461. $cpid = array();
  4462. $cpbz = array();
  4463. $c = 0;
  4464. $g = 0;
  4465. $x = 0;
  4466. $t = 0;
  4467. $s = 0;
  4468. $q = 0;
  4469. foreach ($sd as $k => $v) {
  4470. if ($v['state'] == 0) {
  4471. $c++;
  4472. }
  4473. if ($v['state'] != 9) {
  4474. $g++;
  4475. }
  4476. if ($v['outk'] > 1) {
  4477. $x++;
  4478. }
  4479. if ($v['retreat'] > 0) {
  4480. $t++;
  4481. }
  4482. if ($v['state'] == 8) {
  4483. $s++;
  4484. }
  4485. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4486. $q++;
  4487. }
  4488. $details[$v['details']] = $v['details'];
  4489. if($v['state'] == 0){
  4490. if ($v['cpid'] != 0) {
  4491. $cpid[$v['cpid']] = $v['cpid'];
  4492. }
  4493. if ($v['cpbz'] != '') {
  4494. $cpbz[$v['cpbz']] = $v['cpbz'];
  4495. }
  4496. }
  4497. }
  4498. if (isset($wt[$value['type']])) {
  4499. $rows[$key]['type'] = $wt[$value['type']];
  4500. } else {
  4501. $rows[$key]['type'] = '未设置';
  4502. }
  4503. $rows[$key]['details'] = implode("、", $details);
  4504. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4505. $ftime = time() - 15 * 24 * 3600;
  4506. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4507. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4508. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  4509. $rows[$key]['c'] = $c;
  4510. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  4511. $rows[$key]['t'] = $t;
  4512. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  4513. $rows[$key]['z'] = $z;
  4514. // $jm = $classid;
  4515. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4516. $features = explode('-', trim($features, '-'));
  4517. // $pm = $classid;
  4518. // foreach ($features as $k => $v) {
  4519. // if ($v != 0) {
  4520. // if (!isset($typeclass[$v])) {
  4521. // continue;
  4522. // }
  4523. // if (isset($pm[$typeclass[$v]['classid']])) {
  4524. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4525. // $tz = explode('|', $typeclass[$v]['zh']);
  4526. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4527. // } else {
  4528. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4529. // }
  4530. // if (isset($jm[$typeclass[$v]['classid']])) {
  4531. // if ($typeclass[$v]['jm']) {
  4532. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4533. // }
  4534. // }
  4535. // }
  4536. // }
  4537. // }
  4538. // $zh = implode(" ", $pm);
  4539. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4540. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4541. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4542. // $rows[$key]['features'] = $zh;
  4543. // $jm = array_filter($jm); //去除空值
  4544. // $jm = implode("-", $jm);
  4545. // $rows[$key]['jm'] = $jm;
  4546. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4547. }
  4548. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4549. // echo "<pre>";
  4550. // print_r($tmp_list);
  4551. // die;
  4552. $final_list =[];
  4553. foreach($tmp_list as $k=>$v){
  4554. $final_list[] = [
  4555. "warehouse"=>$v['warehouse'],
  4556. "purchase"=>$v['purchase'],
  4557. "details"=>trim($v['details'],'、'),
  4558. "cpid"=>$v['cpid'],
  4559. "sku"=>$v['sku'],
  4560. "title"=>$v['title'],
  4561. "features"=>$v['pm'],
  4562. "cpbz"=>$v['cpbz'],
  4563. "sm"=>$v['sm'],
  4564. "type"=>$v['type'],
  4565. "g"=>$v["g"],
  4566. "c"=>$v["c"],
  4567. "x"=>$v["x"],
  4568. "t"=>$v["t"],
  4569. "z"=>$v["z"],
  4570. "jm"=>$v["jm"],
  4571. "weight"=>$v["weight"],
  4572. "asd"=>$v["asd"],
  4573. ];
  4574. }
  4575. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4576. $titlename = "<table border=1>
  4577. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4578. <tr align='center'>
  4579. <td>仓库</td>
  4580. <td>供应商</td>
  4581. <td>位置</td>
  4582. <td>库存编码</td>
  4583. <td>SKU</td>
  4584. <td>商品名称</td>
  4585. <td>商品中文</td>
  4586. <td>产品备注</td>
  4587. <td>说明</td>
  4588. <td>类型</td>
  4589. <td>入库总量</td>
  4590. <td>库存数量</td>
  4591. <td>销售数量</td>
  4592. <td>退货数量</td>
  4593. <td>占单数量</td>
  4594. <td>料号</td>
  4595. <td>重量</td>
  4596. <td>类目</td>
  4597. </tr>
  4598. </table>";
  4599. $filename = $title . ".xls";
  4600. $tail = "";
  4601. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4602. }
  4603. }
  4604. }
  4605. //出库+入库数据整合
  4606. public function _excelcr()
  4607. {
  4608. if (isset($_GET['excel'])) {
  4609. $type = $this->input->get('excel', true);
  4610. $category = $this->input->get('category', true);
  4611. $size = $this->input->get('size', true);
  4612. $grade = $this->input->get('grade', true);
  4613. $color = $this->input->get('color', true);
  4614. $lowe = $this->input->get('lowe', true);
  4615. $sku = $this->input->get('sku', true);
  4616. $warehouse = $this->input->get('warehouse', true);
  4617. $purchase = $this->input->get('purchase', true);
  4618. $state = $this->input->get('state', true);
  4619. $sid = $this->input->get('sid', true);
  4620. $ktime = $this->input->get('ktime', true);
  4621. $jtime = $this->input->get('jtime', true);
  4622. $ktime = strtotime($ktime);
  4623. $jtime = strtotime($jtime);
  4624. $where = "1=1";
  4625. $gj = "";
  4626. $ck = "";
  4627. if ($category) {
  4628. $where .= " and features like '%-$category-%'";
  4629. }
  4630. if ($size) {
  4631. $where .= " and features like '%-$size-%'";
  4632. }
  4633. if ($grade) {
  4634. $where .= " and features like '%-$grade-%'";
  4635. }
  4636. if ($color) {
  4637. $where .= " and features like '%-$color-%'";
  4638. }
  4639. if ($lowe) {
  4640. $where .= " and features like '%-$lowe-%'";
  4641. }
  4642. if ($warehouse) {
  4643. $where .= " and warehouse = '$warehouse'";
  4644. }
  4645. if ($purchase) {
  4646. $where .= " and purchase = '$purchase'";
  4647. }
  4648. if ($state) {
  4649. $where .= " and state = '$state'";
  4650. }
  4651. if ($sku) {
  4652. $where .= " and sku like '%$sku%'";
  4653. }
  4654. if ($ktime && $jtime) {
  4655. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4656. }
  4657. $sidwhere = '';
  4658. if ($sid) {
  4659. $sd = "";
  4660. $s = explode(',', trim($sid, ','));
  4661. foreach ($s as $value) {
  4662. $sd .= " id = " . $value . " or";
  4663. }
  4664. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4665. }
  4666. //取得信息列表
  4667. $timeread = $ktime;
  4668. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4669. $timelist = array();
  4670. for ($i = 0; $i < $timenum; $i++) {
  4671. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4672. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4673. }
  4674. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4675. //echo "<pre>";
  4676. //print_r($info_list);
  4677. //exit();
  4678. $rows = array();
  4679. $list = array();
  4680. foreach ($info_list as $key => $value) {
  4681. $thistime = $timelist;
  4682. if (isset($rows[strtolower($value['sku'])])) {
  4683. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4684. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4685. }
  4686. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4687. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4688. }
  4689. } else {
  4690. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4691. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4692. }
  4693. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4694. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4695. }
  4696. $rows[strtolower($value['sku'])] = $thistime;
  4697. }
  4698. }
  4699. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4700. <head>
  4701. <!--[if gte mso 9]><xml>
  4702. <x:ExcelWorkbook>
  4703. <x:ExcelWorksheets>
  4704. <x:ExcelWorksheet>
  4705. <x:Name>EXCEL</x:Name>
  4706. <x:WorksheetOptions>
  4707. <x:Print>
  4708. <x:ValidPrinterInfo />
  4709. </x:Print>
  4710. </x:WorksheetOptions>
  4711. </x:ExcelWorksheet>
  4712. </x:ExcelWorksheets>
  4713. </x:ExcelWorkbook>
  4714. </xml>
  4715. <![endif]-->
  4716. </head><body>";
  4717. $str .= "<table border=1><tr><td>SKU</td>";
  4718. foreach ($timelist as $k => $v) {
  4719. $str .= "<td>" . $k . "出库</td>";
  4720. $str .= "<td>" . $k . "入库</td>";
  4721. }
  4722. $str .= "</tr></table>";
  4723. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4724. foreach ($rows as $key => $val) {
  4725. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4726. foreach ($val as $k => $v) {
  4727. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4728. if ($val[$k]['r'] > 0) {
  4729. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4730. } else {
  4731. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4732. }
  4733. }
  4734. $str .= "</tr>";
  4735. }
  4736. $str .= "</table>";
  4737. $str .= "</body></html>";
  4738. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4739. header("Content-type: application/octet-stream");
  4740. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4741. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4742. header("Pragma: no-cache");
  4743. header("Expires: 0");
  4744. exit($str);
  4745. }
  4746. }
  4747. //数量调整模板导出
  4748. public function _presetout()
  4749. {
  4750. if (isset($_GET['excel'])) {
  4751. $where = "sku != 'Preset' and purchase != 0";
  4752. //数据排序
  4753. $order_str = "id desc";
  4754. if (empty($page)) {
  4755. $start = 0;
  4756. $perpage = 1;
  4757. } else {
  4758. $start = ($page - 1) * $perpage;
  4759. }
  4760. //取得信息列表
  4761. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4762. $rows = array();
  4763. $list = array();
  4764. foreach ($info_list as $value) {
  4765. $warehouse = $this->warehouse->read($value['warehouse']);
  4766. $number = $value['number'];
  4767. $ftime = time() - 15 * 24 * 3600;
  4768. $purchase = $this->purchase->read($value['purchase']);
  4769. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4770. }
  4771. $title = "库存模板";
  4772. $titlename = "<table border=1>
  4773. <tr align='center'>
  4774. <td>仓库</td>
  4775. <td>供应商编码</td>
  4776. <td>SKU</td>
  4777. <td>增减数量(正数或负数)</td>
  4778. <td>增减备注</td>
  4779. <td>库位</td>
  4780. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4781. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4782. </tr>
  4783. </table>";
  4784. $filename = $title . ".xls";
  4785. $tail = "";
  4786. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4787. }
  4788. }
  4789. //数量调整模板导入
  4790. public function _presetedit()
  4791. {
  4792. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4793. $config['upload_path'] = '.' . $dir;
  4794. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4795. $config['allowed_types'] = 'xls|xlsx|csv';
  4796. $config['max_size'] = 10240;
  4797. $this->load->library('upload', $config);
  4798. $this->upload->initialize($config);
  4799. if ($this->upload->do_upload('userfile')) {
  4800. $full_path = $dir . $this->upload->data('file_name');
  4801. $fileName = '.' . $full_path;
  4802. if (!file_exists($fileName)) {
  4803. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4804. exit;
  4805. } else {
  4806. require_once "./data/excel/PHPExcel/IOFactory.php";
  4807. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4808. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4809. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4810. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4811. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4812. ++$column; //如果列数大于26行
  4813. $list = array();
  4814. for ($i = 2; $i <= $row; $i++) // 行数循环
  4815. {
  4816. $data = array();
  4817. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4818. {
  4819. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4820. }
  4821. $list[] = $data;
  4822. }
  4823. }
  4824. $i = 0;
  4825. $j = 0;
  4826. $ed = array();
  4827. foreach ($list as $key => $value) {
  4828. $time = time();
  4829. if ($value['0'] == "") {
  4830. continue;
  4831. }
  4832. $warehouse = $this->warehouse->get_title($value['0']);
  4833. $purchase = $this->purchase->get_bm($value['1']);
  4834. $sku = $value['2'];
  4835. $num = $value['3']; //调整数量
  4836. $text = $value['4']; //扣减说明
  4837. $type = $value['5']; //调整方式0扣减1删除
  4838. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4839. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4840. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4841. if (!$purchase) //如果没有这个SKU
  4842. {
  4843. $ed[] = array($purchase . '-不存在此供应商编码');
  4844. $j++;
  4845. continue;
  4846. }
  4847. if (!$d) //如果没有这个SKU
  4848. {
  4849. $ed[] = array($sku . '-库存中不存在此SKU');
  4850. $j++;
  4851. continue;
  4852. }
  4853. if (!isset($warehouse['id'])) {
  4854. $ed[] = array($sku . '-仓库名错误!');
  4855. $j++;
  4856. continue;
  4857. }
  4858. if ($type != '0' && $type != '1') {
  4859. $ed[] = array($sku . '-扣减方式填写错误!');
  4860. $j++;
  4861. continue;
  4862. }
  4863. if ($num < 0) //扣减库存
  4864. {
  4865. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4866. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4867. $j++;
  4868. continue;
  4869. }
  4870. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4871. if (count($data) < abs($num)) {
  4872. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4873. $j++;
  4874. continue;
  4875. }
  4876. if ($type == 0) //如果扣减方式为 扣减库存
  4877. {
  4878. for ($i = 0; $i < abs($num); $i++) {
  4879. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4880. }
  4881. } else if ($type == 1) {
  4882. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4883. if (count($zt) > 0) {
  4884. $ed[] = array($sku . '-有在途库存无法删除!');
  4885. $j++;
  4886. continue;
  4887. }
  4888. for ($i = 0; $i < abs($num); $i++) {
  4889. $this->whlabel->remove($data[$i]['id']);
  4890. }
  4891. }
  4892. } else if ($num > 0) //增加库存
  4893. {
  4894. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4895. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4896. $j++;
  4897. continue;
  4898. }
  4899. $post['sku'] = $d['sku'];
  4900. $post['shop'] = $d['shop'];
  4901. $post['warehouse'] = $warehouse['id'];
  4902. $post['purchase'] = $purchase['id'];
  4903. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4904. $post['state'] = 0;
  4905. $post['title'] = $d['title'];
  4906. $post['number'] = $d['number'];
  4907. $post['features'] = $d['features'];
  4908. $post['enter'] = $time;
  4909. $post['time'] = $time; //操作时间
  4910. $post['rktype'] = $rktype;
  4911. for ($i = 0; $i < $num; $i++) {
  4912. $post['label'] = time() . rand(100, 999) . $i;
  4913. $this->whlabel->insert($post);
  4914. }
  4915. }
  4916. sleep(1); //防止入库时间一样,需要延迟1秒
  4917. }
  4918. if ($j > 0) {
  4919. $tt = date('Ymd', time());
  4920. $title = '库存导入错误信息-' . $tt;
  4921. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4922. $tail = "\n";
  4923. $filename = $title . ".xls";
  4924. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4925. $dir = '/data/excel/' . $time . '/';
  4926. $file_name = 'error_' . $time . rand(1000, 9999);
  4927. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4928. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4929. fwrite($myfile, $ecl);
  4930. fclose($myfile);
  4931. $error = $dir . $file_name . '.xls';
  4932. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4933. exit;
  4934. } else {
  4935. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4936. exit;
  4937. }
  4938. }
  4939. }
  4940. public function _presetedittwo(){
  4941. $data = $this->input->post(NULL, TRUE);
  4942. if(empty($list)){
  4943. $raw_data = $this->input->raw_input_stream;
  4944. // 解码 JSON
  4945. $data = json_decode($raw_data, true);
  4946. }
  4947. if(empty($data)){
  4948. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4949. exit;
  4950. }
  4951. $list = [];
  4952. if(isset($data['list'])){
  4953. $list = $data['list'];
  4954. }
  4955. $i = 0;
  4956. $j = 0;
  4957. $ed = array();
  4958. foreach ($list as $key => $value) {
  4959. $time = time();
  4960. if ($value['0'] == "") {
  4961. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4962. $j++;
  4963. continue;
  4964. }
  4965. $warehouse = $this->warehouse->get_title($value['0']);
  4966. if(empty($warehouse)){
  4967. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4968. $j++;
  4969. continue;
  4970. }
  4971. $purchase = $this->purchase->get_bm($value['1']);
  4972. $sku = $value['2'];
  4973. $num = $value['3']; //调整数量
  4974. $text = $value['4']; //扣减说明
  4975. $type = 0; //调整方式0扣减1删除
  4976. $details = empty($value['5'])?'':$value['5']; //库位
  4977. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4978. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4979. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4980. if (!$purchase) //如果没有这个SKU
  4981. {
  4982. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4983. $j++;
  4984. continue;
  4985. }
  4986. if (!$d) //如果没有这个SKU
  4987. {
  4988. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4989. $j++;
  4990. continue;
  4991. }
  4992. if (!isset($warehouse['id'])) {
  4993. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4994. $j++;
  4995. continue;
  4996. }
  4997. if ($type != '0' && $type != '1') {
  4998. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4999. $j++;
  5000. continue;
  5001. }
  5002. if ($num < 0) //扣减库存
  5003. {
  5004. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  5005. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  5006. $j++;
  5007. continue;
  5008. }
  5009. if(!empty($details)){
  5010. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  5011. }else{
  5012. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  5013. }
  5014. if (count($data) < abs($num)) {
  5015. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  5016. $j++;
  5017. continue;
  5018. }
  5019. if ($type == 0) //如果扣减方式为 扣减库存
  5020. {
  5021. for ($i = 0; $i < abs($num); $i++) {
  5022. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  5023. }
  5024. } else if ($type == 1) {
  5025. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  5026. if (count($zt) > 0) {
  5027. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  5028. $j++;
  5029. continue;
  5030. }
  5031. for ($i = 0; $i < abs($num); $i++) {
  5032. $this->whlabel->remove($data[$i]['id']);
  5033. }
  5034. }
  5035. } else if ($num > 0) //增加库存
  5036. {
  5037. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5038. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5039. $j++;
  5040. continue;
  5041. }
  5042. if(empty($details)){
  5043. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5044. if(empty($tmp_info)){
  5045. $details = '';
  5046. }else{
  5047. $details = $tmp_info['details'];
  5048. }
  5049. }else{
  5050. if($details == 'DZ001'){
  5051. }else{
  5052. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5053. if(empty($tmp_info)){
  5054. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5055. $j++;
  5056. continue;
  5057. }
  5058. }
  5059. }
  5060. $post['sku'] = $d['sku'];
  5061. $post['shop'] = $d['shop'];
  5062. $post['warehouse'] = $warehouse['id'];
  5063. $post['purchase'] = $purchase['id'];
  5064. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5065. $post['state'] = 0;
  5066. $post['title'] = $d['title'];
  5067. $post['number'] = $d['number'];
  5068. $post['features'] = $d['features'];
  5069. $post['details'] = $details;
  5070. $post['enter'] = $time;
  5071. $post['time'] = $time; //操作时间
  5072. $post['rktype'] = $rktype;
  5073. $post['sku_master_id'] = $d['sku_master_id'];
  5074. $post['sku_shop_id'] = $d['sku_shop_id'];
  5075. for ($i = 0; $i < $num; $i++) {
  5076. $post['label'] = time() . rand(100, 999) . $i;
  5077. $this->whlabel->insert($post);
  5078. }
  5079. }
  5080. sleep(1); //防止入库时间一样,需要延迟1秒
  5081. }
  5082. if ($j > 0) {
  5083. $tt = date('Ymd', time());
  5084. $title = '库存导入错误信息-' . $tt;
  5085. $error = $title . '.xls';
  5086. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5087. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5088. exit;
  5089. } else {
  5090. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5091. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5092. exit;
  5093. }
  5094. }
  5095. //笛卡儿积
  5096. function cp($ps, $sets, $list)
  5097. {
  5098. $result = array();
  5099. $j = 0;
  5100. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5101. if ($i == 0) {
  5102. $result = $sets[$i];
  5103. }
  5104. $tmp = array();
  5105. foreach ($result as $res) {
  5106. foreach ($sets[$i + 1] as $set) {
  5107. $tmp[] = $res . ',' . $set;
  5108. }
  5109. }
  5110. $result = $tmp;
  5111. }
  5112. $this->db->trans_begin();
  5113. foreach ($result as $v) {
  5114. $post = array();
  5115. $title = "";
  5116. $num = "";
  5117. $data = explode(',', $v);
  5118. for ($i = 0; $i < count($list); $i++) {
  5119. $post[$list[$i]] = $data[$i];
  5120. $typeclass = $this->typeclass->read($data[$i]);
  5121. $title = $title . $typeclass['title'] . " ";
  5122. if ($data[$i] != 0) {
  5123. $num .= $data[$i]; //所有数据ID拼接
  5124. }
  5125. }
  5126. foreach ($ps as $kp => $vp) {
  5127. $post[$kp] = $vp;
  5128. }
  5129. $post['number'] = $num;
  5130. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5131. if ($info_list) {
  5132. $j++;
  5133. } else {
  5134. $skunum = $this->whlabel->find_count();
  5135. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5136. $post['title'] = rtrim($title, ' ');
  5137. $this->whlabel->insert($post);
  5138. }
  5139. }
  5140. if ($this->db->trans_status() === FALSE) {
  5141. $this->db->trans_commit();
  5142. return NULL;
  5143. } else {
  5144. $this->db->trans_commit();
  5145. return $j;
  5146. }
  5147. }
  5148. public function _kj($arg_array)
  5149. {
  5150. if (isset($_POST['sku'])) {
  5151. $time = time();
  5152. $sku = $this->input->post('sku', true);
  5153. $warehouse = $this->input->post('warehouse', true);
  5154. $num = $this->input->post('num', true);
  5155. $text = $this->input->post('text', true);
  5156. $purchase = $this->input->post('purchase', true);
  5157. $cktype = $this->input->post('cktype', true);
  5158. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5159. if ($cktype != 1 && $text == '') {
  5160. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5161. exit;
  5162. }
  5163. if ($num > count($order)) {
  5164. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5165. exit;
  5166. } else {
  5167. for ($i = 0; $i < $num; $i++) {
  5168. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5169. }
  5170. }
  5171. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5172. exit;
  5173. }
  5174. $uid = $this->whlabel->read($arg_array[0]);
  5175. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5176. $this->data['data'] = $uid;
  5177. $this->_Template('whlabel_kj', $this->data);
  5178. }
  5179. public function _summary($arg_array)
  5180. {
  5181. $prc = array();
  5182. $purchase = $this->purchase->find_all();
  5183. foreach ($purchase as $k => $v) {
  5184. $prc[$v['id']] = $v['title'];
  5185. }
  5186. if (isset($_GET['excel'])) {
  5187. $ktime = $this->input->get('ktime', true);
  5188. $jtime = $this->input->get('jtime', true);
  5189. $ktime = strtotime($ktime);
  5190. $jtime = strtotime($jtime);
  5191. $where = "1=1";
  5192. if ($ktime && $jtime) {
  5193. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5194. }
  5195. //数据排序
  5196. $order_str = "time desc";
  5197. if (empty($page)) {
  5198. $start = 0;
  5199. $perpage = 1;
  5200. } else {
  5201. $start = ($page - 1) * $perpage;
  5202. }
  5203. //取得信息列表
  5204. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5205. foreach ($info_list as $key => $value) {
  5206. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5207. $warehouse = $this->warehouse->read($value['warehouse']);
  5208. $info_list[$key]['warehouse'] = $warehouse['title'];
  5209. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5210. $details = array();
  5211. $cpid = array();
  5212. foreach ($x as $k => $v) {
  5213. if($v['status'] == 0){
  5214. if ($v['details'] != '') {
  5215. $details[$v['details']] = $v['details'];
  5216. }
  5217. if ($v['cpid'] != 0) {
  5218. $cpid[$v['cpid']] = $v['cpid'];
  5219. }
  5220. }
  5221. }
  5222. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5223. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5224. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5225. $info_list[$key]['s'] = $s;
  5226. $info_list[$key]['x'] = count($x);
  5227. }
  5228. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5229. $titlename = "<table border=1>
  5230. <tr align='center'>
  5231. <td>仓库</td>
  5232. <td>供应商</td>
  5233. <td>出库位置</td>
  5234. <td>出库编码</td>
  5235. <td>SKU</td>
  5236. <td>产品名</td>
  5237. <td>总剩余库存</td>
  5238. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5239. </tr>
  5240. </table>";
  5241. $filename = $title . ".xls";
  5242. $tail = "";
  5243. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5244. }
  5245. }
  5246. //usps发货清单
  5247. public function _manifest()
  5248. {
  5249. if (isset($_POST['manifest'])) {
  5250. $wltext = $this->input->post('wltext', true);
  5251. $time = time() - 16 * 3600;
  5252. $ptime = strtotime(date('Y-m-d', $time));
  5253. $waybill = array();
  5254. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5255. foreach ($fullorder as $v) {
  5256. $waybill[$v['waybill']] = $v['waybill'];
  5257. }
  5258. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5259. foreach ($fullordersmt as $v) {
  5260. $waybill[$v['waybill']] = $v['waybill'];
  5261. }
  5262. $wltext = explode(';', $wltext);
  5263. foreach ($wltext as $v) {
  5264. if (isset($waybill[$v])) {
  5265. unset($waybill[$v]);
  5266. }
  5267. }
  5268. $data = $this->usps->get_manifest($waybill);
  5269. if (isset($data['Description'])) {
  5270. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5271. exit;
  5272. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5273. $bctime = date('Ymd', time());
  5274. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5275. echo json_encode(array('msg' => $pdf, 'success' => true));
  5276. exit;
  5277. } else {
  5278. echo json_encode(array('msg' => $data, 'success' => false));
  5279. exit;
  5280. }
  5281. }
  5282. }
  5283. public function _pdf($pdf, $title, $bctime)
  5284. {
  5285. $pdf_path = './data/pdf/' . $bctime . '/';
  5286. $file_base64 = $pdf;
  5287. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5288. $file_base64 = base64_decode($file_base64);
  5289. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5290. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5291. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5292. }
  5293. /**
  5294. *
  5295. *
  5296. *
  5297. 进销存占单异常索引
  5298. *
  5299. *
  5300. *
  5301. **/
  5302. public function _abnormal()
  5303. {
  5304. $post = $this->input->post(NULL, TRUE);
  5305. if (isset($post['page'])) {
  5306. $page = $this->input->post('page', true);
  5307. $perpage = $this->input->post('perpage', true);
  5308. $sku = $this->input->post('sku', true);
  5309. $where = "1=1";
  5310. //数据排序
  5311. $order_str = "id desc";
  5312. if (empty($page)) {
  5313. $start = 0;
  5314. $perpage = 1;
  5315. } else {
  5316. $start = ($page - 1) * $perpage;
  5317. }
  5318. //取得信息列表
  5319. $info_list = $this->whlabel->find_all($where, '*');
  5320. $rows = array();
  5321. $list = array();
  5322. foreach ($info_list as $key => $value) {
  5323. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5324. }
  5325. foreach ($rows as $value) {
  5326. $warehouse = $this->warehouse->read($value['warehouse']);
  5327. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5328. $number = $value['number'];
  5329. $ftime = time() - 15 * 24 * 3600;
  5330. if ($value['shop'] != '') {
  5331. $shop = $value['shop'];
  5332. $orderdlz = $this->fullorder->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5333. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and shop = '$shop' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5334. $order = array_merge($orderdlz, $ordersmt);
  5335. $od = 0;
  5336. $a = '';
  5337. $orid = '';
  5338. foreach ($order as $v) {
  5339. $or = explode('|', ltrim($v['whlabel'], '|'));
  5340. for ($i = 0; $i < count($or); $i++) {
  5341. $orod = explode('-', $or[$i]);
  5342. if ($orod[0] == $number) {
  5343. $od += $orod[1];
  5344. }
  5345. }
  5346. $orid .= $v['number'] . '-';
  5347. }
  5348. } else {
  5349. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5350. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5351. $order = array_merge($orderdlz, $ordersmt);
  5352. $od = 0;
  5353. $a = '';
  5354. $orid = '';
  5355. $qt = array();
  5356. foreach ($order as $v) {
  5357. $or = explode('|', ltrim($v['whlabel'], '|'));
  5358. for ($i = 0; $i < count($or); $i++) {
  5359. $orod = explode('-', $or[$i]);
  5360. if ($orod[0] == $number) {
  5361. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5362. if ($czzs > 0) {
  5363. if (isset($qt[$v['shop']])) {
  5364. if ($qt[$v['shop']] < $orod[1]) {
  5365. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5366. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5367. } else {
  5368. $qt[$v['shop']] -= $orod[1];
  5369. }
  5370. } else {
  5371. $qt[$v['shop']] = $czzs;
  5372. }
  5373. } else {
  5374. $od += $orod[1];
  5375. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5376. }
  5377. }
  5378. }
  5379. }
  5380. }
  5381. $z = $od . '(' . $orid . ')'; //查看订单号
  5382. //$z = $od;
  5383. if ($od > $c) {
  5384. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5385. }
  5386. }
  5387. $listdata = array_slice($list, $start, $perpage);
  5388. $total = count($list);
  5389. $pagenum = ceil($total / $perpage);
  5390. $over = $total - ($start + $perpage);
  5391. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5392. echo json_encode($rows);
  5393. exit;
  5394. }
  5395. $this->_Template('whlabel_abnormal', $this->data);
  5396. }
  5397. /**
  5398. *
  5399. *
  5400. *
  5401. 进销存占单异常索引
  5402. *
  5403. *
  5404. *
  5405. **/
  5406. public function _error()
  5407. {
  5408. $post = $this->input->post(NULL, TRUE);
  5409. if (isset($post['page'])) {
  5410. $page = $this->input->post('page', true);
  5411. $perpage = $this->input->post('perpage', true);
  5412. $sku = $this->input->post('sku', true);
  5413. $warehouse = $this->input->post('warehouse', true);
  5414. $ktime = $this->input->post('ktime', true);
  5415. $jtime = $this->input->post('jtime', true);
  5416. $ktime = strtotime($ktime);
  5417. $jtime = strtotime($jtime);
  5418. $where = "sku != 'Preset'";
  5419. $gj = '';
  5420. if ($sku) {
  5421. $where .= " and sku like '%$sku%'";
  5422. } else {
  5423. if ($ktime && $jtime) {
  5424. $gj = " and time > '$ktime' and time < '$jtime'";
  5425. }
  5426. }
  5427. if ($warehouse) {
  5428. $where .= " and warehouse = '$warehouse'";
  5429. }
  5430. //数据排序
  5431. $order_str = "id desc";
  5432. if (empty($page)) {
  5433. $start = 0;
  5434. $perpage = 1;
  5435. } else {
  5436. $start = ($page - 1) * $perpage;
  5437. }
  5438. //取得信息列表
  5439. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5440. $rows = array();
  5441. $list = array();
  5442. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5443. // foreach ($info_list as $value)
  5444. // {
  5445. // $warehouse = $this->warehouse->read($value['warehouse']);
  5446. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5447. // $number = $value['number'];$ftime = time()-15*24*3600;
  5448. // if($c < 1)
  5449. // {
  5450. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5451. // }
  5452. // }
  5453. $warehouse_list = $this->warehouse->find_all();
  5454. $warehouse_list = array_column($warehouse_list, null, 'id');
  5455. foreach ($info_list as $value) {
  5456. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5457. 'title' => "",
  5458. ];
  5459. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5460. $number = $value['number'];
  5461. $ftime = time() - 15 * 24 * 3600;
  5462. if ($c < 1) {
  5463. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5464. }
  5465. }
  5466. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5467. // $query = $this->db->query($sql);
  5468. // $info_list = $query->result_array();
  5469. // $sql_two = "select title,id from crowd_warehouse";
  5470. // $query_two = $this->db->query($sql_two);
  5471. // $warehouse_list = $query_two->result_array();
  5472. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5473. // foreach ($info_list as $value)
  5474. // {
  5475. // if(isset($warehouse_arr[$value['warehouse']])){
  5476. // $warehouse = $warehouse_arr[$value['warehouse']];
  5477. // }else{
  5478. // $warehouse = [
  5479. // 'id'=>0,
  5480. // 'title'=>"异常",
  5481. // ];
  5482. // }
  5483. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5484. // $number = $value['number'];$ftime = time()-15*24*3600;
  5485. // if($c < 1)
  5486. // {
  5487. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5488. // }
  5489. // }
  5490. $listdata = array_slice($list, $start, $perpage);
  5491. $total = count($list);
  5492. $pagenum = ceil($total / $perpage);
  5493. $over = $total - ($start + $perpage);
  5494. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5495. echo json_encode($rows);
  5496. exit;
  5497. }
  5498. if (isset($post['s'])) {
  5499. $id_arr = $this->input->post('s');
  5500. $id_arr = explode(',', trim($id_arr, ','));
  5501. if (!$id_arr) {
  5502. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5503. exit;
  5504. }
  5505. //循环删除记录
  5506. foreach ($id_arr as $v) {
  5507. $dd = $this->whlabel->read($v);
  5508. if (!isset($dd['id'])) {
  5509. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5510. exit;
  5511. }
  5512. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5513. if (isset($zt[0])) {
  5514. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5515. exit;
  5516. }
  5517. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5518. foreach ($deldd as $vv) {
  5519. $tmp_info = $vv;
  5520. $tmp_info['del_time'] = time();
  5521. $this->db->insert('whlabelscbf',$tmp_info);
  5522. $this->whlabel->remove($vv['id']);
  5523. }
  5524. }
  5525. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5526. exit;
  5527. }
  5528. $this->_Template('whlabel_error', $this->data);
  5529. }
  5530. public function _errorexcel()
  5531. {
  5532. $post = $this->input->post(NULL, TRUE);
  5533. if (isset($_GET['page'])) {
  5534. $page = $this->input->get('page', true);
  5535. $perpage = $this->input->get('perpage', true);
  5536. $sku = $this->input->get('sku', true);
  5537. $warehouse = $this->input->get('warehouse', true);
  5538. $ktime = $this->input->get('ktime', true);
  5539. $jtime = $this->input->get('jtime', true);
  5540. $ktime = strtotime($ktime);
  5541. $jtime = strtotime($jtime);
  5542. $where = "sku != 'Preset'";
  5543. $gj = '';
  5544. if ($sku) {
  5545. $where .= " and sku like '%$sku%'";
  5546. } else {
  5547. if ($ktime && $jtime) {
  5548. $gj = " and time > '$ktime' and time < '$jtime'";
  5549. }
  5550. }
  5551. if ($warehouse) {
  5552. $where .= " and warehouse = '$warehouse'";
  5553. }
  5554. //数据排序
  5555. $order_str = "id desc";
  5556. if (empty($page)) {
  5557. $start = 0;
  5558. $perpage = 1;
  5559. } else {
  5560. $start = ($page - 1) * $perpage;
  5561. }
  5562. //取得信息列表
  5563. $rows = array();
  5564. $list = array();
  5565. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5566. foreach ($info_list as $value) {
  5567. $warehouse = $this->warehouse->read($value['warehouse']);
  5568. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5569. $number = $value['number'];
  5570. $ftime = time() - 15 * 24 * 3600;
  5571. if ($c < 1) {
  5572. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5573. }
  5574. }
  5575. $title = "0库存汇总";
  5576. $titlename = "<table border=1>
  5577. <tr align='center'>
  5578. <td>仓库</td>
  5579. <td>SKU</td>
  5580. <td>产品</td>
  5581. <td>当前库存</td>
  5582. </tr>
  5583. </table>";
  5584. $filename = $title . ".xls";
  5585. $tail = "";
  5586. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5587. }
  5588. }
  5589. /**
  5590. *
  5591. *
  5592. * 占单
  5593. *
  5594. *
  5595. **/
  5596. public function _kcyz()
  5597. {
  5598. $post = $this->input->post(NULL, TRUE);
  5599. if (isset($post['warehouse'])) {
  5600. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5601. exit; //不再使用
  5602. $warehouse = $this->input->post('warehouse', true);
  5603. $whlabel = $this->input->post('whlabel', true);
  5604. $id = $this->input->post('id', true);
  5605. $shop = $this->input->post('shop', true);
  5606. $number = $this->input->post('number', true);
  5607. if (!$whlabel || $whlabel == '|') {
  5608. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5609. exit;
  5610. }
  5611. $pp = explode('|', trim($whlabel, '|'));
  5612. $x = 0;
  5613. $save = array();
  5614. foreach ($pp as $va) {
  5615. $num = explode('-', $va);
  5616. if ($number) {
  5617. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')"); //通用
  5618. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5619. } else {
  5620. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5621. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5622. }
  5623. $x++;
  5624. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5625. $save[] = $x - 1;
  5626. continue; //提前先加X不然出错,所以要减1
  5627. }
  5628. }
  5629. if (isset($save[0])) {
  5630. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5631. exit;
  5632. } else {
  5633. echo json_encode(array('success' => true));
  5634. exit;
  5635. }
  5636. }
  5637. }
  5638. public function _db()
  5639. {
  5640. $post = $this->input->post(NULL, TRUE);
  5641. if (isset($post['page'])) {
  5642. $page = $this->input->post('page', true);
  5643. $perpage = $this->input->post('perpage', true);
  5644. $sku = $this->input->post('sku', true);
  5645. $number = $this->input->post('number', true);
  5646. $warehouse = $this->input->post('warehouse', true);
  5647. $purchase = $this->input->post('purchase', true);
  5648. $orderinfo = $this->input->post('orderinfo', true);
  5649. $waybill = $this->input->post('waybill', true);
  5650. $category = $this->input->post('category', true);
  5651. $size = $this->input->post('size', true);
  5652. $grade = $this->input->post('grade', true);
  5653. $color = $this->input->post('color', true);
  5654. $lowe = $this->input->post('lowe', true);
  5655. $state = $this->input->post('state', true);
  5656. $label = $this->input->post('label', true);
  5657. $timetk = $this->input->post('timetkk', true);
  5658. $timetj = $this->input->post('timetjj', true);
  5659. $timetk = strtotime($timetk);
  5660. $timetj = strtotime($timetj);
  5661. $where = "dbtime > 0";
  5662. if ($timetk && $timetj) {
  5663. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5664. }
  5665. if ($sku) {
  5666. $where .= " and sku = '$sku'";
  5667. }
  5668. if ($warehouse) {
  5669. $where .= " and warehouse = '$warehouse'";
  5670. if ($warehouse == 12) {
  5671. $w = 'specialstock';
  5672. } else {
  5673. $w = 'whlabel';
  5674. }
  5675. }
  5676. if ($purchase) {
  5677. $where .= " and purchase = '$purchase'";
  5678. }
  5679. if ($category) {
  5680. $where .= " and features like '%-$category-%'";
  5681. }
  5682. if ($size) {
  5683. $where .= " and features like '%-$size-%'";
  5684. }
  5685. if ($grade) {
  5686. $where .= " and features like '%-$grade-%'";
  5687. }
  5688. if ($color) {
  5689. $where .= " and features like '%-$color-%'";
  5690. }
  5691. if ($lowe) {
  5692. $where .= " and features like '%-$lowe-%'";
  5693. }
  5694. if ($state != '') {
  5695. $where .= " and state = '$state'";
  5696. }
  5697. //数据排序
  5698. $order_str = "dbtime desc";
  5699. if (empty($page)) {
  5700. $start = 0;
  5701. $perpage = 1;
  5702. } else {
  5703. $start = ($page - 1) * $perpage;
  5704. }
  5705. //取得信息列表
  5706. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5707. foreach ($info_list as $key => $value) {
  5708. $warehouse = $this->$w->read($value['warehouse']);
  5709. $info_list[$key]['warehouse'] = $warehouse['title'];
  5710. $purchase = $this->purchase->read($value['purchase']);
  5711. $info_list[$key]['purchase'] = $purchase['title'];
  5712. if ($value['enter'] != 0) {
  5713. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5714. } else {
  5715. $info_list[$key]['enter'] = "";
  5716. }
  5717. if ($value['dbtime'] != 0) {
  5718. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5719. } else {
  5720. $info_list[$key]['dbtime'] = "";
  5721. }
  5722. if ($value['state'] == 0) {
  5723. $info_list[$key]['state'] = "在库";
  5724. } else if ($value['state'] == 1) {
  5725. $info_list[$key]['state'] = "出库";
  5726. } else if ($value['state'] == 2) {
  5727. $info_list[$key]['state'] = "退库";
  5728. } else if ($value['state'] == 3) {
  5729. $info_list[$key]['state'] = "调拨中";
  5730. } else if ($value['state'] == 4) {
  5731. $info_list[$key]['state'] = "再加工";
  5732. } else if ($value['state'] == 5) {
  5733. $info_list[$key]['state'] = "维修中";
  5734. } else if ($value['state'] == 6) {
  5735. $info_list[$key]['state'] = "盘亏";
  5736. } else if ($value['state'] == 7) {
  5737. $info_list[$key]['state'] = "更换标签";
  5738. } else if ($value['state'] == 8) {
  5739. $info_list[$key]['state'] = "其它";
  5740. } else if ($value['state'] == 9) {
  5741. $info_list[$key]['state'] = "预设";
  5742. }
  5743. }
  5744. $total = $this->whlabel->find_count($where);
  5745. $pagenum = ceil($total / $perpage);
  5746. $over = $total - ($start + $perpage);
  5747. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5748. echo json_encode($rows);
  5749. exit;
  5750. }
  5751. if (isset($post['outsku'])) {
  5752. $time = time();
  5753. $cz = $this->input->post('cz', true);
  5754. $label = $this->input->post('outsku', true);
  5755. $sl = $this->input->post('sl', true);
  5756. $num = $this->input->post('num', true);
  5757. //$warehouse = $this->input->post('warehouse',true);
  5758. if (!$sl) {
  5759. $sl = 1;
  5760. }
  5761. if (!$warehouse) {
  5762. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5763. exit;
  5764. }
  5765. $dblabel = $this->whlabellabel->get_label($label);
  5766. if ($dblabel) {
  5767. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5768. if (count($data) < 1) {
  5769. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5770. exit;
  5771. }
  5772. if (count($data) < $num) {
  5773. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5774. exit;
  5775. }
  5776. for ($i = 0; $i < $sl; $i++) {
  5777. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5778. }
  5779. echo json_encode(array('success' => true));
  5780. exit;
  5781. } else {
  5782. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5783. exit;
  5784. }
  5785. }
  5786. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5787. $this->_Template('whlabel_db', $this->data);
  5788. }
  5789. public function _dbrk()
  5790. {
  5791. $post = $this->input->post(NULL, TRUE);
  5792. if (isset($post['page'])) {
  5793. $page = $this->input->post('page', true);
  5794. $perpage = $this->input->post('perpage', true);
  5795. $sku = $this->input->post('sku', true);
  5796. $number = $this->input->post('number', true);
  5797. $warehouse = $this->input->post('warehouse', true);
  5798. $purchase = $this->input->post('purchase', true);
  5799. $orderinfo = $this->input->post('orderinfo', true);
  5800. $waybill = $this->input->post('waybill', true);
  5801. $category = $this->input->post('category', true);
  5802. $size = $this->input->post('size', true);
  5803. $grade = $this->input->post('grade', true);
  5804. $color = $this->input->post('color', true);
  5805. $lowe = $this->input->post('lowe', true);
  5806. $state = $this->input->post('state', true);
  5807. $label = $this->input->post('label', true);
  5808. $ctime = $this->input->post('ctime', true);
  5809. $timetk = $this->input->post('timetkk', true);
  5810. $timetj = $this->input->post('timetjj', true);
  5811. $timetk = strtotime($timetk);
  5812. $timetj = strtotime($timetj);
  5813. $where = "dbtime > 0";
  5814. if ($timetk && $timetj) {
  5815. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5816. }
  5817. if ($sku) {
  5818. $where .= " and sku = '$sku'";
  5819. }
  5820. if ($warehouse) {
  5821. $where .= " and warehouse = '$warehouse'";
  5822. }
  5823. if ($purchase) {
  5824. $where .= " and purchase = '$purchase'";
  5825. }
  5826. if ($category) {
  5827. $where .= " and features like '%-$category-%'";
  5828. }
  5829. if ($size) {
  5830. $where .= " and features like '%-$size-%'";
  5831. }
  5832. if ($grade) {
  5833. $where .= " and features like '%-$grade-%'";
  5834. }
  5835. if ($color) {
  5836. $where .= " and features like '%-$color-%'";
  5837. }
  5838. if ($lowe) {
  5839. $where .= " and features like '%-$lowe-%'";
  5840. }
  5841. if ($state != '') {
  5842. $where .= " and state = '$state'";
  5843. }
  5844. //数据排序
  5845. $order_str = "dbtime desc";
  5846. if (empty($page)) {
  5847. $start = 0;
  5848. $perpage = 1;
  5849. } else {
  5850. $start = ($page - 1) * $perpage;
  5851. }
  5852. //取得信息列表
  5853. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5854. foreach ($info_list as $key => $value) {
  5855. $warehouse = $this->warehouse->read($value['warehouse']);
  5856. $info_list[$key]['warehouse'] = $warehouse['title'];
  5857. $purchase = $this->purchase->read($value['purchase']);
  5858. $info_list[$key]['purchase'] = $purchase['title'];
  5859. if ($value['enter'] != 0) {
  5860. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5861. } else {
  5862. $info_list[$key]['enter'] = "";
  5863. }
  5864. if ($value['dbtime'] != 0) {
  5865. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5866. } else {
  5867. $info_list[$key]['dbtime'] = "";
  5868. }
  5869. if ($value['state'] == 0) {
  5870. $info_list[$key]['state'] = "在库";
  5871. } else if ($value['state'] == 1) {
  5872. $info_list[$key]['state'] = "出库";
  5873. } else if ($value['state'] == 2) {
  5874. $info_list[$key]['state'] = "退库";
  5875. } else if ($value['state'] == 3) {
  5876. $info_list[$key]['state'] = "调拨中";
  5877. } else if ($value['state'] == 4) {
  5878. $info_list[$key]['state'] = "再加工";
  5879. } else if ($value['state'] == 5) {
  5880. $info_list[$key]['state'] = "维修中";
  5881. } else if ($value['state'] == 6) {
  5882. $info_list[$key]['state'] = "盘亏";
  5883. } else if ($value['state'] == 7) {
  5884. $info_list[$key]['state'] = "更换标签";
  5885. } else if ($value['state'] == 8) {
  5886. $info_list[$key]['state'] = "其它";
  5887. } else if ($value['state'] == 9) {
  5888. $info_list[$key]['state'] = "预设";
  5889. }
  5890. }
  5891. $total = $this->whlabel->find_count($where);
  5892. $pagenum = ceil($total / $perpage);
  5893. $over = $total - ($start + $perpage);
  5894. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5895. echo json_encode($rows);
  5896. exit;
  5897. }
  5898. if (isset($post['rsku'])) {
  5899. $cz = $this->input->post('cz', true);
  5900. $label = $this->input->post('rsku', true);
  5901. $sl = $this->input->post('sl', true);
  5902. $warehouse = $this->input->post('warehouse', true);
  5903. if (!$sl) {
  5904. $sl = 1;
  5905. }
  5906. if (!$warehouse) {
  5907. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5908. exit;
  5909. }
  5910. $dblabel = $this->whlabellabel->get_label($label);
  5911. if ($dblabel) {
  5912. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5913. if (count($data) < 1) {
  5914. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5915. exit;
  5916. }
  5917. if ($sl > count($data)) {
  5918. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5919. exit;
  5920. }
  5921. $time = time();
  5922. for ($i = 0; $i < $sl; $i++) {
  5923. $this->whlabel->save(array('state' => 0, 'dbwarehouse' => $data[$i]['warehouse'], 'warehouse' => $warehouse, 'enter' => $time, 'time' => $time, 'dbcontent' => $data[$i]['dbcontent'] . $warehouse . '-' . $time . '|',), $data[$i]['id']);
  5924. }
  5925. echo json_encode(array('success' => true));
  5926. exit;
  5927. } else {
  5928. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5929. exit;
  5930. }
  5931. }
  5932. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5933. $this->_Template('whlabel_dbrk', $this->data);
  5934. }
  5935. public function _whlabelczdc()
  5936. {
  5937. if (isset($_GET['excel'])) {
  5938. //数据排序
  5939. $order_str = "id desc";
  5940. if (empty($page)) {
  5941. $start = 0;
  5942. $perpage = 1;
  5943. } else {
  5944. $start = ($page - 1) * $perpage;
  5945. }
  5946. $state = $this->input->get('state', true);
  5947. $sku = $this->input->get('sku', true);
  5948. $ctime = $this->input->get('ctime', true);
  5949. $category = $this->input->get('category', true);
  5950. $size = $this->input->get('size', true);
  5951. $grade = $this->input->get('grade', true);
  5952. $color = $this->input->get('color', true);
  5953. $lowe = $this->input->get('lowe', true);
  5954. $timetk = $this->input->get('timetkk', true);
  5955. $timetj = $this->input->get('timetjj', true);
  5956. $timetk = strtotime($timetk);
  5957. $timetj = strtotime($timetj);
  5958. $where = "dbtime > 0";
  5959. if ($timetk && $timetj) {
  5960. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5961. }
  5962. if ($category) {
  5963. $where .= " and features like '%-$category-%'";
  5964. }
  5965. if ($size) {
  5966. $where .= " and features like '%-$size-%'";
  5967. }
  5968. if ($grade) {
  5969. $where .= " and features like '%-$grade-%'";
  5970. }
  5971. if ($color) {
  5972. $where .= " and features like '%-$color-%'";
  5973. }
  5974. if ($lowe) {
  5975. $where .= " and features like '%-$lowe-%'";
  5976. }
  5977. //取得信息列表
  5978. $info_list = $this->whlabel->find_all($where, '*');
  5979. $rows = array();
  5980. $list = array();
  5981. foreach ($info_list as $key => $value) {
  5982. $rows[$value['sku']] = $value; //所有数据sku
  5983. }
  5984. foreach ($rows as $value) {
  5985. $warehouse = $this->warehouse->read($value['warehouse']);
  5986. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5987. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5988. if ($value['orderinfo'] == 0) {
  5989. $info_list[$key]['orderinfo'] = "";
  5990. }
  5991. if ($value['waybill'] == 0) {
  5992. $info_list[$key]['waybill'] = "";
  5993. }
  5994. if ($value['state'] == 0) {
  5995. $value['state'] = "在库";
  5996. } else if ($value['state'] == 3) {
  5997. $value['state'] = "调拨中";
  5998. }
  5999. $list[] = array($value['sku'], $value['title'], $db, $rk);
  6000. }
  6001. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  6002. $titlename = "<table border=1>
  6003. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  6004. <tr align='center'>
  6005. <td>SKU</td>
  6006. <td>产品</td>
  6007. <td>调拨数量</td>
  6008. <td>入库数量</td>
  6009. </tr>
  6010. </table>";
  6011. $filename = $title . ".xls";
  6012. $tail = "";
  6013. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  6014. }
  6015. }
  6016. public function _print($arg_array)
  6017. {
  6018. if (isset($_SESSION['api'])) {
  6019. $user = $this->user->get_api($_SESSION['api']);
  6020. $usp = $user;
  6021. $fgshop = "";
  6022. $sid = "";
  6023. $wid = "";
  6024. $wtype = "";
  6025. $usersp = explode('|', trim($user['shop'], '|'));
  6026. $userwh = explode('|', trim($user['warehouse'], '|'));
  6027. foreach ($usersp as $value) {
  6028. $fgshop .= " shop = " . $value . " or";
  6029. $sid .= " id = " . $value . " or";
  6030. }
  6031. foreach ($userwh as $value) {
  6032. $wid .= " id = " . $value . " or";
  6033. $wtype .= " type = " . $value . " or";
  6034. }
  6035. }
  6036. $post = $this->input->post(NULL, TRUE);
  6037. if (isset($post['tmsku'])) {
  6038. $tmsku = $this->input->post('tmsku', true);
  6039. if (is_numeric($tmsku)) {
  6040. $yyh = $this->whlabellabel->get_label($tmsku);
  6041. } else {
  6042. $yyh = $this->whlabellabel->get_sku($tmsku);
  6043. if(empty($yyh)){
  6044. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6045. if($r['code'] == -1 ){
  6046. echo json_encode(array('success' => false));
  6047. exit;
  6048. }else{
  6049. echo json_encode(array('features' => $r['data'], 'success' => true));
  6050. exit;
  6051. }
  6052. }
  6053. }
  6054. if ($yyh) {
  6055. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6056. exit;
  6057. } else {
  6058. echo json_encode(array('success' => false));
  6059. exit;
  6060. }
  6061. }
  6062. $classid = $this->classid->sku();
  6063. $pm = $classid;
  6064. $scsku = $classid;
  6065. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6066. if (isset($post['warehouse'])) {
  6067. if ($post['warehouse']) {
  6068. $list = array();
  6069. $num = "";
  6070. $title = "";
  6071. $features = "";
  6072. $order = 0;
  6073. $post['shop'] = '';
  6074. $brand = $this->input->post('brand', true);
  6075. if ($brand != '0,') {
  6076. $b = $this->brand->read(rtrim($brand, ','));
  6077. if ($b) {
  6078. $post['shop'] = str_replace('|', ',', $b['shop']);
  6079. }
  6080. }
  6081. $post['details'] = $this->input->post('details', true); //打印数量
  6082. $xbqnum = $this->input->post('xbqnum', true);
  6083. $post['purchase'] = $this->input->post('purchase', true);
  6084. $post['warehouse'] = $this->input->post('warehouse', true);
  6085. $post['purchase'] = $this->input->post('purchase', true);
  6086. $post['retreatwarehouse'] = $post['warehouse'];
  6087. $post['cpbz'] = $this->input->post('cpbz', true);
  6088. $post['state'] = 9;
  6089. $category = $this->input->post('category', true);
  6090. $list['category'] = $category;
  6091. $list['hairtype'] = $this->input->post('hairtype', true);
  6092. $list['grade'] = $this->input->post('grade', true);
  6093. $size = $this->input->post('size', true);
  6094. $list['size'] = rtrim($size, ',');
  6095. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6096. $list['extension'] = $this->input->post('extension', true);
  6097. if ($category == 1297) {
  6098. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6099. }
  6100. if ($category == 1702) {
  6101. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6102. $list['syother'] = $this->input->post('syother', true);
  6103. }
  6104. if ($category == 133) {
  6105. $list['fittype'] = $this->input->post('fittype', true);
  6106. $list['acother'] = $this->input->post('acother', true);
  6107. }
  6108. $list['color'] = $this->input->post('color', true);
  6109. $list['lowe'] = $this->input->post('lowe', true);
  6110. if ($category == 127) {
  6111. $list['type'] = $this->input->post('type', true);
  6112. $list['headroad'] = $this->input->post('headroad', true);
  6113. $list['density'] = $this->input->post('density', true);
  6114. $list['lacesize'] = $this->input->post('lacesize', true);
  6115. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6116. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6117. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6118. }
  6119. if ($category == 128) {
  6120. $list['lacetype'] = $this->input->post('lacetype', true);
  6121. $list['haircap'] = $this->input->post('haircap', true);
  6122. $list['density'] = $this->input->post('density', true);
  6123. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6124. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6125. $list['wigother'] = $this->input->post('wigother', true);
  6126. $list['wigother1'] = $this->input->post('wigother1', true);
  6127. $list['wigother2'] = $this->input->post('wigother2', true);
  6128. $list['product_related'] = $this->input->post('product_related', true);
  6129. }
  6130. if ($category == 129) {
  6131. $list['wide'] = $this->input->post('wide', true);
  6132. }
  6133. if ($category == 131) {
  6134. $list['gifttype'] = $this->input->post('gifttype', true);
  6135. $list['giftother'] = $this->input->post('giftother', true);
  6136. }
  6137. if ($category == 134) {
  6138. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6139. }
  6140. if ($category == 1297) {
  6141. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6142. $list['sywigother'] = $this->input->post('sywigother', true);
  6143. }
  6144. if ($category == 130 || $category == 133 || $category == 1702) {
  6145. $list['items'] = $this->input->post('items', true);
  6146. $list['weight'] = $this->input->post('weight', true);
  6147. }
  6148. if ($category == 1702) {
  6149. $list['syhairther'] = $this->input->post('syhairther', true);
  6150. }
  6151. if($category == 130){
  6152. $list['jfother'] = $this->input->post('jfother', true);
  6153. }
  6154. foreach ($list as $k => $v) {
  6155. if ($v != 0) {
  6156. $num .= $v;
  6157. $features .= $v . '-';
  6158. $post[$k] = $v;
  6159. $typeclass = $this->typeclass->read($v);
  6160. if (isset($pm[$typeclass['classid']])) {
  6161. if (stripos($typeclass['zh'], '|') !== false) {
  6162. $exzh = explode('|', $typeclass['zh']);
  6163. if($k == 'hairtype'){
  6164. if(!in_array($v,[163,164,165,166])){
  6165. $pm[$typeclass['classid']] = $exzh[0];
  6166. }
  6167. }else{
  6168. $pm[$typeclass['classid']] = $exzh[0];
  6169. }
  6170. } else {
  6171. if($k == 'hairtype'){
  6172. if(!in_array($v,[163,164,165,166])){
  6173. $pm[$typeclass['classid']] = $typeclass['zh'];
  6174. }
  6175. }else{
  6176. $pm[$typeclass['classid']] = $typeclass['zh'];
  6177. }
  6178. }
  6179. }
  6180. if($k == 'hairtype'){
  6181. if(!in_array($v,[163,164,165,166])){
  6182. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6183. }
  6184. }else{
  6185. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6186. }
  6187. if ($k != 'size') {
  6188. $title .= $typeclass['title'] . " ";
  6189. }
  6190. }
  6191. }
  6192. $typeclass = $this->typeclass->read($list['size']);
  6193. $title .= $typeclass['title'];
  6194. $time = time();
  6195. $post['title'] = rtrim($title, ' ');
  6196. $post['number'] = $num;
  6197. $post['features'] = '-' . $features;
  6198. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6199. $featurespp = explode('-', trim($featurespp, '-'));
  6200. if (isset($featurespp[5])) {
  6201. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6202. } else {
  6203. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6204. }
  6205. $post['enter'] = $time;
  6206. $post['time'] = $time; //操作时间
  6207. $scsku = implode("-", $scsku);
  6208. $zh = implode(" ", $pm);
  6209. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6210. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6211. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6212. $post['sku'] = $bqsku;
  6213. $label = time() . rand(0, 9);
  6214. $post['label'] = $label;
  6215. $cpid = $this->whlabellabel->find_count();
  6216. $post['cpid'] = $cpid + 1;
  6217. $cpid = $post['cpid'];
  6218. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6219. //if($whlabelbarcode)
  6220. //{
  6221. //$post['label'] = $whlabelbarcode['label'];
  6222. //if(!$this->whlabellabel->insert($post))
  6223. //{
  6224. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6225. //}
  6226. //}
  6227. //else
  6228. //{
  6229. $this->db->trans_begin();
  6230. $this->whlabellabel->insert($post);
  6231. //$this->whlabelbarcode->insert($post);
  6232. if ($this->db->trans_status() === TRUE) {
  6233. $this->db->trans_commit();
  6234. } else {
  6235. $this->db->trans_rollback();
  6236. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6237. exit;
  6238. }
  6239. //}
  6240. $warehouse_name = "";
  6241. $warehouse = $post['warehouse'];
  6242. if($warehouse == 12){
  6243. $warehouse_name = "特殊库存库";
  6244. }
  6245. // if($warehouse == 13){
  6246. // $warehouse_name = "许昌仓";
  6247. // }
  6248. // if($warehouse == 5){
  6249. // $warehouse_name = "美国店";
  6250. // }
  6251. // if($warehouse == 16){
  6252. // $warehouse_name = "定制头套仓";
  6253. // }
  6254. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6255. if(!empty($warehouse_name)){
  6256. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6257. }
  6258. $purchase = $this->purchase->read($post['purchase']);
  6259. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 0, 'success' => true));
  6260. exit; //特殊仓目前不需要仓库选项
  6261. }
  6262. }
  6263. if (isset($_SESSION['api'])) {
  6264. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6265. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6266. $this->data['wlshop'] = $wlshop;
  6267. $this->data['warehouse'] = $warehouse;
  6268. }
  6269. $whlabelwz = $this->whlabelwz->find_all();
  6270. $this->data['whlabelwz'] = $whlabelwz;
  6271. $this->_Template('whlabel_print', $this->data);
  6272. }
  6273. public function _usaprint($arg_array)
  6274. {
  6275. if (isset($_SESSION['api'])) {
  6276. $user = $this->user->get_api($_SESSION['api']);
  6277. $usp = $user;
  6278. $fgshop = "";
  6279. $sid = "";
  6280. $wid = "";
  6281. $wtype = "";
  6282. $usersp = explode('|', trim($user['shop'], '|'));
  6283. $userwh = explode('|', trim($user['warehouse'], '|'));
  6284. foreach ($usersp as $value) {
  6285. $fgshop .= " shop = " . $value . " or";
  6286. $sid .= " id = " . $value . " or";
  6287. }
  6288. foreach ($userwh as $value) {
  6289. $wid .= " id = " . $value . " or";
  6290. $wtype .= " type = " . $value . " or";
  6291. }
  6292. }
  6293. $post = $this->input->post(NULL, TRUE);
  6294. if (isset($post['tmsku'])) {
  6295. $tmsku = $this->input->post('tmsku', true);
  6296. if (is_numeric($tmsku)) {
  6297. $yyh = $this->whlabellabel->get_label($tmsku);
  6298. } else {
  6299. $yyh = $this->whlabellabel->get_sku($tmsku);
  6300. }
  6301. if ($yyh) {
  6302. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6303. exit;
  6304. } else {
  6305. echo json_encode(array('success' => false));
  6306. exit;
  6307. }
  6308. }
  6309. $classid = $this->classid->sku();
  6310. $pm = $classid;
  6311. $scsku = $classid;
  6312. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6313. if (isset($post['warehouse'])) {
  6314. if ($post['warehouse']) {
  6315. $list = array();
  6316. $num = "";
  6317. $title = "";
  6318. $features = "";
  6319. $order = 0;
  6320. $post['shop'] = '';
  6321. $brand = $this->input->post('brand', true);
  6322. if ($brand != '0,') {
  6323. $b = $this->brand->read(rtrim($brand, ','));
  6324. if ($b) {
  6325. $post['shop'] = str_replace('|', ',', $b['shop']);
  6326. }
  6327. }
  6328. $post['details'] = $this->input->post('details', true); //打印数量
  6329. $xbqnum = $this->input->post('xbqnum', true);
  6330. $post['purchase'] = $this->input->post('purchase', true);
  6331. $post['warehouse'] = $this->input->post('warehouse', true);
  6332. $post['purchase'] = $this->input->post('purchase', true);
  6333. $post['retreatwarehouse'] = $post['warehouse'];
  6334. $post['cpbz'] = $this->input->post('cpbz', true);
  6335. $post['state'] = 9;
  6336. $category = $this->input->post('category', true);
  6337. $list['category'] = $category;
  6338. $list['hairtype'] = $this->input->post('hairtype', true);
  6339. $list['grade'] = $this->input->post('grade', true);
  6340. $size = $this->input->post('size', true);
  6341. $list['size'] = rtrim($size, ',');
  6342. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6343. $list['extension'] = $this->input->post('extension', true);
  6344. if ($category == 1297) {
  6345. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6346. }
  6347. if ($category == 1702) {
  6348. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6349. $list['syother'] = $this->input->post('syother', true);
  6350. }
  6351. if ($category == 133) {
  6352. $list['fittype'] = $this->input->post('fittype', true);
  6353. $list['acother'] = $this->input->post('acother', true);
  6354. }
  6355. $list['color'] = $this->input->post('color', true);
  6356. $list['lowe'] = $this->input->post('lowe', true);
  6357. if ($category == 127) {
  6358. $list['type'] = $this->input->post('type', true);
  6359. $list['headroad'] = $this->input->post('headroad', true);
  6360. $list['density'] = $this->input->post('density', true);
  6361. $list['lacesize'] = $this->input->post('lacesize', true);
  6362. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6363. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6364. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6365. }
  6366. if ($category == 128) {
  6367. $list['lacetype'] = $this->input->post('lacetype', true);
  6368. $list['haircap'] = $this->input->post('haircap', true);
  6369. $list['density'] = $this->input->post('density', true);
  6370. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6371. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6372. $list['wigother'] = $this->input->post('wigother', true);
  6373. $list['wigother1'] = $this->input->post('wigother1', true);
  6374. $list['wigother2'] = $this->input->post('wigother2', true);
  6375. $list['product_related'] = $this->input->post('product_related', true);
  6376. }
  6377. if ($category == 129) {
  6378. $list['wide'] = $this->input->post('wide', true);
  6379. }
  6380. if ($category == 131) {
  6381. $list['gifttype'] = $this->input->post('gifttype', true);
  6382. $list['giftother'] = $this->input->post('giftother', true);
  6383. }
  6384. if ($category == 134) {
  6385. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6386. }
  6387. if ($category == 1297) {
  6388. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6389. $list['sywigother'] = $this->input->post('sywigother', true);
  6390. }
  6391. if ($category == 130 || $category == 133 || $category == 1702) {
  6392. $list['items'] = $this->input->post('items', true);
  6393. $list['weight'] = $this->input->post('weight', true);
  6394. }
  6395. if ($category == 1702) {
  6396. $list['syhairther'] = $this->input->post('syhairther', true);
  6397. }
  6398. foreach ($list as $k => $v) {
  6399. if ($v != 0) {
  6400. $num .= $v;
  6401. $features .= $v . '-';
  6402. $post[$k] = $v;
  6403. $typeclass = $this->typeclass->read($v);
  6404. if (isset($pm[$typeclass['classid']])) {
  6405. if (stripos($typeclass['zh'], '|') !== false) {
  6406. $exzh = explode('|', $typeclass['zh']);
  6407. if($k == 'hairtype'){
  6408. if(!in_array($v,[163,164,165,166])){
  6409. $pm[$typeclass['classid']] = $exzh[0];
  6410. }
  6411. }else{
  6412. $pm[$typeclass['classid']] = $exzh[0];
  6413. }
  6414. } else {
  6415. if($k == 'hairtype'){
  6416. if(!in_array($v,[163,164,165,166])){
  6417. $pm[$typeclass['classid']] = $typeclass['zh'];
  6418. }
  6419. }else{
  6420. $pm[$typeclass['classid']] = $typeclass['zh'];
  6421. }
  6422. }
  6423. }
  6424. if($k == 'hairtype'){
  6425. if(!in_array($v,[163,164,165,166])){
  6426. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6427. }
  6428. }else{
  6429. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6430. }
  6431. if ($k != 'size') {
  6432. $title .= $typeclass['title'] . " ";
  6433. }
  6434. }
  6435. }
  6436. $typeclass = $this->typeclass->read($list['size']);
  6437. $title .= $typeclass['title'];
  6438. $time = time();
  6439. $post['title'] = rtrim($title, ' ');
  6440. $post['number'] = $num;
  6441. $post['features'] = '-' . $features;
  6442. $fp = $this->whlabel->get_features($post['features']);
  6443. if (!$fp) {
  6444. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6445. exit;
  6446. }
  6447. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6448. $featurespp = explode('-', trim($featurespp, '-'));
  6449. if (isset($featurespp[5])) {
  6450. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6451. } else {
  6452. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6453. }
  6454. $post['enter'] = $time;
  6455. $post['time'] = $time; //操作时间
  6456. $scsku = implode("-", $scsku);
  6457. $zh = implode(" ", $pm);
  6458. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6459. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6460. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6461. $post['sku'] = $fp['sku'];
  6462. $post['label'] = $fp['sku'];
  6463. $cpid = $this->whlabellabel->find_count();
  6464. $post['cpid'] = $cpid + 1;
  6465. $cpid = $post['cpid'];
  6466. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6467. //if($whlabelbarcode)
  6468. //{
  6469. //$post['label'] = $whlabelbarcode['label'];
  6470. //if(!$this->whlabellabel->insert($post))
  6471. //{
  6472. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6473. //}
  6474. //}
  6475. //else
  6476. //{
  6477. $this->db->trans_begin();
  6478. $this->whlabellabel->insert($post);
  6479. //$this->whlabelbarcode->insert($post);
  6480. if ($this->db->trans_status() === TRUE) {
  6481. $this->db->trans_commit();
  6482. } else {
  6483. $this->db->trans_rollback();
  6484. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6485. exit;
  6486. }
  6487. //}
  6488. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6489. $purchase = $this->purchase->read($post['purchase']);
  6490. echo json_encode(array('title' => $title, 'num' => $post['label'], 'bqsku' => $bqsku, 'xbqnum' => $xbqnum, 'zh' => str_replace('自然色 ', '', rtrim($zh, ' ')), 'details' => $details, 'purchase' => $purchase['title'], 'cpbz' => $post['cpbz'], 'usa' => 1, 'success' => true));
  6491. exit; //特殊仓目前不需要仓库选项
  6492. }
  6493. }
  6494. if (isset($_SESSION['api'])) {
  6495. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6496. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6497. $this->data['wlshop'] = $wlshop;
  6498. $this->data['warehouse'] = $warehouse;
  6499. }
  6500. $whlabelwz = $this->whlabelwz->find_all();
  6501. $this->data['whlabelwz'] = $whlabelwz;
  6502. $this->_Template('whlabel_usaprint', $this->data);
  6503. }
  6504. public function _printrk($arg_array)
  6505. {
  6506. $prc = array();
  6507. $purchase = $this->purchase->find_all();
  6508. foreach ($purchase as $k => $v) {
  6509. $prc[$v['id']] = $v['title'];
  6510. }
  6511. $post = $this->input->post(NULL, TRUE);
  6512. if (isset($post['page'])) {
  6513. $page = $this->input->post('page', true);
  6514. $perpage = $this->input->post('perpage', true);
  6515. $sku = $this->input->post('sku', true);
  6516. $bs = $this->input->post('bs', true);
  6517. $number = $this->input->post('number', true);
  6518. $warehouse = $this->input->post('warehouse', true);
  6519. $purchase = $this->input->post('purchase', true);
  6520. $orderinfo = $this->input->post('orderinfo', true);
  6521. $waybill = $this->input->post('waybill', true);
  6522. $category = $this->input->post('category', true);
  6523. $size = $this->input->post('size', true);
  6524. $grade = $this->input->post('grade', true);
  6525. $color = $this->input->post('color', true);
  6526. $lowe = $this->input->post('lowe', true);
  6527. $state = $this->input->post('state', true);
  6528. $label = $this->input->post('label', true);
  6529. $timetk = $this->input->post('ktime', true);
  6530. $timetj = $this->input->post('jtime', true);
  6531. $timetk = strtotime($timetk);
  6532. $timetj = strtotime($timetj);
  6533. $where = "1=1 ";
  6534. if ($timetk && $timetj) {
  6535. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6536. }
  6537. if ($sku) {
  6538. $where .= " and sku = '$sku'";
  6539. }
  6540. if ($bs != '') {
  6541. $where .= " and bs = '$bs'";
  6542. }
  6543. if ($number) {
  6544. $where .= " and number = '$number'";
  6545. }
  6546. if ($warehouse) {
  6547. $where .= " and warehouse = '$warehouse'";
  6548. }
  6549. if ($purchase) {
  6550. $where .= " and purchase = '$purchase'";
  6551. }
  6552. if ($orderinfo) {
  6553. $where .= " and orderinfo = '$orderinfo'";
  6554. }
  6555. if ($waybill) {
  6556. $where .= " and waybill = '$waybill'";
  6557. }
  6558. if ($category) {
  6559. $where .= " and features like '%-$category-%'";
  6560. }
  6561. if ($size) {
  6562. $where .= " and features like '%-$size-%'";
  6563. }
  6564. if ($grade) {
  6565. $where .= " and features like '%-$grade-%'";
  6566. }
  6567. if ($color) {
  6568. $where .= " and features like '%-$color-%'";
  6569. }
  6570. if ($lowe) {
  6571. $where .= " and features like '%-$lowe-%'";
  6572. }
  6573. if ($label) {
  6574. $where .= " and label = '$label'";
  6575. }
  6576. // if ($state || $state == 0) {
  6577. // $where .= " and state = '$state'";
  6578. // }
  6579. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6580. //数据排序
  6581. $order_str = "enter desc";
  6582. if (empty($page)) {
  6583. $start = 0;
  6584. $perpage = 1;
  6585. } else {
  6586. $start = ($page - 1) * $perpage;
  6587. }
  6588. //取得信息列表
  6589. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6590. foreach ($info_list as $key => $value) {
  6591. $warehouse = $this->warehouse->read($value['warehouse']);
  6592. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6593. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6594. if ($value['state'] == 0) {
  6595. $info_list[$key]['state'] = "在库";
  6596. } else if ($value['state'] == 1) {
  6597. $info_list[$key]['state'] = "出库";
  6598. } else if ($value['state'] == 2) {
  6599. $info_list[$key]['state'] = "退库";
  6600. } else if ($value['state'] == 3) {
  6601. $info_list[$key]['state'] = "调拨中";
  6602. } else if ($value['state'] == 4) {
  6603. $info_list[$key]['state'] = "再加工";
  6604. } else if ($value['state'] == 5) {
  6605. $info_list[$key]['state'] = "维修中";
  6606. } else if ($value['state'] == 6) {
  6607. $info_list[$key]['state'] = "盘亏";
  6608. } else if ($value['state'] == 7) {
  6609. $info_list[$key]['state'] = "更换标签";
  6610. } else if ($value['state'] == 8) {
  6611. $info_list[$key]['state'] = "其它";
  6612. } else if ($value['state'] == 9) {
  6613. $info_list[$key]['state'] = "预设";
  6614. } else if ($value['state'] == 10) {
  6615. $info_list[$key]['state'] = "美店零售";
  6616. }
  6617. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6618. }
  6619. $total = $this->$ck->find_count($where);
  6620. $pagenum = ceil($total / $perpage);
  6621. $over = $total - ($start + $perpage);
  6622. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6623. echo json_encode($rows);
  6624. exit;
  6625. }
  6626. if (isset($post['tmsku'])) {
  6627. $time = time();
  6628. $tmsku = $this->input->post('tmsku', true);
  6629. //$post['shop'] = $this->input->post('shop',true);
  6630. $num = $this->input->post('num', true);
  6631. $rktype = $this->input->post('rktype', true);
  6632. if ($num > 200) {
  6633. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6634. exit;
  6635. }
  6636. if (!$rktype) {
  6637. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6638. }
  6639. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6640. /**
  6641. $wz = array();
  6642. foreach ($rk as $key=>$value)
  6643. {
  6644. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6645. }
  6646. if(count($wz) > 1)
  6647. {
  6648. $wz = array_values($wz);
  6649. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6650. }
  6651. **/
  6652. if (isset($rk[0]['purchase'])) {
  6653. $rk = $rk[0];
  6654. $j = 0;
  6655. $post['purchase'] = $rk['purchase'];
  6656. $post['warehouse'] = $rk['warehouse'];
  6657. $post['retreatwarehouse'] = $rk['warehouse'];
  6658. $post['sku'] = $rk['sku'];
  6659. $post['number'] = $rk['number'];
  6660. $post['features'] = $rk['features'];
  6661. $post['title'] = $rk['title'];
  6662. $post['enter'] = $time;
  6663. $post['time'] = $time;
  6664. $post['bs'] = 1;
  6665. $post['shop'] = $rk['shop'];
  6666. $post['details'] = $rk['details'];
  6667. $post['cpid'] = $rk['cpid'];
  6668. $post['cpbz'] = $rk['cpbz'];
  6669. $post['rktype'] = $rktype;
  6670. $warehouse = $this->warehouse->read($rk['warehouse']);
  6671. if ($warehouse['bdck'] == '') {
  6672. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6673. exit;
  6674. } else {
  6675. $bdck = $warehouse['bdck'];
  6676. }
  6677. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6678. if (isset($pdwz['details'])) {
  6679. if ($pdwz['details'] != $post['details']) {
  6680. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6681. }else{
  6682. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6683. exit;
  6684. }
  6685. }
  6686. }
  6687. $post['featurespp'] = $rk['featurespp'];
  6688. if ($post['warehouse'] == '5') {
  6689. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6690. if ($yza) {
  6691. if ($post['features'] != $yza[0]['features']) {
  6692. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6693. exit;
  6694. }
  6695. }
  6696. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6697. if ($yzb) {
  6698. if ($post['sku'] != $yzb[0]['sku']) {
  6699. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6700. exit;
  6701. }
  6702. }
  6703. }
  6704. for ($i = 0; $i < $num; $i++) {
  6705. $post['label'] = time() . rand(100, 999) . $i;
  6706. if ($this->$bdck->insert($post)) {
  6707. $j++;
  6708. }
  6709. }
  6710. /**
  6711. if($post['warehouse'] != 12)
  6712. {
  6713. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6714. }
  6715. **/
  6716. $this->whlabelscanlog->insert([
  6717. 'shop'=>$rk['shop'],
  6718. 'type'=>1,
  6719. 'purchase'=>$rk['purchase'],
  6720. 'sku'=>$rk['sku'],
  6721. 'features'=>$rk['features'],
  6722. 'title'=>$rk['title'],
  6723. 'label'=>$rk['label'],
  6724. 'warehouse'=>$rk['warehouse'],
  6725. 'wlid'=>$rk['id'],
  6726. 'num'=>$num,
  6727. 'addtime'=>time()
  6728. ]);
  6729. if ($j == $num) {
  6730. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6731. exit;
  6732. } else {
  6733. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6734. exit;
  6735. }
  6736. } else {
  6737. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6738. exit;
  6739. }
  6740. }
  6741. $this->_Template('whlabel_printrk', $this->data);
  6742. }
  6743. public function _printxzrk($arg_array)
  6744. {
  6745. $post = $this->input->post(NULL, TRUE);
  6746. if (isset($post['wzid'])) {
  6747. $time = time();
  6748. $id = $this->input->post('wzid', true);
  6749. //$post['shop'] = $this->input->post('shop',true);
  6750. $num = 1;
  6751. $rk = $this->whlabellabel->read($id);
  6752. if (isset($rk['purchase'])) {
  6753. $x = 0;
  6754. $post['purchase'] = $rk['purchase'];
  6755. $post['warehouse'] = $rk['warehouse'];
  6756. $post['retreatwarehouse'] = $rk['warehouse'];
  6757. $post['sku'] = $rk['sku'];
  6758. $post['number'] = $rk['number'];
  6759. $post['features'] = $rk['features'];
  6760. $post['title'] = $rk['title'];
  6761. $post['enter'] = $time;
  6762. $post['time'] = $time;
  6763. $post['bs'] = 1;
  6764. $post['shop'] = $rk['shop'];
  6765. $post['details'] = $rk['details'];
  6766. $post['cpid'] = $rk['cpid'];
  6767. $post['cpbz'] = $rk['cpbz'];
  6768. $warehouse = $this->warehouse->read($rk['warehouse']);
  6769. if ($warehouse['bdck'] == '') {
  6770. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6771. exit;
  6772. } else {
  6773. $bdck = $warehouse['bdck'];
  6774. }
  6775. $post['featurespp'] = $rk['featurespp'];
  6776. $this->db->trans_begin();
  6777. for ($i = 0; $i < $num; $i++) {
  6778. $post['label'] = time() . rand(100, 999) . $i;
  6779. $this->$bdck->insert($post);
  6780. }
  6781. /**
  6782. if($post['warehouse'] != 12)
  6783. {
  6784. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6785. }
  6786. **/
  6787. if ($this->db->trans_status() === TRUE) {
  6788. $this->db->trans_commit();
  6789. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6790. exit;
  6791. } else {
  6792. $this->db->trans_rollback();
  6793. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6794. exit;
  6795. }
  6796. } else {
  6797. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6798. exit;
  6799. }
  6800. }
  6801. }
  6802. public function _printck($arg_array)
  6803. {
  6804. $prc = array();
  6805. $purchase = $this->purchase->find_all();
  6806. foreach ($purchase as $k => $v) {
  6807. $prc[$v['id']] = $v['title'];
  6808. }
  6809. $post = $this->input->post(NULL, TRUE);
  6810. if (isset($post['page'])) {
  6811. $page = $this->input->post('page', true);
  6812. $perpage = $this->input->post('perpage', true);
  6813. $sku = $this->input->post('sku', true);
  6814. $bs = $this->input->post('bs', true);
  6815. $number = $this->input->post('number', true);
  6816. $warehouse = $this->input->post('warehouse', true);
  6817. $purchase = $this->input->post('purchase', true);
  6818. $orderinfo = $this->input->post('orderinfo', true);
  6819. $waybill = $this->input->post('waybill', true);
  6820. $category = $this->input->post('category', true);
  6821. $size = $this->input->post('size', true);
  6822. $grade = $this->input->post('grade', true);
  6823. $color = $this->input->post('color', true);
  6824. $lowe = $this->input->post('lowe', true);
  6825. $state = $this->input->post('state', true);
  6826. $label = $this->input->post('label', true);
  6827. $timetk = $this->input->post('ktime', true);
  6828. $timetj = $this->input->post('jtime', true);
  6829. $timetk = strtotime($timetk);
  6830. $timetj = strtotime($timetj);
  6831. $where = "state=1 ";
  6832. if ($timetk && $timetj) {
  6833. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6834. }
  6835. if ($sku) {
  6836. $where .= " and sku = '$sku'";
  6837. }
  6838. if ($bs != '') {
  6839. $where .= " and bs = '$bs'";
  6840. }
  6841. if ($number) {
  6842. $where .= " and number = '$number'";
  6843. }
  6844. if ($warehouse) {
  6845. $where .= " and warehouse = '$warehouse'";
  6846. }
  6847. if ($purchase) {
  6848. $where .= " and purchase = '$purchase'";
  6849. }
  6850. if ($orderinfo) {
  6851. $where .= " and orderinfo = '$orderinfo'";
  6852. }
  6853. if ($waybill) {
  6854. $where .= " and waybill = '$waybill'";
  6855. }
  6856. if ($category) {
  6857. $where .= " and features like '%-$category-%'";
  6858. }
  6859. if ($size) {
  6860. $where .= " and features like '%-$size-%'";
  6861. }
  6862. if ($grade) {
  6863. $where .= " and features like '%-$grade-%'";
  6864. }
  6865. if ($color) {
  6866. $where .= " and features like '%-$color-%'";
  6867. }
  6868. if ($lowe) {
  6869. $where .= " and features like '%-$lowe-%'";
  6870. }
  6871. if ($label) {
  6872. $where .= " and label = '$label'";
  6873. }
  6874. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6875. //数据排序
  6876. $order_str = "outk desc";
  6877. if (empty($page)) {
  6878. $start = 0;
  6879. $perpage = 1;
  6880. } else {
  6881. $start = ($page - 1) * $perpage;
  6882. }
  6883. //取得信息列表
  6884. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6885. foreach ($info_list as $key => $value) {
  6886. $warehouse = $this->warehouse->read($value['warehouse']);
  6887. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6888. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6889. if ($value['state'] == 0) {
  6890. $info_list[$key]['state'] = "在库";
  6891. } else if ($value['state'] == 1) {
  6892. $info_list[$key]['state'] = "出库";
  6893. } else if ($value['state'] == 2) {
  6894. $info_list[$key]['state'] = "退库";
  6895. } else if ($value['state'] == 3) {
  6896. $info_list[$key]['state'] = "调拨中";
  6897. } else if ($value['state'] == 4) {
  6898. $info_list[$key]['state'] = "再加工";
  6899. } else if ($value['state'] == 5) {
  6900. $info_list[$key]['state'] = "维修中";
  6901. } else if ($value['state'] == 6) {
  6902. $info_list[$key]['state'] = "盘亏";
  6903. } else if ($value['state'] == 7) {
  6904. $info_list[$key]['state'] = "更换标签";
  6905. } else if ($value['state'] == 8) {
  6906. $info_list[$key]['state'] = "其它";
  6907. } else if ($value['state'] == 9) {
  6908. $info_list[$key]['state'] = "预设";
  6909. } else if ($value['state'] == 10) {
  6910. $info_list[$key]['state'] = "美店零售";
  6911. }
  6912. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6913. }
  6914. $total = $this->$ck->find_count($where);
  6915. $pagenum = ceil($total / $perpage);
  6916. $over = $total - ($start + $perpage);
  6917. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6918. echo json_encode($rows);
  6919. exit;
  6920. }
  6921. if (isset($post['tmsku'])) {
  6922. $time = time();
  6923. $tmsku = $this->input->post('tmsku', true);
  6924. //$post['shop'] = $this->input->post('shop',true);
  6925. $num = $this->input->post('num', true);
  6926. $cktype = $this->input->post('cktype', true);
  6927. $label = $this->whlabellabel->get_label($tmsku);
  6928. if (!$cktype) {
  6929. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6930. }
  6931. if (!isset($label['warehouse'])) {
  6932. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6933. exit;
  6934. }
  6935. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6936. $extra_where = "";
  6937. if(!empty($label['details'])){
  6938. $extra_where .= " and details = '" . $label['details'] . "'";
  6939. }
  6940. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6941. if (stripos($label['features'], '-126-') !== false) {
  6942. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6943. } else {
  6944. $ck = $this->$xzck->find_all("state = '0' and shop = '" . $label['shop'] . "' and number = '" . $label['number'] . "' and warehouse = '" . $label['warehouse'] . "' and purchase = '" . $label['purchase'] . "' and ( zd = '' or zd is null ) ".$extra_where);
  6945. }
  6946. $j = 0;
  6947. if (count($ck) >= $num) {
  6948. for ($i = 0; $i < $num; $i++) {
  6949. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6950. {
  6951. $j++;
  6952. }
  6953. }
  6954. $this->whlabelscanlog->insert([
  6955. 'shop'=>$label['shop'],
  6956. 'type'=>2,
  6957. 'purchase'=>$label['purchase'],
  6958. 'sku'=>$label['sku'],
  6959. 'features'=>$label['features'],
  6960. 'title'=>$label['title'],
  6961. 'label'=>$label['label'],
  6962. 'warehouse'=>$label['warehouse'],
  6963. 'wlid'=>$label['id'],
  6964. 'num'=>$num,
  6965. 'addtime'=>time()
  6966. ]);
  6967. if ($j == $num) {
  6968. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6969. exit;
  6970. } else {
  6971. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6972. exit;
  6973. }
  6974. } else {
  6975. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6976. exit;
  6977. }
  6978. }
  6979. if(isset($_SESSION['api']))
  6980. {
  6981. $user = $this->user->get_api($_SESSION['api']);
  6982. if(in_array($user['power'],[1,27])){
  6983. $vip = 1;
  6984. }
  6985. }
  6986. else
  6987. {
  6988. $vip = 0;
  6989. header('Location: /');exit;
  6990. }
  6991. $this->data['vip'] = $vip;
  6992. $this->_Template('whlabel_printck', $this->data);
  6993. }
  6994. public function _printexcel()
  6995. {
  6996. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6997. $config['upload_path'] = '.' . $dir;
  6998. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6999. $config['allowed_types'] = 'xls|xlsx|csv';
  7000. $config['max_size'] = 10240;
  7001. $this->load->library('upload', $config);
  7002. $this->upload->initialize($config);
  7003. if ($this->upload->do_upload('userfile')) {
  7004. $full_path = $dir . $this->upload->data('file_name');
  7005. $fileName = '.' . $full_path;
  7006. if (!file_exists($fileName)) {
  7007. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7008. exit;
  7009. } else {
  7010. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7011. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7012. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7013. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7014. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7015. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7016. ++$column; //如果列数大于26行
  7017. $list = array();
  7018. for ($i = 2; $i <= $row; $i++) // 行数循环
  7019. {
  7020. $data = array();
  7021. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7022. {
  7023. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7024. }
  7025. $list[] = $data;
  7026. }
  7027. }
  7028. $ed = array();
  7029. $i = 0;
  7030. $j = 0;
  7031. $dcdata = array();
  7032. $yc = '';
  7033. $cmf_arr = array_column($list, '1');
  7034. array_multisort($cmf_arr, SORT_ASC, $list);
  7035. foreach ($list as $key => $value) {
  7036. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  7037. if ($typeclass) {
  7038. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  7039. } else {
  7040. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  7041. $i++;
  7042. continue;
  7043. }
  7044. }
  7045. if ($i > 0) {
  7046. $yc = $i . '条异常';
  7047. }
  7048. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  7049. exit;
  7050. }
  7051. }
  7052. public function _uck()
  7053. {
  7054. if (isset($_GET['excel'])) {
  7055. $tc = array();
  7056. $typeclass = $this->typeclass->find_all();
  7057. foreach ($typeclass as $v) {
  7058. $tc[$v['id']] = $v['zh'];
  7059. }
  7060. $data = array();
  7061. $t = array();
  7062. $rq = '';
  7063. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  7064. $ts = $ts / (24 * 3600);
  7065. for ($i = 0; $i < $ts; $i++) {
  7066. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  7067. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  7068. }
  7069. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7070. foreach ($info_list as $k => $v) {
  7071. $features = explode('-', trim($v['features'], '-'));
  7072. if (!isset($features[3]) || !isset($features[4])) {
  7073. continue;
  7074. }
  7075. $data[$k][0] = $tc[$features[0]]; //类型
  7076. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7077. $data[$k][2] = $tc[$features[4]]; //曲度
  7078. $data[$k][3] = '';
  7079. if (isset($data[$k][1])) {
  7080. $data[$k][3] .= $data[$k][1];
  7081. }
  7082. if (isset($data[$k][2])) {
  7083. $data[$k][3] .= $data[$k][2];
  7084. }
  7085. if (isset($features[5])) {
  7086. $data[$k][3] .= $tc[$features[5]];
  7087. }
  7088. if (isset($features[2])) {
  7089. $data[$k][3] .= $tc[$features[2]];
  7090. }
  7091. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7092. $data[$k][4] = $v['sku'];
  7093. $data[$k][5] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and (state = 0 or (state = 1 and outk > ' . strtotime(date("Y-m", time())) . '))'); //月初库存
  7094. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7095. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7096. $ztrq = '';
  7097. $ztsl = '';
  7098. if (count($zt) > 0) {
  7099. foreach ($zt as $vv) {
  7100. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7101. $ztsl .= $vv['num'] . '<br>';
  7102. }
  7103. }
  7104. $data[$k][] = trim($ztsl, '<br>');
  7105. $data[$k][] = trim($ztrq, '<br>');
  7106. $byck = 0;
  7107. foreach ($t as $vv) {
  7108. $sl = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and state = 1 and outk > ' . strtotime($vv) . ' and outk < ' . (strtotime($vv) + 24 * 3600));
  7109. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7110. $byck += $sl;
  7111. }
  7112. $data[$k][] = ($byck > 0) ? $byck : '';
  7113. }
  7114. $title = "详情 " . date("Y-m-d", time());
  7115. $titlename = "<table border=1>
  7116. <tr align='center'>
  7117. <td>类别</td>
  7118. <td>颜色</td>
  7119. <td>曲度</td>
  7120. <td>名称</td>
  7121. <td>SKU</td>
  7122. <td>月初库存</td>
  7123. <td>剩余库存</td>
  7124. <td>在途数量</td>
  7125. <td>预达日期</td>" .
  7126. $rq
  7127. . "<td>本月出库</td></tr>
  7128. </table>";
  7129. $filename = $title . ".xls";
  7130. $tail = "";
  7131. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7132. }
  7133. }
  7134. //梦体发现 用数字粘贴 会出现遗产给的数据
  7135. public function _whlabelexcelzh_ztsh()
  7136. {
  7137. if (isset($_GET['excel'])) {
  7138. $where = "sku != 'Preset'";
  7139. //数据排序
  7140. $order_str = "id desc";
  7141. if (empty($page)) {
  7142. $start = 0;
  7143. $perpage = 1;
  7144. } else {
  7145. $start = ($page - 1) * $perpage;
  7146. }
  7147. $category = $this->input->get('category', true);
  7148. $warehouse = $this->input->get('warehouse', true);
  7149. $excelid = $this->input->get('sid', true);
  7150. if ($category) {
  7151. $where .= " and features like '%-$category-%'";
  7152. }
  7153. if ($warehouse) {
  7154. $where .= " and warehouse = '$warehouse'";
  7155. }
  7156. $xzid = '';
  7157. if ($excelid) {
  7158. $excelid = explode(',', trim($excelid, ','));
  7159. foreach ($excelid as $key => $value) {
  7160. $xzid .= " id = " . $value . " or";
  7161. }
  7162. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7163. }
  7164. //取得信息列表
  7165. /**
  7166. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7167. $rows = array();$list = array();
  7168. foreach ($info_list as $key=>$value)
  7169. {
  7170. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7171. }
  7172. **/
  7173. $list = array();
  7174. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7175. foreach ($rows as $key => $value) {
  7176. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7177. $zh = '';
  7178. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7179. foreach ($zt as $v) {
  7180. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7181. }
  7182. $zt = array_sum(array_column($zt, 'num'));
  7183. $number = $value['number'];
  7184. $ftime = time() - 15 * 24 * 3600;
  7185. $warehouse = $this->warehouse->read($value['warehouse']);
  7186. $rows[$key]['warehouse'] = $warehouse['title'];
  7187. $rows[$key]['number'] = $c;
  7188. $rows[$key]['features'] = $zh;
  7189. $rows[$key]['hb'] = $c + $zt;
  7190. }
  7191. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7192. $titlename = "<table border=1>
  7193. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7194. <tr align='center'>
  7195. <td>仓库</td>
  7196. <td>SKU</td>
  7197. <td>产品</td>
  7198. <td>库存数量</td>
  7199. <td>在途数量及预达日期</td>
  7200. <td>在途+库存数量</td>
  7201. </tr>
  7202. </table>";
  7203. $filename = $title . ".xls";
  7204. $tail = "";
  7205. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7206. }
  7207. if (isset($_GET['excel'])) {
  7208. $warehouse = $this->input->get('warehouse', true);
  7209. $sku = $this->input->get('sku', true);
  7210. $cz = $this->input->get('cz', true);
  7211. $text = $this->input->post('text', true);
  7212. $xztime = $this->input->get('xztime', true);
  7213. $timetk = $this->input->get('timetk', true);
  7214. $timetj = $this->input->get('timetj', true);
  7215. $timetk = strtotime($timetk);
  7216. $timetj = strtotime($timetj);
  7217. $where = "time = '0' ";
  7218. if ($warehouse) {
  7219. $where .= " and warehouse = '$warehouse'";
  7220. }
  7221. if ($sku) {
  7222. $where .= " and sku = '$sku'";
  7223. }
  7224. if ($text) {
  7225. $where .= " and text like '%$text%'";
  7226. }
  7227. if ($cz != '') {
  7228. $where .= " and cz = '$cz'";
  7229. }
  7230. if ($timetk && $timetj) {
  7231. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7232. }
  7233. //数据排序
  7234. $order_str = $xztime . " desc";
  7235. //取得信息列表
  7236. $zh = array();
  7237. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7238. foreach ($info_list as $v) {
  7239. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7240. $warehouse = $this->warehouse->read($v['warehouse']);
  7241. $v['warehouse'] = $warehouse['title'];
  7242. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7243. $v['stime'] = date('Y-m-d', $v['stime']);
  7244. if (isset($zh[$v['features']])) {
  7245. $zh[$v['features']]['num'] += $v['num'];
  7246. } else {
  7247. $zh[$v['features']] = $v;
  7248. }
  7249. $zh[$v['features']]['features'] = $c;
  7250. }
  7251. $title = "在途数据" . date('Y-m-d', time());
  7252. $titlename = "<table border=1>
  7253. <tr align='center'>
  7254. <td>仓库</td>
  7255. <td>SKU</td>
  7256. <td>名称</td>
  7257. <td>在途数量</td>
  7258. <td>库存数量</td>
  7259. <td>添加在途日期</td>
  7260. <td>预达日期</td>
  7261. <td>备注</td>
  7262. </tr>
  7263. </table>";
  7264. $filename = $title . ".xls";
  7265. $tail = "";
  7266. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7267. }
  7268. }
  7269. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7270. public function _whlabelexcelzh()
  7271. {
  7272. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7273. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7274. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7275. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7276. $str .= '<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">' . "\n";
  7277. $str .= '<Styles>' . "\n";
  7278. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7279. $str .= '</Styles>' . "\n";
  7280. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7281. $str .= '<Table>' . "\n";
  7282. foreach ($colwidths as $w) {
  7283. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7284. }
  7285. $str .= '<Row>' . "\n";
  7286. foreach ($headers as $h) {
  7287. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7288. }
  7289. $str .= '</Row>' . "\n";
  7290. foreach ($info_list as $row) {
  7291. $str .= '<Row>' . "\n";
  7292. $j = 0;
  7293. foreach ($row as $ke => $va) {
  7294. $va = (string)$va;
  7295. $va = str_replace('<br>', "\n", $va);
  7296. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7297. if ($va === '') {
  7298. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7299. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7300. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7301. } else {
  7302. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7303. }
  7304. $j++;
  7305. }
  7306. $str .= '</Row>' . "\n";
  7307. }
  7308. $str .= '</Table>' . "\n";
  7309. $str .= '</Worksheet>' . "\n";
  7310. $str .= '</Workbook>' . "\n";
  7311. while (ob_get_level()) {
  7312. ob_end_clean();
  7313. }
  7314. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7315. header("Content-Disposition: attachment; filename=" . $filename);
  7316. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7317. header("Pragma: no-cache");
  7318. header("Expires: 0");
  7319. echo $str;
  7320. exit();
  7321. };
  7322. if (isset($_GET['excel'])) {
  7323. $where = "sku != 'Preset'";
  7324. //数据排序
  7325. $order_str = "id desc";
  7326. if (empty($page)) {
  7327. $start = 0;
  7328. $perpage = 1;
  7329. } else {
  7330. $start = ($page - 1) * $perpage;
  7331. }
  7332. $category = $this->input->get('category', true);
  7333. $warehouse = $this->input->get('warehouse', true);
  7334. $excelid = $this->input->get('sid', true);
  7335. if ($category) {
  7336. $where .= " and features like '%-$category-%'";
  7337. }
  7338. if ($warehouse) {
  7339. $where .= " and warehouse = '$warehouse'";
  7340. }
  7341. $xzid = '';
  7342. if ($excelid) {
  7343. $excelid = explode(',', trim($excelid, ','));
  7344. foreach ($excelid as $key => $value) {
  7345. $xzid .= " id = " . $value . " or";
  7346. }
  7347. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7348. }
  7349. $list = array();
  7350. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7351. foreach ($rows as $key => $value) {
  7352. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7353. $zh = '';
  7354. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7355. foreach ($zt as $v) {
  7356. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7357. }
  7358. $zt = array_sum(array_column($zt, 'num'));
  7359. $number = $value['number'];
  7360. $ftime = time() - 15 * 24 * 3600;
  7361. $warehouse = $this->warehouse->read($value['warehouse']);
  7362. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7363. $rows[$key] = array(
  7364. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7365. 'sku' => $value['sku'],
  7366. 'title' => isset($value['title']) ? $value['title'] : '',
  7367. 'number' => $c,
  7368. 'features' => $zh,
  7369. 'hb' => $c + $zt,
  7370. );
  7371. }
  7372. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7373. $filename = $title . ".xls";
  7374. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7375. $numkeys = array('number', 'hb');
  7376. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7377. $colwidths = array(80, 300,450, 50, 120, 80);
  7378. $wrapcols = array(1, 2, 4);
  7379. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7380. }
  7381. if (isset($_GET['excel'])) {
  7382. $warehouse = $this->input->get('warehouse', true);
  7383. $sku = $this->input->get('sku', true);
  7384. $cz = $this->input->get('cz', true);
  7385. $text = $this->input->post('text', true);
  7386. $xztime = $this->input->get('xztime', true);
  7387. $timetk = $this->input->get('timetk', true);
  7388. $timetj = $this->input->get('timetj', true);
  7389. $timetk = strtotime($timetk);
  7390. $timetj = strtotime($timetj);
  7391. $where = "time = '0' ";
  7392. if ($warehouse) {
  7393. $where .= " and warehouse = '$warehouse'";
  7394. }
  7395. if ($sku) {
  7396. $where .= " and sku = '$sku'";
  7397. }
  7398. if ($text) {
  7399. $where .= " and text like '%$text%'";
  7400. }
  7401. if ($cz != '') {
  7402. $where .= " and cz = '$cz'";
  7403. }
  7404. if ($timetk && $timetj) {
  7405. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7406. }
  7407. //数据排序
  7408. $order_str = $xztime . " desc";
  7409. //取得信息列表
  7410. $zh = array();
  7411. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7412. foreach ($info_list as $v) {
  7413. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7414. $warehouse = $this->warehouse->read($v['warehouse']);
  7415. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7416. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7417. $v['stime'] = date('Y-m-d', $v['stime']);
  7418. if (isset($zh[$v['features']])) {
  7419. $zh[$v['features']]['num'] += $v['num'];
  7420. } else {
  7421. $zh[$v['features']] = $v;
  7422. }
  7423. $zh[$v['features']]['features'] = $c;
  7424. }
  7425. $title = "在途数据" . date('Y-m-d', time());
  7426. $filename = $title . ".xls";
  7427. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7428. $numkeys = array('num', 'features');
  7429. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7430. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7431. $wrapcols = array(1, 2, 7);
  7432. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7433. }
  7434. }
  7435. public function _fc()
  7436. {
  7437. $vip = 0;
  7438. if (isset($_SESSION['api'])) {
  7439. $user = $this->user->get_api($_SESSION['api']);
  7440. if ($user['vip'] == 1) {
  7441. $vip = 1;
  7442. }
  7443. } else {
  7444. header('Location: /');
  7445. exit;
  7446. }
  7447. $post = $this->input->post(NULL, TRUE);
  7448. if (isset($post['page'])) {
  7449. $page = $this->input->post('page', true);
  7450. $perpage = $this->input->post('perpage', true);
  7451. $category = $this->input->post('category', true);
  7452. $size = $this->input->post('size', true);
  7453. $grade = $this->input->post('grade', true);
  7454. $color = $this->input->post('color', true);
  7455. $lowe = $this->input->post('lowe', true);
  7456. $sku = $this->input->post('sku');
  7457. $title = $this->input->post('title');
  7458. $warehouse = $this->input->post('warehouse', true);
  7459. $usa = $this->input->post('usa', true);
  7460. $purchase = $this->input->post('purchase', true);
  7461. $lacetype = $this->input->post('lacetype', true);
  7462. $haircap = $this->input->post('haircap', true);
  7463. $density = $this->input->post('density', true);
  7464. $details = $this->input->post('details', true);
  7465. $state = $this->input->post('state', true);
  7466. $ktime = $this->input->post('ktime', true);
  7467. $jtime = $this->input->post('jtime', true);
  7468. $ktime = strtotime($ktime);
  7469. $jtime = strtotime($jtime);
  7470. $where = "state = '11'";
  7471. $gj = "";
  7472. $ck = "";
  7473. if ($lacetype) {
  7474. $where .= " and features like '%-$lacetype-%'";
  7475. }
  7476. if ($category) {
  7477. $where .= " and features like '%-$category-%'";
  7478. }
  7479. if ($size) {
  7480. $where .= " and features like '%-$size-%'";
  7481. }
  7482. if ($grade) {
  7483. $where .= " and features like '%-$grade-%'";
  7484. }
  7485. if ($color) {
  7486. $where .= " and features like '%-$color-%'";
  7487. }
  7488. if ($lowe) {
  7489. $where .= " and features like '%-$lowe-%'";
  7490. }
  7491. if ($haircap) {
  7492. $where .= " and features like '%-$haircap-%'";
  7493. }
  7494. if ($density) {
  7495. $where .= " and features like '%-$density-%'";
  7496. }
  7497. if ($usa) {
  7498. if (!$warehouse) {
  7499. $where .= " and (warehouse = '5' or warehouse = '8')";
  7500. }
  7501. }
  7502. if ($warehouse) {
  7503. $where .= " and warehouse = '$warehouse'";
  7504. }
  7505. if ($details) {
  7506. $where .= " and details = '$details'";
  7507. }
  7508. if ($purchase) {
  7509. $where .= " and purchase = '$purchase'";
  7510. }
  7511. if ($state) {
  7512. $where .= " and state = '$state'";
  7513. }
  7514. if ($ktime && $jtime) {
  7515. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7516. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7517. }
  7518. //数据排序
  7519. $order_str = "id desc";
  7520. if (empty($page)) {
  7521. $start = 0;
  7522. $perpage = 1;
  7523. } else {
  7524. $start = ($page - 1) * $perpage;
  7525. }
  7526. if ($sku) {
  7527. $sku = trim($sku, ' ');
  7528. $sku = trim($sku, ' ');
  7529. $where .= " and sku like '%$sku%'";
  7530. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7531. } else if ($title) {
  7532. $title = trim($title, ' ');
  7533. $title = trim($title, ' ');
  7534. $where .= " and title like '%$title%'";
  7535. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7536. } else {
  7537. //$where .= " and time > '$ktime' and time < '$jtime'";
  7538. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7539. }
  7540. //取得信息列表
  7541. $rows = array();
  7542. $list = array();
  7543. foreach ($info_list as $key => $value) {
  7544. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7545. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7546. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7547. $warehouse = $this->warehouse->read($value['warehouse']);
  7548. $info_list[$key]['warehouse'] = $warehouse['title'];
  7549. $info_list[$key]['number'] = $g;
  7550. $info_list[$key]['features'] = $x;
  7551. $info_list[$key]['x'] = $s;
  7552. }
  7553. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7554. $pagenum = ceil($total / $perpage);
  7555. $over = $total - ($start + $perpage);
  7556. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7557. echo json_encode($rows);
  7558. exit;
  7559. }
  7560. $this->data['vip'] = $vip;
  7561. $this->_Template('whlabel_fc', $this->data);
  7562. }
  7563. public function _fcmb()
  7564. {
  7565. $where = "sku != 'Preset'";
  7566. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7567. foreach ($rows as $k => $v) {
  7568. $warehouse = $this->warehouse->read($v['warehouse']);
  7569. $rows[$k]['warehouse'] = $warehouse['title'];
  7570. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7571. $rows[$k]['t'] = '';
  7572. $rows[$k]['n'] = '';
  7573. }
  7574. $title = "封货产品数据导入模板";
  7575. $titlename = "<table border=1>
  7576. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7577. <tr align='center'>
  7578. <td>仓库</td>
  7579. <td>SKU</td>
  7580. <td>产品</td>
  7581. <td>封存产品总数量</td>
  7582. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7583. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7584. </tr>
  7585. </table>";
  7586. $filename = $title . ".xls";
  7587. $tail = "";
  7588. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7589. }
  7590. public function _fcexcel()
  7591. {
  7592. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7593. $config['upload_path'] = '.' . $dir;
  7594. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7595. $config['allowed_types'] = 'xls|xlsx|csv';
  7596. $config['max_size'] = 10240;
  7597. $this->load->library('upload', $config);
  7598. $this->upload->initialize($config);
  7599. if ($this->upload->do_upload('userfile')) {
  7600. $full_path = $dir . $this->upload->data('file_name');
  7601. $fileName = '.' . $full_path;
  7602. if (!file_exists($fileName)) {
  7603. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7604. exit;
  7605. } else {
  7606. libxml_use_internal_errors(true);
  7607. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7608. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7609. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7610. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7611. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7612. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7613. ++$column; //如果列数大于26行
  7614. $list = array();
  7615. for ($i = 2; $i <= $row; $i++) // 行数循环
  7616. {
  7617. $data = array();
  7618. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7619. {
  7620. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7621. }
  7622. $list[] = $data;
  7623. }
  7624. }
  7625. $i = 0;
  7626. $j = 0;
  7627. $ed = array();
  7628. foreach ($list as $key => $value) {
  7629. $time = time();
  7630. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7631. continue;
  7632. }
  7633. $warehouse = $this->warehouse->get_title($value['0']);
  7634. $sku = $value['1'];
  7635. $type = $value['4']; //调整方式0扣减1删除
  7636. $num = $value['5']; //调整数量
  7637. //$text = $value['4'];//扣减说明
  7638. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7639. if (!$d) //如果没有这个SKU
  7640. {
  7641. $ed[] = array($sku . '-库存中不存在此SKU');
  7642. $j++;
  7643. continue;
  7644. }
  7645. if (!isset($warehouse['id'])) {
  7646. $ed[] = array($sku . '-仓库名错误!');
  7647. $j++;
  7648. continue;
  7649. }
  7650. if ($type == 1 || $type == 2) //扣减库存
  7651. {
  7652. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7653. if (count($data) < abs($num)) {
  7654. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7655. $j++;
  7656. continue;
  7657. }
  7658. if ($type == 1) //转入库存
  7659. {
  7660. for ($i = 0; $i < abs($num); $i++) {
  7661. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7662. }
  7663. } else if ($type == 2) //删除
  7664. {
  7665. for ($i = 0; $i < abs($num); $i++) {
  7666. $this->whlabel->remove($data[$i]['id']);
  7667. }
  7668. }
  7669. } else if ($type == 0) //增加库存
  7670. {
  7671. $post['sku'] = $d['sku'];
  7672. $post['shop'] = '';
  7673. $post['warehouse'] = $warehouse['id'];
  7674. $post['purchase'] = $d['purchase'];
  7675. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7676. $post['state'] = 11;
  7677. $post['title'] = $d['title'];
  7678. $post['number'] = $d['number'];
  7679. $post['features'] = $d['features'];
  7680. $post['enter'] = $time;
  7681. $post['time'] = $time; //操作时间
  7682. for ($i = 0; $i < $num; $i++) {
  7683. $post['label'] = time() . rand(100, 999) . $i;
  7684. $this->whlabel->insert($post);
  7685. }
  7686. }
  7687. sleep(1); //防止入库时间一样,需要延迟1秒
  7688. }
  7689. if ($j > 0) {
  7690. $tt = date('Ymd', time());
  7691. $title = '库存导入错误信息-' . $tt;
  7692. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7693. $tail = "\n";
  7694. $filename = $title . ".xls";
  7695. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7696. $dir = '/data/excel/' . $time . '/';
  7697. $file_name = 'error_' . $time . rand(1000, 9999);
  7698. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7699. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7700. fwrite($myfile, $ecl);
  7701. fclose($myfile);
  7702. $error = $dir . $file_name . '.xls';
  7703. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7704. exit;
  7705. } else {
  7706. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7707. exit;
  7708. }
  7709. }
  7710. }
  7711. public function _fcjxc($arg_array)
  7712. {
  7713. if (isset($_GET['excel'])) {
  7714. $category = $this->input->get('category', true);
  7715. $size = $this->input->get('size', true);
  7716. $grade = $this->input->get('grade', true);
  7717. $color = $this->input->get('color', true);
  7718. $lowe = $this->input->get('lowe', true);
  7719. $sku = $this->input->get('sku');
  7720. $title = $this->input->get('title');
  7721. $warehouse = $arg_array[0];
  7722. $usa = $this->input->get('usa', true);
  7723. $purchase = $this->input->get('purchase', true);
  7724. $lacetype = $this->input->get('lacetype', true);
  7725. $haircap = $this->input->get('haircap', true);
  7726. $density = $this->input->get('density', true);
  7727. $title = $this->input->get('title', true);
  7728. $state = $this->input->get('state', true);
  7729. $ktime = $this->input->get('ktime', true);
  7730. $jtime = $this->input->get('jtime', true);
  7731. $where = "state=11";
  7732. $gj = "";
  7733. $ck = "";
  7734. if ($lacetype) {
  7735. $where .= " and features like '%-$lacetype-%'";
  7736. }
  7737. if ($category) {
  7738. $where .= " and features like '%-$category-%'";
  7739. }
  7740. if ($size) {
  7741. $where .= " and features like '%-$size-%'";
  7742. }
  7743. if ($grade) {
  7744. $where .= " and features like '%-$grade-%'";
  7745. }
  7746. if ($color) {
  7747. $where .= " and features like '%-$color-%'";
  7748. }
  7749. if ($lowe) {
  7750. $where .= " and features like '%-$lowe-%'";
  7751. }
  7752. if ($haircap) {
  7753. $where .= " and features like '%-$haircap-%'";
  7754. }
  7755. if ($density) {
  7756. $where .= " and features like '%-$density-%'";
  7757. }
  7758. if ($usa) {
  7759. if (!$warehouse) {
  7760. $where .= " and (warehouse = '5' or warehouse = '8')";
  7761. }
  7762. }
  7763. if ($warehouse) {
  7764. $where .= " and warehouse = '$warehouse'";
  7765. }
  7766. if ($purchase) {
  7767. $where .= " and purchase = '$purchase'";
  7768. }
  7769. if ($state) {
  7770. $where .= " and state = '$state'";
  7771. }
  7772. $order_str = "id desc";
  7773. if ($sku) {
  7774. $sku = trim($sku, ' ');
  7775. $sku = trim($sku, ' ');
  7776. $where .= " and sku like '%$sku%'";
  7777. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7778. } else if ($title) {
  7779. $title = trim($title, ' ');
  7780. $title = trim($title, ' ');
  7781. $where .= " and title like '%$title%'";
  7782. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7783. } else {
  7784. //$where .= " and time > '$ktime' and time < '$jtime'";
  7785. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7786. }
  7787. //取得信息列表
  7788. $rows = array();
  7789. $list = array();
  7790. foreach ($info_list as $key => $value) {
  7791. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7792. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7793. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7794. $rows[$key] = $value;
  7795. $warehouse = $this->warehouse->read($value['warehouse']);
  7796. $rows[$key]['warehouse'] = $warehouse['title'];
  7797. $rows[$key]['features'] = $g;
  7798. $rows[$key]['a'] = $x;
  7799. $rows[$key]['b'] = $s;
  7800. }
  7801. $title = "总统计表";
  7802. $titlename = "<table border=1>
  7803. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7804. <tr align='center'>
  7805. <td>仓库</td>
  7806. <td>SKU</td>
  7807. <td>产品名称</td>
  7808. <td>录入总量</td>
  7809. <td>取出总量</td>
  7810. <td>剩余总量</td>
  7811. </tr>
  7812. </table>";
  7813. $filename = $title . ".xls";
  7814. $tail = "";
  7815. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7816. }
  7817. $vip = 0;
  7818. if (isset($_SESSION['api'])) {
  7819. $user = $this->user->get_api($_SESSION['api']);
  7820. if ($user['vip'] == 1) {
  7821. $vip = 1;
  7822. }
  7823. } else {
  7824. header('Location: /');
  7825. exit;
  7826. }
  7827. $post = $this->input->post(NULL, TRUE);
  7828. if (isset($post['page'])) {
  7829. $page = $this->input->post('page', true);
  7830. $perpage = $this->input->post('perpage', true);
  7831. $category = $this->input->post('category', true);
  7832. $size = $this->input->post('size', true);
  7833. $grade = $this->input->post('grade', true);
  7834. $color = $this->input->post('color', true);
  7835. $lowe = $this->input->post('lowe', true);
  7836. $sku = $this->input->post('sku');
  7837. $title = $this->input->post('title');
  7838. $warehouse = $arg_array[0];
  7839. $usa = $this->input->post('usa', true);
  7840. $purchase = $this->input->post('purchase', true);
  7841. $lacetype = $this->input->post('lacetype', true);
  7842. $haircap = $this->input->post('haircap', true);
  7843. $density = $this->input->post('density', true);
  7844. $title = $this->input->post('title', true);
  7845. $state = $this->input->post('state', true);
  7846. $ktime = $this->input->post('ktime', true);
  7847. $jtime = $this->input->post('jtime', true);
  7848. $ktime = strtotime($ktime);
  7849. $jtime = strtotime($jtime);
  7850. $where = "state=11";
  7851. $gj = "";
  7852. $ck = "";
  7853. if ($lacetype) {
  7854. $where .= " and features like '%-$lacetype-%'";
  7855. }
  7856. if ($category) {
  7857. $where .= " and features like '%-$category-%'";
  7858. }
  7859. if ($size) {
  7860. $where .= " and features like '%-$size-%'";
  7861. }
  7862. if ($grade) {
  7863. $where .= " and features like '%-$grade-%'";
  7864. }
  7865. if ($color) {
  7866. $where .= " and features like '%-$color-%'";
  7867. }
  7868. if ($lowe) {
  7869. $where .= " and features like '%-$lowe-%'";
  7870. }
  7871. if ($haircap) {
  7872. $where .= " and features like '%-$haircap-%'";
  7873. }
  7874. if ($density) {
  7875. $where .= " and features like '%-$density-%'";
  7876. }
  7877. if ($usa) {
  7878. if (!$warehouse) {
  7879. $where .= " and (warehouse = '5' or warehouse = '8')";
  7880. }
  7881. }
  7882. if ($warehouse) {
  7883. $where .= " and warehouse = '$warehouse'";
  7884. }
  7885. if ($purchase) {
  7886. $where .= " and purchase = '$purchase'";
  7887. }
  7888. if ($state) {
  7889. $where .= " and state = '$state'";
  7890. }
  7891. if ($ktime && $jtime) {
  7892. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7893. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7894. }
  7895. //数据排序
  7896. $order_str = "id desc";
  7897. $xs = 0;
  7898. $rows = array();
  7899. $list = array();
  7900. if (empty($page)) {
  7901. $start = 0;
  7902. $perpage = 1;
  7903. } else {
  7904. $start = ($page - 1) * $perpage;
  7905. }
  7906. if ($sku || $title) {
  7907. if ($title) {
  7908. $title = trim($title, ' ');
  7909. $title = trim($title, ' ');
  7910. $where .= " and title like '%$title%'";
  7911. } else {
  7912. $sku = trim($sku, ' ');
  7913. $sku = trim($sku, ' ');
  7914. $where .= " and sku like '%$sku%'";
  7915. }
  7916. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7917. foreach ($info_list as $key => $value) {
  7918. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7919. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7920. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7921. $rows[$key] = $value;
  7922. $warehouse = $this->warehouse->read($value['warehouse']);
  7923. $rows[$key]['warehouse'] = $warehouse['title'];
  7924. $rows[$key]['features'] = $g;
  7925. $rows[$key]['a'] = $x;
  7926. $rows[$key]['b'] = $s;
  7927. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7928. $xl = $this->whlabel->find_count($where . " and outk > '" . (time() - 30 * 24 * 3600) . "' and outk < '" . time() . "'" . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"'); //30天销量
  7929. $yj = $c / ($xl / 30);
  7930. if ($yj < 7) {
  7931. $rows[$key]['y'] = round($yj) . '天销量';
  7932. } else {
  7933. $rows[$key]['y'] = '正常';
  7934. }
  7935. }
  7936. } else {
  7937. //$where .= " and time > '$ktime' and time < '$jtime'";
  7938. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7939. foreach ($info_list as $key => $value) {
  7940. $g = $this->whlabel->find_count($where . ' and (oldstate = "11" or state = "11") and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state != "9" and features = "' . $value['features'] . '"');
  7941. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7942. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7943. $zs[$key] = $value;
  7944. $warehouse = $this->warehouse->read($value['warehouse']);
  7945. $zs[$key]['warehouse'] = $warehouse['title'];
  7946. $zs[$key]['features'] = $g;
  7947. $zs[$key]['a'] = $x;
  7948. $zs[$key]['b'] = $s;
  7949. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7950. $xl = $this->whlabel->find_count($where . " and outk > '" . (time() - 30 * 24 * 3600) . "' and outk < '" . time() . "'" . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"'); //30天销量
  7951. $yj = $c / ($xl / 30);
  7952. if ($yj < 7) {
  7953. $zs[$key]['y'] = round($yj) . '天销量';
  7954. $rows[$key] = $zs[$key];
  7955. }
  7956. }
  7957. }
  7958. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7959. $pagenum = ceil($total / $perpage);
  7960. $over = $total - ($start + $perpage);
  7961. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7962. echo json_encode($rows);
  7963. exit;
  7964. }
  7965. $this->data['arg_array'] = $arg_array[0];
  7966. $this->_Template('whlabel_fcjxc', $this->data);
  7967. }
  7968. public function _0kcdel()
  7969. {
  7970. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7971. $config['upload_path'] = '.' . $dir;
  7972. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7973. $config['allowed_types'] = 'xls|xlsx|csv';
  7974. $config['max_size'] = 10240;
  7975. $this->load->library('upload', $config);
  7976. $this->upload->initialize($config);
  7977. if ($this->upload->do_upload('userfile')) {
  7978. $full_path = $dir . $this->upload->data('file_name');
  7979. $fileName = '.' . $full_path;
  7980. if (!file_exists($fileName)) {
  7981. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7982. exit;
  7983. } else {
  7984. require_once "./data/excel/PHPExcel/IOFactory.php";
  7985. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7986. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7987. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7988. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7989. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7990. ++$column; //如果列数大于26行
  7991. $list = array();
  7992. for ($i = 2; $i <= $row; $i++) // 行数循环
  7993. {
  7994. $data = array();
  7995. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7996. {
  7997. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7998. }
  7999. $list[] = $data;
  8000. }
  8001. }
  8002. $i = 0;
  8003. $j = 0;
  8004. $ed = array();
  8005. foreach ($list as $key => $value) {
  8006. $time = time();
  8007. if ($value['0'] == "" || $value['1'] == "") {
  8008. continue;
  8009. }
  8010. $warehouse = $this->warehouse->get_title($value['0']);
  8011. $sku = $value['1'];
  8012. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  8013. if (!$d) //如果没有这个SKU
  8014. {
  8015. $ed[] = array($sku . '-库存中不存在此SKU');
  8016. $j++;
  8017. continue;
  8018. }
  8019. if (!isset($warehouse['id'])) {
  8020. $ed[] = array($sku . '-仓库名错误!');
  8021. $j++;
  8022. continue;
  8023. }
  8024. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  8025. if ($z < 1) {
  8026. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  8027. foreach ($z as $v) {
  8028. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  8029. if (count($zt) > 0) {
  8030. $ed[] = array($sku . '-有在途库存无法删除!');
  8031. $j++;
  8032. continue;
  8033. }
  8034. $tmp_info = $v;
  8035. $tmp_info['del_time'] = time();
  8036. $this->db->insert('whlabelscbf',$tmp_info);
  8037. $this->whlabel->remove($v['id']);
  8038. }
  8039. } else {
  8040. $ed[] = array($sku . '-非0库存!');
  8041. $j++;
  8042. continue;
  8043. }
  8044. }
  8045. if ($j > 0) {
  8046. $tt = date('Ymd', time());
  8047. $title = '删除0库存错误信息-' . $tt;
  8048. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8049. $tail = "\n";
  8050. $filename = $title . ".xls";
  8051. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  8052. $dir = '/data/excel/' . $time . '/';
  8053. $file_name = 'error_' . $time . rand(1000, 9999);
  8054. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  8055. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  8056. fwrite($myfile, $ecl);
  8057. fclose($myfile);
  8058. $error = $dir . $file_name . '.xls';
  8059. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  8060. exit;
  8061. } else {
  8062. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  8063. exit;
  8064. }
  8065. }
  8066. }
  8067. public function _gbhtype()
  8068. {
  8069. $post = $this->input->post(NULL, TRUE);
  8070. if (isset($post['s'])) {
  8071. $n = $this->input->post('n');
  8072. $d = $this->input->post('s');
  8073. if (!$d) {
  8074. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8075. exit;
  8076. }
  8077. $d = explode(',', trim($d, ','));
  8078. $t = $this->whlabel_type->read($n);
  8079. //循环删除记录
  8080. foreach ($d as $v) {
  8081. $u = $this->whlabel->read($v);
  8082. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8083. foreach ($data as $val) {
  8084. $this->whlabel->save(array('type' => $n), $val['id']);
  8085. }
  8086. }
  8087. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8088. }
  8089. }
  8090. //出库、退库导出
  8091. public function _dccrtype()
  8092. {
  8093. $classid = $this->classid->sku();
  8094. $pm = $classid;
  8095. $typeclass = array();
  8096. $tc = $this->typeclass->find_all();
  8097. foreach ($tc as $v) {
  8098. $typeclass[$v['id']] = $v;
  8099. }
  8100. $prc = array();
  8101. $purchase = $this->purchase->find_all();
  8102. foreach ($purchase as $k => $v) {
  8103. $prc[$v['id']] = $v['title'];
  8104. }
  8105. if (isset($_GET['sid'])) {
  8106. $wh = array();
  8107. $w = $this->warehouse->find_all('1=1', 'id,title');
  8108. foreach ($w as $v) {
  8109. $wh[$v['id']] = $v['title'];
  8110. }
  8111. $type = $this->input->get('excel', true);
  8112. $category = $this->input->get('category', true);
  8113. $size = $this->input->get('size', true);
  8114. $grade = $this->input->get('grade', true);
  8115. $color = $this->input->get('color', true);
  8116. $lowe = $this->input->get('lowe', true);
  8117. $sku = $this->input->get('sku', true);
  8118. $warehouse = $this->input->get('warehouse', true);
  8119. $lacetype = $this->input->get('lacetype', true);
  8120. $lacecolor = $this->input->get('lacecolor', true);
  8121. $density = $this->input->get('density', true);
  8122. $haircap = $this->input->get('haircap', true);
  8123. $purchase = $this->input->get('purchase', true);
  8124. $title = $this->input->get('title', true);
  8125. $state = $this->input->get('state', true);
  8126. $sid = $this->input->get('sid', true);
  8127. $ktime = $this->input->get('ktime', true);
  8128. $jtime = $this->input->get('jtime', true);
  8129. $ktime = strtotime($ktime);
  8130. $jtime = strtotime($jtime);
  8131. $where = "1=1";
  8132. $gj = "";
  8133. $ck = "";
  8134. if ($category) {
  8135. $where .= " and features like '%-$category-%'";
  8136. }
  8137. if ($size) {
  8138. $where .= " and features like '%-$size-%'";
  8139. }
  8140. if ($grade) {
  8141. $where .= " and features like '%-$grade-%'";
  8142. }
  8143. if ($color) {
  8144. $where .= " and features like '%-$color-%'";
  8145. }
  8146. if ($lowe) {
  8147. $where .= " and features like '%-$lowe-%'";
  8148. }
  8149. if ($warehouse) {
  8150. $where .= " and warehouse = '$warehouse'";
  8151. }
  8152. if ($purchase) {
  8153. $where .= " and purchase = '$purchase'";
  8154. }
  8155. if ($state) {
  8156. $where .= " and state = '$state'";
  8157. }
  8158. if ($lacetype) {
  8159. $where .= " and features like '%-$lacetype-%'";
  8160. }
  8161. if ($lacecolor) {
  8162. $where .= " and features like '%-$lacecolor-%'";
  8163. }
  8164. if ($density) {
  8165. $where .= " and features like '%-$density-%'";
  8166. }
  8167. if ($haircap) {
  8168. $where .= " and features like '%-$haircap-%'";
  8169. }
  8170. if ($title) {
  8171. $title = trim($title, ' ');
  8172. $title = trim($title, ' ');
  8173. $where .= " and title like '%$title%'";
  8174. }
  8175. if ($sku) {
  8176. $sku = trim($sku, ' ');
  8177. $sku = trim($sku, ' ');
  8178. $where .= " and sku like '%$sku%'";
  8179. }
  8180. if ($ktime && $jtime) {
  8181. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8182. }
  8183. $sidwhere = '';
  8184. if ($sid) {
  8185. $sd = "";
  8186. $s = explode(',', trim($sid, ','));
  8187. foreach ($s as $value) {
  8188. $sd .= " id = " . $value . " or";
  8189. }
  8190. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8191. }
  8192. //数据排序
  8193. $order_str = "time desc";
  8194. if (empty($page)) {
  8195. $start = 0;
  8196. $perpage = 1;
  8197. } else {
  8198. $start = ($page - 1) * $perpage;
  8199. }
  8200. $wh = array();
  8201. $w = $this->warehouse->find_all('1=1', 'id,title');
  8202. foreach ($w as $v) {
  8203. $wh[$v['id']] = $v['title'];
  8204. }
  8205. $wt = array();
  8206. $whlabel_type = $this->whlabel_type->find_all();
  8207. foreach ($whlabel_type as $v) {
  8208. $wt[$v['id']] = $v['title'];
  8209. }
  8210. $classid = $this->classid->sku();
  8211. $list = array();
  8212. $rows_r = $this->whlabel->find_pc($where . " and enter > '$ktime' and enter < '$jtime' " . $sidwhere, 'sku,features,warehouse,enter', 'warehouse,sku,title,zh,features,time,enter,rktype,number,text');
  8213. foreach ($rows_r as $key => $value) {
  8214. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8215. $pm = $classid;
  8216. $jm = $classid;
  8217. $rows_r[$key]['enter'] = '入库';
  8218. $rows_r[$key]['time'] = $value['enter'];
  8219. if ($value['rktype'] == 1) {
  8220. $rows_r[$key]['rktype'] = '采购入库';
  8221. } else if ($value['rktype'] == 2) {
  8222. $rows_r[$key]['rktype'] = '盘盈调整';
  8223. } else if ($value['rktype'] == 3) {
  8224. $rows_r[$key]['rktype'] = '其他调整入库';
  8225. } else if ($value['rktype'] == 4) {
  8226. $rows_r[$key]['rktype'] = '其他调整入库';
  8227. } else if ($value['rktype'] == 5) {
  8228. $rows_r[$key]['rktype'] = '退库入库';
  8229. } else if ($value['rktype'] == 6) {
  8230. $rows_r[$key]['rktype'] = '退货可用入库';
  8231. } else if ($value['rktype'] == 7) {
  8232. $rows_r[$key]['rktype'] = '形态转换入库';
  8233. } else {
  8234. $rows_r[$key]['rktype'] = '';
  8235. }
  8236. $features = explode('-', trim($value['features'], '-'));
  8237. foreach ($features as $v) {
  8238. if (isset($typeclass[$v])) {
  8239. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8240. $pm[$typeclass[$v]['classid']] = $zh[0];
  8241. }
  8242. if (isset($typeclass[$v])) {
  8243. if (isset($jm[$typeclass[$v]['classid']])) {
  8244. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8245. }
  8246. }
  8247. }
  8248. $zh = implode(" ", $pm);
  8249. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8250. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8251. $rows_r[$key]['zh'] = $zh;
  8252. $jm = array_filter($jm);
  8253. $rows_r[$key]['features'] = implode("-", $jm);
  8254. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8255. }
  8256. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  8257. foreach ($rows_c as $key => $value) {
  8258. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8259. $pm = $classid;
  8260. $jm = $classid;
  8261. $rows_c[$key]['time'] = $value['outk'];
  8262. $rows_c[$key]['outk'] = '出库';
  8263. if ($value['cktype'] == 1) {
  8264. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8265. } else if ($value['cktype'] == 2) {
  8266. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8267. } else if ($value['cktype'] == 3) {
  8268. $rows_c[$key]['cktype'] = '盘亏调整';
  8269. } else if ($value['cktype'] == 4) {
  8270. $rows_c[$key]['cktype'] = '其他调整出库';
  8271. } else if ($value['cktype'] == 5) {
  8272. $rows_c[$key]['cktype'] = '形态转换出库';
  8273. } else {
  8274. $rows_c[$key]['cktype'] = '';
  8275. }
  8276. unset($rows_c[$key]['state']);
  8277. $features = explode('-', trim($value['features'], '-'));
  8278. foreach ($features as $v) {
  8279. if (isset($typeclass[$v])) {
  8280. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8281. $pm[$typeclass[$v]['classid']] = $zh[0];
  8282. }
  8283. if (isset($typeclass[$v])) {
  8284. if (isset($jm[$typeclass[$v]['classid']])) {
  8285. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8286. }
  8287. }
  8288. }
  8289. $zh = implode(" ", $pm);
  8290. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8291. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8292. $rows_c[$key]['zh'] = $zh;
  8293. $jm = array_filter($jm);
  8294. $rows_c[$key]['features'] = implode("-", $jm);
  8295. $rows_c[$key]['number'] = 1;
  8296. }
  8297. $merged = $rows_r;
  8298. foreach ($rows_c as $key => $value) {
  8299. if (isset($merged[$key])) {
  8300. $merged[] = $value;
  8301. } else {
  8302. $merged[$key] = $value;
  8303. }
  8304. }
  8305. usort($merged, function ($a, $b) {
  8306. return $a['time'] - $b['time'];
  8307. });
  8308. foreach ($merged as $key => $value) {
  8309. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8310. }
  8311. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8312. $titlename = "<table border=1>
  8313. <tr align='center'>
  8314. <td>仓库</td>
  8315. <td>SKU</td>
  8316. <td>商品名称</td>
  8317. <td>仓库品名</td>
  8318. <td>料号</td>
  8319. <td>时间</td>
  8320. <td>操作</td>
  8321. <td>类型</td>
  8322. <td>数量</td>
  8323. <td>备注</td>
  8324. </tr>
  8325. </table>";
  8326. $filename = $title . ".xlsx";
  8327. $tail = "";
  8328. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8329. }
  8330. }
  8331. /*************************************处理exceljs导出****************************************************/
  8332. public function _excelrjs(){
  8333. if (isset($_GET['excel'])) {
  8334. $category = $this->input->get('category', true);
  8335. $size = $this->input->get('size', true);
  8336. $grade = $this->input->get('grade', true);
  8337. $color = $this->input->get('color', true);
  8338. $lowe = $this->input->get('lowe', true);
  8339. $sku = $this->input->get('sku', true);
  8340. $warehouse = $this->input->get('warehouse', true);
  8341. $purchase = $this->input->get('purchase', true);
  8342. $ktime = $this->input->get('ktime', true);
  8343. $jtime = $this->input->get('jtime', true);
  8344. $ktime = strtotime($ktime);
  8345. $jtime = strtotime($jtime);
  8346. $where = "1=1";
  8347. $gj = "";
  8348. $ck = "";
  8349. if ($category) {
  8350. $where .= " and features like '%-$category-%'";
  8351. }
  8352. if ($size) {
  8353. $where .= " and features like '%-$size-%'";
  8354. }
  8355. if ($grade) {
  8356. $where .= " and features like '%-$grade-%'";
  8357. }
  8358. if ($color) {
  8359. $where .= " and features like '%-$color-%'";
  8360. }
  8361. if ($lowe) {
  8362. $where .= " and features like '%-$lowe-%'";
  8363. }
  8364. if ($warehouse) {
  8365. $where .= " and warehouse = '$warehouse'";
  8366. }
  8367. if ($purchase) {
  8368. $where .= " and purchase = '$purchase'";
  8369. }
  8370. if ($sku) {
  8371. $where .= " and sku = '$sku'";
  8372. }
  8373. if ($ktime && $jtime) {
  8374. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8375. }
  8376. //数据排序
  8377. $order_str = "id desc";
  8378. if (empty($page)) {
  8379. $start = 0;
  8380. $perpage = 1;
  8381. } else {
  8382. $start = ($page - 1) * $perpage;
  8383. }
  8384. $list = array();
  8385. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8386. foreach ($rows as $value) {
  8387. $ck = $this->warehouse->read($value['warehouse']);
  8388. $warehouse = $ck['title'];
  8389. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8390. $retreatwarehouse = $tkck['title'];
  8391. $gy = $this->purchase->read($value['purchase']);
  8392. $purchase = $gy['title'];
  8393. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8394. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8395. }
  8396. if(empty($list)){
  8397. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8398. }else{
  8399. $final_list = [];
  8400. foreach($list as $v){
  8401. $final_list[] = array_values($v);
  8402. }
  8403. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8404. array_unshift($final_list,[
  8405. "仓库","SKU","商品名称","时间","数量"
  8406. ]);
  8407. array_unshift($final_list,[
  8408. $title,"","","",""
  8409. ]);
  8410. $merges = [
  8411. [
  8412. "s"=>["r"=>0,"c"=>0],
  8413. "e"=>["r"=>0,"c"=>4]
  8414. ]
  8415. ];
  8416. $cols = [
  8417. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8418. ];
  8419. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8420. }
  8421. }
  8422. }
  8423. //出库、退库导出
  8424. public function _excelctjs()
  8425. {
  8426. $classid = $this->classid->sku();
  8427. $pm = $classid;
  8428. $typeclass = array();
  8429. $tc = $this->typeclass->find_all();
  8430. foreach ($tc as $v) {
  8431. $typeclass[$v['id']] = $v;
  8432. }
  8433. $prc = array();
  8434. $purchase = $this->purchase->find_all();
  8435. foreach ($purchase as $k => $v) {
  8436. $prc[$v['id']] = $v['title'];
  8437. }
  8438. if (isset($_GET['excel'])) {
  8439. $wh = array();
  8440. $w = $this->warehouse->find_all('1=1', 'id,title');
  8441. foreach ($w as $v) {
  8442. $wh[$v['id']] = $v['title'];
  8443. }
  8444. $type = $this->input->get('excel', true);
  8445. $category = $this->input->get('category', true);
  8446. $size = $this->input->get('size', true);
  8447. $grade = $this->input->get('grade', true);
  8448. $color = $this->input->get('color', true);
  8449. $lowe = $this->input->get('lowe', true);
  8450. $sku = $this->input->get('sku', true);
  8451. $title = $this->input->get('title', true);
  8452. $warehouse = $this->input->get('warehouse', true);
  8453. $purchase = $this->input->get('purchase', true);
  8454. $lacetype = $this->input->get('lacetype', true);
  8455. $haircap = $this->input->get('haircap', true);
  8456. $lacecolor = $this->input->get('lacecolor', true);
  8457. $density = $this->input->get('density', true);
  8458. $details = $this->input->get('details', true);
  8459. $state = $this->input->get('state', true);
  8460. $shop = $this->input->get('shop', true);
  8461. $hairnumber = $this->input->get('hairnumber', true);
  8462. $type_leixi = $this->input->get('type', true);
  8463. $cpbz = $this->input->get('cpbz', true);
  8464. $sm = $this->input->get('sm', true);
  8465. $sid = $this->input->get('sid', true);
  8466. $ktime = $this->input->get('ktime', true);
  8467. $jtime = $this->input->get('jtime', true);
  8468. $ktime = strtotime($ktime);
  8469. $jtime = strtotime($jtime);
  8470. //$where = " 1=1 ";
  8471. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8472. $where = " sku != '' ";
  8473. $gj = "";
  8474. $ck = "";
  8475. if ($category) {
  8476. $where .= " and features like '%-$category-%'";
  8477. }
  8478. if ($size) {
  8479. $where .= " and features like '%-$size-%'";
  8480. }
  8481. if ($grade) {
  8482. $where .= " and features like '%-$grade-%'";
  8483. }
  8484. if ($color) {
  8485. $where .= " and features like '%-$color-%'";
  8486. }
  8487. if ($lowe) {
  8488. $where .= " and features like '%-$lowe-%'";
  8489. }
  8490. if ($warehouse) {
  8491. $where .= " and warehouse = '$warehouse'";
  8492. }
  8493. if ($purchase) {
  8494. $where .= " and purchase = '$purchase'";
  8495. }
  8496. if ($state) {
  8497. $where .= " and state = '$state'";
  8498. }
  8499. if ($lacetype) {
  8500. $where .= " and features like '%-$lacetype-%'";
  8501. }
  8502. if ($lacecolor) {
  8503. $where .= " and features like '%-$lacecolor-%'";
  8504. }
  8505. if ($density) {
  8506. $where .= " and features like '%-$density-%'";
  8507. }
  8508. if ($haircap) {
  8509. $where .= " and features like '%-$haircap-%'";
  8510. }
  8511. if ($details) {
  8512. $where .= " and details = '$details'";
  8513. }
  8514. if ($shop) {
  8515. $where .= " and shop like '%$shop%'";
  8516. }
  8517. if ($title) {
  8518. $title = trim($title, ' ');
  8519. $title = trim($title, ' ');
  8520. $where .= " and title like '%$title%'";
  8521. }
  8522. if (!empty($hairnumber)) {
  8523. $where .= " and features like '%-128-%' ";
  8524. if ($hairnumber < 0) {
  8525. $class_list = $this->typeclass->find_all('classid = 43');
  8526. foreach ($class_list as $v) {
  8527. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8528. }
  8529. } else {
  8530. $where .= " and features like '%-$hairnumber-%'";
  8531. }
  8532. }
  8533. if ($type_leixi) {
  8534. $where .= " and type = '$type_leixi'";
  8535. }
  8536. if ($cpbz) {
  8537. $where .= " and cpbz like '%$cpbz%' ";
  8538. }
  8539. if ($sm) {
  8540. $where .= " and sm like '%$sm%' ";
  8541. }
  8542. if ($sku) {
  8543. $sku = trim($sku, ' ');
  8544. $sku = trim($sku, ' ');
  8545. $where .= " and sku like '%$sku%'";
  8546. }
  8547. if ($ktime && $jtime) {
  8548. if ($type == 1) {
  8549. $tl = '出库';
  8550. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8551. } else if ($type == 2) {
  8552. $tl = '退库';
  8553. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8554. } else if ($type == 3) {
  8555. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8556. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8557. } else if ($type == 4) {
  8558. $tl = '出库+零售';
  8559. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8560. } else if ($type == 5) {
  8561. $tl = '零售';
  8562. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8563. }
  8564. }
  8565. $sidwhere = '';
  8566. if ($sid) {
  8567. $sd = "";
  8568. $s = explode(',', trim($sid, ','));
  8569. foreach ($s as $value) {
  8570. $sd .= " id = " . $value . " or";
  8571. }
  8572. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8573. }
  8574. //数据排序
  8575. $order_str = "time desc";
  8576. if (empty($page)) {
  8577. $start = 0;
  8578. $perpage = 1;
  8579. } else {
  8580. $start = ($page - 1) * $perpage;
  8581. }
  8582. //取得信息列表
  8583. if ($type != 3 && $type != 5) {
  8584. if ($type == 1 || $type == 4) {
  8585. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8586. foreach ($info_list as $key => $value) {
  8587. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8588. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8589. $warehouse = $this->warehouse->read($value['warehouse']);
  8590. $info_list[$key]['warehouse'] = $warehouse['title'];
  8591. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8592. $features = explode('-', trim($features, '-'));
  8593. $pm = $classid;
  8594. foreach ($features as $k => $v) {
  8595. if ($v != 0) {
  8596. if (!isset($typeclass[$v])) {
  8597. continue;
  8598. }
  8599. if (isset($pm[$typeclass[$v]['classid']])) {
  8600. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8601. $tz = explode('|', $typeclass[$v]['zh']);
  8602. $pm[$typeclass[$v]['classid']] = $tz[0];
  8603. } else {
  8604. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8605. }
  8606. }
  8607. }
  8608. }
  8609. $zh = implode(" ", $pm);
  8610. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8611. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8612. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8613. $info_list[$key]['features'] = $zh;
  8614. }
  8615. $final_list = [];
  8616. foreach($info_list as $k=>$v){
  8617. $number = "";
  8618. if(!empty($v['orderinfo'])){
  8619. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8620. if(!empty($tmp_info['number'])){
  8621. $number = $tmp_info['number'];
  8622. }
  8623. }
  8624. $final_list[] = [
  8625. 'warehouse'=>$v['warehouse'],
  8626. 'purchase'=>$v['purchase'],
  8627. 'sku'=>$v['sku'],
  8628. 'title'=>$v['title'],
  8629. 'features'=>$v['features'],
  8630. 'label'=>$v['label'],
  8631. 'orderinfo'=>$v['orderinfo'],
  8632. 'number'=>$number,
  8633. 'waybill'=>$v['waybill'],
  8634. 'outk'=>$v['outk'],
  8635. ];
  8636. }
  8637. } else {
  8638. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8639. foreach ($info_list as $key => $value) {
  8640. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8641. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8642. $warehouse = $this->warehouse->read($value['warehouse']);
  8643. $info_list[$key]['warehouse'] = $warehouse['title'];
  8644. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8645. $features = explode('-', trim($features, '-'));
  8646. $pm = $classid;
  8647. foreach ($features as $k => $v) {
  8648. if ($v != 0) {
  8649. if (!isset($typeclass[$v])) {
  8650. continue;
  8651. }
  8652. if (isset($pm[$typeclass[$v]['classid']])) {
  8653. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8654. $tz = explode('|', $typeclass[$v]['zh']);
  8655. $pm[$typeclass[$v]['classid']] = $tz[0];
  8656. } else {
  8657. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8658. }
  8659. }
  8660. }
  8661. }
  8662. $zh = implode(" ", $pm);
  8663. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8664. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8665. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8666. $info_list[$key]['features'] = $zh;
  8667. }
  8668. $final_list = [];
  8669. foreach($info_list as $k=>$v){
  8670. $number = "";
  8671. if(!empty($v['orderinfo'])){
  8672. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8673. if(!empty($tmp_info['number'])){
  8674. $number = $tmp_info['number'];
  8675. }
  8676. }
  8677. $final_list[] = [
  8678. 'warehouse'=>$v['warehouse'],
  8679. 'purchase'=>$v['purchase'],
  8680. 'sku'=>$v['sku'],
  8681. 'title'=>$v['title'],
  8682. 'features'=>$v['features'],
  8683. 'label'=>$v['label'],
  8684. 'orderinfo'=>$v['orderinfo'],
  8685. 'number'=>$number,
  8686. 'waybill'=>$v['waybill'],
  8687. 'retreat'=>$v['retreat'],
  8688. ];
  8689. }
  8690. }
  8691. if(empty($final_list)){
  8692. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8693. }else{
  8694. $end_list = [];
  8695. foreach($final_list as $v){
  8696. $end_list[] = array_values($v);
  8697. }
  8698. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8699. array_unshift($end_list,[
  8700. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8701. ]);
  8702. array_unshift($end_list,[
  8703. $title,"","","","","","","","",""
  8704. ]);
  8705. $merges = [
  8706. [
  8707. "s"=>["r"=>0,"c"=>0],
  8708. "e"=>["r"=>0,"c"=>9]
  8709. ]
  8710. ];
  8711. $cols = [
  8712. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8713. ];
  8714. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8715. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8716. ] )));
  8717. }
  8718. } else if ($type == 5) {
  8719. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8720. foreach ($info_list as $key => $value) {
  8721. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8722. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8723. $warehouse = $this->warehouse->read($value['warehouse']);
  8724. $info_list[$key]['warehouse'] = $warehouse['title'];
  8725. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8726. $features = explode('-', trim($features, '-'));
  8727. $pm = $classid;
  8728. foreach ($features as $k => $v) {
  8729. if ($v != 0) {
  8730. if (!isset($typeclass[$v])) {
  8731. continue;
  8732. }
  8733. if (isset($pm[$typeclass[$v]['classid']])) {
  8734. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8735. $tz = explode('|', $typeclass[$v]['zh']);
  8736. $pm[$typeclass[$v]['classid']] = $tz[0];
  8737. } else {
  8738. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8739. }
  8740. }
  8741. }
  8742. }
  8743. $zh = implode(" ", $pm);
  8744. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8745. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8746. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8747. $info_list[$key]['features'] = $zh;
  8748. }
  8749. if(empty($info_list)){
  8750. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8751. }else{
  8752. $final_list = [];
  8753. foreach($info_list as $v){
  8754. $final_list[] = array_values($v);
  8755. }
  8756. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8757. array_unshift($final_list,[
  8758. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8759. ]);
  8760. array_unshift($final_list,[
  8761. $title,"","","","","","",
  8762. ]);
  8763. $merges = [
  8764. [
  8765. "s"=>["r"=>0,"c"=>0],
  8766. "e"=>["r"=>0,"c"=>6]
  8767. ]
  8768. ];
  8769. $cols = [
  8770. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8771. ];
  8772. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8773. }
  8774. } else {
  8775. $wh = array();
  8776. $w = $this->warehouse->find_all('1=1', 'id,title');
  8777. foreach ($w as $v) {
  8778. $wh[$v['id']] = $v['title'];
  8779. }
  8780. $wt = array();
  8781. $whlabel_type = $this->whlabel_type->find_all();
  8782. foreach ($whlabel_type as $v) {
  8783. $wt[$v['id']] = $v['title'];
  8784. }
  8785. $classid = $this->classid->sku();
  8786. $list = array();
  8787. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8788. foreach ($rows as $key => $value) {
  8789. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8790. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8791. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  8792. $details = array();
  8793. $cpid = array();
  8794. $cpbz = array();
  8795. $c = 0;
  8796. $g = 0;
  8797. $x = 0;
  8798. $t = 0;
  8799. $s = 0;
  8800. $q = 0;
  8801. foreach ($sd as $k => $v) {
  8802. if ($v['state'] == 0) {
  8803. $c++;
  8804. }
  8805. if ($v['state'] != 9) {
  8806. $g++;
  8807. }
  8808. if ($v['outk'] > 1) {
  8809. $x++;
  8810. }
  8811. if ($v['retreat'] > 0) {
  8812. $t++;
  8813. }
  8814. if ($v['state'] == 8) {
  8815. $s++;
  8816. }
  8817. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8818. $q++;
  8819. }
  8820. $details[$v['details']] = $v['details'];
  8821. if ($v['cpid'] != 0) {
  8822. $cpid[$v['cpid']] = $v['cpid'];
  8823. }
  8824. if ($v['cpbz'] != '') {
  8825. $cpbz[$v['cpbz']] = $v['cpbz'];
  8826. }
  8827. }
  8828. if (isset($wt[$value['type']])) {
  8829. $rows[$key]['type'] = $wt[$value['type']];
  8830. } else {
  8831. $rows[$key]['type'] = '未设置';
  8832. }
  8833. $rows[$key]['details'] = implode("、", $details);
  8834. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8835. $ftime = time() - 15 * 24 * 3600;
  8836. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8837. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8838. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  8839. $rows[$key]['c'] = $c;
  8840. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  8841. $rows[$key]['t'] = $t;
  8842. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  8843. $rows[$key]['z'] = $z;
  8844. // $jm = $classid;
  8845. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8846. $features = explode('-', trim($features, '-'));
  8847. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8848. }
  8849. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8850. $final_list =[];
  8851. foreach($tmp_list as $k=>$v){
  8852. $final_list[] = [
  8853. "warehouse"=>$v['warehouse'],
  8854. "purchase"=>$v['purchase'],
  8855. "details"=>$v['details'],
  8856. "cpid"=>$v['cpid'],
  8857. "sku"=>$v['sku'],
  8858. "title"=>$v['title'],
  8859. "features"=>$v['pm'],
  8860. "cpbz"=>$v['cpbz'],
  8861. "sm"=>$v['sm'],
  8862. "type"=>$v['type'],
  8863. "g"=>$v["g"],
  8864. "c"=>$v["c"],
  8865. "x"=>$v["x"],
  8866. "t"=>$v["t"],
  8867. "z"=>$v["z"],
  8868. "jm"=>$v["jm"],
  8869. "weight"=>$v["weight"],
  8870. "asd"=>$v["asd"],
  8871. ];
  8872. }
  8873. if(empty($final_list)){
  8874. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8875. }else{
  8876. $end_list = [];
  8877. foreach($final_list as $v){
  8878. $end_list[] = array_values($v);
  8879. }
  8880. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8881. array_unshift($end_list,[
  8882. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8883. ]);
  8884. array_unshift($end_list,[
  8885. $title,"","","","","","","","","","","","","","","","","",""
  8886. ]);
  8887. $merges = [
  8888. [
  8889. "s"=>["r"=>0,"c"=>0],
  8890. "e"=>["r"=>0,"c"=>6]
  8891. ]
  8892. ];
  8893. $cols = [
  8894. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8895. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8896. ];
  8897. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8898. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8899. ])));
  8900. }
  8901. }
  8902. }
  8903. }
  8904. public function _exceljxcjs(){
  8905. $classid = $this->classid->sku();
  8906. $pm = $classid;
  8907. $typeclass = array();
  8908. $tc = $this->typeclass->find_all();
  8909. foreach ($tc as $v) {
  8910. $typeclass[$v['id']] = $v;
  8911. }
  8912. $prc = array();
  8913. $purchase = $this->purchase->find_all();
  8914. foreach ($purchase as $k => $v) {
  8915. $prc[$v['id']] = $v['title'];
  8916. }
  8917. if(!isset($_GET['excel'])){
  8918. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8919. }
  8920. $where = "sku != 'Preset'";
  8921. //数据排序
  8922. $order_str = "id desc";
  8923. if (empty($page)) {
  8924. $start = 0;
  8925. $perpage = 1;
  8926. } else {
  8927. $start = ($page - 1) * $perpage;
  8928. }
  8929. $category = $this->input->get('category', true);
  8930. $warehouse = $this->input->get('warehouse', true);
  8931. $excelid = $this->input->get('sid', true);
  8932. if ($category) {
  8933. $where .= " and features like '%-$category-%'";
  8934. }
  8935. if ($warehouse) {
  8936. $where .= " and warehouse = '$warehouse'";
  8937. }
  8938. $xzid = '';
  8939. if ($excelid) {
  8940. $excelid = explode(',', trim($excelid, ','));
  8941. foreach ($excelid as $key => $value) {
  8942. $xzid .= " id = " . $value . " or";
  8943. }
  8944. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8945. }
  8946. $wt = array();
  8947. $whlabel_type = $this->whlabel_type->find_all();
  8948. foreach ($whlabel_type as $v) {
  8949. $wt[$v['id']] = $v['title'];
  8950. }
  8951. $wh = array();
  8952. $w = $this->warehouse->find_all('1=1', 'id,title');
  8953. foreach ($w as $v) {
  8954. $wh[$v['id']] = $v['title'];
  8955. }
  8956. $list = array();
  8957. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8958. foreach ($rows as $key => $value) {
  8959. if (isset($wt[$value['type']])) {
  8960. $rows[$key]['type'] = $wt[$value['type']];
  8961. } else {
  8962. $rows[$key]['type'] = '未设置';
  8963. }
  8964. $bm = '03';
  8965. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8966. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8967. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  8968. $details = array();
  8969. $cpid = array();
  8970. $cpbz = array();
  8971. $c = 0;
  8972. $g = 0;
  8973. $x = 0;
  8974. $t = 0;
  8975. $s = 0;
  8976. $q = 0;
  8977. foreach ($sd as $k => $v) {
  8978. if ($v['state'] == 0) {
  8979. $c++;
  8980. if ($v['cpid'] != 0) {
  8981. $cpid[$v['cpid']] = $v['cpid'];
  8982. }
  8983. if ($v['cpbz'] != '') {
  8984. $cpbz[$v['cpbz']] = $v['cpbz'];
  8985. }
  8986. }
  8987. if ($v['state'] != 9) {
  8988. $g++;
  8989. }
  8990. if ($v['state'] == 1) {
  8991. $x++;
  8992. }
  8993. if ($v['state'] == 2) {
  8994. $t++;
  8995. }
  8996. if ($v['state'] == 8) {
  8997. $s++;
  8998. }
  8999. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  9000. $q++;
  9001. }
  9002. $details[$v['details']] = $v['details'];
  9003. }
  9004. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  9005. $rows[$key]['details'] = implode("、", $details);
  9006. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9007. $number = $value['number'];
  9008. $ftime = time() - 15 * 24 * 3600;
  9009. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  9010. $rows[$key]['number'] = $g;
  9011. $rows[$key]['c'] = $c;
  9012. $rows[$key]['x'] = $x;
  9013. $rows[$key]['t'] = $t;
  9014. $rows[$key]['s'] = $s;
  9015. $rows[$key]['q'] = $q;
  9016. $rows[$key]['z'] = $z;
  9017. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  9018. $features = explode('-', trim($features, '-'));
  9019. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  9020. }
  9021. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  9022. $final_list = [];
  9023. foreach ($list as $k => $v) {
  9024. if (empty($v['sku'])) {
  9025. continue;
  9026. }
  9027. $final_list[] = [
  9028. $v["warehouse"],
  9029. $v["purchase"],
  9030. $v["details"],
  9031. $v["cpid"],
  9032. $v["dbcontent"],
  9033. $v["sku"],
  9034. $v["bm"],
  9035. $v["jm"],
  9036. $v["title"],
  9037. $v["pm"],
  9038. $v["cpbz"],
  9039. $v["sm"],
  9040. $v["type"],
  9041. $v["number"],
  9042. $v["c"],
  9043. $v["x"],
  9044. $v["t"],
  9045. $v["s"],
  9046. $v["q"],
  9047. $v["z"],
  9048. $v['weight'],
  9049. ];
  9050. }
  9051. if(empty($final_list)){
  9052. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9053. }
  9054. $title = "总进销存统计表";
  9055. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  9056. $merges = [
  9057. [
  9058. "s"=>["r"=>0,"c"=>0],
  9059. "e"=>["r"=>0,"c"=>21]
  9060. ]
  9061. ];
  9062. $cols = [
  9063. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  9064. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9065. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9066. ];
  9067. array_unshift($final_list, $first_row);
  9068. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  9069. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9070. }
  9071. public function _summaryjs($arg_array)
  9072. {
  9073. $prc = array();
  9074. $purchase = $this->purchase->find_all();
  9075. foreach ($purchase as $k => $v) {
  9076. $prc[$v['id']] = $v['title'];
  9077. }
  9078. if (isset($_GET['excel'])) {
  9079. $ktime = $this->input->get('ktime', true);
  9080. $jtime = $this->input->get('jtime', true);
  9081. $ktime = strtotime($ktime);
  9082. $jtime = strtotime($jtime);
  9083. $where = "1=1";
  9084. if ($ktime && $jtime) {
  9085. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9086. }
  9087. //数据排序
  9088. $order_str = "time desc";
  9089. if (empty($page)) {
  9090. $start = 0;
  9091. $perpage = 1;
  9092. } else {
  9093. $start = ($page - 1) * $perpage;
  9094. }
  9095. //取得信息列表
  9096. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9097. foreach ($info_list as $key => $value) {
  9098. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9099. $warehouse = $this->warehouse->read($value['warehouse']);
  9100. $info_list[$key]['warehouse'] = $warehouse['title'];
  9101. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9102. $details = array();
  9103. $cpid = array();
  9104. foreach ($x as $k => $v) {
  9105. if ($v['details'] != '') {
  9106. $details[$v['details']] = $v['details'];
  9107. }
  9108. if ($v['cpid'] != 0) {
  9109. $cpid[$v['cpid']] = $v['cpid'];
  9110. }
  9111. }
  9112. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9113. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9114. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9115. $info_list[$key]['s'] = $s;
  9116. $info_list[$key]['x'] = count($x);
  9117. }
  9118. if(empty($info_list)){
  9119. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9120. }
  9121. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9122. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9123. $merges = [
  9124. [
  9125. "s"=>["r"=>0,"c"=>0],
  9126. "e"=>["r"=>0,"c"=>7]
  9127. ]
  9128. ];
  9129. $cols = [
  9130. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9131. ];
  9132. $final_list = [];
  9133. foreach($info_list as $k => $v){
  9134. $final_list[] = array_values($v);
  9135. }
  9136. array_unshift($final_list, $first_row);
  9137. array_unshift($final_list,[
  9138. $title,"","","","","","","","",
  9139. ]);
  9140. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9141. $titlename = "<table border=1>
  9142. <tr align='center'>
  9143. <td>仓库</td>
  9144. <td>供应商</td>
  9145. <td>出库位置</td>
  9146. <td>出库编码</td>
  9147. <td>SKU</td>
  9148. <td>产品名</td>
  9149. <td>总剩余库存</td>
  9150. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9151. </tr>
  9152. </table>";
  9153. $filename = $title . ".xls";
  9154. $tail = "";
  9155. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9156. }
  9157. }
  9158. public function _uckjs()
  9159. {
  9160. if (isset($_GET['excel'])) {
  9161. $tc = array();
  9162. $typeclass = $this->typeclass->find_all();
  9163. foreach ($typeclass as $v) {
  9164. $tc[$v['id']] = $v['zh'];
  9165. }
  9166. $first_row = [
  9167. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9168. ];
  9169. $t = array();
  9170. $rq = '';
  9171. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9172. $ts = $ts / (24 * 3600);
  9173. for ($i = 0; $i < $ts; $i++) {
  9174. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9175. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9176. }
  9177. $day_len = count($t);
  9178. $first_row[] = "本月出库";
  9179. $merges = [
  9180. ];
  9181. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9182. $excel_key = 1;
  9183. $final_list = [];
  9184. foreach ($info_list as $k => $v) {
  9185. $features = explode('-', trim($v['features'], '-'));
  9186. if (!isset($features[3]) || !isset($features[4])) {
  9187. continue;
  9188. }
  9189. $tmp = [];
  9190. $tmp[0] = $tc[$features[0]]; //类型
  9191. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9192. $tmp[2] = $tc[$features[4]]; //曲度
  9193. $tmp[3] = '';
  9194. if (isset($data[$k][1])) {
  9195. $tmp[3] .=$tmp[1];
  9196. }
  9197. if (isset($data[$k][2])) {
  9198. $tmp[3] .= $tmp[2];
  9199. }
  9200. if (isset($features[5])) {
  9201. $tmp[3] .= $tc[$features[5]];
  9202. }
  9203. if (isset($features[2])) {
  9204. $tmp[3] .= $tc[$features[2]];
  9205. }
  9206. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9207. $tmp[4] = $v['sku'];
  9208. $tmp[5] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and (state = 0 or (state = 1 and outk > ' . strtotime(date("Y-m", time())) . '))'); //月初库存
  9209. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9210. $tmp[7] ="";
  9211. $tmp[8] ="";
  9212. $byck = 0;
  9213. foreach ($t as $vv) {
  9214. $sl = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and state = 1 and outk > ' . strtotime($vv) . ' and outk < ' . (strtotime($vv) + 24 * 3600));
  9215. $tmp[] = ($sl > 0) ? $sl : '';
  9216. $byck += $sl;
  9217. }
  9218. $tmp[] = ($byck > 0) ? $byck : '';
  9219. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9220. // $ztrq = '';
  9221. // $ztsl = '';
  9222. // if (count($zt) > 0) {
  9223. // foreach ($zt as $vv) {
  9224. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9225. // $ztsl .= $vv['num'] . '<br>';
  9226. // }
  9227. // }
  9228. if(empty($zt)){
  9229. $final_list[] = $tmp;
  9230. $excel_key = $excel_key + 1;
  9231. }else{
  9232. $len = count($zt);
  9233. if($len == 1){
  9234. $tmp[7] = $zt[0]['num'] ;
  9235. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9236. $final_list[] = $tmp;
  9237. $excel_key = $excel_key + 1;
  9238. }else{
  9239. foreach($zt as $vv){
  9240. $tmp[7] = "";
  9241. $tmp[8] = "";
  9242. $tmp[7] = $vv['num'];
  9243. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9244. $final_list[] = $tmp;
  9245. }
  9246. $merges[] = [
  9247. "s"=>["r"=>$excel_key,"c"=>0],
  9248. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9249. ];
  9250. $merges[] = [
  9251. "s"=>["r"=>$excel_key,"c"=>1],
  9252. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9253. ];
  9254. $merges[] = [
  9255. "s"=>["r"=>$excel_key,"c"=>2],
  9256. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9257. ];
  9258. $merges[] = [
  9259. "s"=>["r"=>$excel_key,"c"=>3],
  9260. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9261. ];
  9262. $merges[] = [
  9263. "s"=>["r"=>$excel_key,"c"=>4],
  9264. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9265. ];
  9266. $merges[] = [
  9267. "s"=>["r"=>$excel_key,"c"=>5],
  9268. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9269. ];
  9270. $merges[] = [
  9271. "s"=>["r"=>$excel_key,"c"=>6],
  9272. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9273. ];
  9274. for($i=1;$i<=$day_len;$i++){
  9275. $merges[] = [
  9276. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9277. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9278. ];
  9279. }
  9280. $merges[] = [
  9281. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9282. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9283. ];
  9284. $excel_key = $excel_key + $len;
  9285. }
  9286. }
  9287. }
  9288. $title = "详情 " . date("Y-m-d", time());
  9289. if(empty($final_list)){
  9290. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9291. }
  9292. $cols = [
  9293. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9294. ];
  9295. array_unshift($final_list, $first_row);
  9296. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9297. }
  9298. }
  9299. public function _whlabelexcelzhjs(){
  9300. if(empty($_GET['excel'])){
  9301. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9302. }
  9303. $where = "sku != 'Preset' and sku != '' ";
  9304. //数据排序
  9305. $order_str = "id desc";
  9306. if (empty($page)) {
  9307. $start = 0;
  9308. $perpage = 1;
  9309. } else {
  9310. $start = ($page - 1) * $perpage;
  9311. }
  9312. $category = $this->input->get('category', true);
  9313. $warehouse = $this->input->get('warehouse', true);
  9314. $excelid = $this->input->get('sid', true);
  9315. if ($category) {
  9316. $where .= " and features like '%-$category-%'";
  9317. }
  9318. if ($warehouse) {
  9319. $where .= " and warehouse = '$warehouse'";
  9320. }
  9321. $xzid = '';
  9322. if ($excelid) {
  9323. $excelid = explode(',', trim($excelid, ','));
  9324. foreach ($excelid as $key => $value) {
  9325. $xzid .= " id = " . $value . " or";
  9326. }
  9327. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9328. }
  9329. $merges = [
  9330. [
  9331. "s"=>["r"=>0,"c"=>0],
  9332. "e"=>["r"=>0,"c"=>6]
  9333. ]
  9334. ];
  9335. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9336. $excel_index = 2;
  9337. $final_list = [];
  9338. foreach ($rows as $key => $value) {
  9339. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9340. $zh = '';
  9341. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9342. // foreach ($zt_list as $v) {
  9343. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9344. // }
  9345. $zt = array_sum(array_column($zt_list, 'num'));
  9346. $number = $value['number'];
  9347. $ftime = time() - 15 * 24 * 3600;
  9348. $warehouse = $this->warehouse->read($value['warehouse']);
  9349. // $rows[$key]['warehouse'] = $warehouse['title'];
  9350. // $rows[$key]['number'] = $c;
  9351. // $rows[$key]['features'] = $zh;
  9352. //$rows[$key]['hb'] = $c + $zt;
  9353. $tmp = [];
  9354. $tmp[0] = $warehouse['title'];
  9355. $tmp[1] = $value['sku'];
  9356. $tmp[2] = $value['title'];
  9357. $tmp[3] = $c;
  9358. $tmp[4] = "";
  9359. $tmp[5] = $c + $zt;
  9360. if(empty($zt_list)){
  9361. $tmp[4] = "";
  9362. $final_list[] = $tmp;
  9363. $excel_index = $excel_index + 1;
  9364. }else{
  9365. if(count($zt_list) == 1){
  9366. $tmp[4] = "";
  9367. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9368. $final_list[] = $tmp;
  9369. $excel_index = $excel_index + 1;
  9370. }else{
  9371. $len = count($zt_list);
  9372. foreach ($zt_list as $v){
  9373. $tmp[4] = "";
  9374. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9375. $final_list[] = $tmp;
  9376. }
  9377. $merges[] = [
  9378. "s"=>["r"=>$excel_index,"c"=>0],
  9379. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9380. ];
  9381. $merges[] = [
  9382. "s"=>["r"=>$excel_index,"c"=>1],
  9383. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9384. ];
  9385. $merges[] = [
  9386. "s"=>["r"=>$excel_index,"c"=>2],
  9387. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9388. ];
  9389. $merges[] = [
  9390. "s"=>["r"=>$excel_index,"c"=>3],
  9391. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9392. ];
  9393. $merges[] = [
  9394. "s"=>["r"=>$excel_index,"c"=>5],
  9395. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9396. ];
  9397. $excel_index = $excel_index + $len;
  9398. }
  9399. }
  9400. }
  9401. $first_row = [
  9402. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9403. ];
  9404. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9405. if(empty($final_list)){
  9406. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9407. }
  9408. $cols = [
  9409. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9410. ];
  9411. array_unshift($final_list, $first_row);
  9412. array_unshift($final_list, [
  9413. $title,"","","","",""
  9414. ]);
  9415. $end_list = [];
  9416. foreach ($final_list as $key => $value) {
  9417. $end_list[] = array_values($value);
  9418. }
  9419. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9420. }
  9421. //出库、退库导出
  9422. public function _dccrtypejs()
  9423. {
  9424. $classid = $this->classid->sku();
  9425. $pm = $classid;
  9426. $typeclass = array();
  9427. $tc = $this->typeclass->find_all();
  9428. foreach ($tc as $v) {
  9429. $typeclass[$v['id']] = $v;
  9430. }
  9431. $prc = array();
  9432. $purchase = $this->purchase->find_all();
  9433. foreach ($purchase as $k => $v) {
  9434. $prc[$v['id']] = $v['title'];
  9435. }
  9436. if (isset($_GET['sid'])) {
  9437. $wh = array();
  9438. $w = $this->warehouse->find_all('1=1', 'id,title');
  9439. foreach ($w as $v) {
  9440. $wh[$v['id']] = $v['title'];
  9441. }
  9442. $type = $this->input->get('excel', true);
  9443. $category = $this->input->get('category', true);
  9444. $size = $this->input->get('size', true);
  9445. $grade = $this->input->get('grade', true);
  9446. $color = $this->input->get('color', true);
  9447. $lowe = $this->input->get('lowe', true);
  9448. $sku = $this->input->get('sku', true);
  9449. $warehouse = $this->input->get('warehouse', true);
  9450. $lacetype = $this->input->get('lacetype', true);
  9451. $lacecolor = $this->input->get('lacecolor', true);
  9452. $density = $this->input->get('density', true);
  9453. $haircap = $this->input->get('haircap', true);
  9454. $purchase = $this->input->get('purchase', true);
  9455. $title = $this->input->get('title', true);
  9456. $state = $this->input->get('state', true);
  9457. $sid = $this->input->get('sid', true);
  9458. $ktime = $this->input->get('ktime', true);
  9459. $jtime = $this->input->get('jtime', true);
  9460. $ktime = strtotime($ktime);
  9461. $jtime = strtotime($jtime);
  9462. $where = "1=1";
  9463. $gj = "";
  9464. $ck = "";
  9465. if ($category) {
  9466. $where .= " and features like '%-$category-%'";
  9467. }
  9468. if ($size) {
  9469. $where .= " and features like '%-$size-%'";
  9470. }
  9471. if ($grade) {
  9472. $where .= " and features like '%-$grade-%'";
  9473. }
  9474. if ($color) {
  9475. $where .= " and features like '%-$color-%'";
  9476. }
  9477. if ($lowe) {
  9478. $where .= " and features like '%-$lowe-%'";
  9479. }
  9480. if ($warehouse) {
  9481. $where .= " and warehouse = '$warehouse'";
  9482. }
  9483. if ($purchase) {
  9484. $where .= " and purchase = '$purchase'";
  9485. }
  9486. if ($state) {
  9487. $where .= " and state = '$state'";
  9488. }
  9489. if ($lacetype) {
  9490. $where .= " and features like '%-$lacetype-%'";
  9491. }
  9492. if ($lacecolor) {
  9493. $where .= " and features like '%-$lacecolor-%'";
  9494. }
  9495. if ($density) {
  9496. $where .= " and features like '%-$density-%'";
  9497. }
  9498. if ($haircap) {
  9499. $where .= " and features like '%-$haircap-%'";
  9500. }
  9501. if ($title) {
  9502. $title = trim($title, ' ');
  9503. $title = trim($title, ' ');
  9504. $where .= " and title like '%$title%'";
  9505. }
  9506. if ($sku) {
  9507. $sku = trim($sku, ' ');
  9508. $sku = trim($sku, ' ');
  9509. $where .= " and sku like '%$sku%'";
  9510. }
  9511. if ($ktime && $jtime) {
  9512. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9513. }
  9514. $sidwhere = '';
  9515. if ($sid) {
  9516. $sd = "";
  9517. $s = explode(',', trim($sid, ','));
  9518. foreach ($s as $value) {
  9519. $sd .= " id = " . $value . " or";
  9520. }
  9521. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9522. }
  9523. //数据排序
  9524. $order_str = "time desc";
  9525. if (empty($page)) {
  9526. $start = 0;
  9527. $perpage = 1;
  9528. } else {
  9529. $start = ($page - 1) * $perpage;
  9530. }
  9531. $wh = array();
  9532. $w = $this->warehouse->find_all('1=1', 'id,title');
  9533. foreach ($w as $v) {
  9534. $wh[$v['id']] = $v['title'];
  9535. }
  9536. $wt = array();
  9537. $whlabel_type = $this->whlabel_type->find_all();
  9538. foreach ($whlabel_type as $v) {
  9539. $wt[$v['id']] = $v['title'];
  9540. }
  9541. $classid = $this->classid->sku();
  9542. $list = array();
  9543. $rows_r = $this->whlabel->find_pc($where . " and enter > '$ktime' and enter < '$jtime' " . $sidwhere, 'sku,features,warehouse,enter', 'warehouse,sku,title,zh,features,time,enter,rktype,number,text');
  9544. foreach ($rows_r as $key => $value) {
  9545. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9546. $pm = $classid;
  9547. $jm = $classid;
  9548. $rows_r[$key]['enter'] = '入库';
  9549. $rows_r[$key]['time'] = $value['enter'];
  9550. if ($value['rktype'] == 1) {
  9551. $rows_r[$key]['rktype'] = '采购入库';
  9552. } else if ($value['rktype'] == 2) {
  9553. $rows_r[$key]['rktype'] = '盘盈调整';
  9554. } else if ($value['rktype'] == 3) {
  9555. $rows_r[$key]['rktype'] = '其他调整入库';
  9556. } else if ($value['rktype'] == 4) {
  9557. $rows_r[$key]['rktype'] = '其他调整入库';
  9558. } else if ($value['rktype'] == 5) {
  9559. $rows_r[$key]['rktype'] = '退库入库';
  9560. } else if ($value['rktype'] == 6) {
  9561. $rows_r[$key]['rktype'] = '退货可用入库';
  9562. } else if ($value['rktype'] == 7) {
  9563. $rows_r[$key]['rktype'] = '形态转换入库';
  9564. } else {
  9565. $rows_r[$key]['rktype'] = '';
  9566. }
  9567. $features = explode('-', trim($value['features'], '-'));
  9568. foreach ($features as $v) {
  9569. if (isset($typeclass[$v])) {
  9570. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9571. $pm[$typeclass[$v]['classid']] = $zh[0];
  9572. }
  9573. if (isset($typeclass[$v])) {
  9574. if (isset($jm[$typeclass[$v]['classid']])) {
  9575. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9576. }
  9577. }
  9578. }
  9579. $zh = implode(" ", $pm);
  9580. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9581. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9582. $rows_r[$key]['zh'] = $zh;
  9583. $jm = array_filter($jm);
  9584. $rows_r[$key]['features'] = implode("-", $jm);
  9585. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9586. }
  9587. $rows_c = $this->whlabel->find_all($where . " and outk > '$ktime' and outk < '$jtime' " . $sidwhere, 'warehouse,sku,title,zh,features,time,outk,cktype,number,textout,state');
  9588. foreach ($rows_c as $key => $value) {
  9589. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9590. $pm = $classid;
  9591. $jm = $classid;
  9592. $rows_c[$key]['time'] = $value['outk'];
  9593. $rows_c[$key]['outk'] = '出库';
  9594. if ($value['cktype'] == 1) {
  9595. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9596. } else if ($value['cktype'] == 2) {
  9597. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9598. } else if ($value['cktype'] == 3) {
  9599. $rows_c[$key]['cktype'] = '盘亏调整';
  9600. } else if ($value['cktype'] == 4) {
  9601. $rows_c[$key]['cktype'] = '其他调整出库';
  9602. } else if ($value['cktype'] == 5) {
  9603. $rows_c[$key]['cktype'] = '形态转换出库';
  9604. } else {
  9605. $rows_c[$key]['cktype'] = '';
  9606. }
  9607. unset($rows_c[$key]['state']);
  9608. $features = explode('-', trim($value['features'], '-'));
  9609. foreach ($features as $v) {
  9610. if (isset($typeclass[$v])) {
  9611. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9612. $pm[$typeclass[$v]['classid']] = $zh[0];
  9613. }
  9614. if (isset($typeclass[$v])) {
  9615. if (isset($jm[$typeclass[$v]['classid']])) {
  9616. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9617. }
  9618. }
  9619. }
  9620. $zh = implode(" ", $pm);
  9621. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9622. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9623. $rows_c[$key]['zh'] = $zh;
  9624. $jm = array_filter($jm);
  9625. $rows_c[$key]['features'] = implode("-", $jm);
  9626. $rows_c[$key]['number'] = 1;
  9627. }
  9628. $merged = $rows_r;
  9629. foreach ($rows_c as $key => $value) {
  9630. if (isset($merged[$key])) {
  9631. $merged[] = $value;
  9632. } else {
  9633. $merged[$key] = $value;
  9634. }
  9635. }
  9636. usort($merged, function ($a, $b) {
  9637. return $a['time'] - $b['time'];
  9638. });
  9639. foreach ($merged as $key => $value) {
  9640. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9641. }
  9642. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9643. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9644. $cols = [
  9645. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9646. ];
  9647. $final_list= [];
  9648. foreach($merged as $key => $value){
  9649. $final_list[] = array_values($value) ;
  9650. }
  9651. if(empty($merged)){
  9652. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9653. }
  9654. array_unshift($final_list, $first_row);
  9655. $end_list = [];
  9656. foreach ($final_list as $key => $value) {
  9657. $end_list[] = array_values($value);
  9658. }
  9659. $merges = [];
  9660. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9661. }
  9662. }
  9663. public function _errorexceljs()
  9664. {
  9665. $post = $this->input->post(NULL, TRUE);
  9666. if (isset($_GET['page'])) {
  9667. $page = $this->input->get('page', true);
  9668. $perpage = $this->input->get('perpage', true);
  9669. $sku = $this->input->get('sku', true);
  9670. $warehouse = $this->input->get('warehouse', true);
  9671. $ktime = $this->input->get('ktime', true);
  9672. $jtime = $this->input->get('jtime', true);
  9673. $ktime = strtotime($ktime);
  9674. $jtime = strtotime($jtime);
  9675. $where = "sku != 'Preset'";
  9676. $gj = '';
  9677. if ($sku) {
  9678. $where .= " and sku like '%$sku%'";
  9679. } else {
  9680. if ($ktime && $jtime) {
  9681. $gj = " and time > '$ktime' and time < '$jtime'";
  9682. }
  9683. }
  9684. if ($warehouse) {
  9685. $where .= " and warehouse = '$warehouse'";
  9686. }
  9687. //数据排序
  9688. $order_str = "id desc";
  9689. if (empty($page)) {
  9690. $start = 0;
  9691. $perpage = 1;
  9692. } else {
  9693. $start = ($page - 1) * $perpage;
  9694. }
  9695. //取得信息列表
  9696. $rows = array();
  9697. $list = array();
  9698. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9699. foreach ($info_list as $value) {
  9700. $warehouse = $this->warehouse->read($value['warehouse']);
  9701. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9702. $number = $value['number'];
  9703. $ftime = time() - 15 * 24 * 3600;
  9704. if ($c < 1) {
  9705. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9706. }
  9707. }
  9708. $title = "0库存汇总";
  9709. $first_row = ["仓库","SKU","产品","当前库存"];
  9710. $cols = [
  9711. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9712. ];
  9713. $final_list= [];
  9714. foreach($list as $key => $value){
  9715. $final_list[] = array_values($value) ;
  9716. }
  9717. if(empty($final_list)){
  9718. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9719. }
  9720. array_unshift($final_list, $first_row);
  9721. $merges = [];
  9722. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9723. }
  9724. }
  9725. }