Whlabel.php 338 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962
  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. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg, $arg_array)
  51. {
  52. if ($arg == 'existence') //在库标签
  53. {
  54. $this->_existence();
  55. } else if ($arg == 'cpbqdc') //在库标签
  56. {
  57. $this->_cpbqdc();
  58. } else if ($arg == 'type') //进销存浏览
  59. {
  60. $this->_type();
  61. }else if ($arg == 'typev1') //进销存浏览
  62. {
  63. $this->_typev1();
  64. } else if ($arg == 'typedy') //进销存浏览店员页面
  65. {
  66. $this->_typedy($arg_array);
  67. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  68. {
  69. $this->_typedy_ck($arg_array);
  70. } else if ($arg == 'typeck') {
  71. $this->_typeck($arg_array);
  72. } else if ($arg == 'whlabeckdc') {
  73. $this->_whlabeckdc($arg_array);
  74. } else if ($arg == 'usatype') //美仓进销存浏览
  75. {
  76. $this->_usatype();
  77. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  78. {
  79. $this->_usatypeapp();
  80. } else if ($arg == 'enteradd') //入库操作
  81. {
  82. $this->_enteradd();
  83. } else if ($arg == 'enteredit') //修改
  84. {
  85. $this->_enteredit($arg_array);
  86. } else if ($arg == 'enter') //入库浏览
  87. {
  88. $this->_enter();
  89. } else if ($arg == 'out') //出库浏览
  90. {
  91. $this->_out();
  92. } else if ($arg == 'label') //出库标签浏览
  93. {
  94. $this->_label();
  95. } else if ($arg == 'outorder') //独立站出库订单
  96. {
  97. $this->_outorder();
  98. } else if ($arg == 'soutorder') //速卖通出库订单
  99. {
  100. $this->_soutorder();
  101. } else if ($arg == 'toutorder') //TT出库订单
  102. {
  103. $this->_toutorder();
  104. }else if ($arg == 'aoutorder') //amz出库订单
  105. {
  106. $this->_aoutorder();
  107. } else if ($arg == 'retreat') //退库订单
  108. {
  109. $this->_retreat();
  110. } else if ($arg == 'retreatlk') //退库订单
  111. {
  112. $this->_retreatlk();
  113. } else if ($arg == 'change') //更换标签
  114. {
  115. $this->_change();
  116. } else if ($arg == 'del') //删除
  117. {
  118. $this->_del();
  119. } else if ($arg == 'exceljxc') //进销存信息导出
  120. {
  121. $this->_exceljxc();
  122. } else if ($arg == 'excelr') //入库信息导出
  123. {
  124. $this->_excelr();
  125. } else if ($arg == 'excelct') //出库、退库信息导出
  126. {
  127. $this->_excelct();
  128. } else if ($arg == 'dccrtype') //根据出入库类型导出
  129. {
  130. $this->_dccrtype();
  131. } else if ($arg == 'excelcr') //出库、退库信息导出
  132. {
  133. $this->_excelcr();
  134. } else if ($arg == 'kcyz') //库存验证
  135. {
  136. $this->_kcyz();
  137. } else if ($arg == 'kj') //库存扣减
  138. {
  139. $this->_kj($arg_array);
  140. } else if ($arg == 'presetout') //预设库存导入
  141. {
  142. $this->_presetout($arg_array);
  143. } else if ($arg == 'presetedit') //预设库存导入
  144. {
  145. $this->_presetedit($arg_array);
  146. }else if ($arg == 'presetedittwo') //预设库存导入
  147. {
  148. $this->_presetedittwo($arg_array);
  149. } else if ($arg == 'summary') //汇总导出
  150. {
  151. $this->_summary($arg_array);
  152. } else if ($arg == 'manifest') //usps发货清单
  153. {
  154. $this->_manifest();
  155. } else if ($arg == 'abnormal') //占单异常
  156. {
  157. $this->_abnormal();
  158. } else if ($arg == 'error') //0库存SKU
  159. {
  160. $this->_error();
  161. } else if ($arg == 'errorexcel') //0库存SKU导出
  162. {
  163. $this->_errorexcel();
  164. } else if ($arg == 'db') {
  165. $this->_db();
  166. } else if ($arg == 'dbrk') {
  167. $this->_dbrk();
  168. } else if ($arg == 'whlabelczdc') {
  169. $this->_whlabelczdc();
  170. } else if ($arg == 'print') {
  171. $this->_print($arg_array);
  172. } else if ($arg == 'usaprint') {
  173. $this->_usaprint($arg_array);
  174. } else if ($arg == 'printck') {
  175. $this->_printck($arg_array);
  176. } else if ($arg == 'printrk') {
  177. $this->_printrk($arg_array);
  178. } else if ($arg == 'printxzrk') {
  179. $this->_printxzrk($arg_array);
  180. } else if ($arg == 'printexcel') {
  181. $this->_printexcel($arg_array);
  182. } else if ($arg == 'uck') {
  183. $this->_uck();
  184. } else if ($arg == 'whlabelexcelzh') {
  185. $this->_whlabelexcelzh();
  186. } else if ($arg == 'fc') {
  187. $this->_fc();
  188. } else if ($arg == 'fcmb') {
  189. $this->_fcmb();
  190. } else if ($arg == 'fcexcel') {
  191. $this->_fcexcel();
  192. } else if ($arg == 'fcjxc') {
  193. $this->_fcjxc($arg_array);
  194. } else if ($arg == '0kcdel') {
  195. $this->_0kcdel(); //导表删除0库存
  196. } else if ($arg == 'gbhtype') {
  197. $this->_gbhtype(); //更改备货状态
  198. } else if($arg == 'excelrjs'){
  199. $this->_excelrjs();
  200. } else if($arg == 'excelctjs'){
  201. $this->_excelctjs();
  202. }else if ($arg == 'exceljxcjs') //进销存信息导出
  203. {
  204. $this->_exceljxcjs();
  205. } else if ($arg == 'summaryjs') //汇总导出
  206. {
  207. $this->_summaryjs($arg_array);
  208. }else if($arg == 'uckjs'){
  209. $this->_uckjs();
  210. }else if ($arg == 'whlabelexcelzhjs') {
  211. $this->_whlabelexcelzhjs();
  212. }else if($arg == 'dccrtypejs'){
  213. $this->_dccrtypejs();
  214. }else if($arg == 'errorexceljs'){
  215. $this->_errorexceljs();
  216. }else if($arg == "w_t_cs"){
  217. $this->_w_t_cs(); //首页
  218. }else {
  219. $this->_index();
  220. }
  221. }
  222. public function _w_t_cs(){
  223. $vip = 0;
  224. if (isset($_SESSION['api'])) {
  225. $user = $this->user->get_api($_SESSION['api']);
  226. $fgshop = "";
  227. $sid = "";
  228. $usersp = explode('|', trim($user['shop'], '|'));
  229. foreach ($usersp as $value) {
  230. $fgshop .= " shop = " . $value . " or";
  231. $sid .= " id = " . $value . " or";
  232. }
  233. if ($user['vip'] == 1) {
  234. $vip = 1;
  235. }
  236. } else {
  237. header('Location: /');
  238. exit;
  239. }
  240. $prc = array();
  241. $purchase = $this->purchase->find_all();
  242. foreach ($purchase as $k => $v) {
  243. $prc[$v['id']] = $v['title'];
  244. }
  245. $company = array();
  246. $ct = $this->company->find_all();
  247. foreach ($ct as $k => $v) {
  248. $company[$v['id']] = $v['title'];
  249. }
  250. $sp = array();
  251. $s = $this->shop->find_all('1=1', 'id,shopname');
  252. foreach ($s as $v) {
  253. $sp[$v['id']] = $v['shopname'];
  254. }
  255. $wh = array();
  256. $w = $this->warehouse->find_all('1=1', 'id,title');
  257. foreach ($w as $v) {
  258. $wh[$v['id']] = $v['title'];
  259. }
  260. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  261. $this->data['shop'] = $wlshop;
  262. $this->data['vip'] = $vip;
  263. $this->_Template('whlabel_typejs', $this->data);
  264. }
  265. //管理
  266. public function _index()
  267. {
  268. $post = $this->input->post(NULL, TRUE);
  269. if (isset($post['page'])) {
  270. $page = $this->input->post('page', true);
  271. $perpage = $this->input->post('perpage', true);
  272. $sku = $this->input->post('sku', true);
  273. $number = $this->input->post('number', true);
  274. $warehouse = $this->input->post('warehouse', true);
  275. $purchase = $this->input->post('purchase', true);
  276. $orderinfo = $this->input->post('orderinfo', true);
  277. $waybill = $this->input->post('waybill', true);
  278. $category = $this->input->post('category', true);
  279. $size = $this->input->post('size', true);
  280. $grade = $this->input->post('grade', true);
  281. $color = $this->input->post('color', true);
  282. $lowe = $this->input->post('lowe', true);
  283. $state = $this->input->post('state', true);
  284. $label = $this->input->post('label', true);
  285. $timetk = $this->input->post('timetkk', true);
  286. $timetj = $this->input->post('timetjj', true);
  287. $timetk = strtotime($timetk);
  288. $timetj = strtotime($timetj);
  289. $where = "1=1 ";
  290. if ($timetk && $timetj) {
  291. $where .= " and time > '$timetk' and time < '$timetj'";
  292. }
  293. if ($sku) {
  294. $where .= " and sku = '$sku'";
  295. }
  296. if ($number) {
  297. $where .= " and number = '$number'";
  298. }
  299. if ($warehouse) {
  300. $where .= " and warehouse = '$warehouse'";
  301. }
  302. if ($purchase) {
  303. $where .= " and purchase = '$purchase'";
  304. }
  305. if ($orderinfo) {
  306. $where .= " and orderinfo = '$orderinfo'";
  307. }
  308. if ($waybill) {
  309. $where .= " and waybill = '$waybill'";
  310. }
  311. if ($category) {
  312. $where .= " and features like '%-$category-%'";
  313. }
  314. if ($size) {
  315. $where .= " and features like '%-$size-%'";
  316. }
  317. if ($grade) {
  318. $where .= " and features like '%-$grade-%'";
  319. }
  320. if ($color) {
  321. $where .= " and features like '%-$color-%'";
  322. }
  323. if ($lowe) {
  324. $where .= " and features like '%-$lowe-%'";
  325. }
  326. if ($label) {
  327. $where .= " and label = '$label'";
  328. }
  329. if ($state != '') {
  330. $where .= " and state = '$state'";
  331. }
  332. //数据排序
  333. $order_str = "time desc";
  334. if (empty($page)) {
  335. $start = 0;
  336. $perpage = 1;
  337. } else {
  338. $start = ($page - 1) * $perpage;
  339. }
  340. //取得信息列表
  341. $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);
  342. foreach ($info_list as $key => $value) {
  343. $warehouse = $this->warehouse->read($value['warehouse']);
  344. $info_list[$key]['warehouse'] = $warehouse['title'];
  345. $purchase = $this->purchase->read($value['purchase']);
  346. $info_list[$key]['purchase'] = $purchase['title'];
  347. if ($value['enter'] != 0) {
  348. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  349. } else {
  350. $info_list[$key]['enter'] = "";
  351. }
  352. if ($value['outk'] != 0) {
  353. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  354. } else {
  355. $info_list[$key]['outk'] = "";
  356. }
  357. if ($value['printing'] != 0) {
  358. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  359. } else {
  360. $info_list[$key]['printing'] = "";
  361. }
  362. if ($value['orderinfo'] == 0) {
  363. $info_list[$key]['orderinfo'] = "";
  364. }
  365. if ($value['waybill'] == 0) {
  366. $info_list[$key]['waybill'] = "";
  367. }
  368. if ($value['state'] == 0) {
  369. $info_list[$key]['state'] = "在库";
  370. } else if ($value['state'] == 1) {
  371. $info_list[$key]['state'] = "出库";
  372. } else if ($value['state'] == 2) {
  373. $info_list[$key]['state'] = "退库";
  374. } else if ($value['state'] == 3) {
  375. $info_list[$key]['state'] = "调拨中";
  376. } else if ($value['state'] == 4) {
  377. $info_list[$key]['state'] = "再加工";
  378. } else if ($value['state'] == 5) {
  379. $info_list[$key]['state'] = "维修中";
  380. } else if ($value['state'] == 6) {
  381. $info_list[$key]['state'] = "盘亏";
  382. } else if ($value['state'] == 7) {
  383. $info_list[$key]['state'] = "更换标签";
  384. } else if ($value['state'] == 8) {
  385. $info_list[$key]['state'] = "其它";
  386. } else if ($value['state'] == 9) {
  387. $info_list[$key]['state'] = "预设";
  388. } else if ($value['state'] == 10) {
  389. $info_list[$key]['state'] = "美店零售";
  390. }
  391. if ($value['text'] == "") {
  392. $info_list[$key]['text'] = "";
  393. }
  394. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  395. }
  396. $total = $this->whlabel->find_count($where);
  397. $pagenum = ceil($total / $perpage);
  398. $over = $total - ($start + $perpage);
  399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  400. echo json_encode($rows);
  401. exit;
  402. }
  403. if (isset($post['outsku'])) {
  404. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  405. $cz = $this->input->post('cz', true);
  406. if ($cz == '1') {
  407. $sku = $this->input->post('outsku', true);
  408. if ($sku) {
  409. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  410. if (count($data) < 1) {
  411. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  412. exit;
  413. }
  414. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  415. echo json_encode(array('success' => true));
  416. exit;
  417. }
  418. } else {
  419. $sku = $this->input->post('outsku', true);
  420. if ($sku) {
  421. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  422. if (count($data) < 1) {
  423. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  424. exit;
  425. }
  426. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  427. echo json_encode(array('success' => true));
  428. exit;
  429. }
  430. }
  431. }
  432. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  433. $this->_Template('whlabel', $this->data);
  434. }
  435. //在库标签
  436. public function _existence()
  437. {
  438. $post = $this->input->post(NULL, TRUE);
  439. if (isset($post['s'])) {
  440. $id_arr = $this->input->post('s');
  441. $id_arr = explode(',', $id_arr);
  442. if (!$id_arr) {
  443. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  444. exit;
  445. }
  446. //循环删除记录
  447. foreach ($id_arr as $v) {
  448. $sid = $this->whlabel->read($v);
  449. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  450. if ($count > 0) {
  451. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  452. exit;
  453. }
  454. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  455. if (count($zt) > 0) {
  456. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  457. exit;
  458. }
  459. $this->whlabel->remove($v);
  460. }
  461. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  462. exit;
  463. }
  464. if (isset($post['page'])) {
  465. $page = $this->input->post('page', true);
  466. $perpage = $this->input->post('perpage', true);
  467. $warehouse = $this->input->post('warehouse', true);
  468. $label = $this->input->post('label', true);
  469. $where = "1=1 and state = 0";
  470. if ($warehouse) {
  471. $where .= " and warehouse = '$warehouse'";
  472. }
  473. if ($label) {
  474. $where .= " and label = '$label'";
  475. }
  476. //数据排序
  477. $order_str = "time asc";
  478. if (empty($page)) {
  479. $start = 0;
  480. $perpage = 1;
  481. } else {
  482. $start = ($page - 1) * $perpage;
  483. }
  484. //取得信息列表
  485. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  486. foreach ($info_list as $key => $value) {
  487. if ($value['enter'] != 0) {
  488. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  489. } else {
  490. $info_list[$key]['enter'] = "";
  491. }
  492. if ($value['printing'] != 0) {
  493. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  494. } else {
  495. $info_list[$key]['printing'] = "";
  496. }
  497. }
  498. $total = $this->whlabel->find_count($where);
  499. $pagenum = ceil($total / $perpage);
  500. $over = $total - ($start + $perpage);
  501. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  502. echo json_encode($rows);
  503. exit;
  504. }
  505. $this->_Template('whlabel_existence', $this->data);
  506. }
  507. //进销存浏览
  508. public function _typedy($arg_array)
  509. {
  510. $prc = array();
  511. $purchase = $this->purchase->find_all();
  512. foreach ($purchase as $k => $v) {
  513. $prc[$v['id']] = $v['title'];
  514. }
  515. $post = $this->input->post(NULL, TRUE);
  516. if (isset($post['page'])) {
  517. $page = $this->input->post('page', true);
  518. $perpage = $this->input->post('perpage', true);
  519. $category = $this->input->post('category', true);
  520. $size = $this->input->post('size', true);
  521. $grade = $this->input->post('grade', true);
  522. $color = $this->input->post('color', true);
  523. $lowe = $this->input->post('lowe', true);
  524. $sku = $this->input->post('sku');
  525. $title = $this->input->post('title');
  526. $warehouse = $this->input->post('warehouse', true);
  527. $usa = $this->input->post('usa', true);
  528. $purchase = $this->input->post('purchase', true);
  529. $lacetype = $this->input->post('lacetype', true);
  530. $haircap = $this->input->post('haircap', true);
  531. $density = $this->input->post('density', true);
  532. $details = $this->input->post('details', true);
  533. $state = $this->input->post('state', true);
  534. $lacecolor = $this->input->post('lacecolor', true);
  535. $hairnumber = $this->input->post('hairnumber', true);
  536. $cklx = $this->input->post('cklx', true);
  537. $ktime = $this->input->post('ktime', true);
  538. $jtime = $this->input->post('jtime', true);
  539. $sm = $this->input->post('sm', true);
  540. $cpbz = $this->input->post('cpbz', true);
  541. $type = $this->input->post('type', true);
  542. $ktime = strtotime($ktime);
  543. $jtime = strtotime($jtime);
  544. $where = "1=1";
  545. $gj = "";
  546. $ck = "";
  547. if ($usa) {
  548. if (!$warehouse) {
  549. $where .= " and (warehouse = '5' or warehouse = '8')";
  550. }
  551. }
  552. if ($warehouse) {
  553. $where .= " and warehouse = '$warehouse'";
  554. }
  555. if ($details) {
  556. $where .= " and details = '$details'";
  557. }
  558. if ($purchase) {
  559. $where .= " and purchase = '$purchase'";
  560. }
  561. if (isset($state)) {
  562. if($state >-1){
  563. $where .= " and state = '$state'";
  564. }
  565. }
  566. if ($lacetype) {
  567. $where .= " and features like '%-$lacetype-%'";
  568. }
  569. if ($category) {
  570. $where .= " and features like '%-$category-%'";
  571. }
  572. if ($size) {
  573. $where .= " and features like '%-$size-%'";
  574. }
  575. if ($grade) {
  576. $where .= " and features like '%-$grade-%'";
  577. }
  578. if ($color) {
  579. $where .= " and features like '%-$color-%'";
  580. }
  581. if ($lowe) {
  582. $where .= " and features like '%-$lowe-%'";
  583. }
  584. if ($haircap) {
  585. $where .= " and features like '%-$haircap-%'";
  586. }
  587. if ($density) {
  588. $where .= " and features like '%-$density-%'";
  589. }
  590. if ($lacecolor) {
  591. $where .= " and features like '%-$lacecolor-%'";
  592. }
  593. if($sm){
  594. $where .= " and sm like '%".$sm."%'";
  595. }
  596. if($cpbz){
  597. $where .= " and cpbz like '%".$cpbz."%'";
  598. }
  599. if($type){
  600. $where .= " and type = ".$type."";
  601. }
  602. if (!empty($hairnumber)) {
  603. $where .= " and features like '%-128-%' ";
  604. if ($hairnumber < 0) {
  605. $class_list = $this->typeclass->find_all('classid = 43');
  606. foreach ($class_list as $v) {
  607. $where .= " and features not like '%-" . $v['id'] . "-%'";
  608. }
  609. } else {
  610. $where .= " and features like '%-$hairnumber-%'";
  611. }
  612. }
  613. $where_add = '';
  614. if ($cklx) {
  615. $shop = $this->shop->read($cklx);
  616. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  617. }
  618. if ($ktime && $jtime) {
  619. $gj = " and enter > '$ktime' and enter < '$jtime'";
  620. $ck = " and outk > '$ktime' and outk < '$jtime'";
  621. }
  622. //数据排序
  623. $order_str = "id desc";
  624. if (empty($page)) {
  625. $start = 0;
  626. $perpage = 1;
  627. } else {
  628. $start = ($page - 1) * $perpage;
  629. }
  630. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  631. if ($sku) {
  632. $sku = trim($sku, ' ');
  633. $sku = trim($sku, ' ');
  634. $where .= " and sku like '%$sku%'";
  635. $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);
  636. } else if ($title) {
  637. $title = trim($title, ' ');
  638. $title = trim($title, ' ');
  639. $where .= " and title like '%$title%'";
  640. $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);
  641. } else {
  642. //$where .= " and time > '$ktime' and time < '$jtime'";
  643. $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);
  644. }
  645. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  646. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  647. foreach ($info_list as $k => $v) {
  648. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  649. unset($info_list[$k]['pm']);
  650. unset($info_list[$k]['jm']);
  651. unset($info_list[$k]['bm']);
  652. }
  653. //取得信息列表
  654. $rows = array();
  655. $list = array();
  656. foreach ($info_list as $key => $value) {
  657. $warehouse = $this->warehouse->read($value['warehouse']);
  658. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  659. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  660. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  661. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  662. $info_list[$key]['label'] = $value['sm'];
  663. $number = $value['number'];
  664. $ftime = time() - 15 * 24 * 3600;
  665. $info_list[$key]['warehouse'] = $warehouse['title'];
  666. $info_list[$key]['features'] = count($c);
  667. $z = count($z); //查看订单号
  668. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  669. $ztdata = '';
  670. if (count($zt) > 0) {
  671. foreach ($zt as $vv) {
  672. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  673. }
  674. }
  675. $info_list[$key]['number'] = $ztdata;
  676. $info_list[$key]['sm'] = $z;
  677. $details = array();
  678. $cpid = array();
  679. foreach ($c as $k => $v) {
  680. $details[$v['details']] = $v['details'];
  681. if ($v['cpid'] != 0) {
  682. $cpid[$v['cpid']] = $v['cpid'];
  683. }
  684. }
  685. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  686. if ($value['shop'] != '') {
  687. $shop = explode(',', trim($value['shop'], ','));
  688. $shop = $this->shop->read($shop[0]);
  689. $info_list[$key]['shop'] = $shop['shopname'];
  690. }
  691. }
  692. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  693. $pagenum = ceil($total / $perpage);
  694. $over = $total - ($start + $perpage);
  695. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  696. echo json_encode($rows);
  697. exit;
  698. }
  699. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  700. $this->_Template('whlabel_typedy', $this->data);
  701. }
  702. //进销存浏览
  703. public function _typedy_ck($arg_array)
  704. {
  705. $prc = array();
  706. $purchase = $this->purchase->find_all();
  707. foreach ($purchase as $k => $v) {
  708. $prc[$v['id']] = $v['title'];
  709. }
  710. $post = $this->input->post(NULL, TRUE);
  711. if (isset($post['page'])) {
  712. $page = $this->input->post('page', true);
  713. $perpage = $this->input->post('perpage', true);
  714. $category = $this->input->post('category', true);
  715. $size = $this->input->post('size', true);
  716. $grade = $this->input->post('grade', true);
  717. $color = $this->input->post('color', true);
  718. $lowe = $this->input->post('lowe', true);
  719. $sku = $this->input->post('sku');
  720. $title = $this->input->post('title');
  721. $warehouse = $this->input->post('warehouse', true);
  722. $usa = $this->input->post('usa', true);
  723. $purchase = $this->input->post('purchase', true);
  724. $lacetype = $this->input->post('lacetype', true);
  725. $haircap = $this->input->post('haircap', true);
  726. $density = $this->input->post('density', true);
  727. $details = $this->input->post('details', true);
  728. $state = $this->input->post('state', true);
  729. $lacecolor = $this->input->post('lacecolor', true);
  730. $cklx = $this->input->post('cklx', true);
  731. $ktime = $this->input->post('ktime', true);
  732. $jtime = $this->input->post('jtime', true);
  733. $ktime = strtotime($ktime);
  734. $jtime = strtotime($jtime);
  735. $where = "1=1";
  736. $gj = "";
  737. $ck = "";
  738. if ($lacetype) {
  739. $where .= " and features like '%-$lacetype-%'";
  740. }
  741. if ($category) {
  742. $where .= " and features like '%-$category-%'";
  743. }
  744. if ($size) {
  745. $where .= " and features like '%-$size-%'";
  746. }
  747. if ($grade) {
  748. $where .= " and features like '%-$grade-%'";
  749. }
  750. if ($color) {
  751. $where .= " and features like '%-$color-%'";
  752. }
  753. if ($lowe) {
  754. $where .= " and features like '%-$lowe-%'";
  755. }
  756. if ($haircap) {
  757. $where .= " and features like '%-$haircap-%'";
  758. }
  759. if ($density) {
  760. $where .= " and features like '%-$density-%'";
  761. }
  762. if ($lacecolor) {
  763. $where .= " and features like '%-$lacecolor-%'";
  764. }
  765. if ($usa) {
  766. if (!$warehouse) {
  767. $where .= " and (warehouse = '5' or warehouse = '8')";
  768. }
  769. }
  770. if ($warehouse) {
  771. $where .= " and warehouse = '$warehouse'";
  772. }
  773. if ($details) {
  774. $where .= " and details = '$details'";
  775. }
  776. if ($purchase) {
  777. $where .= " and purchase = '$purchase'";
  778. }
  779. if ($state) {
  780. $where .= " and state = '$state'";
  781. }
  782. $where_add = '';
  783. if ($cklx) {
  784. $shop = $this->shop->read($cklx);
  785. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  786. }
  787. if ($ktime && $jtime) {
  788. $gj = " and enter > '$ktime' and enter < '$jtime'";
  789. $ck = " and outk > '$ktime' and outk < '$jtime'";
  790. }
  791. //数据排序
  792. $order_str = "id desc";
  793. if (empty($page)) {
  794. $start = 0;
  795. $perpage = 1;
  796. } else {
  797. $start = ($page - 1) * $perpage;
  798. }
  799. if ($sku) {
  800. $sku = trim($sku, ' ');
  801. $sku = trim($sku, ' ');
  802. $where .= " and sku like '%$sku%'";
  803. $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);
  804. } else if ($title) {
  805. $title = trim($title, ' ');
  806. $title = trim($title, ' ');
  807. $where .= " and title like '%$title%'";
  808. $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);
  809. } else {
  810. //$where .= " and time > '$ktime' and time < '$jtime'";
  811. $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);
  812. }
  813. //取得信息列表
  814. $rows = array();
  815. $list = array();
  816. foreach ($info_list as $key => $value) {
  817. $warehouse = $this->warehouse->read($value['warehouse']);
  818. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  819. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  820. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  821. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  822. $ftime = time() - 15 * 24 * 3600;
  823. $info_list[$key]['warehouse'] = $warehouse['title'];
  824. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  825. //$z = count($z);//查看订单号
  826. //$info_list[$key]['zd'] = $z;
  827. $details = array();
  828. $cpid = array();
  829. foreach ($c as $k => $v) {
  830. $details[$v['details']] = $v['details'];
  831. if ($v['cpid'] != 0) {
  832. $cpid[$v['cpid']] = $v['cpid'];
  833. }
  834. }
  835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  836. if ($value['shop'] != '') {
  837. $shop = explode(',', trim($value['shop'], ','));
  838. $shop = $this->shop->read($shop[0]);
  839. $info_list[$key]['shop'] = $shop['shopname'];
  840. }
  841. }
  842. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  843. $pagenum = ceil($total / $perpage);
  844. $over = $total - ($start + $perpage);
  845. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  846. echo json_encode($rows);
  847. exit;
  848. }
  849. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  850. $this->_Template('whlabel_typedy_ck', $this->data);
  851. }
  852. public function _typeck($arg_array)
  853. {
  854. $prc = array();
  855. $purchase = $this->purchase->find_all();
  856. foreach ($purchase as $k => $v) {
  857. $prc[$v['id']] = $v['title'];
  858. }
  859. $post = $this->input->post(NULL, TRUE);
  860. if (isset($post['page'])) {
  861. $page = $this->input->post('page', true);
  862. $perpage = $this->input->post('perpage', true);
  863. $category = $this->input->post('category', true);
  864. $size = $this->input->post('size', true);
  865. $grade = $this->input->post('grade', true);
  866. $color = $this->input->post('color', true);
  867. $lacecolor = $this->input->post('lacecolor', true);
  868. $lowe = $this->input->post('lowe', true);
  869. $sku = $this->input->post('sku');
  870. $title = $this->input->post('title');
  871. $warehouse = 13;
  872. $usa = $this->input->post('usa', true);
  873. $purchase = $this->input->post('purchase', true);
  874. $lacetype = $this->input->post('lacetype', true);
  875. $haircap = $this->input->post('haircap', true);
  876. $density = $this->input->post('density', true);
  877. $details = $this->input->post('details', true);
  878. $state = $this->input->post('state', true);
  879. $ktime = $this->input->post('ktime', true);
  880. $jtime = $this->input->post('jtime', true);
  881. $ktime = strtotime($ktime);
  882. $jtime = strtotime($jtime);
  883. $where = "1=1";
  884. $gj = "";
  885. $ck = "";
  886. if ($lacetype) {
  887. $where .= " and features like '%-$lacetype-%'";
  888. }
  889. if ($category) {
  890. $where .= " and features like '%-$category-%'";
  891. }
  892. if ($size) {
  893. $where .= " and features like '%-$size-%'";
  894. }
  895. if ($grade) {
  896. $where .= " and features like '%-$grade-%'";
  897. }
  898. if ($color) {
  899. $where .= " and features like '%-$color-%'";
  900. }
  901. if ($lacecolor) {
  902. $where .= " and features like '%-$lacecolor-%'";
  903. }
  904. if ($lowe) {
  905. $where .= " and features like '%-$lowe-%'";
  906. }
  907. if ($haircap) {
  908. $where .= " and features like '%-$haircap-%'";
  909. }
  910. if ($density) {
  911. $where .= " and features like '%-$density-%'";
  912. }
  913. if ($warehouse) {
  914. $where .= " and warehouse = '$warehouse'";
  915. }
  916. if ($details) {
  917. $where .= " and details = '$details'";
  918. }
  919. if ($purchase) {
  920. $where .= " and purchase = '$purchase'";
  921. }
  922. if ($state) {
  923. $where .= " and state = '$state'";
  924. }
  925. if ($ktime && $jtime) {
  926. $gj = " and enter > '$ktime' and enter < '$jtime'";
  927. $ck = " and outk > '$ktime' and outk < '$jtime'";
  928. }
  929. //数据排序
  930. $order_str = "id desc";
  931. if (empty($page)) {
  932. $start = 0;
  933. $perpage = 1;
  934. } else {
  935. $start = ($page - 1) * $perpage;
  936. }
  937. if ($sku) {
  938. $sku = trim($sku, ' ');
  939. $sku = trim($sku, ' ');
  940. $where .= " and sku like '%$sku%'";
  941. } else if ($title) {
  942. $title = trim($title, ' ');
  943. $title = trim($title, ' ');
  944. $where .= " and title like '%$title%'";
  945. }
  946. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  947. //取得信息列表
  948. $t = array();
  949. $typeclass = $this->typeclass->find_all();
  950. foreach ($typeclass as $v) {
  951. $t[$v['id']] = $v;
  952. }
  953. $rows = array();
  954. $list = array();
  955. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  956. foreach ($info_list as $key => $value) {
  957. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  958. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  959. $warehouse = $this->warehouse->read($value['warehouse']);
  960. $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');
  961. $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'] . '"');
  962. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  963. $number = $value['number'];
  964. $ftime = time() - 15 * 24 * 3600;
  965. $z = count($z); //查看订单号
  966. $info_list[$key]['warehouse'] = $warehouse['title'];
  967. $info_list[$key]['features'] = count($c);
  968. $info_list[$key]['number'] = $z;
  969. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  970. $details = array();
  971. $cpid = array();
  972. foreach ($c as $k => $v) {
  973. $details[$v['details']] = $v['details'];
  974. if ($v['cpid'] != 0) {
  975. $cpid[$v['cpid']] = $v['cpid'];
  976. }
  977. }
  978. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  979. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  980. unset($info_list[$key]['pm']);
  981. unset($info_list[$key]['jm']);
  982. unset($info_list[$key]['bm']);
  983. }
  984. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  985. $pagenum = ceil($total / $perpage);
  986. $over = $total - ($start + $perpage);
  987. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  988. echo json_encode($rows);
  989. exit;
  990. }
  991. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  992. $this->_Template('whlabel_typeck', $this->data);
  993. }
  994. //进销存导出
  995. public function _whlabeckdc()
  996. {
  997. $prc = array();
  998. $purchase = $this->purchase->find_all();
  999. foreach ($purchase as $k => $v) {
  1000. $prc[$v['id']] = $v['title'];
  1001. }
  1002. if (isset($_GET['excel'])) {
  1003. $where = "sku != 'Preset'";
  1004. //数据排序
  1005. $order_str = "id desc";
  1006. if (empty($page)) {
  1007. $start = 0;
  1008. $perpage = 1;
  1009. } else {
  1010. $start = ($page - 1) * $perpage;
  1011. }
  1012. $category = $this->input->get('category', true);
  1013. $color = $this->input->get('color', true);
  1014. $lowe = $this->input->get('lowe', true);
  1015. $lacetype = $this->input->get('lacetype', true);
  1016. $size = $this->input->get('size', true);
  1017. $density = $this->input->get('density', true);
  1018. $haircap = $this->input->get('haircap', true);
  1019. $sku = $this->input->get('sku', true);
  1020. $details = $this->input->get('details', true);
  1021. $warehouse = 13;
  1022. $excelid = $this->input->get('sid', true);
  1023. if ($category) {
  1024. $where .= " and features like '%-$category-%'";
  1025. }
  1026. if ($color) {
  1027. $where .= " and features like '%-$color-%'";
  1028. }
  1029. if ($lowe) {
  1030. $where .= " and features like '%-$lowe-%'";
  1031. }
  1032. if ($lacetype) {
  1033. $where .= " and features like '%-$lacetype-%'";
  1034. }
  1035. if ($size) {
  1036. $where .= " and features like '%-$size-%'";
  1037. }
  1038. if ($density) {
  1039. $where .= " and features like '%-$density-%'";
  1040. }
  1041. if ($haircap) {
  1042. $where .= " and features like '%-$haircap-%'";
  1043. }
  1044. if ($warehouse) {
  1045. $where .= " and warehouse = '$warehouse'";
  1046. }
  1047. if ($sku) {
  1048. $where .= " and sku like '%$sku%'";
  1049. }
  1050. if ($details) {
  1051. $where .= " and details = '$details'";
  1052. }
  1053. $xzid = '';
  1054. if ($excelid) {
  1055. $excelid = explode(',', trim($excelid, ','));
  1056. foreach ($excelid as $key => $value) {
  1057. $xzid .= " id = " . $value . " or";
  1058. }
  1059. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1060. }
  1061. //取得信息列表
  1062. /**
  1063. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1064. $rows = array();$list = array();
  1065. foreach ($info_list as $key=>$value)
  1066. {
  1067. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1068. }
  1069. **/
  1070. $wh = array();
  1071. $w = $this->warehouse->find_all('1=1', 'id,title');
  1072. foreach ($w as $v) {
  1073. $wh[$v['id']] = $v['title'];
  1074. }
  1075. $tc = array();
  1076. $tcdata = array();
  1077. $list = array();
  1078. $classid = $this->classid->sku();
  1079. $tcall = $this->typeclass->find_all();
  1080. $typeclass = array();
  1081. foreach ($tcall as $v)
  1082. {
  1083. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1084. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1085. }
  1086. $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 ");
  1087. foreach ($rows as $key => $value) {
  1088. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1089. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1090. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1091. $rows[$key]['cpbz'] = $u9_info['bm'];
  1092. $rows[$key]['cs'] = $u9_info['jm'];
  1093. if(empty($value['details'])){
  1094. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1095. }else{
  1096. $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');
  1097. }
  1098. $details = array();
  1099. $cpid = array();
  1100. $cpbz = array();
  1101. $c = 0;
  1102. $g = 0;
  1103. $x = 0;
  1104. $t = 0;
  1105. $s = 0;
  1106. $q = 0;
  1107. foreach ($sd as $k => $v) {
  1108. if ($v['state'] == 0) {
  1109. $c++;
  1110. }
  1111. if ($v['state'] != 9) {
  1112. $g++;
  1113. }
  1114. if ($v['state'] == 1) {
  1115. $x++;
  1116. }
  1117. if ($v['state'] == 2) {
  1118. $t++;
  1119. }
  1120. if ($v['state'] == 8) {
  1121. $s++;
  1122. }
  1123. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1124. $q++;
  1125. }
  1126. $details[$v['details']] = $v['details'];
  1127. if ($v['cpid'] != 0) {
  1128. $cpid[$v['cpid']] = $v['cpid'];
  1129. }
  1130. if ($v['cpbz'] != '') {
  1131. $cpbz[$v['cpbz']] = $v['cpbz'];
  1132. }
  1133. }
  1134. $rows[$key]['details'] = implode("、", $details);
  1135. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1136. $number = $value['number'];
  1137. $ftime = time() - 15 * 24 * 3600;
  1138. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1139. $rows[$key]['number'] = $g;
  1140. $rows[$key]['features'] = $c;
  1141. $rows[$key]['x'] = $x;
  1142. $rows[$key]['t'] = $t;
  1143. $rows[$key]['s'] = $s;
  1144. $rows[$key]['q'] = $q;
  1145. $rows[$key]['wzsl'] = count($details);
  1146. //cpbzs
  1147. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1148. $unique_arr = array_unique($tmp_cpbzs);
  1149. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1150. }
  1151. $title = "进销存统计表" . date('Y-m-d', time());
  1152. $titlename = "<table border=1>
  1153. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1154. <tr align='center'>
  1155. <td>仓库</td>
  1156. <td>供应商</td>
  1157. <td>位置</td>
  1158. <td>库存编码</td>
  1159. <td>SKU</td>
  1160. <td>用友编码</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. </tr>
  1173. </table>";
  1174. $filename = $title . ".xls";
  1175. $tail = "";
  1176. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1177. }
  1178. }
  1179. public function _type()
  1180. {
  1181. $vip = 0;
  1182. if (isset($_SESSION['api'])) {
  1183. $user = $this->user->get_api($_SESSION['api']);
  1184. $fgshop = "";
  1185. $sid = "";
  1186. $usersp = explode('|', trim($user['shop'], '|'));
  1187. foreach ($usersp as $value) {
  1188. $fgshop .= " shop = " . $value . " or";
  1189. $sid .= " id = " . $value . " or";
  1190. }
  1191. if ($user['vip'] == 1) {
  1192. $vip = 1;
  1193. }
  1194. } else {
  1195. header('Location: /');
  1196. exit;
  1197. }
  1198. $prc = array();
  1199. $purchase = $this->purchase->find_all();
  1200. foreach ($purchase as $k => $v) {
  1201. $prc[$v['id']] = $v['title'];
  1202. }
  1203. $company = array();
  1204. $ct = $this->company->find_all();
  1205. foreach ($ct as $k => $v) {
  1206. $company[$v['id']] = $v['title'];
  1207. }
  1208. $sp = array();
  1209. $s = $this->shop->find_all('1=1', 'id,shopname');
  1210. foreach ($s as $v) {
  1211. $sp[$v['id']] = $v['shopname'];
  1212. }
  1213. $wh = array();
  1214. $w = $this->warehouse->find_all('1=1', 'id,title');
  1215. foreach ($w as $v) {
  1216. $wh[$v['id']] = $v['title'];
  1217. }
  1218. $post = $this->input->post(NULL, TRUE);
  1219. if (isset($post['page'])) {
  1220. $page = $this->input->post('page', true);
  1221. $perpage = $this->input->post('perpage', true);
  1222. $category = $this->input->post('category', true);
  1223. $size = $this->input->post('size', true);
  1224. $grade = $this->input->post('grade', true);
  1225. $color = $this->input->post('color', true);
  1226. $lowe = $this->input->post('lowe', true);
  1227. $sku = $this->input->post('sku');
  1228. $title = $this->input->post('title');
  1229. $warehouse = $this->input->post('warehouse', true);
  1230. $usa = $this->input->post('usa', true);
  1231. $purchase = $this->input->post('purchase', true);
  1232. $lacetype = $this->input->post('lacetype', true);
  1233. $haircap = $this->input->post('haircap', true);
  1234. $density = $this->input->post('density', true);
  1235. $details = $this->input->post('details', true);
  1236. $state = $this->input->post('state', true);
  1237. $shop = $this->input->post('shop', true);
  1238. $lacecolor = $this->input->post('lacecolor', true);
  1239. $hairnumber = $this->input->post('hairnumber', true);
  1240. $type = $this->input->post('type', true);
  1241. $ktime = $this->input->post('ktime', true);
  1242. $jtime = $this->input->post('jtime', true);
  1243. $ktime = strtotime($ktime);
  1244. $jtime = strtotime($jtime);
  1245. $cpbz = $this->input->post('cpbz', true);
  1246. $sm = $this->input->post('sm', true);
  1247. $where = "1=1";
  1248. $gj = "";
  1249. $ck = "";
  1250. if ($usa) {
  1251. if (!$warehouse) {
  1252. $where .= " and (warehouse = '5' or warehouse = '8')";
  1253. }
  1254. }
  1255. if ($warehouse) {
  1256. $where .= " and warehouse = '$warehouse'";
  1257. }
  1258. if ($details) {
  1259. $where .= " and details = '$details'";
  1260. }
  1261. if ($purchase) {
  1262. $where .= " and purchase = '$purchase'";
  1263. }
  1264. if ($state) {
  1265. $where .= " and state = '$state'";
  1266. }
  1267. if ($shop) {
  1268. $where .= " and shop like '%$shop%'";
  1269. }
  1270. if ($type) {
  1271. $where .= " and type = '$type'";
  1272. }
  1273. if ($ktime && $jtime) {
  1274. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1275. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1276. }
  1277. if ($cpbz) {
  1278. $where .= " and cpbz like '%$cpbz%' ";
  1279. }
  1280. if ($sm) {
  1281. $where .= " and sm like '%$sm%' ";
  1282. }
  1283. if ($lacecolor) {
  1284. $where .= " and features like '%-$lacecolor-%'";
  1285. }
  1286. if ($lacetype) {
  1287. $where .= " and features like '%-$lacetype-%'";
  1288. }
  1289. if ($category) {
  1290. $where .= " and features like '%-$category-%'";
  1291. }
  1292. if ($size) {
  1293. $where .= " and features like '%-$size-%'";
  1294. }
  1295. if ($grade) {
  1296. $where .= " and features like '%-$grade-%'";
  1297. }
  1298. if ($color) {
  1299. $where .= " and features like '%-$color-%'";
  1300. }
  1301. if ($lowe) {
  1302. $where .= " and features like '%-$lowe-%'";
  1303. }
  1304. if ($haircap) {
  1305. $where .= " and features like '%-$haircap-%'";
  1306. }
  1307. if ($density) {
  1308. $where .= " and features like '%-$density-%'";
  1309. }
  1310. if (!empty($hairnumber)) {
  1311. $where .= " and features like '%-128-%' ";
  1312. if ($hairnumber < 0) {
  1313. $class_list = $this->typeclass->find_all('classid = 43');
  1314. foreach ($class_list as $v) {
  1315. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1316. }
  1317. } else {
  1318. $where .= " and features like '%-$hairnumber-%'";
  1319. }
  1320. }
  1321. //数据排序
  1322. $order_str = "id desc";
  1323. if (empty($page)) {
  1324. $start = 0;
  1325. $perpage = 1;
  1326. } else {
  1327. $start = ($page - 1) * $perpage;
  1328. }
  1329. $fjnr = '';
  1330. if ($sku) {
  1331. $sku = trim($sku, ' ');
  1332. $sku = trim($sku, ' ');
  1333. $fjnr .= " and sku like '%$sku%'";
  1334. }
  1335. if ($title) {
  1336. $title = trim($title, ' ');
  1337. $title = trim($title, ' ');
  1338. $fjnr .= " and title like '%$title%'";
  1339. }
  1340. $wt = array();
  1341. $whlabel_type = $this->whlabel_type->find_all();
  1342. foreach ($whlabel_type as $v) {
  1343. $wt[$v['id']] = $v['title'];
  1344. }
  1345. //$where .= " and time > '$ktime' and time < '$jtime'";
  1346. $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
  1347. //取得信息列表
  1348. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1349. $rows = array();
  1350. $list = array();
  1351. foreach ($info_list as $key => $value) {
  1352. if (isset($wt[$value['type']])) {
  1353. $info_list[$key]['type'] = $wt[$value['type']];
  1354. } else {
  1355. $info_list[$key]['type'] = '未设置';
  1356. }
  1357. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1358. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1359. $ztdata = '';
  1360. if (count($zt) > 0) {
  1361. foreach ($zt as $vv) {
  1362. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1363. }
  1364. }
  1365. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1366. $cdata = array_filter($qbdata, function ($item) {
  1367. return $item['state'] < 1;
  1368. });
  1369. $c = array_sum(array_column($cdata, 'jnum'));
  1370. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1371. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1372. });
  1373. $g = array_sum(array_column($gdata, 'jnum'));
  1374. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1375. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1376. });
  1377. $x = array_sum(array_column($xdata, 'jnum'));
  1378. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1379. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1380. });
  1381. $t = array_sum(array_column($tdata, 'jnum'));
  1382. // $zdata = array_filter($qbdata, function ($item) {
  1383. // return $item['zd'] != "" && $item['state'] < 1;
  1384. // });
  1385. // $z = array_sum(array_column($zdata, 'jnum'));
  1386. $zdata = array_filter($qbdata, function ($item) {
  1387. return $item['zd'] != "" && $item['state'] < 1;
  1388. });
  1389. $z = array_sum(array_column($zdata, 'jnum'));
  1390. //$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');
  1391. //$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'].'"');
  1392. //$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'].'"');
  1393. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1394. //$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'].'"');
  1395. $details = array();
  1396. $cpid = array();
  1397. $od = array();
  1398. $odid = '';
  1399. $companytitle = '';
  1400. $shop_list = [];
  1401. foreach ($qbdata as $v) {
  1402. if ($v['zd'] != "" && $v['state'] < 1) {
  1403. if (!isset($od[$v['zd']])) {
  1404. $od[$v['zd']] = 1; //所有数据sku
  1405. } else {
  1406. $od[$v['zd']] = $od[$v['zd']] + 1;
  1407. }
  1408. }
  1409. if($v['state'] == 0){
  1410. $details[$v['details']] = $v['details'];
  1411. }
  1412. if ($v['state'] < 1) {
  1413. //$details[$v['details']] = $v['details'];
  1414. if ($v['cpid'] != 0) {
  1415. $cpid[$v['cpid']] = $v['cpid'];
  1416. }
  1417. }
  1418. if($v['state'] == 0){
  1419. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1420. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1421. }
  1422. if ($v['shop'] != '') {
  1423. $shop = explode(',', trim($v['shop'], ','));
  1424. foreach ($shop as $vv) {
  1425. if (!in_array($vv, $shop_list)) {
  1426. $shop_list[] = $vv;
  1427. }
  1428. }
  1429. }
  1430. }
  1431. }
  1432. foreach ($od as $k => $vv) {
  1433. $odid .= $k . '数量' . $vv;
  1434. }
  1435. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1436. $info_list[$key]['label'] = $value['sm'];
  1437. $number = $value['number'];
  1438. $ftime = time() - 15 * 24 * 3600;
  1439. $z = $z . '(' . $odid . ')'; //查看订单号
  1440. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1441. $info_list[$key]['features'] = $c;
  1442. $info_list[$key]['number'] = $ztdata;
  1443. $info_list[$key]['sm'] = $g;
  1444. $info_list[$key]['x'] = $x;
  1445. $info_list[$key]['t'] = $t;
  1446. $info_list[$key]['z'] = $z;
  1447. /**
  1448. foreach ($cdata as $k=>$v)
  1449. {
  1450. $details[$v['details']] = $v['details'];
  1451. if($v['cpid'] != 0)
  1452. {
  1453. $cpid[$v['cpid']] = $v['cpid'];
  1454. }
  1455. }
  1456. **/
  1457. $info_list[$key]['shop'] = '';
  1458. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1459. // if ($value['shop'] != '') {
  1460. // $shop = explode(',', trim($value['shop'], ','));
  1461. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1462. // }
  1463. $shop_list = array_unique($shop_list);
  1464. $shop_str = '';
  1465. foreach ($shop_list as $v) {
  1466. if(isset($sp[$v])){
  1467. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1468. }
  1469. }
  1470. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1471. /**
  1472. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1473. if(isset($companytitle[0]))
  1474. {
  1475. foreach ($companytitle as $k=>$v)
  1476. {
  1477. if($v['companytitle'] != '')
  1478. {
  1479. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1480. }
  1481. }
  1482. }
  1483. **/
  1484. }
  1485. $final_all_list = [];
  1486. foreach ($info_list as $k => $v) {
  1487. $final_all_list[] = [
  1488. 'id' => $v['id'],
  1489. "warehouse" => $v["warehouse"],
  1490. "purchase" => $v["purchase"],
  1491. "sku" => $v["sku"],
  1492. "title" => $v["title"] . "<br/>" . $v["pm"],
  1493. "details" => $v["details"],
  1494. "shop" => $v["shop"],
  1495. "cpbz" => $v["cpbz"],
  1496. 'label' => $v['label'],
  1497. "type" => $v["type"],
  1498. "features" => $v["features"],
  1499. "number" => $v["number"],
  1500. "sm" => $v["sm"],
  1501. "x" => $v["x"],
  1502. "t" => $v["t"],
  1503. "z" => $v["z"]
  1504. ];
  1505. }
  1506. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1507. $pagenum = ceil($total / $perpage);
  1508. $over = $total - ($start + $perpage);
  1509. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1510. echo json_encode($rows);
  1511. exit;
  1512. }
  1513. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1514. $this->data['shop'] = $wlshop;
  1515. $this->data['vip'] = $vip;
  1516. $this->_Template('whlabel_type', $this->data);
  1517. }
  1518. /**
  1519. * _type 优化版 v1
  1520. * 优化点:
  1521. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1522. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1523. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1524. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1525. */
  1526. public function _typev1()
  1527. {
  1528. $vip = 0;
  1529. if (isset($_SESSION['api'])) {
  1530. $user = $this->user->get_api($_SESSION['api']);
  1531. $fgshop = "";
  1532. $sid = "";
  1533. $usersp = explode('|', trim($user['shop'], '|'));
  1534. foreach ($usersp as $value) {
  1535. $fgshop .= " shop = " . $value . " or";
  1536. $sid .= " id = " . $value . " or";
  1537. }
  1538. if ($user['vip'] == 1) {
  1539. $vip = 1;
  1540. }
  1541. } else {
  1542. header('Location: /');
  1543. exit;
  1544. }
  1545. $prc = array();
  1546. $purchase = $this->purchase->find_all();
  1547. foreach ($purchase as $k => $v) {
  1548. $prc[$v['id']] = $v['title'];
  1549. }
  1550. $company = array();
  1551. $ct = $this->company->find_all();
  1552. foreach ($ct as $k => $v) {
  1553. $company[$v['id']] = $v['title'];
  1554. }
  1555. $sp = array();
  1556. $s = $this->shop->find_all('1=1', 'id,shopname');
  1557. foreach ($s as $v) {
  1558. $sp[$v['id']] = $v['shopname'];
  1559. }
  1560. $wh = array();
  1561. $w = $this->warehouse->find_all('1=1', 'id,title');
  1562. foreach ($w as $v) {
  1563. $wh[$v['id']] = $v['title'];
  1564. }
  1565. $post = $this->input->post(NULL, TRUE);
  1566. if (isset($post['page'])) {
  1567. $page = $this->input->post('page', true);
  1568. $perpage = $this->input->post('perpage', true);
  1569. $category = $this->input->post('category', true);
  1570. $size = $this->input->post('size', true);
  1571. $grade = $this->input->post('grade', true);
  1572. $color = $this->input->post('color', true);
  1573. $lowe = $this->input->post('lowe', true);
  1574. $sku = $this->input->post('sku');
  1575. $title = $this->input->post('title');
  1576. $warehouse = $this->input->post('warehouse', true);
  1577. $usa = $this->input->post('usa', true);
  1578. $purchase = $this->input->post('purchase', true);
  1579. $lacetype = $this->input->post('lacetype', true);
  1580. $haircap = $this->input->post('haircap', true);
  1581. $density = $this->input->post('density', true);
  1582. $details = $this->input->post('details', true);
  1583. $state = $this->input->post('state', true);
  1584. $shop = $this->input->post('shop', true);
  1585. $lacecolor = $this->input->post('lacecolor', true);
  1586. $hairnumber = $this->input->post('hairnumber', true);
  1587. $type = $this->input->post('type', true);
  1588. $ktime = $this->input->post('ktime', true);
  1589. $jtime = $this->input->post('jtime', true);
  1590. $ktime = strtotime($ktime);
  1591. $jtime = strtotime($jtime);
  1592. $cpbz = $this->input->post('cpbz', true);
  1593. $sm = $this->input->post('sm', true);
  1594. $where = "1=1";
  1595. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1596. $where_no_features = "1=1";
  1597. if ($usa) {
  1598. if (!$warehouse) {
  1599. $where .= " and (warehouse = '5' or warehouse = '8')";
  1600. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1601. }
  1602. }
  1603. if ($warehouse) {
  1604. $where .= " and warehouse = '$warehouse'";
  1605. $where_no_features .= " and warehouse = '$warehouse'";
  1606. }
  1607. if ($details) {
  1608. $where .= " and details = '$details'";
  1609. $where_no_features .= " and details = '$details'";
  1610. }
  1611. if ($purchase) {
  1612. $where .= " and purchase = '$purchase'";
  1613. $where_no_features .= " and purchase = '$purchase'";
  1614. }
  1615. if ($state) {
  1616. $where .= " and state = '$state'";
  1617. $where_no_features .= " and state = '$state'";
  1618. }
  1619. if ($shop) {
  1620. $where .= " and shop like '%$shop%'";
  1621. $where_no_features .= " and shop like '%$shop%'";
  1622. }
  1623. if ($type) {
  1624. $where .= " and type = '$type'";
  1625. $where_no_features .= " and type = '$type'";
  1626. }
  1627. if ($cpbz) {
  1628. $where .= " and cpbz like '%$cpbz%' ";
  1629. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1630. }
  1631. if ($sm) {
  1632. $where .= " and sm like '%$sm%' ";
  1633. $where_no_features .= " and sm like '%$sm%' ";
  1634. }
  1635. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1636. if ($lacecolor) {
  1637. $where .= " and features like '%-$lacecolor-%'";
  1638. }
  1639. if ($lacetype) {
  1640. $where .= " and features like '%-$lacetype-%'";
  1641. }
  1642. if ($category) {
  1643. $where .= " and features like '%-$category-%'";
  1644. }
  1645. if ($size) {
  1646. $where .= " and features like '%-$size-%'";
  1647. }
  1648. if ($grade) {
  1649. $where .= " and features like '%-$grade-%'";
  1650. }
  1651. if ($color) {
  1652. $where .= " and features like '%-$color-%'";
  1653. }
  1654. if ($lowe) {
  1655. $where .= " and features like '%-$lowe-%'";
  1656. }
  1657. if ($haircap) {
  1658. $where .= " and features like '%-$haircap-%'";
  1659. }
  1660. if ($density) {
  1661. $where .= " and features like '%-$density-%'";
  1662. }
  1663. if (!empty($hairnumber)) {
  1664. $where .= " and features like '%-128-%' ";
  1665. if ($hairnumber < 0) {
  1666. $class_list = $this->typeclass->find_all('classid = 43');
  1667. foreach ($class_list as $v) {
  1668. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1669. }
  1670. } else {
  1671. $where .= " and features like '%-$hairnumber-%'";
  1672. }
  1673. }
  1674. //数据排序
  1675. $order_str = "id desc";
  1676. if (empty($page)) {
  1677. $start = 0;
  1678. $perpage = 1;
  1679. } else {
  1680. $start = ($page - 1) * $perpage;
  1681. }
  1682. $fjnr = '';
  1683. if ($sku) {
  1684. $sku = trim($sku, ' ');
  1685. $sku = trim($sku, ' ');
  1686. $fjnr .= " and sku like '%$sku%'";
  1687. }
  1688. if ($title) {
  1689. $title = trim($title, ' ');
  1690. $title = trim($title, ' ');
  1691. $fjnr .= " and title like '%$title%'";
  1692. }
  1693. $wt = array();
  1694. $whlabel_type = $this->whlabel_type->find_all();
  1695. foreach ($whlabel_type as $v) {
  1696. $wt[$v['id']] = $v['title'];
  1697. }
  1698. // 列表分组(与原来完全一致)
  1699. $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);
  1700. //取得信息列表
  1701. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1702. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1703. $keys = array();
  1704. foreach ($info_list as $v) {
  1705. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1706. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1707. }
  1708. // 组合键函数,用于 PHP 端按分组索引
  1709. $comboKey = function ($r) {
  1710. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1711. };
  1712. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1713. $all_qb = array();
  1714. if (!empty($keys)) {
  1715. $keyInSql = implode(',', $keys);
  1716. $qbAll = $this->whlabel->find_all(
  1717. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1718. );
  1719. foreach ($qbAll as $r) {
  1720. $all_qb[$comboKey($r)][] = $r;
  1721. }
  1722. }
  1723. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1724. $all_zt = array();
  1725. if (!empty($info_list)) {
  1726. $ztKeys = array();
  1727. foreach ($info_list as $v) {
  1728. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1729. . addslashes($v['warehouse']) . "','"
  1730. . addslashes($v['features']) . "')";
  1731. }
  1732. $ztInSql = implode(',', $ztKeys);
  1733. $ztAll = $this->whlabeltransport->find_all(
  1734. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1735. '*',
  1736. 'stime'
  1737. );
  1738. foreach ($ztAll as $r) {
  1739. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1740. $all_zt[$ck][] = $r;
  1741. }
  1742. }
  1743. $rows = array();
  1744. $list = array();
  1745. foreach ($info_list as $key => $value) {
  1746. if (isset($wt[$value['type']])) {
  1747. $info_list[$key]['type'] = $wt[$value['type']];
  1748. } else {
  1749. $info_list[$key]['type'] = '未设置';
  1750. }
  1751. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1752. // transport 在途数据:从预取数组中取
  1753. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1754. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1755. $ztdata = '';
  1756. if (count($zt) > 0) {
  1757. foreach ($zt as $vv) {
  1758. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1759. }
  1760. }
  1761. // whlabel 组数据:从预取数组中取
  1762. $qbCk = $comboKey($value);
  1763. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1764. $cdata = array_filter($qbdata, function ($item) {
  1765. return $item['state'] < 1;
  1766. });
  1767. $c = array_sum(array_column($cdata, 'jnum'));
  1768. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1769. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1770. });
  1771. $g = array_sum(array_column($gdata, 'jnum'));
  1772. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1773. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1774. });
  1775. $x = array_sum(array_column($xdata, 'jnum'));
  1776. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1777. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1778. });
  1779. $t = array_sum(array_column($tdata, 'jnum'));
  1780. $zdata = array_filter($qbdata, function ($item) {
  1781. return $item['zd'] != "" && $item['state'] < 1;
  1782. });
  1783. $z = array_sum(array_column($zdata, 'jnum'));
  1784. $detailsArr = array();
  1785. $cpid = array();
  1786. $od = array();
  1787. $odid = '';
  1788. $companytitle = '';
  1789. $shop_list = [];
  1790. foreach ($qbdata as $v) {
  1791. if ($v['zd'] != "" && $v['state'] < 1) {
  1792. if (!isset($od[$v['zd']])) {
  1793. $od[$v['zd']] = 1;
  1794. } else {
  1795. $od[$v['zd']] = $od[$v['zd']] + 1;
  1796. }
  1797. }
  1798. if ($v['state'] == 0) {
  1799. $detailsArr[$v['details']] = $v['details'];
  1800. }
  1801. if ($v['state'] < 1) {
  1802. if ($v['cpid'] != 0) {
  1803. $cpid[$v['cpid']] = $v['cpid'];
  1804. }
  1805. }
  1806. if ($v['state'] == 0) {
  1807. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1808. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1809. }
  1810. if ($v['shop'] != '') {
  1811. $shopArr = explode(',', trim($v['shop'], ','));
  1812. foreach ($shopArr as $vv) {
  1813. if (!in_array($vv, $shop_list)) {
  1814. $shop_list[] = $vv;
  1815. }
  1816. }
  1817. }
  1818. }
  1819. }
  1820. foreach ($od as $k => $vv) {
  1821. $odid .= $k . '数量' . $vv;
  1822. }
  1823. $info_list[$key]['cpbz'] = $value['cpbz'];
  1824. $info_list[$key]['label'] = $value['sm'];
  1825. $number = $value['number'];
  1826. $z = $z . '(' . $odid . ')';
  1827. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1828. $info_list[$key]['features'] = $c;
  1829. $info_list[$key]['number'] = $ztdata;
  1830. $info_list[$key]['sm'] = $g;
  1831. $info_list[$key]['x'] = $x;
  1832. $info_list[$key]['t'] = $t;
  1833. $info_list[$key]['z'] = $z;
  1834. $info_list[$key]['shop'] = '';
  1835. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1836. $shop_list = array_unique($shop_list);
  1837. $shop_str = '';
  1838. foreach ($shop_list as $v) {
  1839. if (isset($sp[$v])) {
  1840. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1841. }
  1842. }
  1843. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1844. }
  1845. $final_all_list = [];
  1846. foreach ($info_list as $k => $v) {
  1847. $final_all_list[] = [
  1848. 'id' => $v['id'],
  1849. "warehouse" => $v["warehouse"],
  1850. "purchase" => $v["purchase"],
  1851. "sku" => $v["sku"],
  1852. "title" => $v["title"] . "<br/>" . $v["pm"],
  1853. "details" => $v["details"],
  1854. "shop" => $v["shop"],
  1855. "cpbz" => $v["cpbz"],
  1856. 'label' => $v['label'],
  1857. "type" => $v["type"],
  1858. "features" => $v["features"],
  1859. "number" => $v["number"],
  1860. "sm" => $v["sm"],
  1861. "x" => $v["x"],
  1862. "t" => $v["t"],
  1863. "z" => $v["z"]
  1864. ];
  1865. }
  1866. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1867. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1868. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1869. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1870. $countResult = $this->whlabel->query($countSql)->result_array();
  1871. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1872. $pagenum = ceil($total / $perpage);
  1873. $over = $total - ($start + $perpage);
  1874. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1875. echo json_encode($rows);
  1876. exit;
  1877. }
  1878. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1879. $this->data['shop'] = $wlshop;
  1880. $this->data['vip'] = $vip;
  1881. $this->_Template('whlabel_typev1', $this->data);
  1882. }
  1883. //美仓进销存浏览
  1884. public function _usatype()
  1885. {
  1886. if (isset($_SESSION['api'])) {
  1887. $user = $this->user->get_api($_SESSION['api']);
  1888. $usp = $user;
  1889. $fgshop = "";
  1890. $sid = "";
  1891. $wid = "";
  1892. $wtype = "";
  1893. $userwh = explode('|', trim($user['warehouse'], '|'));
  1894. foreach ($userwh as $value) {
  1895. $wid .= " id = " . $value . " or";
  1896. $wtype .= " type = " . $value . " or";
  1897. }
  1898. }
  1899. $prc = array();
  1900. $purchase = $this->purchase->find_all();
  1901. foreach ($purchase as $k => $v) {
  1902. $prc[$v['id']] = $v['title'];
  1903. }
  1904. $post = $this->input->post(NULL, TRUE);
  1905. if (isset($post['page'])) {
  1906. $page = $this->input->post('page', true);
  1907. $perpage = $this->input->post('perpage', true);
  1908. $category = $this->input->post('category', true);
  1909. $size = $this->input->post('size', true);
  1910. $grade = $this->input->post('grade', true);
  1911. $color = $this->input->post('color', true);
  1912. $lowe = $this->input->post('lowe', true);
  1913. $sku = $this->input->post('sku');
  1914. $title = $this->input->post('title');
  1915. $warehouse = $this->input->post('warehouse', true);
  1916. $usa = $this->input->post('usa', true);
  1917. $purchase = $this->input->post('purchase', true);
  1918. $lacetype = $this->input->post('lacetype', true);
  1919. $haircap = $this->input->post('haircap', true);
  1920. $density = $this->input->post('density', true);
  1921. $details = $this->input->post('details', true);
  1922. $state = $this->input->post('state', true);
  1923. $lacecolor = $this->input->post('lacecolor', true);
  1924. $cklx = $this->input->post('cklx', true);
  1925. $ktime = $this->input->post('ktime', true);
  1926. $jtime = $this->input->post('jtime', true);
  1927. $ktime = strtotime($ktime);
  1928. $jtime = strtotime($jtime);
  1929. $where = "1=1";
  1930. $gj = "";
  1931. $ck = "";
  1932. if ($lacetype) {
  1933. $where .= " and features like '%-$lacetype-%'";
  1934. }
  1935. if ($category) {
  1936. $where .= " and features like '%-$category-%'";
  1937. }
  1938. if ($size) {
  1939. $where .= " and features like '%-$size-%'";
  1940. }
  1941. if ($grade) {
  1942. $where .= " and features like '%-$grade-%'";
  1943. }
  1944. if ($color) {
  1945. $where .= " and features like '%-$color-%'";
  1946. }
  1947. if ($lowe) {
  1948. $where .= " and features like '%-$lowe-%'";
  1949. }
  1950. if ($haircap) {
  1951. $where .= " and features like '%-$haircap-%'";
  1952. }
  1953. if ($density) {
  1954. $where .= " and features like '%-$density-%'";
  1955. }
  1956. if ($lacecolor) {
  1957. $where .= " and features like '%-$lacecolor-%'";
  1958. }
  1959. if ($usa) {
  1960. if (!$warehouse) {
  1961. $where .= " and (warehouse = '5' or warehouse = '8')";
  1962. }
  1963. }
  1964. if ($warehouse) {
  1965. $where .= " and warehouse = '$warehouse'";
  1966. }
  1967. if ($details) {
  1968. $where .= " and details = '$details'";
  1969. }
  1970. if ($purchase) {
  1971. $where .= " and purchase = '$purchase'";
  1972. }
  1973. if ($state) {
  1974. $where .= " and state = '$state'";
  1975. }
  1976. $where_add = '';
  1977. if ($cklx) {
  1978. $shop = $this->shop->read($cklx);
  1979. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1980. }
  1981. if ($ktime && $jtime) {
  1982. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1983. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1984. }
  1985. //数据排序
  1986. $order_str = "id desc";
  1987. if (empty($page)) {
  1988. $start = 0;
  1989. $perpage = 1;
  1990. } else {
  1991. $start = ($page - 1) * $perpage;
  1992. }
  1993. if ($sku) {
  1994. $sku = trim($sku, ' ');
  1995. $sku = trim($sku, ' ');
  1996. $where .= " and sku like '%$sku%'";
  1997. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1998. } else if ($title) {
  1999. $title = trim($title, ' ');
  2000. $title = trim($title, ' ');
  2001. $where .= " and title like '%$title%'";
  2002. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2003. } else {
  2004. //$where .= " and time > '$ktime' and time < '$jtime'";
  2005. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2006. }
  2007. //取得信息列表
  2008. $rows = array();
  2009. $list = array();
  2010. foreach ($info_list as $key => $value) {
  2011. $warehouse = $this->warehouse->read($value['warehouse']);
  2012. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2013. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2016. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2017. $od = array();
  2018. $odid = '';
  2019. foreach ($z as $v) {
  2020. if (!isset($od[$v['zd']])) {
  2021. $od[$v['zd']] = 1; //所有数据sku
  2022. } else {
  2023. $od[$v['zd']] = $od[$v['zd']] + 1;
  2024. }
  2025. }
  2026. foreach ($od as $k => $vv) {
  2027. $odid .= $k . '数量' . $vv . ' ';
  2028. }
  2029. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2030. $info_list[$key]['features'] = $c;
  2031. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2032. $ztdata = '';
  2033. if (count($zt) > 0) {
  2034. foreach ($zt as $vv) {
  2035. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2036. }
  2037. }
  2038. $info_list[$key]['warehouse'] = $ztdata;
  2039. $info_list[$key]['g'] = $g;
  2040. $info_list[$key]['x'] = $x;
  2041. $info_list[$key]['t'] = $t;
  2042. $info_list[$key]['z'] = $z;
  2043. }
  2044. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2045. $pagenum = ceil($total / $perpage);
  2046. $over = $total - ($start + $perpage);
  2047. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2048. echo json_encode($rows);
  2049. exit;
  2050. }
  2051. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2052. $this->data['warehouse'] = $warehouse;
  2053. $this->_Template('whlabel_typeusa', $this->data);
  2054. }
  2055. //美仓进销存浏览
  2056. public function _usatypeapp()
  2057. {
  2058. $post = $this->input->post(NULL, TRUE);
  2059. if (isset($post['page'])) {
  2060. $page = $this->input->post('page', true);
  2061. $perpage = $this->input->post('perpage', true);
  2062. $sku = $this->input->post('sku', true);
  2063. $warehouse = 5;
  2064. $title = $this->input->post('title', true);
  2065. $state = $this->input->post('state', true);
  2066. $ktime = $this->input->post('ktime', true);
  2067. $jtime = $this->input->post('jtime', true);
  2068. $ktime = strtotime($ktime);
  2069. $jtime = strtotime($jtime);
  2070. $where = "1=1";
  2071. $gj = "";
  2072. $ck = "";
  2073. if ($title) {
  2074. $st = explode(' ', trim($title, ' '));
  2075. foreach ($st as $v) {
  2076. $where .= " and title like '%$v%'";
  2077. }
  2078. }
  2079. if ($warehouse) {
  2080. $where .= " and warehouse = '$warehouse'";
  2081. }
  2082. if ($state) {
  2083. $where .= " and state = '$state'";
  2084. }
  2085. if ($sku) {
  2086. $where .= " and sku like '%$sku%'";
  2087. }
  2088. if ($ktime && $jtime) {
  2089. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2090. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2091. }
  2092. //数据排序
  2093. $order_str = "id desc";
  2094. if (empty($page)) {
  2095. $start = 0;
  2096. $perpage = 1;
  2097. } else {
  2098. $start = ($page - 1) * $perpage;
  2099. }
  2100. //取得信息列表
  2101. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2102. $rows = array();
  2103. $list = array();
  2104. foreach ($info_list as $key => $value) {
  2105. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2106. }
  2107. $rowsdq = array_slice($rows, $start, $perpage);
  2108. foreach ($rowsdq as $value) {
  2109. $warehouse = $this->warehouse->read($value['warehouse']);
  2110. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2111. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2112. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2113. $od = array();
  2114. $odid = '';
  2115. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2116. }
  2117. $total = count($rows);
  2118. $pagenum = ceil($total / $perpage);
  2119. $over = $total - ($start + $perpage);
  2120. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2121. echo json_encode($rows);
  2122. exit;
  2123. }
  2124. $this->_Template('phone/p_usatypeapp', $this->data);
  2125. }
  2126. //入库操作
  2127. public function _enteradd()
  2128. {
  2129. $dt = 0;
  2130. if (isset($_SESSION['api'])) {
  2131. $user = $this->user->get_api($_SESSION['api']);
  2132. $usp = $user;
  2133. $fgshop = "";
  2134. $sid = "";
  2135. $user = explode('|', trim($user['shop'], '|'));
  2136. foreach ($user as $value) {
  2137. $fgshop .= " shop = " . $value . " or";
  2138. $sid .= " id = " . $value . " or";
  2139. }
  2140. }
  2141. $tc = $this->typeclass->find_all();
  2142. $typeclass = array();
  2143. foreach ($tc as $v) {
  2144. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2145. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2146. }
  2147. $post = $this->input->post(NULL, TRUE);
  2148. if (isset($post['sku'])) {
  2149. $list = array();
  2150. $num = "";
  2151. $title = "";
  2152. $features = "";
  2153. $order = $this->input->post('order', true);
  2154. $shop = $this->input->post('shop', true);
  2155. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2156. $sku = $this->input->post('sku', true);
  2157. $post['sm'] = $this->input->post('sm', true);
  2158. $post['warehouse'] = $this->input->post('warehouse', true);
  2159. $post['purchase'] = $this->input->post('purchase', true);
  2160. $post['retreatwarehouse'] = $post['warehouse'];
  2161. $post['state'] = $this->input->post('state', true);
  2162. $post['rktype'] = $this->input->post('rktype', true);
  2163. $post['text'] = $this->input->post('text', true);
  2164. $category = $this->input->post('category', true);
  2165. $list['category'] = $category;
  2166. $list['hairtype'] = $this->input->post('hairtype', true);
  2167. $list['grade'] = $this->input->post('grade', true);
  2168. $size = $this->input->post('size', true);
  2169. $xzsku = $this->input->post('xzsku', true);
  2170. $list['size'] = rtrim($size, ',');
  2171. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2172. $list['extension'] = $this->input->post('extension', true);
  2173. if ($category == 1297) {
  2174. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2175. }
  2176. if ($category == 1702) {
  2177. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2178. $list['syother'] = $this->input->post('syother', true);
  2179. }
  2180. if ($category == 133) {
  2181. $list['fittype'] = $this->input->post('fittype', true);
  2182. $list['acother'] = $this->input->post('acother', true);
  2183. }
  2184. $list['color'] = $this->input->post('color', true);
  2185. $list['lowe'] = $this->input->post('lowe', true);
  2186. if (!$post['purchase']) {
  2187. $post['purchase'] = 1;
  2188. }
  2189. if ($category == 127) {
  2190. $list['type'] = $this->input->post('type', true);
  2191. $list['headroad'] = $this->input->post('headroad', true);
  2192. $list['density'] = $this->input->post('density', true);
  2193. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. }
  2196. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2197. $list['lacetypes'] = $this->input->post('lacetypes', 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. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2243. if ($k != 'size') {
  2244. $title .= $typeclass[$v]['title'] . " ";
  2245. }
  2246. if (isset($pm[$typeclass[$v]['classid']])) {
  2247. if ($typeclass[$v]['title'] == '9A') {
  2248. $pm[$typeclass[$v]['classid']] = '9A';
  2249. } else if ($typeclass[$v]['title'] == '10A') {
  2250. $pm[$typeclass[$v]['classid']] = '10A';
  2251. } else {
  2252. $clzh = $typeclass[$v]['zh'];
  2253. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2254. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2255. $clzh = $clzh[0];
  2256. }
  2257. $pm[$typeclass[$v]['classid']] = $clzh;
  2258. }
  2259. }
  2260. }
  2261. }
  2262. $zh = implode(" ", $pm);
  2263. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2264. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2265. if ($list['size']) {
  2266. $typeclass = $this->typeclass->read($list['size']);
  2267. $title .= $typeclass['title'];
  2268. }
  2269. $time = time();
  2270. if ($xzsku) {
  2271. $scsku = implode("-", $scsku);
  2272. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2273. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2274. $post['sku'] = trim($scsku, ' ');
  2275. } else {
  2276. $post['sku'] = $sku;
  2277. }
  2278. //$post['sku'] = trim($sku,' ');
  2279. $post['title'] = rtrim($title, ' ');
  2280. $post['number'] = $num;
  2281. $post['features'] = '-' . $features;
  2282. $post['enter'] = $time;
  2283. $post['time'] = $time; //操作时间
  2284. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2285. if ($yza) {
  2286. if ($post['features'] != $yza[0]['features']) {
  2287. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2288. exit;
  2289. }
  2290. }
  2291. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2292. if ($yzb) {
  2293. if ($post['sku'] != $yzb[0]['sku']) {
  2294. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2295. exit;
  2296. }
  2297. }
  2298. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2299. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2300. exit;
  2301. }
  2302. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2303. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2304. exit;
  2305. }
  2306. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2307. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2308. exit;
  2309. }
  2310. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2311. if (isset($yz[0]['type'])) {
  2312. $post['type'] = $yz[0]['type'];
  2313. }
  2314. if ($post['state'] == 9) //如果选择预设库存
  2315. {
  2316. $this->whlabel->insert($post);
  2317. } else {
  2318. /**
  2319. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2320. if($ljg == 1)
  2321. {
  2322. for($i=0;$i<$order;$i++)
  2323. {
  2324. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2325. $this->whlabel->insert($post);
  2326. }
  2327. }
  2328. **/
  2329. //if($post['warehouse'] == '5')
  2330. //{
  2331. //}
  2332. $yydata = $post;
  2333. $yydata['zh'] = $zh;
  2334. /**
  2335. $wl = $this->apiyy->get_cjlp($yydata);
  2336. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2337. {
  2338. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2339. }
  2340. if($wl['Data'][0]['m_isSucess'] != 1)
  2341. {
  2342. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2343. }
  2344. **/
  2345. for ($i = 0; $i < $order; $i++) {
  2346. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2347. $this->whlabel->insert($post);
  2348. }
  2349. }
  2350. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2351. exit;
  2352. }
  2353. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2354. $this->data['wlshop'] = $wlshop;
  2355. $this->_Template('whlabel_enteradd', $this->data);
  2356. }
  2357. //修改产品
  2358. public function _enteredit($arg_array)
  2359. {
  2360. $dt = 0;
  2361. if (isset($_SESSION['api'])) {
  2362. $user = $this->user->get_api($_SESSION['api']);
  2363. $usp = $user;
  2364. $fgshop = "";
  2365. $sid = "";
  2366. $user = explode('|', trim($user['shop'], '|'));
  2367. foreach ($user as $value) {
  2368. $fgshop .= " shop = " . $value . " or";
  2369. $sid .= " id = " . $value . " or";
  2370. }
  2371. }
  2372. $post = $this->input->post(NULL, TRUE);
  2373. if (isset($post['sku'])) {
  2374. $list = array();
  2375. $num = "";
  2376. $title = "";
  2377. $features = "";
  2378. $id = $this->input->post('id', true);
  2379. $order = $this->input->post('order', true);
  2380. $shop = $this->input->post('shop', true);
  2381. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2382. $post['sku'] = $this->input->post('sku', true);
  2383. $post['sm'] = $this->input->post('sm', true);
  2384. $post['warehouse'] = $this->input->post('warehouse', true);
  2385. $post['purchase'] = $this->input->post('purchase', true);
  2386. $post['retreatwarehouse'] = $post['warehouse'];
  2387. $category = $this->input->post('category', true);
  2388. $list['category'] = $category;
  2389. $list['hairtype'] = $this->input->post('hairtype', true);
  2390. $list['grade'] = $this->input->post('grade', true);
  2391. $size = $this->input->post('size', true);
  2392. $list['size'] = rtrim($size, ',');
  2393. $post['rktype'] = $this->input->post('rktype', true);
  2394. $post['text'] = $this->input->post('text', true);
  2395. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2396. $list['extension'] = $this->input->post('extension', true);
  2397. if ($category == 1297) {
  2398. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2399. }
  2400. if ($category == 1702) {
  2401. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2402. $list['syother'] = $this->input->post('syother', true);
  2403. }
  2404. if ($category == 133) {
  2405. $list['fittype'] = $this->input->post('fittype', true);
  2406. $list['acother'] = $this->input->post('acother', true);
  2407. }
  2408. $list['color'] = $this->input->post('color', true);
  2409. $list['lowe'] = $this->input->post('lowe', true);
  2410. if (!$post['purchase']) {
  2411. $post['purchase'] = 1;
  2412. }
  2413. if ($category == 127) {
  2414. $list['type'] = $this->input->post('type', true);
  2415. $list['headroad'] = $this->input->post('headroad', true);
  2416. $list['density'] = $this->input->post('density', true);
  2417. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  2418. $list['lacesize'] = $this->input->post('lacesize', true);
  2419. }
  2420. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2421. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2422. }
  2423. if ($category == 128) {
  2424. $list['lacetype'] = $this->input->post('lacetype', true);
  2425. $list['haircap'] = $this->input->post('haircap', true);
  2426. $list['density'] = $this->input->post('density', true);
  2427. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2428. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2429. $list['wigother'] = $this->input->post('wigother', true);
  2430. $list['wigother1'] = $this->input->post('wigother1', true);
  2431. $list['wigother2'] = $this->input->post('wigother2', true);
  2432. $list['product_related'] = $this->input->post('product_related', true);
  2433. }
  2434. if ($category == 129) {
  2435. $list['wide'] = $this->input->post('wide', true);
  2436. }
  2437. if ($category == 131) {
  2438. $list['gifttype'] = $this->input->post('gifttype', true);
  2439. $list['giftother'] = $this->input->post('giftother', true);
  2440. }
  2441. if ($category == 134) {
  2442. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2443. }
  2444. if ($category == 1297) {
  2445. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2446. $list['sywigother'] = $this->input->post('sywigother', true);
  2447. }
  2448. if ($category == 130 || $category == 133 || $category == 1702) {
  2449. $list['items'] = $this->input->post('items', true);
  2450. $list['weight'] = $this->input->post('weight', true);
  2451. }
  2452. if($category == 130){
  2453. $list['jfother'] = $this->input->post('jfother', true);
  2454. }
  2455. if ($category == 1702) {
  2456. $list['syhairther'] = $this->input->post('syhairther', true);
  2457. }
  2458. foreach ($list as $k => $v) {
  2459. if ($v != 0) {
  2460. $num .= $v;
  2461. $features .= $v . '-';
  2462. $typeclass = $this->typeclass->read($v);
  2463. if ($k != 'size') {
  2464. $title .= $typeclass['title'] . " ";
  2465. }
  2466. }
  2467. }
  2468. $typeclass = $this->typeclass->read($list['size']);
  2469. $title .= $typeclass['title'];
  2470. $time = time();
  2471. $post['title'] = rtrim($title, ' ');
  2472. $post['number'] = $num;
  2473. $post['features'] = '-' . $features;
  2474. $post['time'] = $time; //操作时间
  2475. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2476. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2477. exit;
  2478. }
  2479. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2480. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2481. exit;
  2482. }
  2483. $uid = $this->whlabel->read($id);
  2484. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2485. if ($datanum > 0) {
  2486. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2487. exit;
  2488. }
  2489. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2490. {
  2491. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2492. if ($yza) {
  2493. if ($post['features'] != $yza[0]['features']) {
  2494. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2495. exit;
  2496. }
  2497. }
  2498. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2499. if ($yzb) {
  2500. if ($post['sku'] != $yzb[0]['sku']) {
  2501. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2502. exit;
  2503. }
  2504. }
  2505. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2506. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2507. exit;
  2508. }
  2509. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2510. foreach ($data as $v) {
  2511. $post['id'] = $v['id'];
  2512. $this->whlabel->save($post, $v['id']);
  2513. }
  2514. } else {
  2515. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2516. if ($data > 0) {
  2517. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2518. exit;
  2519. } else {
  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. }
  2526. }
  2527. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2528. exit;
  2529. }
  2530. $uid = $this->whlabel->read($arg_array[0]);
  2531. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2532. $this->data['enter'] = $uid;
  2533. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2534. $this->data['wlshop'] = $wlshop;
  2535. $this->_Template('whlabel_enteredit', $this->data);
  2536. }
  2537. //入库浏览
  2538. public function _enter()
  2539. {
  2540. $post = $this->input->post(NULL, TRUE);
  2541. if (isset($post['s'])) {
  2542. $id_arr = $this->input->post('s');
  2543. $id_arr = explode(',', $id_arr);
  2544. if (!$id_arr) {
  2545. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2546. exit;
  2547. }
  2548. //循环删除记录
  2549. foreach ($id_arr as $v) {
  2550. $sid = $this->whlabel->read($v);
  2551. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2552. if ($count > 0) {
  2553. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2554. exit;
  2555. }
  2556. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2557. foreach ($info_list as $va) {
  2558. $this->whlabel->remove($va['id']);
  2559. }
  2560. }
  2561. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2562. exit;
  2563. }
  2564. $sp = array();
  2565. $s = $this->shop->find_all('1=1', 'id,shopname');
  2566. foreach ($s as $v) {
  2567. $sp[$v['id']] = $v['shopname'];
  2568. }
  2569. $wh = array();
  2570. $w = $this->warehouse->find_all('1=1', 'id,title');
  2571. foreach ($w as $v) {
  2572. $wh[$v['id']] = $v['title'];
  2573. }
  2574. if (isset($post['page'])) {
  2575. $page = $this->input->post('page', true);
  2576. $perpage = $this->input->post('perpage', true);
  2577. $category = $this->input->post('category', true);
  2578. $size = $this->input->post('size', true);
  2579. $grade = $this->input->post('grade', true);
  2580. $color = $this->input->post('color', true);
  2581. $lowe = $this->input->post('lowe', true);
  2582. $sku = $this->input->post('sku', true);
  2583. $warehouse = $this->input->post('warehouse', true);
  2584. $purchase = $this->input->post('purchase', true);
  2585. $ktime = $this->input->post('ktime', true);
  2586. $jtime = $this->input->post('jtime', true);
  2587. $ktime = strtotime($ktime);
  2588. $jtime = strtotime($jtime);
  2589. $where = "1=1";
  2590. $gj = "";
  2591. $ck = "";
  2592. if ($category) {
  2593. $where .= " and features like '%-$category-%'";
  2594. }
  2595. if ($size) {
  2596. $where .= " and features like '%-$size-%'";
  2597. }
  2598. if ($grade) {
  2599. $where .= " and features like '%-$grade-%'";
  2600. }
  2601. if ($color) {
  2602. $where .= " and features like '%-$color-%'";
  2603. }
  2604. if ($lowe) {
  2605. $where .= " and features like '%-$lowe-%'";
  2606. }
  2607. if ($warehouse) {
  2608. $where .= " and warehouse = '$warehouse'";
  2609. }
  2610. if ($purchase) {
  2611. $where .= " and purchase = '$purchase'";
  2612. }
  2613. if ($sku) {
  2614. $where .= " and sku like '%$sku%'";
  2615. }
  2616. if ($ktime && $jtime) {
  2617. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2618. }
  2619. //数据排序
  2620. $order_str = "enter desc";
  2621. if (empty($page)) {
  2622. $start = 0;
  2623. $perpage = 1;
  2624. } else {
  2625. $start = ($page - 1) * $perpage;
  2626. }
  2627. //取得信息列表
  2628. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2629. foreach ($info_list as $k => $v) {
  2630. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2631. if ($v['shop'] == '') {
  2632. $s = '通用';
  2633. } else {
  2634. $info_list[$k]['shop'] = '';
  2635. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2636. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2637. }
  2638. }
  2639. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2640. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2641. $info_list[$k]['g'] = $g;
  2642. }
  2643. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2644. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2645. $pagenum = ceil($total / $perpage);
  2646. $over = $total - ($start + $perpage);
  2647. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2648. echo json_encode($rows);
  2649. exit;
  2650. }
  2651. $this->_Template('whlabel_enter', $this->data);
  2652. }
  2653. //出库浏览
  2654. public function _out()
  2655. {
  2656. $post = $this->input->post(NULL, TRUE);
  2657. if (isset($post['page'])) {
  2658. $page = $this->input->post('page', true);
  2659. $perpage = $this->input->post('perpage', true);
  2660. $category = $this->input->post('category', true);
  2661. $size = $this->input->post('size', true);
  2662. $grade = $this->input->post('grade', true);
  2663. $color = $this->input->post('color', true);
  2664. $lowe = $this->input->post('lowe', true);
  2665. $sku = $this->input->post('sku', true);
  2666. $warehouse = $this->input->post('warehouse', true);
  2667. $purchase = $this->input->post('purchase', true);
  2668. $state = $this->input->post('state', true);
  2669. $ktime = $this->input->post('ktime', true);
  2670. $jtime = $this->input->post('jtime', true);
  2671. $ktime = strtotime($ktime);
  2672. $jtime = strtotime($jtime);
  2673. $where = "state=3";
  2674. $gj = "";
  2675. $ck = "";
  2676. if ($category) {
  2677. $where .= " and features like '%-$category-%'";
  2678. }
  2679. if ($size) {
  2680. $where .= " and features like '%-$size-%'";
  2681. }
  2682. if ($grade) {
  2683. $where .= " and features like '%-$grade-%'";
  2684. }
  2685. if ($color) {
  2686. $where .= " and features like '%-$color-%'";
  2687. }
  2688. if ($lowe) {
  2689. $where .= " and features like '%-$lowe-%'";
  2690. }
  2691. if ($state) {
  2692. $where .= " and state = '$state'";
  2693. }
  2694. if ($warehouse) {
  2695. $where .= " and warehouse = '$warehouse'";
  2696. }
  2697. if ($purchase) {
  2698. $where .= " and purchase = '$purchase'";
  2699. }
  2700. if ($sku) {
  2701. $where .= " and sku = '$sku'";
  2702. }
  2703. if ($ktime && $jtime) {
  2704. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2705. }
  2706. //数据排序
  2707. $order_str = "id desc";
  2708. if (empty($page)) {
  2709. $start = 0;
  2710. $perpage = 1;
  2711. } else {
  2712. $start = ($page - 1) * $perpage;
  2713. }
  2714. //取得信息列表
  2715. $info_list = $this->whlabel->find_all($where, 'sku');
  2716. $rows = array();
  2717. $list = array();
  2718. foreach ($info_list as $key => $value) {
  2719. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2720. }
  2721. $rows = array_unique($rows); //删除重复记录
  2722. foreach ($rows as $key => $value) {
  2723. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2724. $ck = $this->warehouse->read($data['warehouse']);
  2725. $warehouse = $ck['title'];
  2726. $gy = $this->purchase->read($data['purchase']);
  2727. $purchase = $gy['purchase'];
  2728. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2729. $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);
  2730. }
  2731. $total = count($list);
  2732. $pagenum = ceil($total / $perpage);
  2733. $over = $total - ($start + $perpage);
  2734. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2735. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2736. echo json_encode($rows);
  2737. exit;
  2738. }
  2739. $this->_Template('whlabel_out', $this->data);
  2740. }
  2741. //出库标签浏览
  2742. public function _label()
  2743. {
  2744. $post = $this->input->post(NULL, TRUE);
  2745. if (isset($post['page'])) {
  2746. $page = $this->input->post('page', true);
  2747. $perpage = $this->input->post('perpage', true);
  2748. $sku = $this->input->post('sku', true);
  2749. $warehouse = $this->input->post('warehouse', true);
  2750. $purchase = $this->input->post('purchase', true);
  2751. $orderinfo = $this->input->post('orderinfo', true);
  2752. $waybill = $this->input->post('waybill', true);
  2753. $category = $this->input->post('category', true);
  2754. $size = $this->input->post('size', true);
  2755. $grade = $this->input->post('grade', true);
  2756. $color = $this->input->post('color', true);
  2757. $lowe = $this->input->post('lowe', true);
  2758. $where = "state=1";
  2759. if ($sku) {
  2760. $where .= " and sku = '$sku'";
  2761. }
  2762. if ($warehouse) {
  2763. $where .= " and warehouse = '$warehouse'";
  2764. }
  2765. if ($purchase) {
  2766. $where .= " and purchase = '$purchase'";
  2767. }
  2768. if ($orderinfo) {
  2769. $where .= " and orderinfo = '$orderinfo'";
  2770. }
  2771. if ($waybill) {
  2772. $where .= " and waybill = '$waybill'";
  2773. }
  2774. if ($category) {
  2775. $where .= " and features like '%-$category-%'";
  2776. }
  2777. if ($size) {
  2778. $where .= " and features like '%-$size-%'";
  2779. }
  2780. if ($grade) {
  2781. $where .= " and features like '%-$grade-%'";
  2782. }
  2783. if ($color) {
  2784. $where .= " and features like '%-$color-%'";
  2785. }
  2786. if ($lowe) {
  2787. $where .= " and features like '%-$lowe-%'";
  2788. }
  2789. //数据排序
  2790. $order_str = "outk desc";
  2791. if (empty($page)) {
  2792. $start = 0;
  2793. $perpage = 1;
  2794. } else {
  2795. $start = ($page - 1) * $perpage;
  2796. }
  2797. //取得信息列表
  2798. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2799. foreach ($info_list as $key => $value) {
  2800. $warehouse = $this->warehouse->read($value['warehouse']);
  2801. $info_list[$key]['warehouse'] = $warehouse['title'];
  2802. $purchase = $this->purchase->read($value['purchase']);
  2803. $info_list[$key]['purchase'] = $purchase['title'];
  2804. if ($value['outk'] != 0) {
  2805. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2806. } else {
  2807. $info_list[$key]['outk'] = "";
  2808. }
  2809. if ($value['orderinfo'] == 0) {
  2810. $info_list[$key]['orderinfo'] = "";
  2811. }
  2812. if ($value['waybill'] == 0) {
  2813. $info_list[$key]['waybill'] = "";
  2814. }
  2815. }
  2816. $total = $this->whlabel->find_count($where);
  2817. $pagenum = ceil($total / $perpage);
  2818. $over = $total - ($start + $perpage);
  2819. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2820. echo json_encode($rows);
  2821. exit;
  2822. }
  2823. $this->_Template('whlabel_label', $this->data);
  2824. }
  2825. //独立站出库订单
  2826. public function _outorder()
  2827. {
  2828. if (isset($_SESSION['api'])) {
  2829. $user = $this->user->get_api($_SESSION['api']);
  2830. $usp = $user;
  2831. $fgshop = "";
  2832. $sid = "";
  2833. $user = explode('|', trim($user['shop'], '|'));
  2834. foreach ($user as $value) {
  2835. $fgshop .= " shop = " . $value . " or";
  2836. $sid .= " id = " . $value . " or";
  2837. }
  2838. } else {
  2839. echo "请重新登录";
  2840. }
  2841. $post = $this->input->post(NULL, TRUE);
  2842. if (isset($post['page'])) {
  2843. $page = $this->input->post('page', true);
  2844. $perpage = $this->input->post('perpage', true);
  2845. $warehouse = $this->input->post('warehouse', true);
  2846. $xztime = $this->input->post('xztime', true);
  2847. $timetk = $this->input->post('timetkk', true);
  2848. $timetj = $this->input->post('timetjj', true);
  2849. $shop = $this->input->post('shop', true);
  2850. $source = $this->input->post('source', true);
  2851. $orderinfo = $this->input->post('orderinfo', true);
  2852. $number = $this->input->post('number', true);
  2853. $sfxh = $this->input->post('sfxh', true);
  2854. $express = $this->input->post('express', true);
  2855. $waybill = $this->input->post('waybill', true);
  2856. $library = $this->input->post('library', true);
  2857. $country = $this->input->post('country', true);
  2858. $so = $this->input->post('so', true);
  2859. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2860. $print = $this->input->post('print', true);
  2861. $state = $this->input->post('state', true);
  2862. $orderurl = $this->input->post('orderurl', true);
  2863. $productid = $this->input->post('productid', true);
  2864. $timetk = strtotime($timetk);
  2865. $timetj = strtotime($timetj);
  2866. /**
  2867. $sj = $this->input->post('sj',true);
  2868. if($sj)
  2869. {
  2870. $sj = $this->input->post('sj',true);
  2871. }
  2872. else
  2873. {
  2874. $sj = "fullorder";
  2875. }
  2876. **/
  2877. $sj = "fullorder";
  2878. $where = "1=1";
  2879. if ($warehouse) {
  2880. $where .= " and type = '$warehouse'";
  2881. }
  2882. if ($timetk && $timetj) {
  2883. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2884. }
  2885. if ($orderinfo) {
  2886. $where .= " and orderinfo = '$orderinfo'";
  2887. }
  2888. if ($number) {
  2889. $where .= " and number = '$number'";
  2890. }
  2891. if ($express) {
  2892. $where .= " and express = '$express'";
  2893. }
  2894. if ($waybill) {
  2895. $where .= " and waybill = '$waybill'";
  2896. }
  2897. if ($library) {
  2898. $where .= " and library = '$library'";
  2899. }
  2900. if ($print) {
  2901. $where .= " and print = '$print'";
  2902. }
  2903. if ($libraryconfirm) {
  2904. $where .= " and libraryconfirm = '$libraryconfirm'";
  2905. }
  2906. if ($state) {
  2907. $where .= " and state = '$state'";
  2908. }
  2909. if ($shop) {
  2910. $where .= " and shop = '$shop'";
  2911. }
  2912. if ($country) {
  2913. $where .= " and country = '$country'";
  2914. }
  2915. if ($sfxh != '') {
  2916. $where .= " and sfxh = '$sfxh'";
  2917. }
  2918. if ($so) {
  2919. $where .= " and shipremarks like '%$so%'";
  2920. }
  2921. if ($source) {
  2922. if ($source == '2d') {
  2923. $where .= " and source >= '2'";
  2924. } else {
  2925. $where .= " and source = '$source'";
  2926. }
  2927. }
  2928. if (isset($_SESSION['api'])) {
  2929. foreach ($user as $value) {
  2930. $fgshop .= " shop = " . $value . " or";
  2931. }
  2932. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2933. }
  2934. if ($orderurl) {
  2935. $url = $this->orderurl->read($orderurl);
  2936. $where .= " and link like '%" . $url['url'] . "%'";
  2937. }
  2938. if($productid){
  2939. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2940. }
  2941. //数据排序
  2942. $order_str = "librarytime desc";
  2943. if (empty($page)) {
  2944. $start = 0;
  2945. $perpage = 1;
  2946. } else {
  2947. $start = ($page - 1) * $perpage;
  2948. }
  2949. //取得信息列表
  2950. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2951. //格式化数据
  2952. foreach ($info_list as $key => $value) {
  2953. $shop = $this->shop->read($value['shop']);
  2954. $info_list[$key]['shop'] = $shop['shopname'];
  2955. $express = $this->express->read($value['express']);
  2956. $info_list[$key]['express'] = $express['servicename'];
  2957. $warehouse = $this->warehouse->read($value['type']);
  2958. $info_list[$key]['type'] = $warehouse['title'];
  2959. if ($value['librarytime'] == '0') {
  2960. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2961. } else {
  2962. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2963. }
  2964. }
  2965. $total = $this->$sj->find_count($where);
  2966. $pagenum = ceil($total / $perpage);
  2967. $over = $total - ($start + $perpage);
  2968. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2969. echo json_encode($rows);
  2970. exit;
  2971. }
  2972. $this->data['express'] = $this->express->find_all();
  2973. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2974. $this->data['wlshop'] = $wlshop;
  2975. $user = $this->user->get_api($_SESSION['api']);
  2976. $powerid = $this->power->read($user['power']);
  2977. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2978. $pid = '';
  2979. foreach ($powertext as $v) {
  2980. $pid .= " id = " . $v . " or";
  2981. }
  2982. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2983. $this->data['fullorderexcel'] = $fullorderexcel;
  2984. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2985. $this->data['orderurl'] = $orderurl;
  2986. $this->_Template('whlabel_outorder', $this->data);
  2987. }
  2988. //tt出库
  2989. public function _toutorder()
  2990. {
  2991. $fgshop = "";
  2992. $sid = "";
  2993. if (isset($_SESSION['api'])) {
  2994. $user = $this->user->get_api($_SESSION['api']);
  2995. $usp = $user;
  2996. $user = explode('|', trim($user['shop'], '|'));
  2997. foreach ($user as $value) {
  2998. $fgshop .= " shop = " . $value . " or";
  2999. $sid .= " id = " . $value . " or";
  3000. }
  3001. } else {
  3002. echo "请重新登录";
  3003. die;
  3004. }
  3005. $post = $this->input->post(NULL, TRUE);
  3006. if (isset($post['page'])) {
  3007. $page = $this->input->post('page', true);
  3008. $perpage = $this->input->post('perpage', true);
  3009. $warehouse = $this->input->post('warehouse', true);
  3010. $xztime = $this->input->post('xztime', true);
  3011. $timetk = $this->input->post('timetkk', true);
  3012. $timetj = $this->input->post('timetjj', true);
  3013. $shop = $this->input->post('shop', true);
  3014. $source = $this->input->post('source', true);
  3015. $orderinfo = $this->input->post('orderinfo', true);
  3016. $number = $this->input->post('number', true);
  3017. $sfxh = $this->input->post('sfxh', true);
  3018. $express = $this->input->post('express', true);
  3019. $waybill = $this->input->post('waybill', true);
  3020. $library = $this->input->post('library', true);
  3021. $country = $this->input->post('country', true);
  3022. $so = $this->input->post('so', true);
  3023. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3024. $print = $this->input->post('print', true);
  3025. $state = $this->input->post('state', true);
  3026. $orderurl = $this->input->post('orderurl', true);
  3027. $timetk = strtotime($timetk);
  3028. $timetj = strtotime($timetj);
  3029. /**
  3030. $sj = $this->input->post('sj',true);
  3031. if($sj)
  3032. {
  3033. $sj = $this->input->post('sj',true);
  3034. }
  3035. else
  3036. {
  3037. $sj = "fullorder";
  3038. }
  3039. **/
  3040. $sj = "fullordertt";
  3041. $where = "1=1";
  3042. if ($warehouse) {
  3043. $where .= " and type = '$warehouse'";
  3044. }
  3045. if ($timetk && $timetj) {
  3046. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3047. }
  3048. if ($orderinfo) {
  3049. $where .= " and orderinfo = '$orderinfo'";
  3050. }
  3051. if ($number) {
  3052. $where .= " and number = '$number'";
  3053. }
  3054. if ($express) {
  3055. $where .= " and express = '$express'";
  3056. }
  3057. if ($waybill) {
  3058. $where .= " and waybill = '$waybill'";
  3059. }
  3060. if ($library) {
  3061. $where .= " and library = '$library'";
  3062. }
  3063. if ($print) {
  3064. $where .= " and print = '$print'";
  3065. }
  3066. if ($libraryconfirm) {
  3067. $where .= " and libraryconfirm = '$libraryconfirm'";
  3068. }
  3069. if ($state) {
  3070. $where .= " and state = '$state'";
  3071. }
  3072. if ($shop) {
  3073. $where .= " and shop = '$shop'";
  3074. }
  3075. if ($country) {
  3076. $where .= " and country = '$country'";
  3077. }
  3078. if ($sfxh != '') {
  3079. $where .= " and sfxh = '$sfxh'";
  3080. }
  3081. if ($so) {
  3082. $where .= " and shipremarks like '%$so%'";
  3083. }
  3084. if ($source) {
  3085. if ($source == '2d') {
  3086. $where .= " and source >= '2'";
  3087. } else {
  3088. $where .= " and source = '$source'";
  3089. }
  3090. }
  3091. if (isset($_SESSION['api'])) {
  3092. foreach ($user as $value) {
  3093. $fgshop .= " shop = " . $value . " or";
  3094. }
  3095. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3096. }
  3097. if ($orderurl) {
  3098. $url = $this->orderurl->read($orderurl);
  3099. $where .= " and link like '%" . $url['url'] . "%'";
  3100. }
  3101. //数据排序
  3102. $order_str = "librarytime desc";
  3103. if (empty($page)) {
  3104. $start = 0;
  3105. $perpage = 1;
  3106. } else {
  3107. $start = ($page - 1) * $perpage;
  3108. }
  3109. //取得信息列表
  3110. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3111. //格式化数据
  3112. foreach ($info_list as $key => $value) {
  3113. $shop = $this->shop->read($value['shop']);
  3114. $info_list[$key]['shop'] = $shop['shopname'];
  3115. $express = $this->express->read($value['express']);
  3116. $info_list[$key]['express'] = $express['servicename'];
  3117. $warehouse = $this->warehouse->read($value['type']);
  3118. $info_list[$key]['type'] = $warehouse['title'];
  3119. if ($value['librarytime'] == '0') {
  3120. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3121. } else {
  3122. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3123. }
  3124. }
  3125. $total = $this->$sj->find_count($where);
  3126. $pagenum = ceil($total / $perpage);
  3127. $over = $total - ($start + $perpage);
  3128. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3129. echo json_encode($rows);
  3130. exit;
  3131. }
  3132. $this->data['express'] = $this->express->find_all();
  3133. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3134. $this->data['wlshop'] = $wlshop;
  3135. $user = $this->user->get_api($_SESSION['api']);
  3136. $powerid = $this->power->read($user['power']);
  3137. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3138. $pid = '';
  3139. foreach ($powertext as $v) {
  3140. $pid .= " id = " . $v . " or";
  3141. }
  3142. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3143. $this->data['fullorderexcel'] = $fullorderexcel;
  3144. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3145. $this->data['orderurl'] = $orderurl;
  3146. $this->_Template('whlabel_toutorder', $this->data);
  3147. }
  3148. //tt出库
  3149. public function _aoutorder()
  3150. {
  3151. if (isset($_SESSION['api'])) {
  3152. $user = $this->user->get_api($_SESSION['api']);
  3153. $usp = $user;
  3154. $fgshop = "";
  3155. $sid = "";
  3156. $user = explode('|', trim($user['shop'], '|'));
  3157. foreach ($user as $value) {
  3158. $fgshop .= " shop = " . $value . " or";
  3159. $sid .= " id = " . $value . " or";
  3160. }
  3161. } else {
  3162. echo "请重新登录";
  3163. }
  3164. $post = $this->input->post(NULL, TRUE);
  3165. if (isset($post['page'])) {
  3166. $page = $this->input->post('page', true);
  3167. $perpage = $this->input->post('perpage', true);
  3168. $warehouse = $this->input->post('warehouse', true);
  3169. $xztime = $this->input->post('xztime', true);
  3170. $timetk = $this->input->post('timetkk', true);
  3171. $timetj = $this->input->post('timetjj', true);
  3172. $shop = $this->input->post('shop', true);
  3173. $source = $this->input->post('source', true);
  3174. $orderinfo = $this->input->post('orderinfo', true);
  3175. $number = $this->input->post('number', true);
  3176. $sfxh = $this->input->post('sfxh', true);
  3177. $express = $this->input->post('express', true);
  3178. $waybill = $this->input->post('waybill', true);
  3179. $library = $this->input->post('library', true);
  3180. $country = $this->input->post('country', true);
  3181. $so = $this->input->post('so', true);
  3182. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3183. $print = $this->input->post('print', true);
  3184. $state = $this->input->post('state', true);
  3185. $orderurl = $this->input->post('orderurl', true);
  3186. $timetk = strtotime($timetk);
  3187. $timetj = strtotime($timetj);
  3188. /**
  3189. $sj = $this->input->post('sj',true);
  3190. if($sj)
  3191. {
  3192. $sj = $this->input->post('sj',true);
  3193. }
  3194. else
  3195. {
  3196. $sj = "fullorder";
  3197. }
  3198. **/
  3199. $sj = "fullorderamz";
  3200. $where = "1=1";
  3201. if ($warehouse) {
  3202. $where .= " and type = '$warehouse'";
  3203. }
  3204. if ($timetk && $timetj) {
  3205. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3206. }
  3207. if ($orderinfo) {
  3208. $where .= " and orderinfo = '$orderinfo'";
  3209. }
  3210. if ($number) {
  3211. $where .= " and number = '$number'";
  3212. }
  3213. if ($express) {
  3214. $where .= " and express = '$express'";
  3215. }
  3216. if ($waybill) {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if ($library) {
  3220. $where .= " and library = '$library'";
  3221. }
  3222. if ($print) {
  3223. $where .= " and print = '$print'";
  3224. }
  3225. if ($libraryconfirm) {
  3226. $where .= " and libraryconfirm = '$libraryconfirm'";
  3227. }
  3228. if ($state) {
  3229. $where .= " and state = '$state'";
  3230. }
  3231. if ($shop) {
  3232. $where .= " and shop = '$shop'";
  3233. }
  3234. if ($country) {
  3235. $where .= " and country = '$country'";
  3236. }
  3237. if ($sfxh != '') {
  3238. $where .= " and sfxh = '$sfxh'";
  3239. }
  3240. if ($so) {
  3241. $where .= " and shipremarks like '%$so%'";
  3242. }
  3243. if ($source) {
  3244. if ($source == '2d') {
  3245. $where .= " and source >= '2'";
  3246. } else {
  3247. $where .= " and source = '$source'";
  3248. }
  3249. }
  3250. if (isset($_SESSION['api'])) {
  3251. foreach ($user as $value) {
  3252. $fgshop .= " shop = " . $value . " or";
  3253. }
  3254. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3255. }
  3256. if ($orderurl) {
  3257. $url = $this->orderurl->read($orderurl);
  3258. $where .= " and link like '%" . $url['url'] . "%'";
  3259. }
  3260. //数据排序
  3261. $order_str = "librarytime desc";
  3262. if (empty($page)) {
  3263. $start = 0;
  3264. $perpage = 1;
  3265. } else {
  3266. $start = ($page - 1) * $perpage;
  3267. }
  3268. //取得信息列表
  3269. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3270. //格式化数据
  3271. foreach ($info_list as $key => $value) {
  3272. $shop = $this->shop->read($value['shop']);
  3273. $info_list[$key]['shop'] = $shop['shopname'];
  3274. $express = $this->express->read($value['express']);
  3275. $info_list[$key]['express'] = $express['servicename'];
  3276. $warehouse = $this->warehouse->read($value['type']);
  3277. $info_list[$key]['type'] = $warehouse['title'];
  3278. if ($value['librarytime'] == '0') {
  3279. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3280. } else {
  3281. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3282. }
  3283. }
  3284. $total = $this->$sj->find_count($where);
  3285. $pagenum = ceil($total / $perpage);
  3286. $over = $total - ($start + $perpage);
  3287. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3288. echo json_encode($rows);
  3289. exit;
  3290. }
  3291. $this->data['express'] = $this->express->find_all();
  3292. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3293. $this->data['wlshop'] = $wlshop;
  3294. $user = $this->user->get_api($_SESSION['api']);
  3295. $powerid = $this->power->read($user['power']);
  3296. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3297. $pid = '';
  3298. foreach ($powertext as $v) {
  3299. $pid .= " id = " . $v . " or";
  3300. }
  3301. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3302. $this->data['fullorderexcel'] = $fullorderexcel;
  3303. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3304. $this->data['orderurl'] = $orderurl;
  3305. $this->_Template('whlabel_aoutorder', $this->data);
  3306. }
  3307. //速卖通出库订单
  3308. public function _soutorder()
  3309. {
  3310. if (isset($_SESSION['api'])) {
  3311. $user = $this->user->get_api($_SESSION['api']);
  3312. $usp = $user;
  3313. $fgshop = "";
  3314. $sid = "";
  3315. $user = explode('|', trim($user['shop'], '|'));
  3316. foreach ($user as $value) {
  3317. $sid .= " id = " . $value . " or";
  3318. }
  3319. }
  3320. $post = $this->input->post(NULL, TRUE);
  3321. if (isset($post['page'])) {
  3322. $page = $this->input->post('page', true);
  3323. $perpage = $this->input->post('perpage', true);
  3324. $warehouse = $this->input->post('warehouse', true);
  3325. $xztime = $this->input->post('xztime', true);
  3326. $timetk = $this->input->post('timetkk', true);
  3327. $timetj = $this->input->post('timetjj', true);
  3328. $shop = $this->input->post('shop', true);
  3329. $source = $this->input->post('source', true);
  3330. $orderinfo = $this->input->post('orderinfo', true);
  3331. $number = $this->input->post('number', true);
  3332. $express = $this->input->post('express', true);
  3333. $waybill = $this->input->post('waybill', true);
  3334. $library = $this->input->post('library', true);
  3335. $country = $this->input->post('country', true);
  3336. $sfxh = $this->input->post('sfxh', true);
  3337. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3338. $print = $this->input->post('print', true);
  3339. $state = $this->input->post('state', true);
  3340. $so = $this->input->post('so', true);
  3341. $timetk = strtotime($timetk);
  3342. $timetj = strtotime($timetj);
  3343. /**
  3344. $sj = $this->input->post('sj',true);
  3345. if($sj)
  3346. {
  3347. $sj = $this->input->post('sj',true);
  3348. }
  3349. else
  3350. {
  3351. $sj = "fullorder";
  3352. }
  3353. **/
  3354. $sj = "fullordersmt";
  3355. $where = "1=1";
  3356. if ($warehouse) {
  3357. $where .= " and type = '$warehouse'";
  3358. }
  3359. if ($timetk && $timetj) {
  3360. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3361. }
  3362. if ($orderinfo) {
  3363. $where .= " and orderinfo = '$orderinfo'";
  3364. }
  3365. if ($number) {
  3366. $where .= " and number = '$number'";
  3367. }
  3368. if ($express) {
  3369. $where .= " and express = '$express'";
  3370. }
  3371. if ($waybill) {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if ($library) {
  3375. $where .= " and library = '$library'";
  3376. }
  3377. if ($print) {
  3378. $where .= " and print = '$print'";
  3379. }
  3380. if ($libraryconfirm) {
  3381. $where .= " and libraryconfirm = '$libraryconfirm'";
  3382. }
  3383. if ($state) {
  3384. $where .= " and state = '$state'";
  3385. }
  3386. if ($shop) {
  3387. $where .= " and shop = '$shop'";
  3388. }
  3389. if ($sfxh != '') {
  3390. $where .= " and sfxh = '$sfxh'";
  3391. }
  3392. if ($so) {
  3393. $where .= " and shipremarks like '%$so%'";
  3394. }
  3395. if ($source) {
  3396. $where .= " and source = '$source'";
  3397. }
  3398. if ($country) {
  3399. $where .= " and country = '$country'";
  3400. } else {
  3401. if (isset($_SESSION['api'])) {
  3402. foreach ($user as $value) {
  3403. $fgshop .= " shop = " . $value . " or";
  3404. }
  3405. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3406. }
  3407. }
  3408. //数据排序
  3409. $order_str = "librarytime desc";
  3410. if (empty($page)) {
  3411. $start = 0;
  3412. $perpage = 1;
  3413. } else {
  3414. $start = ($page - 1) * $perpage;
  3415. }
  3416. //取得信息列表
  3417. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3418. //格式化数据
  3419. foreach ($info_list as $key => $value) {
  3420. $shop = $this->shop->read($value['shop']);
  3421. $info_list[$key]['shop'] = $shop['shopname'];
  3422. $express = $this->express->read($value['express']);
  3423. $info_list[$key]['express'] = $express['servicename'];
  3424. $warehouse = $this->warehouse->read($value['type']);
  3425. $info_list[$key]['type'] = $warehouse['title'];
  3426. if ($value['librarytime'] == '0') {
  3427. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3428. } else {
  3429. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3430. }
  3431. }
  3432. $total = $this->$sj->find_count($where);
  3433. $pagenum = ceil($total / $perpage);
  3434. $over = $total - ($start + $perpage);
  3435. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3436. echo json_encode($rows);
  3437. exit;
  3438. }
  3439. $this->data['express'] = $this->express->find_all();
  3440. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3441. $this->data['wlshop'] = $wlshop;
  3442. $user = $this->user->get_api($_SESSION['api']);
  3443. $powerid = $this->power->read($user['power']);
  3444. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3445. $pid = '';
  3446. foreach ($powertext as $v) {
  3447. $pid .= " id = " . $v . " or";
  3448. }
  3449. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3450. $this->data['fullorderexcel'] = $fullorderexcel;
  3451. $this->_Template('whlabel_soutorder', $this->data);
  3452. }
  3453. //订单退库
  3454. public function _retreat()
  3455. {
  3456. $post = $this->input->post(NULL, TRUE);
  3457. if (isset($post['page'])) {
  3458. $page = $this->input->post('page', true);
  3459. $perpage = $this->input->post('perpage', true);
  3460. $warehouse = $this->input->post('warehouse', true);
  3461. $timetk = $this->input->post('timetk', true);
  3462. $timetj = $this->input->post('timetj', true);
  3463. $shop = $this->input->post('shop', true);
  3464. $source = $this->input->post('source', true);
  3465. $state = $this->input->post('state', true);
  3466. $review = $this->input->post('review', true);
  3467. $state = $this->input->post('state', true);
  3468. $express = $this->input->post('express', true);
  3469. $orderinfo = $this->input->post('orderinfo', true);
  3470. $user = $this->input->post('user', true);
  3471. $name = $this->input->post('name', true);
  3472. $waybill = $this->input->post('waybill', true);
  3473. $timetk = strtotime($timetk);
  3474. $timetj = strtotime($timetj);
  3475. $where = "(state=206 or state=210) and mergeid = 0";
  3476. if ($warehouse) {
  3477. $where .= " and state = '$warehouse'";
  3478. }
  3479. if ($timetk && $timetj) {
  3480. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3481. }
  3482. if ($shop) {
  3483. $where .= " and shop = '$shop'";
  3484. }
  3485. if ($source) {
  3486. $where .= " and source = '$source'";
  3487. }
  3488. if ($state) {
  3489. $where .= " and state = '$state'";
  3490. }
  3491. if ($review) {
  3492. $where .= " and review = '$review'";
  3493. }
  3494. if ($state) {
  3495. $where .= " and state = '$state'";
  3496. }
  3497. if ($express) {
  3498. $where .= " and express = '$express'";
  3499. }
  3500. if ($orderinfo) {
  3501. $where .= " and orderinfo = '$orderinfo'";
  3502. }
  3503. if ($user) {
  3504. $where .= " and user = '$user'";
  3505. }
  3506. if ($name) {
  3507. $where .= " and name = '$name'";
  3508. }
  3509. if ($waybill) {
  3510. $where .= " and waybill = '$waybill'";
  3511. }
  3512. //数据排序
  3513. $order_str = "id desc";
  3514. if (empty($page)) {
  3515. $start = 0;
  3516. $perpage = 1;
  3517. } else {
  3518. $start = ($page - 1) * $perpage;
  3519. }
  3520. //取得信息列表
  3521. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3522. //格式化数据
  3523. foreach ($info_list as $key => $value) {
  3524. $shop = $this->shop->read($value['shop']);
  3525. $info_list[$key]['shop'] = $shop['shopname'];
  3526. $warehouse = $this->warehouse->read($value['warehouse']);
  3527. $info_list[$key]['warehouse'] = $warehouse['title'];
  3528. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3529. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3530. if ($value['waybill'] == 0) {
  3531. $info_list[$key]['waybill'] = "";
  3532. }
  3533. $express = $this->express->read($value['express']);
  3534. $info_list[$key]['express'] = $express['title'];
  3535. $typeclass = $this->typeclass->read($value['state']);
  3536. $info_list[$key]['state'] = $typeclass['title'];
  3537. }
  3538. $total = $this->fullorder->find_count($where);
  3539. $pagenum = ceil($total / $perpage);
  3540. $over = $total - ($start + $perpage);
  3541. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3542. echo json_encode($rows);
  3543. exit;
  3544. }
  3545. $this->data['express'] = $this->express->find_all();
  3546. $this->_Template('whlabel_retreat', $this->data);
  3547. }
  3548. //退库标签浏览
  3549. public function _retreatlk()
  3550. {
  3551. $post = $this->input->post(NULL, TRUE);
  3552. if (isset($post['page'])) {
  3553. $page = $this->input->post('page', true);
  3554. $perpage = $this->input->post('perpage', true);
  3555. $timetk = $this->input->post('timetk', true);
  3556. $timetj = $this->input->post('timetj', true);
  3557. $sku = $this->input->post('sku', true);
  3558. $warehouse = $this->input->post('warehouse', true);
  3559. $purchase = $this->input->post('purchase', true);
  3560. $orderinfo = $this->input->post('orderinfo', true);
  3561. $waybill = $this->input->post('waybill', true);
  3562. $category = $this->input->post('category', true);
  3563. $size = $this->input->post('size', true);
  3564. $grade = $this->input->post('grade', true);
  3565. $color = $this->input->post('color', true);
  3566. $lowe = $this->input->post('lowe', true);
  3567. $state = $this->input->post('state', true);
  3568. $timetk = strtotime($timetk);
  3569. $timetj = strtotime($timetj);
  3570. $where = "state=2";
  3571. if ($timetk && $timetj) {
  3572. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3573. }
  3574. if ($sku) {
  3575. $where .= " and sku = '$sku'";
  3576. }
  3577. if ($warehouse) {
  3578. $where .= " and warehouse = '$warehouse'";
  3579. }
  3580. if ($purchase) {
  3581. $where .= " and purchase = '$purchase'";
  3582. }
  3583. if ($orderinfo) {
  3584. $where .= " and orderinfo = '$orderinfo'";
  3585. }
  3586. if ($waybill) {
  3587. $where .= " and waybill = '$waybill'";
  3588. }
  3589. if ($category) {
  3590. $where .= " and features like '%-$category-%'";
  3591. }
  3592. if ($size) {
  3593. $where .= " and features like '%-$size-%'";
  3594. }
  3595. if ($grade) {
  3596. $where .= " and features like '%-$grade-%'";
  3597. }
  3598. if ($color) {
  3599. $where .= " and features like '%-$color-%'";
  3600. }
  3601. if ($lowe) {
  3602. $where .= " and features like '%-$lowe-%'";
  3603. }
  3604. //数据排序
  3605. $order_str = "time desc";
  3606. if (empty($page)) {
  3607. $start = 0;
  3608. $perpage = 1;
  3609. } else {
  3610. $start = ($page - 1) * $perpage;
  3611. }
  3612. //取得信息列表
  3613. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3614. foreach ($info_list as $key => $value) {
  3615. $warehouse = $this->warehouse->read($value['warehouse']);
  3616. $info_list[$key]['warehouse'] = $warehouse['title'];
  3617. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3618. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3619. $purchase = $this->purchase->read($value['purchase']);
  3620. $info_list[$key]['purchase'] = $purchase['title'];
  3621. if ($value['outk'] != 0) {
  3622. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3623. } else {
  3624. $info_list[$key]['outk'] = "";
  3625. }
  3626. if ($value['retreat'] != 0) {
  3627. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3628. } else {
  3629. $info_list[$key]['retreat'] = "";
  3630. }
  3631. if ($value['orderinfo'] == 0) {
  3632. $info_list[$key]['orderinfo'] = "";
  3633. }
  3634. if ($value['waybill'] == 0) {
  3635. $info_list[$key]['waybill'] = "";
  3636. }
  3637. }
  3638. $total = $this->whlabel->find_count($where);
  3639. $pagenum = ceil($total / $perpage);
  3640. $over = $total - ($start + $perpage);
  3641. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3642. echo json_encode($rows);
  3643. exit;
  3644. }
  3645. $this->_Template('whlabel_retreatlk', $this->data);
  3646. }
  3647. //更换标签及浏览
  3648. public function _change()
  3649. {
  3650. $post = $this->input->post(NULL, TRUE);
  3651. if (isset($post['page'])) {
  3652. $page = $this->input->post('page', true);
  3653. $perpage = $this->input->post('perpage', true);
  3654. $timetk = $this->input->post('timetk', true);
  3655. $timetj = $this->input->post('timetj', true);
  3656. $label = $this->input->post('label', true);
  3657. $oldlabel = $this->input->post('oldlabel', true);
  3658. $timetk = strtotime($timetk);
  3659. $timetj = strtotime($timetj);
  3660. $where = "state=10 ";
  3661. if ($timetk && $timetj) {
  3662. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3663. }
  3664. if ($label) {
  3665. $where .= " and label = '$label'";
  3666. }
  3667. if ($oldlabel) {
  3668. $where .= " and oldlabel = '$oldlabel'";
  3669. }
  3670. //数据排序
  3671. $order_str = "time asc";
  3672. if (empty($page)) {
  3673. $start = 0;
  3674. $perpage = 1;
  3675. } else {
  3676. $start = ($page - 1) * $perpage;
  3677. }
  3678. //取得信息列表
  3679. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3680. foreach ($info_list as $key => $value) {
  3681. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3682. }
  3683. $total = $this->whlabel->find_count($where);
  3684. $pagenum = ceil($total / $perpage);
  3685. $over = $total - ($start + $perpage);
  3686. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3687. echo json_encode($rows);
  3688. exit;
  3689. }
  3690. $this->_Template('whlabel_change', $this->data);
  3691. }
  3692. //产品标签
  3693. public function _cpbqdc()
  3694. {
  3695. if (isset($_GET['excel'])) {
  3696. $where = "1=1";
  3697. //数据排序
  3698. $order_str = "id desc";
  3699. if (empty($page)) {
  3700. $start = 0;
  3701. $perpage = 1;
  3702. } else {
  3703. $start = ($page - 1) * $perpage;
  3704. }
  3705. $warehouse = $this->input->get('warehouse', true);
  3706. $state = $this->input->get('state', true);
  3707. $timetk = $this->input->get('timetkk', true);
  3708. $timetj = $this->input->get('timetjj', true);
  3709. $timetk = strtotime($timetk);
  3710. $timetj = strtotime($timetj);
  3711. if ($warehouse) {
  3712. $where .= " and warehouse = '$warehouse'";
  3713. }
  3714. if ($state || $state == 0) {
  3715. $where .= " and state = '$state'";
  3716. }
  3717. if ($timetk && $timetj) {
  3718. $where .= " and time > '$timetk' and time < '$timetj'";
  3719. }
  3720. //取得信息列表
  3721. $info_list = $this->whlabel->find_all($where, '*');
  3722. $rows = array();
  3723. $list = array();
  3724. foreach ($info_list as $key => $value) {
  3725. $rows[$value['time']] = $value; //所有数据sku
  3726. }
  3727. foreach ($rows as $value) {
  3728. $warehouse = $this->warehouse->read($value['warehouse']);
  3729. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3730. $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);
  3731. }
  3732. $title = "产品标签统计表";
  3733. $titlename = "<table border=1>
  3734. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3735. <tr align='center'>
  3736. <td>仓库</td>
  3737. <td>SKU</td>
  3738. <td>产品</td>
  3739. <td>入库时间</td>
  3740. <td>操作时间</td>
  3741. <td>备注</td>
  3742. <td>数量</td>
  3743. </tr>
  3744. </table>";
  3745. $filename = $title . ".xls";
  3746. $tail = "";
  3747. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3748. }
  3749. }
  3750. //进销存导出
  3751. public function _exceljxc()
  3752. {
  3753. $classid = $this->classid->sku();
  3754. $pm = $classid;
  3755. $typeclass = array();
  3756. $tc = $this->typeclass->find_all();
  3757. foreach ($tc as $v) {
  3758. $typeclass[$v['id']] = $v;
  3759. }
  3760. $prc = array();
  3761. $purchase = $this->purchase->find_all();
  3762. foreach ($purchase as $k => $v) {
  3763. $prc[$v['id']] = $v['title'];
  3764. }
  3765. if (isset($_GET['excel'])) {
  3766. $where = "sku != 'Preset'";
  3767. //数据排序
  3768. $order_str = "id desc";
  3769. if (empty($page)) {
  3770. $start = 0;
  3771. $perpage = 1;
  3772. } else {
  3773. $start = ($page - 1) * $perpage;
  3774. }
  3775. $category = $this->input->get('category', true);
  3776. $warehouse = $this->input->get('warehouse', true);
  3777. $excelid = $this->input->get('sid', true);
  3778. if ($category) {
  3779. $where .= " and features like '%-$category-%'";
  3780. }
  3781. if ($warehouse) {
  3782. $where .= " and warehouse = '$warehouse'";
  3783. }
  3784. $xzid = '';
  3785. if ($excelid) {
  3786. $excelid = explode(',', trim($excelid, ','));
  3787. foreach ($excelid as $key => $value) {
  3788. $xzid .= " id = " . $value . " or";
  3789. }
  3790. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3791. }
  3792. //取得信息列表
  3793. /**
  3794. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3795. $rows = array();$list = array();
  3796. foreach ($info_list as $key=>$value)
  3797. {
  3798. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3799. }
  3800. **/
  3801. $wt = array();
  3802. $whlabel_type = $this->whlabel_type->find_all();
  3803. foreach ($whlabel_type as $v) {
  3804. $wt[$v['id']] = $v['title'];
  3805. }
  3806. $wh = array();
  3807. $w = $this->warehouse->find_all('1=1', 'id,title');
  3808. foreach ($w as $v) {
  3809. $wh[$v['id']] = $v['title'];
  3810. }
  3811. $list = array();
  3812. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3813. foreach ($rows as $key => $value) {
  3814. if (isset($wt[$value['type']])) {
  3815. $rows[$key]['type'] = $wt[$value['type']];
  3816. } else {
  3817. $rows[$key]['type'] = '未设置';
  3818. }
  3819. $bm = '03';
  3820. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3821. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3822. $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');
  3823. $details = array();
  3824. $cpid = array();
  3825. $cpbz = array();
  3826. $c = 0;
  3827. $g = 0;
  3828. $x = 0;
  3829. $t = 0;
  3830. $s = 0;
  3831. $q = 0;
  3832. foreach ($sd as $k => $v) {
  3833. if ($v['state'] == 0) {
  3834. $c++;
  3835. if ($v['cpid'] != 0) {
  3836. $cpid[$v['cpid']] = $v['cpid'];
  3837. }
  3838. if ($v['cpbz'] != '') {
  3839. $cpbz[$v['cpbz']] = $v['cpbz'];
  3840. }
  3841. }
  3842. if ($v['state'] != 9) {
  3843. $g++;
  3844. }
  3845. if ($v['state'] == 1) {
  3846. $x++;
  3847. }
  3848. if ($v['state'] == 2) {
  3849. $t++;
  3850. }
  3851. if ($v['state'] == 8) {
  3852. $s++;
  3853. }
  3854. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3855. $q++;
  3856. }
  3857. $details[$v['details']] = $v['details'];
  3858. }
  3859. $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'] . '"');
  3860. $rows[$key]['details'] = implode("、", $details);
  3861. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3862. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3863. $number = $value['number'];
  3864. $ftime = time() - 15 * 24 * 3600;
  3865. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3866. $rows[$key]['number'] = $g;
  3867. $rows[$key]['c'] = $c;
  3868. $rows[$key]['x'] = $x;
  3869. $rows[$key]['t'] = $t;
  3870. $rows[$key]['s'] = $s;
  3871. $rows[$key]['q'] = $q;
  3872. $rows[$key]['z'] = $z;
  3873. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3874. $features = explode('-', trim($features, '-'));
  3875. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3876. // $pm = $classid;
  3877. // $jm = $classid;
  3878. // foreach($features as $k=>$v)
  3879. // {
  3880. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3881. // {
  3882. // if($typeclass[$v]['bm'] != '')
  3883. // {
  3884. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3885. // }
  3886. // }
  3887. // if($v != 0)
  3888. // {
  3889. // if(!isset($typeclass[$v]))
  3890. // {
  3891. // continue;
  3892. // }
  3893. // if(isset($pm[$typeclass[$v]['classid']]))
  3894. // {
  3895. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3896. // {
  3897. // $tz = explode('|',$typeclass[$v]['zh']);
  3898. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3899. // }
  3900. // else
  3901. // {
  3902. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3903. // }
  3904. // }
  3905. // if(isset($jm[$typeclass[$v]['classid']]))
  3906. // {
  3907. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3908. // }
  3909. // }
  3910. // }
  3911. // $jm = array_filter($jm);
  3912. // $rows[$key]['bs'] = implode("-",$jm);
  3913. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3914. // $zh = implode(" ",$pm);
  3915. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3916. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3917. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3918. // $rows[$key]['features'] = $zh;
  3919. }
  3920. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3921. $final_list = [];
  3922. foreach ($list as $k => $v) {
  3923. if (empty($v['sku'])) {
  3924. continue;
  3925. }
  3926. $final_list[] = [
  3927. "warehouse" => $v["warehouse"],
  3928. "purchase" => $v["purchase"],
  3929. "details" => $v["details"],
  3930. "cpid" => $v["cpid"],
  3931. "dbcontent" => $v["dbcontent"],
  3932. "sku" => $v["sku"],
  3933. "cs" => $v["bm"],
  3934. "bs" => $v["jm"],
  3935. "title" => $v["title"],
  3936. "features" => $v["pm"],
  3937. "cpbz" => $v["cpbz"],
  3938. "sm" => $v["sm"],
  3939. "type" => $v["type"],
  3940. "number" => $v["number"],
  3941. "c" => $v["c"],
  3942. "x" => $v["x"],
  3943. "t" => $v["t"],
  3944. "s" => $v["s"],
  3945. "q" => $v["q"],
  3946. "z" => $v["z"],
  3947. "weight" => $v['weight'],
  3948. ];
  3949. }
  3950. $title = "总进销存统计表";
  3951. $titlename = "<table border=1>
  3952. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3953. <tr align='center'>
  3954. <td>仓库</td>
  3955. <td>供应商</td>
  3956. <td>位置</td>
  3957. <td>库存编码</td>
  3958. <td>类目</td>
  3959. <td>SKU</td>
  3960. <td>用友编码</td>
  3961. <td>用友料号</td>
  3962. <td>商品名称</td>
  3963. <td>商品中文</td>
  3964. <td>产品备注</td>
  3965. <td>库位负责人</td>
  3966. <td>类型</td>
  3967. <td>入库总量</td>
  3968. <td>库存数量</td>
  3969. <td>销售数量</td>
  3970. <td>退货数量</td>
  3971. <td>删除数量</td>
  3972. <td>其它操作</td>
  3973. <td>占单数量</td>
  3974. <td>重量(g)</td>
  3975. </tr>
  3976. </table>";
  3977. $filename = $title . ".xls";
  3978. $tail = "";
  3979. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3980. }
  3981. }
  3982. //入库导出
  3983. public function _excelr()
  3984. {
  3985. if (isset($_GET['excel'])) {
  3986. $category = $this->input->get('category', true);
  3987. $size = $this->input->get('size', true);
  3988. $grade = $this->input->get('grade', true);
  3989. $color = $this->input->get('color', true);
  3990. $lowe = $this->input->get('lowe', true);
  3991. $sku = $this->input->get('sku', true);
  3992. $warehouse = $this->input->get('warehouse', true);
  3993. $purchase = $this->input->get('purchase', true);
  3994. $ktime = $this->input->get('ktime', true);
  3995. $jtime = $this->input->get('jtime', true);
  3996. $rktype = $this->input->get('rktype',true);
  3997. $ktime = strtotime($ktime);
  3998. $jtime = strtotime($jtime);
  3999. $where = "1=1";
  4000. $gj = "";
  4001. $ck = "";
  4002. if ($category) {
  4003. $where .= " and features like '%-$category-%'";
  4004. }
  4005. if ($size) {
  4006. $where .= " and features like '%-$size-%'";
  4007. }
  4008. if ($grade) {
  4009. $where .= " and features like '%-$grade-%'";
  4010. }
  4011. if ($color) {
  4012. $where .= " and features like '%-$color-%'";
  4013. }
  4014. if ($lowe) {
  4015. $where .= " and features like '%-$lowe-%'";
  4016. }
  4017. if ($warehouse) {
  4018. $where .= " and warehouse = '$warehouse'";
  4019. }
  4020. if ($purchase) {
  4021. $where .= " and purchase = '$purchase'";
  4022. }
  4023. if ($sku) {
  4024. $where .= " and sku = '$sku'";
  4025. }
  4026. if($rktype){
  4027. $where .= " and rktype = '$rktype' ";
  4028. }
  4029. if ($ktime && $jtime) {
  4030. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4031. }
  4032. //数据排序
  4033. $order_str = "id desc";
  4034. if (empty($page)) {
  4035. $start = 0;
  4036. $perpage = 1;
  4037. } else {
  4038. $start = ($page - 1) * $perpage;
  4039. }
  4040. $list = array();
  4041. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4042. foreach ($rows as $value) {
  4043. $ck = $this->warehouse->read($value['warehouse']);
  4044. $warehouse = $ck['title'];
  4045. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4046. $retreatwarehouse = $tkck['title'];
  4047. $gy = $this->purchase->read($value['purchase']);
  4048. $purchase = $gy['title'];
  4049. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4050. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4051. }
  4052. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4053. $titlename = "<table border=1>
  4054. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4055. <tr align='center'>
  4056. <td>仓库</td>
  4057. <td>SKU</td>
  4058. <td>产品</td>
  4059. <td>时间</td>
  4060. <td>数量</td>
  4061. </tr>
  4062. </table>";
  4063. $filename = $title . ".xls";
  4064. $tail = "";
  4065. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4066. }
  4067. }
  4068. //出库、退库导出
  4069. public function _excelct()
  4070. {
  4071. $classid = $this->classid->sku();
  4072. $pm = $classid;
  4073. $typeclass = array();
  4074. $tc = $this->typeclass->find_all();
  4075. foreach ($tc as $v) {
  4076. $typeclass[$v['id']] = $v;
  4077. }
  4078. $prc = array();
  4079. $purchase = $this->purchase->find_all();
  4080. foreach ($purchase as $k => $v) {
  4081. $prc[$v['id']] = $v['title'];
  4082. }
  4083. if (isset($_GET['excel'])) {
  4084. $wh = array();
  4085. $w = $this->warehouse->find_all('1=1', 'id,title');
  4086. foreach ($w as $v) {
  4087. $wh[$v['id']] = $v['title'];
  4088. }
  4089. $type = $this->input->get('excel', true);
  4090. $category = $this->input->get('category', true);
  4091. $size = $this->input->get('size', true);
  4092. $grade = $this->input->get('grade', true);
  4093. $color = $this->input->get('color', true);
  4094. $lowe = $this->input->get('lowe', true);
  4095. $sku = $this->input->get('sku', true);
  4096. $title = $this->input->get('title', true);
  4097. $warehouse = $this->input->get('warehouse', true);
  4098. $purchase = $this->input->get('purchase', true);
  4099. $lacetype = $this->input->get('lacetype', true);
  4100. $haircap = $this->input->get('haircap', true);
  4101. $lacecolor = $this->input->get('lacecolor', true);
  4102. $density = $this->input->get('density', true);
  4103. $details = $this->input->get('details', true);
  4104. $state = $this->input->get('state', true);
  4105. $shop = $this->input->get('shop', true);
  4106. $hairnumber = $this->input->get('hairnumber', true);
  4107. $type_leixi = $this->input->get('type', true);
  4108. $cpbz = $this->input->get('cpbz', true);
  4109. $sm = $this->input->get('sm', true);
  4110. $sid = $this->input->get('sid', true);
  4111. $ktime = $this->input->get('ktime', true);
  4112. $jtime = $this->input->get('jtime', true);
  4113. $ktime = strtotime($ktime);
  4114. $jtime = strtotime($jtime);
  4115. //$where = " 1=1 ";
  4116. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4117. $where = " sku != '' ";
  4118. $gj = "";
  4119. $ck = "";
  4120. if ($category) {
  4121. $where .= " and features like '%-$category-%'";
  4122. }
  4123. if ($size) {
  4124. $where .= " and features like '%-$size-%'";
  4125. }
  4126. if ($grade) {
  4127. $where .= " and features like '%-$grade-%'";
  4128. }
  4129. if ($color) {
  4130. $where .= " and features like '%-$color-%'";
  4131. }
  4132. if ($lowe) {
  4133. $where .= " and features like '%-$lowe-%'";
  4134. }
  4135. if ($warehouse) {
  4136. $where .= " and warehouse = '$warehouse'";
  4137. }
  4138. if ($purchase) {
  4139. $where .= " and purchase = '$purchase'";
  4140. }
  4141. if ($state) {
  4142. $where .= " and state = '$state'";
  4143. }
  4144. if ($lacetype) {
  4145. $where .= " and features like '%-$lacetype-%'";
  4146. }
  4147. if ($lacecolor) {
  4148. $where .= " and features like '%-$lacecolor-%'";
  4149. }
  4150. if ($density) {
  4151. $where .= " and features like '%-$density-%'";
  4152. }
  4153. if ($haircap) {
  4154. $where .= " and features like '%-$haircap-%'";
  4155. }
  4156. if ($details) {
  4157. $where .= " and details = '$details'";
  4158. }
  4159. if ($shop) {
  4160. $where .= " and shop like '%$shop%'";
  4161. }
  4162. if ($title) {
  4163. $title = trim($title, ' ');
  4164. $title = trim($title, ' ');
  4165. $where .= " and title like '%$title%'";
  4166. }
  4167. if (!empty($hairnumber)) {
  4168. $where .= " and features like '%-128-%' ";
  4169. if ($hairnumber < 0) {
  4170. $class_list = $this->typeclass->find_all('classid = 43');
  4171. foreach ($class_list as $v) {
  4172. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4173. }
  4174. } else {
  4175. $where .= " and features like '%-$hairnumber-%'";
  4176. }
  4177. }
  4178. if ($type_leixi) {
  4179. $where .= " and type = '$type_leixi'";
  4180. }
  4181. if ($cpbz) {
  4182. $where .= " and cpbz like '%$cpbz%' ";
  4183. }
  4184. if ($sm) {
  4185. $where .= " and sm like '%$sm%' ";
  4186. }
  4187. if ($sku) {
  4188. $sku = trim($sku, ' ');
  4189. $sku = trim($sku, ' ');
  4190. $where .= " and sku like '%$sku%'";
  4191. }
  4192. if ($ktime && $jtime) {
  4193. if ($type == 1) {
  4194. $tl = '出库';
  4195. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4196. } else if ($type == 2) {
  4197. $tl = '退库';
  4198. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4199. } else if ($type == 3) {
  4200. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4201. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4202. } else if ($type == 4) {
  4203. $tl = '出库+零售';
  4204. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4205. } else if ($type == 5) {
  4206. $tl = '零售';
  4207. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4208. }
  4209. }
  4210. $sidwhere = '';
  4211. if ($sid) {
  4212. $sd = "";
  4213. $s = explode(',', trim($sid, ','));
  4214. foreach ($s as $value) {
  4215. $sd .= " id = " . $value . " or";
  4216. }
  4217. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4218. }
  4219. //数据排序
  4220. $order_str = "time desc";
  4221. if (empty($page)) {
  4222. $start = 0;
  4223. $perpage = 1;
  4224. } else {
  4225. $start = ($page - 1) * $perpage;
  4226. }
  4227. //取得信息列表
  4228. if ($type != 3 && $type != 5) {
  4229. if ($type == 1 || $type == 4) {
  4230. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4231. foreach ($info_list as $key => $value) {
  4232. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4233. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4234. $warehouse = $this->warehouse->read($value['warehouse']);
  4235. $info_list[$key]['warehouse'] = $warehouse['title'];
  4236. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4237. $features = explode('-', trim($features, '-'));
  4238. $pm = $classid;
  4239. foreach ($features as $k => $v) {
  4240. if ($v != 0) {
  4241. if (!isset($typeclass[$v])) {
  4242. continue;
  4243. }
  4244. if (isset($pm[$typeclass[$v]['classid']])) {
  4245. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4246. $tz = explode('|', $typeclass[$v]['zh']);
  4247. $pm[$typeclass[$v]['classid']] = $tz[0];
  4248. } else {
  4249. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4250. }
  4251. }
  4252. }
  4253. }
  4254. $zh = implode(" ", $pm);
  4255. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4256. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4257. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4258. $info_list[$key]['features'] = $zh;
  4259. }
  4260. $final_list = [];
  4261. foreach($info_list as $k=>$v){
  4262. $number = "";
  4263. if(!empty($v['orderinfo'])){
  4264. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4265. if(!empty($tmp_info['number'])){
  4266. $number = $tmp_info['number'];
  4267. }
  4268. }
  4269. $final_list[] = [
  4270. 'warehouse'=>$v['warehouse'],
  4271. 'purchase'=>$v['purchase'],
  4272. 'sku'=>$v['sku'],
  4273. 'title'=>$v['title'],
  4274. 'features'=>$v['features'],
  4275. 'label'=>$v['label'],
  4276. 'orderinfo'=>$v['orderinfo'],
  4277. 'number'=>$number,
  4278. 'waybill'=>$v['waybill'],
  4279. 'outk'=>$v['outk'],
  4280. ];
  4281. }
  4282. } else {
  4283. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4284. foreach ($info_list as $key => $value) {
  4285. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4286. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4287. $warehouse = $this->warehouse->read($value['warehouse']);
  4288. $info_list[$key]['warehouse'] = $warehouse['title'];
  4289. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4290. $features = explode('-', trim($features, '-'));
  4291. $pm = $classid;
  4292. foreach ($features as $k => $v) {
  4293. if ($v != 0) {
  4294. if (!isset($typeclass[$v])) {
  4295. continue;
  4296. }
  4297. if (isset($pm[$typeclass[$v]['classid']])) {
  4298. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4299. $tz = explode('|', $typeclass[$v]['zh']);
  4300. $pm[$typeclass[$v]['classid']] = $tz[0];
  4301. } else {
  4302. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4303. }
  4304. }
  4305. }
  4306. }
  4307. $zh = implode(" ", $pm);
  4308. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4309. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4310. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4311. $info_list[$key]['features'] = $zh;
  4312. }
  4313. $final_list = [];
  4314. foreach($info_list as $k=>$v){
  4315. $number = "";
  4316. if(!empty($v['orderinfo'])){
  4317. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4318. if(!empty($tmp_info['number'])){
  4319. $number = $tmp_info['number'];
  4320. }
  4321. }
  4322. $final_list[] = [
  4323. 'warehouse'=>$v['warehouse'],
  4324. 'purchase'=>$v['purchase'],
  4325. 'sku'=>$v['sku'],
  4326. 'title'=>$v['title'],
  4327. 'features'=>$v['features'],
  4328. 'label'=>$v['label'],
  4329. 'orderinfo'=>$v['orderinfo'],
  4330. 'number'=>$number,
  4331. 'waybill'=>$v['waybill'],
  4332. 'retreat'=>$v['retreat'],
  4333. ];
  4334. }
  4335. }
  4336. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4337. $titlename = "<table border=1>
  4338. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4339. <tr align='center'>
  4340. <td>仓库</td>
  4341. <td>供应商</td>
  4342. <td>SKU</td>
  4343. <td>商品名称</td>
  4344. <td>商品中文</td>
  4345. <td>标签</td>
  4346. <td>订单号</td>
  4347. <td>订单编码</td>
  4348. <td>运单号</td>
  4349. <td>" . $tl . "时间(中国时间)</td>
  4350. </tr>
  4351. </table>";
  4352. $filename = $title . ".xls";
  4353. $tail = "";
  4354. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4355. } else if ($type == 5) {
  4356. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4357. foreach ($info_list as $key => $value) {
  4358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4359. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4360. $warehouse = $this->warehouse->read($value['warehouse']);
  4361. $info_list[$key]['warehouse'] = $warehouse['title'];
  4362. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4363. $features = explode('-', trim($features, '-'));
  4364. $pm = $classid;
  4365. foreach ($features as $k => $v) {
  4366. if ($v != 0) {
  4367. if (!isset($typeclass[$v])) {
  4368. continue;
  4369. }
  4370. if (isset($pm[$typeclass[$v]['classid']])) {
  4371. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4372. $tz = explode('|', $typeclass[$v]['zh']);
  4373. $pm[$typeclass[$v]['classid']] = $tz[0];
  4374. } else {
  4375. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4376. }
  4377. }
  4378. }
  4379. }
  4380. $zh = implode(" ", $pm);
  4381. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4382. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4383. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4384. $info_list[$key]['features'] = $zh;
  4385. }
  4386. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4387. $titlename = "<table border=1>
  4388. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4389. <tr align='center'>
  4390. <td>仓库</td>
  4391. <td>供应商</td>
  4392. <td>SKU</td>
  4393. <td>商品名称</td>
  4394. <td>商品中文</td>
  4395. <td>标签</td>
  4396. <td>" . $tl . "时间(中国时间)</td>
  4397. </tr>
  4398. </table>";
  4399. $filename = $title . ".xls";
  4400. $tail = "";
  4401. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4402. } else {
  4403. /**
  4404. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4405. $rows = array();$list = array();
  4406. foreach ($info_list as $key=>$value)
  4407. {
  4408. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4409. }
  4410. **/
  4411. $wh = array();
  4412. $w = $this->warehouse->find_all('1=1', 'id,title');
  4413. foreach ($w as $v) {
  4414. $wh[$v['id']] = $v['title'];
  4415. }
  4416. $wt = array();
  4417. $whlabel_type = $this->whlabel_type->find_all();
  4418. foreach ($whlabel_type as $v) {
  4419. $wt[$v['id']] = $v['title'];
  4420. }
  4421. $classid = $this->classid->sku();
  4422. $list = array();
  4423. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4424. foreach ($rows as $key => $value) {
  4425. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4426. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4427. $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');
  4428. $details = array();
  4429. $cpid = array();
  4430. $cpbz = array();
  4431. $c = 0;
  4432. $g = 0;
  4433. $x = 0;
  4434. $t = 0;
  4435. $s = 0;
  4436. $q = 0;
  4437. foreach ($sd as $k => $v) {
  4438. if ($v['state'] == 0) {
  4439. $c++;
  4440. }
  4441. if ($v['state'] != 9) {
  4442. $g++;
  4443. }
  4444. if ($v['outk'] > 1) {
  4445. $x++;
  4446. }
  4447. if ($v['retreat'] > 0) {
  4448. $t++;
  4449. }
  4450. if ($v['state'] == 8) {
  4451. $s++;
  4452. }
  4453. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4454. $q++;
  4455. }
  4456. $details[$v['details']] = $v['details'];
  4457. if($v['state'] == 0){
  4458. if ($v['cpid'] != 0) {
  4459. $cpid[$v['cpid']] = $v['cpid'];
  4460. }
  4461. if ($v['cpbz'] != '') {
  4462. $cpbz[$v['cpbz']] = $v['cpbz'];
  4463. }
  4464. }
  4465. }
  4466. if (isset($wt[$value['type']])) {
  4467. $rows[$key]['type'] = $wt[$value['type']];
  4468. } else {
  4469. $rows[$key]['type'] = '未设置';
  4470. }
  4471. $rows[$key]['details'] = implode("、", $details);
  4472. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4473. $ftime = time() - 15 * 24 * 3600;
  4474. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4475. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4476. $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);
  4477. $rows[$key]['c'] = $c;
  4478. $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);
  4479. $rows[$key]['t'] = $t;
  4480. $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'] . '"');
  4481. $rows[$key]['z'] = $z;
  4482. // $jm = $classid;
  4483. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4484. $features = explode('-', trim($features, '-'));
  4485. // $pm = $classid;
  4486. // foreach ($features as $k => $v) {
  4487. // if ($v != 0) {
  4488. // if (!isset($typeclass[$v])) {
  4489. // continue;
  4490. // }
  4491. // if (isset($pm[$typeclass[$v]['classid']])) {
  4492. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4493. // $tz = explode('|', $typeclass[$v]['zh']);
  4494. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4495. // } else {
  4496. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4497. // }
  4498. // if (isset($jm[$typeclass[$v]['classid']])) {
  4499. // if ($typeclass[$v]['jm']) {
  4500. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4501. // }
  4502. // }
  4503. // }
  4504. // }
  4505. // }
  4506. // $zh = implode(" ", $pm);
  4507. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4508. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4509. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4510. // $rows[$key]['features'] = $zh;
  4511. // $jm = array_filter($jm); //去除空值
  4512. // $jm = implode("-", $jm);
  4513. // $rows[$key]['jm'] = $jm;
  4514. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4515. }
  4516. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4517. // echo "<pre>";
  4518. // print_r($tmp_list);
  4519. // die;
  4520. $final_list =[];
  4521. foreach($tmp_list as $k=>$v){
  4522. $final_list[] = [
  4523. "warehouse"=>$v['warehouse'],
  4524. "purchase"=>$v['purchase'],
  4525. "details"=>trim($v['details'],'、'),
  4526. "cpid"=>$v['cpid'],
  4527. "sku"=>$v['sku'],
  4528. "title"=>$v['title'],
  4529. "features"=>$v['pm'],
  4530. "cpbz"=>$v['cpbz'],
  4531. "sm"=>$v['sm'],
  4532. "type"=>$v['type'],
  4533. "g"=>$v["g"],
  4534. "c"=>$v["c"],
  4535. "x"=>$v["x"],
  4536. "t"=>$v["t"],
  4537. "z"=>$v["z"],
  4538. "jm"=>$v["jm"],
  4539. "weight"=>$v["weight"],
  4540. "asd"=>$v["asd"],
  4541. ];
  4542. }
  4543. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4544. $titlename = "<table border=1>
  4545. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4546. <tr align='center'>
  4547. <td>仓库</td>
  4548. <td>供应商</td>
  4549. <td>位置</td>
  4550. <td>库存编码</td>
  4551. <td>SKU</td>
  4552. <td>商品名称</td>
  4553. <td>商品中文</td>
  4554. <td>产品备注</td>
  4555. <td>说明</td>
  4556. <td>类型</td>
  4557. <td>入库总量</td>
  4558. <td>库存数量</td>
  4559. <td>销售数量</td>
  4560. <td>退货数量</td>
  4561. <td>占单数量</td>
  4562. <td>料号</td>
  4563. <td>重量</td>
  4564. <td>类目</td>
  4565. </tr>
  4566. </table>";
  4567. $filename = $title . ".xls";
  4568. $tail = "";
  4569. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4570. }
  4571. }
  4572. }
  4573. //出库+入库数据整合
  4574. public function _excelcr()
  4575. {
  4576. if (isset($_GET['excel'])) {
  4577. $type = $this->input->get('excel', true);
  4578. $category = $this->input->get('category', true);
  4579. $size = $this->input->get('size', true);
  4580. $grade = $this->input->get('grade', true);
  4581. $color = $this->input->get('color', true);
  4582. $lowe = $this->input->get('lowe', true);
  4583. $sku = $this->input->get('sku', true);
  4584. $warehouse = $this->input->get('warehouse', true);
  4585. $purchase = $this->input->get('purchase', true);
  4586. $state = $this->input->get('state', true);
  4587. $sid = $this->input->get('sid', true);
  4588. $ktime = $this->input->get('ktime', true);
  4589. $jtime = $this->input->get('jtime', true);
  4590. $ktime = strtotime($ktime);
  4591. $jtime = strtotime($jtime);
  4592. $where = "1=1";
  4593. $gj = "";
  4594. $ck = "";
  4595. if ($category) {
  4596. $where .= " and features like '%-$category-%'";
  4597. }
  4598. if ($size) {
  4599. $where .= " and features like '%-$size-%'";
  4600. }
  4601. if ($grade) {
  4602. $where .= " and features like '%-$grade-%'";
  4603. }
  4604. if ($color) {
  4605. $where .= " and features like '%-$color-%'";
  4606. }
  4607. if ($lowe) {
  4608. $where .= " and features like '%-$lowe-%'";
  4609. }
  4610. if ($warehouse) {
  4611. $where .= " and warehouse = '$warehouse'";
  4612. }
  4613. if ($purchase) {
  4614. $where .= " and purchase = '$purchase'";
  4615. }
  4616. if ($state) {
  4617. $where .= " and state = '$state'";
  4618. }
  4619. if ($sku) {
  4620. $where .= " and sku like '%$sku%'";
  4621. }
  4622. if ($ktime && $jtime) {
  4623. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4624. }
  4625. $sidwhere = '';
  4626. if ($sid) {
  4627. $sd = "";
  4628. $s = explode(',', trim($sid, ','));
  4629. foreach ($s as $value) {
  4630. $sd .= " id = " . $value . " or";
  4631. }
  4632. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4633. }
  4634. //取得信息列表
  4635. $timeread = $ktime;
  4636. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4637. $timelist = array();
  4638. for ($i = 0; $i < $timenum; $i++) {
  4639. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4640. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4641. }
  4642. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4643. //echo "<pre>";
  4644. //print_r($info_list);
  4645. //exit();
  4646. $rows = array();
  4647. $list = array();
  4648. foreach ($info_list as $key => $value) {
  4649. $thistime = $timelist;
  4650. if (isset($rows[strtolower($value['sku'])])) {
  4651. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4652. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4653. }
  4654. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4655. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4656. }
  4657. } else {
  4658. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4659. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4660. }
  4661. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4662. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4663. }
  4664. $rows[strtolower($value['sku'])] = $thistime;
  4665. }
  4666. }
  4667. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4668. <head>
  4669. <!--[if gte mso 9]><xml>
  4670. <x:ExcelWorkbook>
  4671. <x:ExcelWorksheets>
  4672. <x:ExcelWorksheet>
  4673. <x:Name>EXCEL</x:Name>
  4674. <x:WorksheetOptions>
  4675. <x:Print>
  4676. <x:ValidPrinterInfo />
  4677. </x:Print>
  4678. </x:WorksheetOptions>
  4679. </x:ExcelWorksheet>
  4680. </x:ExcelWorksheets>
  4681. </x:ExcelWorkbook>
  4682. </xml>
  4683. <![endif]-->
  4684. </head><body>";
  4685. $str .= "<table border=1><tr><td>SKU</td>";
  4686. foreach ($timelist as $k => $v) {
  4687. $str .= "<td>" . $k . "出库</td>";
  4688. $str .= "<td>" . $k . "入库</td>";
  4689. }
  4690. $str .= "</tr></table>";
  4691. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4692. foreach ($rows as $key => $val) {
  4693. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4694. foreach ($val as $k => $v) {
  4695. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4696. if ($val[$k]['r'] > 0) {
  4697. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4698. } else {
  4699. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4700. }
  4701. }
  4702. $str .= "</tr>";
  4703. }
  4704. $str .= "</table>";
  4705. $str .= "</body></html>";
  4706. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4707. header("Content-type: application/octet-stream");
  4708. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4709. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4710. header("Pragma: no-cache");
  4711. header("Expires: 0");
  4712. exit($str);
  4713. }
  4714. }
  4715. //数量调整模板导出
  4716. public function _presetout()
  4717. {
  4718. if (isset($_GET['excel'])) {
  4719. $where = "sku != 'Preset' and purchase != 0";
  4720. //数据排序
  4721. $order_str = "id desc";
  4722. if (empty($page)) {
  4723. $start = 0;
  4724. $perpage = 1;
  4725. } else {
  4726. $start = ($page - 1) * $perpage;
  4727. }
  4728. //取得信息列表
  4729. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4730. $rows = array();
  4731. $list = array();
  4732. foreach ($info_list as $value) {
  4733. $warehouse = $this->warehouse->read($value['warehouse']);
  4734. $number = $value['number'];
  4735. $ftime = time() - 15 * 24 * 3600;
  4736. $purchase = $this->purchase->read($value['purchase']);
  4737. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4738. }
  4739. $title = "库存模板";
  4740. $titlename = "<table border=1>
  4741. <tr align='center'>
  4742. <td>仓库</td>
  4743. <td>供应商编码</td>
  4744. <td>SKU</td>
  4745. <td>增减数量(正数或负数)</td>
  4746. <td>增减备注</td>
  4747. <td>库位</td>
  4748. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4749. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4750. </tr>
  4751. </table>";
  4752. $filename = $title . ".xls";
  4753. $tail = "";
  4754. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4755. }
  4756. }
  4757. //数量调整模板导入
  4758. public function _presetedit()
  4759. {
  4760. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4761. $config['upload_path'] = '.' . $dir;
  4762. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4763. $config['allowed_types'] = 'xls|xlsx|csv';
  4764. $config['max_size'] = 10240;
  4765. $this->load->library('upload', $config);
  4766. $this->upload->initialize($config);
  4767. if ($this->upload->do_upload('userfile')) {
  4768. $full_path = $dir . $this->upload->data('file_name');
  4769. $fileName = '.' . $full_path;
  4770. if (!file_exists($fileName)) {
  4771. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4772. exit;
  4773. } else {
  4774. require_once "./data/excel/PHPExcel/IOFactory.php";
  4775. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4776. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4777. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4778. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4779. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4780. ++$column; //如果列数大于26行
  4781. $list = array();
  4782. for ($i = 2; $i <= $row; $i++) // 行数循环
  4783. {
  4784. $data = array();
  4785. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4786. {
  4787. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4788. }
  4789. $list[] = $data;
  4790. }
  4791. }
  4792. $i = 0;
  4793. $j = 0;
  4794. $ed = array();
  4795. foreach ($list as $key => $value) {
  4796. $time = time();
  4797. if ($value['0'] == "") {
  4798. continue;
  4799. }
  4800. $warehouse = $this->warehouse->get_title($value['0']);
  4801. $purchase = $this->purchase->get_bm($value['1']);
  4802. $sku = $value['2'];
  4803. $num = $value['3']; //调整数量
  4804. $text = $value['4']; //扣减说明
  4805. $type = $value['5']; //调整方式0扣减1删除
  4806. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4807. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4808. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4809. if (!$purchase) //如果没有这个SKU
  4810. {
  4811. $ed[] = array($purchase . '-不存在此供应商编码');
  4812. $j++;
  4813. continue;
  4814. }
  4815. if (!$d) //如果没有这个SKU
  4816. {
  4817. $ed[] = array($sku . '-库存中不存在此SKU');
  4818. $j++;
  4819. continue;
  4820. }
  4821. if (!isset($warehouse['id'])) {
  4822. $ed[] = array($sku . '-仓库名错误!');
  4823. $j++;
  4824. continue;
  4825. }
  4826. if ($type != '0' && $type != '1') {
  4827. $ed[] = array($sku . '-扣减方式填写错误!');
  4828. $j++;
  4829. continue;
  4830. }
  4831. if ($num < 0) //扣减库存
  4832. {
  4833. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4834. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4835. $j++;
  4836. continue;
  4837. }
  4838. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4839. if (count($data) < abs($num)) {
  4840. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4841. $j++;
  4842. continue;
  4843. }
  4844. if ($type == 0) //如果扣减方式为 扣减库存
  4845. {
  4846. for ($i = 0; $i < abs($num); $i++) {
  4847. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4848. }
  4849. } else if ($type == 1) {
  4850. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4851. if (count($zt) > 0) {
  4852. $ed[] = array($sku . '-有在途库存无法删除!');
  4853. $j++;
  4854. continue;
  4855. }
  4856. for ($i = 0; $i < abs($num); $i++) {
  4857. $this->whlabel->remove($data[$i]['id']);
  4858. }
  4859. }
  4860. } else if ($num > 0) //增加库存
  4861. {
  4862. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4863. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4864. $j++;
  4865. continue;
  4866. }
  4867. $post['sku'] = $d['sku'];
  4868. $post['shop'] = $d['shop'];
  4869. $post['warehouse'] = $warehouse['id'];
  4870. $post['purchase'] = $purchase['id'];
  4871. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4872. $post['state'] = 0;
  4873. $post['title'] = $d['title'];
  4874. $post['number'] = $d['number'];
  4875. $post['features'] = $d['features'];
  4876. $post['enter'] = $time;
  4877. $post['time'] = $time; //操作时间
  4878. $post['rktype'] = $rktype;
  4879. for ($i = 0; $i < $num; $i++) {
  4880. $post['label'] = time() . rand(100, 999) . $i;
  4881. $this->whlabel->insert($post);
  4882. }
  4883. }
  4884. sleep(1); //防止入库时间一样,需要延迟1秒
  4885. }
  4886. if ($j > 0) {
  4887. $tt = date('Ymd', time());
  4888. $title = '库存导入错误信息-' . $tt;
  4889. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4890. $tail = "\n";
  4891. $filename = $title . ".xls";
  4892. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4893. $dir = '/data/excel/' . $time . '/';
  4894. $file_name = 'error_' . $time . rand(1000, 9999);
  4895. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4896. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4897. fwrite($myfile, $ecl);
  4898. fclose($myfile);
  4899. $error = $dir . $file_name . '.xls';
  4900. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4901. exit;
  4902. } else {
  4903. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4904. exit;
  4905. }
  4906. }
  4907. }
  4908. public function _presetedittwo(){
  4909. $data = $this->input->post(NULL, TRUE);
  4910. if(empty($list)){
  4911. $raw_data = $this->input->raw_input_stream;
  4912. // 解码 JSON
  4913. $data = json_decode($raw_data, true);
  4914. }
  4915. if(empty($data)){
  4916. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4917. exit;
  4918. }
  4919. $list = [];
  4920. if(isset($data['list'])){
  4921. $list = $data['list'];
  4922. }
  4923. $i = 0;
  4924. $j = 0;
  4925. $ed = array();
  4926. foreach ($list as $key => $value) {
  4927. $time = time();
  4928. if ($value['0'] == "") {
  4929. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4930. $j++;
  4931. continue;
  4932. }
  4933. $warehouse = $this->warehouse->get_title($value['0']);
  4934. if(empty($warehouse)){
  4935. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4936. $j++;
  4937. continue;
  4938. }
  4939. $purchase = $this->purchase->get_bm($value['1']);
  4940. $sku = $value['2'];
  4941. $num = $value['3']; //调整数量
  4942. $text = $value['4']; //扣减说明
  4943. $type = 0; //调整方式0扣减1删除
  4944. $details = empty($value['5'])?'':$value['5']; //库位
  4945. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4946. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4947. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4948. if (!$purchase) //如果没有这个SKU
  4949. {
  4950. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4951. $j++;
  4952. continue;
  4953. }
  4954. if (!$d) //如果没有这个SKU
  4955. {
  4956. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4957. $j++;
  4958. continue;
  4959. }
  4960. if (!isset($warehouse['id'])) {
  4961. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  4962. $j++;
  4963. continue;
  4964. }
  4965. if ($type != '0' && $type != '1') {
  4966. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  4967. $j++;
  4968. continue;
  4969. }
  4970. if ($num < 0) //扣减库存
  4971. {
  4972. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4973. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  4974. $j++;
  4975. continue;
  4976. }
  4977. if(!empty($details)){
  4978. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  4979. }else{
  4980. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  4981. }
  4982. if (count($data) < abs($num)) {
  4983. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  4984. $j++;
  4985. continue;
  4986. }
  4987. if ($type == 0) //如果扣减方式为 扣减库存
  4988. {
  4989. for ($i = 0; $i < abs($num); $i++) {
  4990. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4991. }
  4992. } else if ($type == 1) {
  4993. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4994. if (count($zt) > 0) {
  4995. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  4996. $j++;
  4997. continue;
  4998. }
  4999. for ($i = 0; $i < abs($num); $i++) {
  5000. $this->whlabel->remove($data[$i]['id']);
  5001. }
  5002. }
  5003. } else if ($num > 0) //增加库存
  5004. {
  5005. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5006. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5007. $j++;
  5008. continue;
  5009. }
  5010. if(empty($details)){
  5011. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5012. if(empty($tmp_info)){
  5013. $details = '';
  5014. }else{
  5015. $details = $tmp_info['details'];
  5016. }
  5017. }else{
  5018. if($details == 'DZ001'){
  5019. }else{
  5020. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5021. if(empty($tmp_info)){
  5022. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5023. $j++;
  5024. continue;
  5025. }
  5026. }
  5027. }
  5028. $post['sku'] = $d['sku'];
  5029. $post['shop'] = $d['shop'];
  5030. $post['warehouse'] = $warehouse['id'];
  5031. $post['purchase'] = $purchase['id'];
  5032. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5033. $post['state'] = 0;
  5034. $post['title'] = $d['title'];
  5035. $post['number'] = $d['number'];
  5036. $post['features'] = $d['features'];
  5037. $post['details'] = $details;
  5038. $post['enter'] = $time;
  5039. $post['time'] = $time; //操作时间
  5040. $post['rktype'] = $rktype;
  5041. $post['sku_master_id'] = $d['sku_master_id'];
  5042. $post['sku_shop_id'] = $d['sku_shop_id'];
  5043. for ($i = 0; $i < $num; $i++) {
  5044. $post['label'] = time() . rand(100, 999) . $i;
  5045. $this->whlabel->insert($post);
  5046. }
  5047. }
  5048. sleep(1); //防止入库时间一样,需要延迟1秒
  5049. }
  5050. if ($j > 0) {
  5051. $tt = date('Ymd', time());
  5052. $title = '库存导入错误信息-' . $tt;
  5053. $error = $title . '.xls';
  5054. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5055. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5056. exit;
  5057. } else {
  5058. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5059. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5060. exit;
  5061. }
  5062. }
  5063. //笛卡儿积
  5064. function cp($ps, $sets, $list)
  5065. {
  5066. $result = array();
  5067. $j = 0;
  5068. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5069. if ($i == 0) {
  5070. $result = $sets[$i];
  5071. }
  5072. $tmp = array();
  5073. foreach ($result as $res) {
  5074. foreach ($sets[$i + 1] as $set) {
  5075. $tmp[] = $res . ',' . $set;
  5076. }
  5077. }
  5078. $result = $tmp;
  5079. }
  5080. $this->db->trans_begin();
  5081. foreach ($result as $v) {
  5082. $post = array();
  5083. $title = "";
  5084. $num = "";
  5085. $data = explode(',', $v);
  5086. for ($i = 0; $i < count($list); $i++) {
  5087. $post[$list[$i]] = $data[$i];
  5088. $typeclass = $this->typeclass->read($data[$i]);
  5089. $title = $title . $typeclass['title'] . " ";
  5090. if ($data[$i] != 0) {
  5091. $num .= $data[$i]; //所有数据ID拼接
  5092. }
  5093. }
  5094. foreach ($ps as $kp => $vp) {
  5095. $post[$kp] = $vp;
  5096. }
  5097. $post['number'] = $num;
  5098. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5099. if ($info_list) {
  5100. $j++;
  5101. } else {
  5102. $skunum = $this->whlabel->find_count();
  5103. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5104. $post['title'] = rtrim($title, ' ');
  5105. $this->whlabel->insert($post);
  5106. }
  5107. }
  5108. if ($this->db->trans_status() === FALSE) {
  5109. $this->db->trans_commit();
  5110. return NULL;
  5111. } else {
  5112. $this->db->trans_commit();
  5113. return $j;
  5114. }
  5115. }
  5116. public function _kj($arg_array)
  5117. {
  5118. if (isset($_POST['sku'])) {
  5119. $time = time();
  5120. $sku = $this->input->post('sku', true);
  5121. $warehouse = $this->input->post('warehouse', true);
  5122. $num = $this->input->post('num', true);
  5123. $text = $this->input->post('text', true);
  5124. $purchase = $this->input->post('purchase', true);
  5125. $cktype = $this->input->post('cktype', true);
  5126. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5127. if ($cktype != 1 && $text == '') {
  5128. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5129. exit;
  5130. }
  5131. if ($num > count($order)) {
  5132. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5133. exit;
  5134. } else {
  5135. for ($i = 0; $i < $num; $i++) {
  5136. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5137. }
  5138. }
  5139. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5140. exit;
  5141. }
  5142. $uid = $this->whlabel->read($arg_array[0]);
  5143. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5144. $this->data['data'] = $uid;
  5145. $this->_Template('whlabel_kj', $this->data);
  5146. }
  5147. public function _summary($arg_array)
  5148. {
  5149. $prc = array();
  5150. $purchase = $this->purchase->find_all();
  5151. foreach ($purchase as $k => $v) {
  5152. $prc[$v['id']] = $v['title'];
  5153. }
  5154. if (isset($_GET['excel'])) {
  5155. $ktime = $this->input->get('ktime', true);
  5156. $jtime = $this->input->get('jtime', true);
  5157. $ktime = strtotime($ktime);
  5158. $jtime = strtotime($jtime);
  5159. $where = "1=1";
  5160. if ($ktime && $jtime) {
  5161. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5162. }
  5163. //数据排序
  5164. $order_str = "time desc";
  5165. if (empty($page)) {
  5166. $start = 0;
  5167. $perpage = 1;
  5168. } else {
  5169. $start = ($page - 1) * $perpage;
  5170. }
  5171. //取得信息列表
  5172. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5173. foreach ($info_list as $key => $value) {
  5174. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5175. $warehouse = $this->warehouse->read($value['warehouse']);
  5176. $info_list[$key]['warehouse'] = $warehouse['title'];
  5177. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5178. $details = array();
  5179. $cpid = array();
  5180. foreach ($x as $k => $v) {
  5181. if($v['status'] == 0){
  5182. if ($v['details'] != '') {
  5183. $details[$v['details']] = $v['details'];
  5184. }
  5185. if ($v['cpid'] != 0) {
  5186. $cpid[$v['cpid']] = $v['cpid'];
  5187. }
  5188. }
  5189. }
  5190. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5191. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5192. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5193. $info_list[$key]['s'] = $s;
  5194. $info_list[$key]['x'] = count($x);
  5195. }
  5196. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5197. $titlename = "<table border=1>
  5198. <tr align='center'>
  5199. <td>仓库</td>
  5200. <td>供应商</td>
  5201. <td>出库位置</td>
  5202. <td>出库编码</td>
  5203. <td>SKU</td>
  5204. <td>产品名</td>
  5205. <td>总剩余库存</td>
  5206. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5207. </tr>
  5208. </table>";
  5209. $filename = $title . ".xls";
  5210. $tail = "";
  5211. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5212. }
  5213. }
  5214. //usps发货清单
  5215. public function _manifest()
  5216. {
  5217. if (isset($_POST['manifest'])) {
  5218. $wltext = $this->input->post('wltext', true);
  5219. $time = time() - 16 * 3600;
  5220. $ptime = strtotime(date('Y-m-d', $time));
  5221. $waybill = array();
  5222. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5223. foreach ($fullorder as $v) {
  5224. $waybill[$v['waybill']] = $v['waybill'];
  5225. }
  5226. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5227. foreach ($fullordersmt as $v) {
  5228. $waybill[$v['waybill']] = $v['waybill'];
  5229. }
  5230. $wltext = explode(';', $wltext);
  5231. foreach ($wltext as $v) {
  5232. if (isset($waybill[$v])) {
  5233. unset($waybill[$v]);
  5234. }
  5235. }
  5236. $data = $this->usps->get_manifest($waybill);
  5237. if (isset($data['Description'])) {
  5238. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5239. exit;
  5240. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5241. $bctime = date('Ymd', time());
  5242. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5243. echo json_encode(array('msg' => $pdf, 'success' => true));
  5244. exit;
  5245. } else {
  5246. echo json_encode(array('msg' => $data, 'success' => false));
  5247. exit;
  5248. }
  5249. }
  5250. }
  5251. public function _pdf($pdf, $title, $bctime)
  5252. {
  5253. $pdf_path = './data/pdf/' . $bctime . '/';
  5254. $file_base64 = $pdf;
  5255. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5256. $file_base64 = base64_decode($file_base64);
  5257. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5258. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5259. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5260. }
  5261. /**
  5262. *
  5263. *
  5264. *
  5265. 进销存占单异常索引
  5266. *
  5267. *
  5268. *
  5269. **/
  5270. public function _abnormal()
  5271. {
  5272. $post = $this->input->post(NULL, TRUE);
  5273. if (isset($post['page'])) {
  5274. $page = $this->input->post('page', true);
  5275. $perpage = $this->input->post('perpage', true);
  5276. $sku = $this->input->post('sku', true);
  5277. $where = "1=1";
  5278. //数据排序
  5279. $order_str = "id desc";
  5280. if (empty($page)) {
  5281. $start = 0;
  5282. $perpage = 1;
  5283. } else {
  5284. $start = ($page - 1) * $perpage;
  5285. }
  5286. //取得信息列表
  5287. $info_list = $this->whlabel->find_all($where, '*');
  5288. $rows = array();
  5289. $list = array();
  5290. foreach ($info_list as $key => $value) {
  5291. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5292. }
  5293. foreach ($rows as $value) {
  5294. $warehouse = $this->warehouse->read($value['warehouse']);
  5295. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5296. $number = $value['number'];
  5297. $ftime = time() - 15 * 24 * 3600;
  5298. if ($value['shop'] != '') {
  5299. $shop = $value['shop'];
  5300. $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');
  5301. $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');
  5302. $order = array_merge($orderdlz, $ordersmt);
  5303. $od = 0;
  5304. $a = '';
  5305. $orid = '';
  5306. foreach ($order as $v) {
  5307. $or = explode('|', ltrim($v['whlabel'], '|'));
  5308. for ($i = 0; $i < count($or); $i++) {
  5309. $orod = explode('-', $or[$i]);
  5310. if ($orod[0] == $number) {
  5311. $od += $orod[1];
  5312. }
  5313. }
  5314. $orid .= $v['number'] . '-';
  5315. }
  5316. } else {
  5317. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5318. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5319. $order = array_merge($orderdlz, $ordersmt);
  5320. $od = 0;
  5321. $a = '';
  5322. $orid = '';
  5323. $qt = array();
  5324. foreach ($order as $v) {
  5325. $or = explode('|', ltrim($v['whlabel'], '|'));
  5326. for ($i = 0; $i < count($or); $i++) {
  5327. $orod = explode('-', $or[$i]);
  5328. if ($orod[0] == $number) {
  5329. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5330. if ($czzs > 0) {
  5331. if (isset($qt[$v['shop']])) {
  5332. if ($qt[$v['shop']] < $orod[1]) {
  5333. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5334. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5335. } else {
  5336. $qt[$v['shop']] -= $orod[1];
  5337. }
  5338. } else {
  5339. $qt[$v['shop']] = $czzs;
  5340. }
  5341. } else {
  5342. $od += $orod[1];
  5343. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5344. }
  5345. }
  5346. }
  5347. }
  5348. }
  5349. $z = $od . '(' . $orid . ')'; //查看订单号
  5350. //$z = $od;
  5351. if ($od > $c) {
  5352. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5353. }
  5354. }
  5355. $listdata = array_slice($list, $start, $perpage);
  5356. $total = count($list);
  5357. $pagenum = ceil($total / $perpage);
  5358. $over = $total - ($start + $perpage);
  5359. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5360. echo json_encode($rows);
  5361. exit;
  5362. }
  5363. $this->_Template('whlabel_abnormal', $this->data);
  5364. }
  5365. /**
  5366. *
  5367. *
  5368. *
  5369. 进销存占单异常索引
  5370. *
  5371. *
  5372. *
  5373. **/
  5374. public function _error()
  5375. {
  5376. $post = $this->input->post(NULL, TRUE);
  5377. if (isset($post['page'])) {
  5378. $page = $this->input->post('page', true);
  5379. $perpage = $this->input->post('perpage', true);
  5380. $sku = $this->input->post('sku', true);
  5381. $warehouse = $this->input->post('warehouse', true);
  5382. $ktime = $this->input->post('ktime', true);
  5383. $jtime = $this->input->post('jtime', true);
  5384. $ktime = strtotime($ktime);
  5385. $jtime = strtotime($jtime);
  5386. $where = "sku != 'Preset'";
  5387. $gj = '';
  5388. if ($sku) {
  5389. $where .= " and sku like '%$sku%'";
  5390. } else {
  5391. if ($ktime && $jtime) {
  5392. $gj = " and time > '$ktime' and time < '$jtime'";
  5393. }
  5394. }
  5395. if ($warehouse) {
  5396. $where .= " and warehouse = '$warehouse'";
  5397. }
  5398. //数据排序
  5399. $order_str = "id desc";
  5400. if (empty($page)) {
  5401. $start = 0;
  5402. $perpage = 1;
  5403. } else {
  5404. $start = ($page - 1) * $perpage;
  5405. }
  5406. //取得信息列表
  5407. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5408. $rows = array();
  5409. $list = array();
  5410. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5411. // foreach ($info_list as $value)
  5412. // {
  5413. // $warehouse = $this->warehouse->read($value['warehouse']);
  5414. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5415. // $number = $value['number'];$ftime = time()-15*24*3600;
  5416. // if($c < 1)
  5417. // {
  5418. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5419. // }
  5420. // }
  5421. $warehouse_list = $this->warehouse->find_all();
  5422. $warehouse_list = array_column($warehouse_list, null, 'id');
  5423. foreach ($info_list as $value) {
  5424. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5425. 'title' => "",
  5426. ];
  5427. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5428. $number = $value['number'];
  5429. $ftime = time() - 15 * 24 * 3600;
  5430. if ($c < 1) {
  5431. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5432. }
  5433. }
  5434. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5435. // $query = $this->db->query($sql);
  5436. // $info_list = $query->result_array();
  5437. // $sql_two = "select title,id from crowd_warehouse";
  5438. // $query_two = $this->db->query($sql_two);
  5439. // $warehouse_list = $query_two->result_array();
  5440. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5441. // foreach ($info_list as $value)
  5442. // {
  5443. // if(isset($warehouse_arr[$value['warehouse']])){
  5444. // $warehouse = $warehouse_arr[$value['warehouse']];
  5445. // }else{
  5446. // $warehouse = [
  5447. // 'id'=>0,
  5448. // 'title'=>"异常",
  5449. // ];
  5450. // }
  5451. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5452. // $number = $value['number'];$ftime = time()-15*24*3600;
  5453. // if($c < 1)
  5454. // {
  5455. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5456. // }
  5457. // }
  5458. $listdata = array_slice($list, $start, $perpage);
  5459. $total = count($list);
  5460. $pagenum = ceil($total / $perpage);
  5461. $over = $total - ($start + $perpage);
  5462. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5463. echo json_encode($rows);
  5464. exit;
  5465. }
  5466. if (isset($post['s'])) {
  5467. $id_arr = $this->input->post('s');
  5468. $id_arr = explode(',', trim($id_arr, ','));
  5469. if (!$id_arr) {
  5470. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5471. exit;
  5472. }
  5473. //循环删除记录
  5474. foreach ($id_arr as $v) {
  5475. $dd = $this->whlabel->read($v);
  5476. if (!isset($dd['id'])) {
  5477. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5478. exit;
  5479. }
  5480. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5481. if (isset($zt[0])) {
  5482. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5483. exit;
  5484. }
  5485. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5486. foreach ($deldd as $vv) {
  5487. $this->whlabel->remove($vv['id']);
  5488. }
  5489. }
  5490. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5491. exit;
  5492. }
  5493. $this->_Template('whlabel_error', $this->data);
  5494. }
  5495. public function _errorexcel()
  5496. {
  5497. $post = $this->input->post(NULL, TRUE);
  5498. if (isset($_GET['page'])) {
  5499. $page = $this->input->get('page', true);
  5500. $perpage = $this->input->get('perpage', true);
  5501. $sku = $this->input->get('sku', true);
  5502. $warehouse = $this->input->get('warehouse', true);
  5503. $ktime = $this->input->get('ktime', true);
  5504. $jtime = $this->input->get('jtime', true);
  5505. $ktime = strtotime($ktime);
  5506. $jtime = strtotime($jtime);
  5507. $where = "sku != 'Preset'";
  5508. $gj = '';
  5509. if ($sku) {
  5510. $where .= " and sku like '%$sku%'";
  5511. } else {
  5512. if ($ktime && $jtime) {
  5513. $gj = " and time > '$ktime' and time < '$jtime'";
  5514. }
  5515. }
  5516. if ($warehouse) {
  5517. $where .= " and warehouse = '$warehouse'";
  5518. }
  5519. //数据排序
  5520. $order_str = "id desc";
  5521. if (empty($page)) {
  5522. $start = 0;
  5523. $perpage = 1;
  5524. } else {
  5525. $start = ($page - 1) * $perpage;
  5526. }
  5527. //取得信息列表
  5528. $rows = array();
  5529. $list = array();
  5530. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5531. foreach ($info_list as $value) {
  5532. $warehouse = $this->warehouse->read($value['warehouse']);
  5533. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5534. $number = $value['number'];
  5535. $ftime = time() - 15 * 24 * 3600;
  5536. if ($c < 1) {
  5537. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5538. }
  5539. }
  5540. $title = "0库存汇总";
  5541. $titlename = "<table border=1>
  5542. <tr align='center'>
  5543. <td>仓库</td>
  5544. <td>SKU</td>
  5545. <td>产品</td>
  5546. <td>当前库存</td>
  5547. </tr>
  5548. </table>";
  5549. $filename = $title . ".xls";
  5550. $tail = "";
  5551. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5552. }
  5553. }
  5554. /**
  5555. *
  5556. *
  5557. * 占单
  5558. *
  5559. *
  5560. **/
  5561. public function _kcyz()
  5562. {
  5563. $post = $this->input->post(NULL, TRUE);
  5564. if (isset($post['warehouse'])) {
  5565. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5566. exit; //不再使用
  5567. $warehouse = $this->input->post('warehouse', true);
  5568. $whlabel = $this->input->post('whlabel', true);
  5569. $id = $this->input->post('id', true);
  5570. $shop = $this->input->post('shop', true);
  5571. $number = $this->input->post('number', true);
  5572. if (!$whlabel || $whlabel == '|') {
  5573. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5574. exit;
  5575. }
  5576. $pp = explode('|', trim($whlabel, '|'));
  5577. $x = 0;
  5578. $save = array();
  5579. foreach ($pp as $va) {
  5580. $num = explode('-', $va);
  5581. if ($number) {
  5582. $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 = '')"); //通用
  5583. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5584. } else {
  5585. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5586. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5587. }
  5588. $x++;
  5589. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5590. $save[] = $x - 1;
  5591. continue; //提前先加X不然出错,所以要减1
  5592. }
  5593. }
  5594. if (isset($save[0])) {
  5595. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5596. exit;
  5597. } else {
  5598. echo json_encode(array('success' => true));
  5599. exit;
  5600. }
  5601. }
  5602. }
  5603. public function _db()
  5604. {
  5605. $post = $this->input->post(NULL, TRUE);
  5606. if (isset($post['page'])) {
  5607. $page = $this->input->post('page', true);
  5608. $perpage = $this->input->post('perpage', true);
  5609. $sku = $this->input->post('sku', true);
  5610. $number = $this->input->post('number', true);
  5611. $warehouse = $this->input->post('warehouse', true);
  5612. $purchase = $this->input->post('purchase', true);
  5613. $orderinfo = $this->input->post('orderinfo', true);
  5614. $waybill = $this->input->post('waybill', true);
  5615. $category = $this->input->post('category', true);
  5616. $size = $this->input->post('size', true);
  5617. $grade = $this->input->post('grade', true);
  5618. $color = $this->input->post('color', true);
  5619. $lowe = $this->input->post('lowe', true);
  5620. $state = $this->input->post('state', true);
  5621. $label = $this->input->post('label', true);
  5622. $timetk = $this->input->post('timetkk', true);
  5623. $timetj = $this->input->post('timetjj', true);
  5624. $timetk = strtotime($timetk);
  5625. $timetj = strtotime($timetj);
  5626. $where = "dbtime > 0";
  5627. if ($timetk && $timetj) {
  5628. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5629. }
  5630. if ($sku) {
  5631. $where .= " and sku = '$sku'";
  5632. }
  5633. if ($warehouse) {
  5634. $where .= " and warehouse = '$warehouse'";
  5635. if ($warehouse == 12) {
  5636. $w = 'specialstock';
  5637. } else {
  5638. $w = 'whlabel';
  5639. }
  5640. }
  5641. if ($purchase) {
  5642. $where .= " and purchase = '$purchase'";
  5643. }
  5644. if ($category) {
  5645. $where .= " and features like '%-$category-%'";
  5646. }
  5647. if ($size) {
  5648. $where .= " and features like '%-$size-%'";
  5649. }
  5650. if ($grade) {
  5651. $where .= " and features like '%-$grade-%'";
  5652. }
  5653. if ($color) {
  5654. $where .= " and features like '%-$color-%'";
  5655. }
  5656. if ($lowe) {
  5657. $where .= " and features like '%-$lowe-%'";
  5658. }
  5659. if ($state != '') {
  5660. $where .= " and state = '$state'";
  5661. }
  5662. //数据排序
  5663. $order_str = "dbtime desc";
  5664. if (empty($page)) {
  5665. $start = 0;
  5666. $perpage = 1;
  5667. } else {
  5668. $start = ($page - 1) * $perpage;
  5669. }
  5670. //取得信息列表
  5671. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5672. foreach ($info_list as $key => $value) {
  5673. $warehouse = $this->$w->read($value['warehouse']);
  5674. $info_list[$key]['warehouse'] = $warehouse['title'];
  5675. $purchase = $this->purchase->read($value['purchase']);
  5676. $info_list[$key]['purchase'] = $purchase['title'];
  5677. if ($value['enter'] != 0) {
  5678. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5679. } else {
  5680. $info_list[$key]['enter'] = "";
  5681. }
  5682. if ($value['dbtime'] != 0) {
  5683. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5684. } else {
  5685. $info_list[$key]['dbtime'] = "";
  5686. }
  5687. if ($value['state'] == 0) {
  5688. $info_list[$key]['state'] = "在库";
  5689. } else if ($value['state'] == 1) {
  5690. $info_list[$key]['state'] = "出库";
  5691. } else if ($value['state'] == 2) {
  5692. $info_list[$key]['state'] = "退库";
  5693. } else if ($value['state'] == 3) {
  5694. $info_list[$key]['state'] = "调拨中";
  5695. } else if ($value['state'] == 4) {
  5696. $info_list[$key]['state'] = "再加工";
  5697. } else if ($value['state'] == 5) {
  5698. $info_list[$key]['state'] = "维修中";
  5699. } else if ($value['state'] == 6) {
  5700. $info_list[$key]['state'] = "盘亏";
  5701. } else if ($value['state'] == 7) {
  5702. $info_list[$key]['state'] = "更换标签";
  5703. } else if ($value['state'] == 8) {
  5704. $info_list[$key]['state'] = "其它";
  5705. } else if ($value['state'] == 9) {
  5706. $info_list[$key]['state'] = "预设";
  5707. }
  5708. }
  5709. $total = $this->whlabel->find_count($where);
  5710. $pagenum = ceil($total / $perpage);
  5711. $over = $total - ($start + $perpage);
  5712. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5713. echo json_encode($rows);
  5714. exit;
  5715. }
  5716. if (isset($post['outsku'])) {
  5717. $time = time();
  5718. $cz = $this->input->post('cz', true);
  5719. $label = $this->input->post('outsku', true);
  5720. $sl = $this->input->post('sl', true);
  5721. $num = $this->input->post('num', true);
  5722. //$warehouse = $this->input->post('warehouse',true);
  5723. if (!$sl) {
  5724. $sl = 1;
  5725. }
  5726. if (!$warehouse) {
  5727. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5728. exit;
  5729. }
  5730. $dblabel = $this->whlabellabel->get_label($label);
  5731. if ($dblabel) {
  5732. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5733. if (count($data) < 1) {
  5734. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5735. exit;
  5736. }
  5737. if (count($data) < $num) {
  5738. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5739. exit;
  5740. }
  5741. for ($i = 0; $i < $sl; $i++) {
  5742. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5743. }
  5744. echo json_encode(array('success' => true));
  5745. exit;
  5746. } else {
  5747. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5748. exit;
  5749. }
  5750. }
  5751. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5752. $this->_Template('whlabel_db', $this->data);
  5753. }
  5754. public function _dbrk()
  5755. {
  5756. $post = $this->input->post(NULL, TRUE);
  5757. if (isset($post['page'])) {
  5758. $page = $this->input->post('page', true);
  5759. $perpage = $this->input->post('perpage', true);
  5760. $sku = $this->input->post('sku', true);
  5761. $number = $this->input->post('number', true);
  5762. $warehouse = $this->input->post('warehouse', true);
  5763. $purchase = $this->input->post('purchase', true);
  5764. $orderinfo = $this->input->post('orderinfo', true);
  5765. $waybill = $this->input->post('waybill', true);
  5766. $category = $this->input->post('category', true);
  5767. $size = $this->input->post('size', true);
  5768. $grade = $this->input->post('grade', true);
  5769. $color = $this->input->post('color', true);
  5770. $lowe = $this->input->post('lowe', true);
  5771. $state = $this->input->post('state', true);
  5772. $label = $this->input->post('label', true);
  5773. $ctime = $this->input->post('ctime', true);
  5774. $timetk = $this->input->post('timetkk', true);
  5775. $timetj = $this->input->post('timetjj', true);
  5776. $timetk = strtotime($timetk);
  5777. $timetj = strtotime($timetj);
  5778. $where = "dbtime > 0";
  5779. if ($timetk && $timetj) {
  5780. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5781. }
  5782. if ($sku) {
  5783. $where .= " and sku = '$sku'";
  5784. }
  5785. if ($warehouse) {
  5786. $where .= " and warehouse = '$warehouse'";
  5787. }
  5788. if ($purchase) {
  5789. $where .= " and purchase = '$purchase'";
  5790. }
  5791. if ($category) {
  5792. $where .= " and features like '%-$category-%'";
  5793. }
  5794. if ($size) {
  5795. $where .= " and features like '%-$size-%'";
  5796. }
  5797. if ($grade) {
  5798. $where .= " and features like '%-$grade-%'";
  5799. }
  5800. if ($color) {
  5801. $where .= " and features like '%-$color-%'";
  5802. }
  5803. if ($lowe) {
  5804. $where .= " and features like '%-$lowe-%'";
  5805. }
  5806. if ($state != '') {
  5807. $where .= " and state = '$state'";
  5808. }
  5809. //数据排序
  5810. $order_str = "dbtime desc";
  5811. if (empty($page)) {
  5812. $start = 0;
  5813. $perpage = 1;
  5814. } else {
  5815. $start = ($page - 1) * $perpage;
  5816. }
  5817. //取得信息列表
  5818. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5819. foreach ($info_list as $key => $value) {
  5820. $warehouse = $this->warehouse->read($value['warehouse']);
  5821. $info_list[$key]['warehouse'] = $warehouse['title'];
  5822. $purchase = $this->purchase->read($value['purchase']);
  5823. $info_list[$key]['purchase'] = $purchase['title'];
  5824. if ($value['enter'] != 0) {
  5825. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5826. } else {
  5827. $info_list[$key]['enter'] = "";
  5828. }
  5829. if ($value['dbtime'] != 0) {
  5830. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5831. } else {
  5832. $info_list[$key]['dbtime'] = "";
  5833. }
  5834. if ($value['state'] == 0) {
  5835. $info_list[$key]['state'] = "在库";
  5836. } else if ($value['state'] == 1) {
  5837. $info_list[$key]['state'] = "出库";
  5838. } else if ($value['state'] == 2) {
  5839. $info_list[$key]['state'] = "退库";
  5840. } else if ($value['state'] == 3) {
  5841. $info_list[$key]['state'] = "调拨中";
  5842. } else if ($value['state'] == 4) {
  5843. $info_list[$key]['state'] = "再加工";
  5844. } else if ($value['state'] == 5) {
  5845. $info_list[$key]['state'] = "维修中";
  5846. } else if ($value['state'] == 6) {
  5847. $info_list[$key]['state'] = "盘亏";
  5848. } else if ($value['state'] == 7) {
  5849. $info_list[$key]['state'] = "更换标签";
  5850. } else if ($value['state'] == 8) {
  5851. $info_list[$key]['state'] = "其它";
  5852. } else if ($value['state'] == 9) {
  5853. $info_list[$key]['state'] = "预设";
  5854. }
  5855. }
  5856. $total = $this->whlabel->find_count($where);
  5857. $pagenum = ceil($total / $perpage);
  5858. $over = $total - ($start + $perpage);
  5859. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5860. echo json_encode($rows);
  5861. exit;
  5862. }
  5863. if (isset($post['rsku'])) {
  5864. $cz = $this->input->post('cz', true);
  5865. $label = $this->input->post('rsku', true);
  5866. $sl = $this->input->post('sl', true);
  5867. $warehouse = $this->input->post('warehouse', true);
  5868. if (!$sl) {
  5869. $sl = 1;
  5870. }
  5871. if (!$warehouse) {
  5872. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5873. exit;
  5874. }
  5875. $dblabel = $this->whlabellabel->get_label($label);
  5876. if ($dblabel) {
  5877. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5878. if (count($data) < 1) {
  5879. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5880. exit;
  5881. }
  5882. if ($sl > count($data)) {
  5883. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5884. exit;
  5885. }
  5886. $time = time();
  5887. for ($i = 0; $i < $sl; $i++) {
  5888. $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']);
  5889. }
  5890. echo json_encode(array('success' => true));
  5891. exit;
  5892. } else {
  5893. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5894. exit;
  5895. }
  5896. }
  5897. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5898. $this->_Template('whlabel_dbrk', $this->data);
  5899. }
  5900. public function _whlabelczdc()
  5901. {
  5902. if (isset($_GET['excel'])) {
  5903. //数据排序
  5904. $order_str = "id desc";
  5905. if (empty($page)) {
  5906. $start = 0;
  5907. $perpage = 1;
  5908. } else {
  5909. $start = ($page - 1) * $perpage;
  5910. }
  5911. $state = $this->input->get('state', true);
  5912. $sku = $this->input->get('sku', true);
  5913. $ctime = $this->input->get('ctime', true);
  5914. $category = $this->input->get('category', true);
  5915. $size = $this->input->get('size', true);
  5916. $grade = $this->input->get('grade', true);
  5917. $color = $this->input->get('color', true);
  5918. $lowe = $this->input->get('lowe', true);
  5919. $timetk = $this->input->get('timetkk', true);
  5920. $timetj = $this->input->get('timetjj', true);
  5921. $timetk = strtotime($timetk);
  5922. $timetj = strtotime($timetj);
  5923. $where = "dbtime > 0";
  5924. if ($timetk && $timetj) {
  5925. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5926. }
  5927. if ($category) {
  5928. $where .= " and features like '%-$category-%'";
  5929. }
  5930. if ($size) {
  5931. $where .= " and features like '%-$size-%'";
  5932. }
  5933. if ($grade) {
  5934. $where .= " and features like '%-$grade-%'";
  5935. }
  5936. if ($color) {
  5937. $where .= " and features like '%-$color-%'";
  5938. }
  5939. if ($lowe) {
  5940. $where .= " and features like '%-$lowe-%'";
  5941. }
  5942. //取得信息列表
  5943. $info_list = $this->whlabel->find_all($where, '*');
  5944. $rows = array();
  5945. $list = array();
  5946. foreach ($info_list as $key => $value) {
  5947. $rows[$value['sku']] = $value; //所有数据sku
  5948. }
  5949. foreach ($rows as $value) {
  5950. $warehouse = $this->warehouse->read($value['warehouse']);
  5951. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5952. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5953. if ($value['orderinfo'] == 0) {
  5954. $info_list[$key]['orderinfo'] = "";
  5955. }
  5956. if ($value['waybill'] == 0) {
  5957. $info_list[$key]['waybill'] = "";
  5958. }
  5959. if ($value['state'] == 0) {
  5960. $value['state'] = "在库";
  5961. } else if ($value['state'] == 3) {
  5962. $value['state'] = "调拨中";
  5963. }
  5964. $list[] = array($value['sku'], $value['title'], $db, $rk);
  5965. }
  5966. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  5967. $titlename = "<table border=1>
  5968. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  5969. <tr align='center'>
  5970. <td>SKU</td>
  5971. <td>产品</td>
  5972. <td>调拨数量</td>
  5973. <td>入库数量</td>
  5974. </tr>
  5975. </table>";
  5976. $filename = $title . ".xls";
  5977. $tail = "";
  5978. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5979. }
  5980. }
  5981. public function _print($arg_array)
  5982. {
  5983. if (isset($_SESSION['api'])) {
  5984. $user = $this->user->get_api($_SESSION['api']);
  5985. $usp = $user;
  5986. $fgshop = "";
  5987. $sid = "";
  5988. $wid = "";
  5989. $wtype = "";
  5990. $usersp = explode('|', trim($user['shop'], '|'));
  5991. $userwh = explode('|', trim($user['warehouse'], '|'));
  5992. foreach ($usersp as $value) {
  5993. $fgshop .= " shop = " . $value . " or";
  5994. $sid .= " id = " . $value . " or";
  5995. }
  5996. foreach ($userwh as $value) {
  5997. $wid .= " id = " . $value . " or";
  5998. $wtype .= " type = " . $value . " or";
  5999. }
  6000. }
  6001. $post = $this->input->post(NULL, TRUE);
  6002. if (isset($post['tmsku'])) {
  6003. $tmsku = $this->input->post('tmsku', true);
  6004. if (is_numeric($tmsku)) {
  6005. $yyh = $this->whlabellabel->get_label($tmsku);
  6006. } else {
  6007. $yyh = $this->whlabellabel->get_sku($tmsku);
  6008. if(empty($yyh)){
  6009. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6010. if($r['code'] == -1 ){
  6011. echo json_encode(array('success' => false));
  6012. exit;
  6013. }else{
  6014. echo json_encode(array('features' => $r['data'], 'success' => true));
  6015. exit;
  6016. }
  6017. }
  6018. }
  6019. if ($yyh) {
  6020. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6021. exit;
  6022. } else {
  6023. echo json_encode(array('success' => false));
  6024. exit;
  6025. }
  6026. }
  6027. $classid = $this->classid->sku();
  6028. $pm = $classid;
  6029. $scsku = $classid;
  6030. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6031. if (isset($post['warehouse'])) {
  6032. if ($post['warehouse']) {
  6033. $list = array();
  6034. $num = "";
  6035. $title = "";
  6036. $features = "";
  6037. $order = 0;
  6038. $post['shop'] = '';
  6039. $brand = $this->input->post('brand', true);
  6040. if ($brand != '0,') {
  6041. $b = $this->brand->read(rtrim($brand, ','));
  6042. if ($b) {
  6043. $post['shop'] = str_replace('|', ',', $b['shop']);
  6044. }
  6045. }
  6046. $post['details'] = $this->input->post('details', true); //打印数量
  6047. $xbqnum = $this->input->post('xbqnum', true);
  6048. $post['purchase'] = $this->input->post('purchase', true);
  6049. $post['warehouse'] = $this->input->post('warehouse', true);
  6050. $post['purchase'] = $this->input->post('purchase', true);
  6051. $post['retreatwarehouse'] = $post['warehouse'];
  6052. $post['cpbz'] = $this->input->post('cpbz', true);
  6053. $post['state'] = 9;
  6054. $category = $this->input->post('category', true);
  6055. $list['category'] = $category;
  6056. $list['hairtype'] = $this->input->post('hairtype', true);
  6057. $list['grade'] = $this->input->post('grade', true);
  6058. $size = $this->input->post('size', true);
  6059. $list['size'] = rtrim($size, ',');
  6060. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6061. $list['extension'] = $this->input->post('extension', true);
  6062. if ($category == 1297) {
  6063. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6064. }
  6065. if ($category == 1702) {
  6066. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6067. $list['syother'] = $this->input->post('syother', true);
  6068. }
  6069. if ($category == 133) {
  6070. $list['fittype'] = $this->input->post('fittype', true);
  6071. $list['acother'] = $this->input->post('acother', true);
  6072. }
  6073. $list['color'] = $this->input->post('color', true);
  6074. $list['lowe'] = $this->input->post('lowe', true);
  6075. if ($category == 127) {
  6076. $list['type'] = $this->input->post('type', true);
  6077. $list['headroad'] = $this->input->post('headroad', true);
  6078. $list['density'] = $this->input->post('density', true);
  6079. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6080. $list['lacesize'] = $this->input->post('lacesize', true);
  6081. }
  6082. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6083. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6084. }
  6085. if ($category == 128) {
  6086. $list['lacetype'] = $this->input->post('lacetype', true);
  6087. $list['haircap'] = $this->input->post('haircap', true);
  6088. $list['density'] = $this->input->post('density', true);
  6089. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6090. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6091. $list['wigother'] = $this->input->post('wigother', true);
  6092. $list['wigother1'] = $this->input->post('wigother1', true);
  6093. $list['wigother2'] = $this->input->post('wigother2', true);
  6094. $list['product_related'] = $this->input->post('product_related', true);
  6095. }
  6096. if ($category == 129) {
  6097. $list['wide'] = $this->input->post('wide', true);
  6098. }
  6099. if ($category == 131) {
  6100. $list['gifttype'] = $this->input->post('gifttype', true);
  6101. $list['giftother'] = $this->input->post('giftother', true);
  6102. }
  6103. if ($category == 134) {
  6104. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6105. }
  6106. if ($category == 1297) {
  6107. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6108. $list['sywigother'] = $this->input->post('sywigother', true);
  6109. }
  6110. if ($category == 130 || $category == 133 || $category == 1702) {
  6111. $list['items'] = $this->input->post('items', true);
  6112. $list['weight'] = $this->input->post('weight', true);
  6113. }
  6114. if ($category == 1702) {
  6115. $list['syhairther'] = $this->input->post('syhairther', true);
  6116. }
  6117. if($category == 130){
  6118. $list['jfother'] = $this->input->post('jfother', true);
  6119. }
  6120. foreach ($list as $k => $v) {
  6121. if ($v != 0) {
  6122. $num .= $v;
  6123. $features .= $v . '-';
  6124. $post[$k] = $v;
  6125. $typeclass = $this->typeclass->read($v);
  6126. if (isset($pm[$typeclass['classid']])) {
  6127. if (stripos($typeclass['zh'], '|') !== false) {
  6128. $exzh = explode('|', $typeclass['zh']);
  6129. $pm[$typeclass['classid']] = $exzh[0];
  6130. } else {
  6131. $pm[$typeclass['classid']] = $typeclass['zh'];
  6132. }
  6133. }
  6134. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6135. if ($k != 'size') {
  6136. $title .= $typeclass['title'] . " ";
  6137. }
  6138. }
  6139. }
  6140. $typeclass = $this->typeclass->read($list['size']);
  6141. $title .= $typeclass['title'];
  6142. $time = time();
  6143. $post['title'] = rtrim($title, ' ');
  6144. $post['number'] = $num;
  6145. $post['features'] = '-' . $features;
  6146. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6147. $featurespp = explode('-', trim($featurespp, '-'));
  6148. if (isset($featurespp[5])) {
  6149. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6150. } else {
  6151. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6152. }
  6153. $post['enter'] = $time;
  6154. $post['time'] = $time; //操作时间
  6155. $scsku = implode("-", $scsku);
  6156. $zh = implode(" ", $pm);
  6157. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6158. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6159. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6160. $post['sku'] = $bqsku;
  6161. $label = time() . rand(0, 9);
  6162. $post['label'] = $label;
  6163. $cpid = $this->whlabellabel->find_count();
  6164. $post['cpid'] = $cpid + 1;
  6165. $cpid = $post['cpid'];
  6166. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6167. //if($whlabelbarcode)
  6168. //{
  6169. //$post['label'] = $whlabelbarcode['label'];
  6170. //if(!$this->whlabellabel->insert($post))
  6171. //{
  6172. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6173. //}
  6174. //}
  6175. //else
  6176. //{
  6177. $this->db->trans_begin();
  6178. $this->whlabellabel->insert($post);
  6179. //$this->whlabelbarcode->insert($post);
  6180. if ($this->db->trans_status() === TRUE) {
  6181. $this->db->trans_commit();
  6182. } else {
  6183. $this->db->trans_rollback();
  6184. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6185. exit;
  6186. }
  6187. //}
  6188. $warehouse_name = "";
  6189. $warehouse = $post['warehouse'];
  6190. if($warehouse == 12){
  6191. $warehouse_name = "特殊库存库";
  6192. }
  6193. // if($warehouse == 13){
  6194. // $warehouse_name = "许昌仓";
  6195. // }
  6196. // if($warehouse == 5){
  6197. // $warehouse_name = "美国店";
  6198. // }
  6199. // if($warehouse == 16){
  6200. // $warehouse_name = "定制头套仓";
  6201. // }
  6202. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6203. if(!empty($warehouse_name)){
  6204. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6205. }
  6206. $purchase = $this->purchase->read($post['purchase']);
  6207. 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));
  6208. exit; //特殊仓目前不需要仓库选项
  6209. }
  6210. }
  6211. if (isset($_SESSION['api'])) {
  6212. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6213. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6214. $this->data['wlshop'] = $wlshop;
  6215. $this->data['warehouse'] = $warehouse;
  6216. }
  6217. $whlabelwz = $this->whlabelwz->find_all();
  6218. $this->data['whlabelwz'] = $whlabelwz;
  6219. $this->_Template('whlabel_print', $this->data);
  6220. }
  6221. public function _usaprint($arg_array)
  6222. {
  6223. if (isset($_SESSION['api'])) {
  6224. $user = $this->user->get_api($_SESSION['api']);
  6225. $usp = $user;
  6226. $fgshop = "";
  6227. $sid = "";
  6228. $wid = "";
  6229. $wtype = "";
  6230. $usersp = explode('|', trim($user['shop'], '|'));
  6231. $userwh = explode('|', trim($user['warehouse'], '|'));
  6232. foreach ($usersp as $value) {
  6233. $fgshop .= " shop = " . $value . " or";
  6234. $sid .= " id = " . $value . " or";
  6235. }
  6236. foreach ($userwh as $value) {
  6237. $wid .= " id = " . $value . " or";
  6238. $wtype .= " type = " . $value . " or";
  6239. }
  6240. }
  6241. $post = $this->input->post(NULL, TRUE);
  6242. if (isset($post['tmsku'])) {
  6243. $tmsku = $this->input->post('tmsku', true);
  6244. if (is_numeric($tmsku)) {
  6245. $yyh = $this->whlabellabel->get_label($tmsku);
  6246. } else {
  6247. $yyh = $this->whlabellabel->get_sku($tmsku);
  6248. }
  6249. if ($yyh) {
  6250. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6251. exit;
  6252. } else {
  6253. echo json_encode(array('success' => false));
  6254. exit;
  6255. }
  6256. }
  6257. $classid = $this->classid->sku();
  6258. $pm = $classid;
  6259. $scsku = $classid;
  6260. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6261. if (isset($post['warehouse'])) {
  6262. if ($post['warehouse']) {
  6263. $list = array();
  6264. $num = "";
  6265. $title = "";
  6266. $features = "";
  6267. $order = 0;
  6268. $post['shop'] = '';
  6269. $brand = $this->input->post('brand', true);
  6270. if ($brand != '0,') {
  6271. $b = $this->brand->read(rtrim($brand, ','));
  6272. if ($b) {
  6273. $post['shop'] = str_replace('|', ',', $b['shop']);
  6274. }
  6275. }
  6276. $post['details'] = $this->input->post('details', true); //打印数量
  6277. $xbqnum = $this->input->post('xbqnum', true);
  6278. $post['purchase'] = $this->input->post('purchase', true);
  6279. $post['warehouse'] = $this->input->post('warehouse', true);
  6280. $post['purchase'] = $this->input->post('purchase', true);
  6281. $post['retreatwarehouse'] = $post['warehouse'];
  6282. $post['cpbz'] = $this->input->post('cpbz', true);
  6283. $post['state'] = 9;
  6284. $category = $this->input->post('category', true);
  6285. $list['category'] = $category;
  6286. $list['hairtype'] = $this->input->post('hairtype', true);
  6287. $list['grade'] = $this->input->post('grade', true);
  6288. $size = $this->input->post('size', true);
  6289. $list['size'] = rtrim($size, ',');
  6290. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6291. $list['extension'] = $this->input->post('extension', true);
  6292. if ($category == 1297) {
  6293. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6294. }
  6295. if ($category == 1702) {
  6296. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6297. $list['syother'] = $this->input->post('syother', true);
  6298. }
  6299. if ($category == 133) {
  6300. $list['fittype'] = $this->input->post('fittype', true);
  6301. $list['acother'] = $this->input->post('acother', true);
  6302. }
  6303. $list['color'] = $this->input->post('color', true);
  6304. $list['lowe'] = $this->input->post('lowe', true);
  6305. if ($category == 127) {
  6306. $list['type'] = $this->input->post('type', true);
  6307. $list['headroad'] = $this->input->post('headroad', true);
  6308. $list['density'] = $this->input->post('density', true);
  6309. if ($list['type'] == 195 || $list['type'] == 197 || $list['type'] == 199) {
  6310. $list['lacesize'] = $this->input->post('lacesize', true);
  6311. }
  6312. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6313. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6314. }
  6315. if ($category == 128) {
  6316. $list['lacetype'] = $this->input->post('lacetype', true);
  6317. $list['haircap'] = $this->input->post('haircap', true);
  6318. $list['density'] = $this->input->post('density', true);
  6319. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6320. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6321. $list['wigother'] = $this->input->post('wigother', true);
  6322. $list['wigother1'] = $this->input->post('wigother1', true);
  6323. $list['wigother2'] = $this->input->post('wigother2', true);
  6324. $list['product_related'] = $this->input->post('product_related', true);
  6325. }
  6326. if ($category == 129) {
  6327. $list['wide'] = $this->input->post('wide', true);
  6328. }
  6329. if ($category == 131) {
  6330. $list['gifttype'] = $this->input->post('gifttype', true);
  6331. $list['giftother'] = $this->input->post('giftother', true);
  6332. }
  6333. if ($category == 134) {
  6334. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6335. }
  6336. if ($category == 1297) {
  6337. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6338. $list['sywigother'] = $this->input->post('sywigother', true);
  6339. }
  6340. if ($category == 130 || $category == 133 || $category == 1702) {
  6341. $list['items'] = $this->input->post('items', true);
  6342. $list['weight'] = $this->input->post('weight', true);
  6343. }
  6344. if ($category == 1702) {
  6345. $list['syhairther'] = $this->input->post('syhairther', true);
  6346. }
  6347. foreach ($list as $k => $v) {
  6348. if ($v != 0) {
  6349. $num .= $v;
  6350. $features .= $v . '-';
  6351. $post[$k] = $v;
  6352. $typeclass = $this->typeclass->read($v);
  6353. if (isset($pm[$typeclass['classid']])) {
  6354. if (stripos($typeclass['zh'], '|') !== false) {
  6355. $exzh = explode('|', $typeclass['zh']);
  6356. $pm[$typeclass['classid']] = $exzh[0];
  6357. } else {
  6358. $pm[$typeclass['classid']] = $typeclass['zh'];
  6359. }
  6360. }
  6361. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6362. if ($k != 'size') {
  6363. $title .= $typeclass['title'] . " ";
  6364. }
  6365. }
  6366. }
  6367. $typeclass = $this->typeclass->read($list['size']);
  6368. $title .= $typeclass['title'];
  6369. $time = time();
  6370. $post['title'] = rtrim($title, ' ');
  6371. $post['number'] = $num;
  6372. $post['features'] = '-' . $features;
  6373. $fp = $this->whlabel->get_features($post['features']);
  6374. if (!$fp) {
  6375. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6376. exit;
  6377. }
  6378. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6379. $featurespp = explode('-', trim($featurespp, '-'));
  6380. if (isset($featurespp[5])) {
  6381. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6382. } else {
  6383. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6384. }
  6385. $post['enter'] = $time;
  6386. $post['time'] = $time; //操作时间
  6387. $scsku = implode("-", $scsku);
  6388. $zh = implode(" ", $pm);
  6389. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6390. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6391. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6392. $post['sku'] = $fp['sku'];
  6393. $post['label'] = $fp['sku'];
  6394. $cpid = $this->whlabellabel->find_count();
  6395. $post['cpid'] = $cpid + 1;
  6396. $cpid = $post['cpid'];
  6397. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6398. //if($whlabelbarcode)
  6399. //{
  6400. //$post['label'] = $whlabelbarcode['label'];
  6401. //if(!$this->whlabellabel->insert($post))
  6402. //{
  6403. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6404. //}
  6405. //}
  6406. //else
  6407. //{
  6408. $this->db->trans_begin();
  6409. $this->whlabellabel->insert($post);
  6410. //$this->whlabelbarcode->insert($post);
  6411. if ($this->db->trans_status() === TRUE) {
  6412. $this->db->trans_commit();
  6413. } else {
  6414. $this->db->trans_rollback();
  6415. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6416. exit;
  6417. }
  6418. //}
  6419. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6420. $purchase = $this->purchase->read($post['purchase']);
  6421. 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));
  6422. exit; //特殊仓目前不需要仓库选项
  6423. }
  6424. }
  6425. if (isset($_SESSION['api'])) {
  6426. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6427. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6428. $this->data['wlshop'] = $wlshop;
  6429. $this->data['warehouse'] = $warehouse;
  6430. }
  6431. $whlabelwz = $this->whlabelwz->find_all();
  6432. $this->data['whlabelwz'] = $whlabelwz;
  6433. $this->_Template('whlabel_usaprint', $this->data);
  6434. }
  6435. public function _printrk($arg_array)
  6436. {
  6437. $prc = array();
  6438. $purchase = $this->purchase->find_all();
  6439. foreach ($purchase as $k => $v) {
  6440. $prc[$v['id']] = $v['title'];
  6441. }
  6442. $post = $this->input->post(NULL, TRUE);
  6443. if (isset($post['page'])) {
  6444. $page = $this->input->post('page', true);
  6445. $perpage = $this->input->post('perpage', true);
  6446. $sku = $this->input->post('sku', true);
  6447. $bs = $this->input->post('bs', true);
  6448. $number = $this->input->post('number', true);
  6449. $warehouse = $this->input->post('warehouse', true);
  6450. $purchase = $this->input->post('purchase', true);
  6451. $orderinfo = $this->input->post('orderinfo', true);
  6452. $waybill = $this->input->post('waybill', true);
  6453. $category = $this->input->post('category', true);
  6454. $size = $this->input->post('size', true);
  6455. $grade = $this->input->post('grade', true);
  6456. $color = $this->input->post('color', true);
  6457. $lowe = $this->input->post('lowe', true);
  6458. $state = $this->input->post('state', true);
  6459. $label = $this->input->post('label', true);
  6460. $timetk = $this->input->post('ktime', true);
  6461. $timetj = $this->input->post('jtime', true);
  6462. $timetk = strtotime($timetk);
  6463. $timetj = strtotime($timetj);
  6464. $where = "1=1 ";
  6465. if ($timetk && $timetj) {
  6466. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6467. }
  6468. if ($sku) {
  6469. $where .= " and sku = '$sku'";
  6470. }
  6471. if ($bs != '') {
  6472. $where .= " and bs = '$bs'";
  6473. }
  6474. if ($number) {
  6475. $where .= " and number = '$number'";
  6476. }
  6477. if ($warehouse) {
  6478. $where .= " and warehouse = '$warehouse'";
  6479. }
  6480. if ($purchase) {
  6481. $where .= " and purchase = '$purchase'";
  6482. }
  6483. if ($orderinfo) {
  6484. $where .= " and orderinfo = '$orderinfo'";
  6485. }
  6486. if ($waybill) {
  6487. $where .= " and waybill = '$waybill'";
  6488. }
  6489. if ($category) {
  6490. $where .= " and features like '%-$category-%'";
  6491. }
  6492. if ($size) {
  6493. $where .= " and features like '%-$size-%'";
  6494. }
  6495. if ($grade) {
  6496. $where .= " and features like '%-$grade-%'";
  6497. }
  6498. if ($color) {
  6499. $where .= " and features like '%-$color-%'";
  6500. }
  6501. if ($lowe) {
  6502. $where .= " and features like '%-$lowe-%'";
  6503. }
  6504. if ($label) {
  6505. $where .= " and label = '$label'";
  6506. }
  6507. if ($state || $state == 0) {
  6508. $where .= " and state = '$state'";
  6509. }
  6510. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6511. //数据排序
  6512. $order_str = "enter desc";
  6513. if (empty($page)) {
  6514. $start = 0;
  6515. $perpage = 1;
  6516. } else {
  6517. $start = ($page - 1) * $perpage;
  6518. }
  6519. //取得信息列表
  6520. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6521. foreach ($info_list as $key => $value) {
  6522. $warehouse = $this->warehouse->read($value['warehouse']);
  6523. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6524. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6525. if ($value['state'] == 0) {
  6526. $info_list[$key]['state'] = "在库";
  6527. } else if ($value['state'] == 1) {
  6528. $info_list[$key]['state'] = "出库";
  6529. } else if ($value['state'] == 2) {
  6530. $info_list[$key]['state'] = "退库";
  6531. } else if ($value['state'] == 3) {
  6532. $info_list[$key]['state'] = "调拨中";
  6533. } else if ($value['state'] == 4) {
  6534. $info_list[$key]['state'] = "再加工";
  6535. } else if ($value['state'] == 5) {
  6536. $info_list[$key]['state'] = "维修中";
  6537. } else if ($value['state'] == 6) {
  6538. $info_list[$key]['state'] = "盘亏";
  6539. } else if ($value['state'] == 7) {
  6540. $info_list[$key]['state'] = "更换标签";
  6541. } else if ($value['state'] == 8) {
  6542. $info_list[$key]['state'] = "其它";
  6543. } else if ($value['state'] == 9) {
  6544. $info_list[$key]['state'] = "预设";
  6545. } else if ($value['state'] == 10) {
  6546. $info_list[$key]['state'] = "美店零售";
  6547. }
  6548. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6549. }
  6550. $total = $this->$ck->find_count($where);
  6551. $pagenum = ceil($total / $perpage);
  6552. $over = $total - ($start + $perpage);
  6553. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6554. echo json_encode($rows);
  6555. exit;
  6556. }
  6557. if (isset($post['tmsku'])) {
  6558. $time = time();
  6559. $tmsku = $this->input->post('tmsku', true);
  6560. //$post['shop'] = $this->input->post('shop',true);
  6561. $num = $this->input->post('num', true);
  6562. $rktype = $this->input->post('rktype', true);
  6563. if ($num > 200) {
  6564. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6565. exit;
  6566. }
  6567. if (!$rktype) {
  6568. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6569. }
  6570. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6571. /**
  6572. $wz = array();
  6573. foreach ($rk as $key=>$value)
  6574. {
  6575. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6576. }
  6577. if(count($wz) > 1)
  6578. {
  6579. $wz = array_values($wz);
  6580. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6581. }
  6582. **/
  6583. if (isset($rk[0]['purchase'])) {
  6584. $rk = $rk[0];
  6585. $j = 0;
  6586. $post['purchase'] = $rk['purchase'];
  6587. $post['warehouse'] = $rk['warehouse'];
  6588. $post['retreatwarehouse'] = $rk['warehouse'];
  6589. $post['sku'] = $rk['sku'];
  6590. $post['number'] = $rk['number'];
  6591. $post['features'] = $rk['features'];
  6592. $post['title'] = $rk['title'];
  6593. $post['enter'] = $time;
  6594. $post['time'] = $time;
  6595. $post['bs'] = 1;
  6596. $post['shop'] = $rk['shop'];
  6597. $post['details'] = $rk['details'];
  6598. $post['cpid'] = $rk['cpid'];
  6599. $post['cpbz'] = $rk['cpbz'];
  6600. $post['rktype'] = $rktype;
  6601. $warehouse = $this->warehouse->read($rk['warehouse']);
  6602. if ($warehouse['bdck'] == '') {
  6603. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6604. exit;
  6605. } else {
  6606. $bdck = $warehouse['bdck'];
  6607. }
  6608. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6609. if (isset($pdwz['details'])) {
  6610. if ($pdwz['details'] != $post['details']) {
  6611. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6612. }else{
  6613. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6614. exit;
  6615. }
  6616. }
  6617. }
  6618. $post['featurespp'] = $rk['featurespp'];
  6619. if ($post['warehouse'] == '5') {
  6620. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6621. if ($yza) {
  6622. if ($post['features'] != $yza[0]['features']) {
  6623. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6624. exit;
  6625. }
  6626. }
  6627. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6628. if ($yzb) {
  6629. if ($post['sku'] != $yzb[0]['sku']) {
  6630. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6631. exit;
  6632. }
  6633. }
  6634. }
  6635. for ($i = 0; $i < $num; $i++) {
  6636. $post['label'] = time() . rand(100, 999) . $i;
  6637. if ($this->$bdck->insert($post)) {
  6638. $j++;
  6639. }
  6640. }
  6641. /**
  6642. if($post['warehouse'] != 12)
  6643. {
  6644. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6645. }
  6646. **/
  6647. $this->whlabelscanlog->insert([
  6648. 'shop'=>$rk['shop'],
  6649. 'type'=>1,
  6650. 'purchase'=>$rk['purchase'],
  6651. 'sku'=>$rk['sku'],
  6652. 'features'=>$rk['features'],
  6653. 'title'=>$rk['title'],
  6654. 'label'=>$rk['label'],
  6655. 'warehouse'=>$rk['warehouse'],
  6656. 'wlid'=>$rk['id'],
  6657. 'num'=>$num,
  6658. 'addtime'=>time()
  6659. ]);
  6660. if ($j == $num) {
  6661. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6662. exit;
  6663. } else {
  6664. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6665. exit;
  6666. }
  6667. } else {
  6668. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6669. exit;
  6670. }
  6671. }
  6672. $this->_Template('whlabel_printrk', $this->data);
  6673. }
  6674. public function _printxzrk($arg_array)
  6675. {
  6676. $post = $this->input->post(NULL, TRUE);
  6677. if (isset($post['wzid'])) {
  6678. $time = time();
  6679. $id = $this->input->post('wzid', true);
  6680. //$post['shop'] = $this->input->post('shop',true);
  6681. $num = 1;
  6682. $rk = $this->whlabellabel->read($id);
  6683. if (isset($rk['purchase'])) {
  6684. $x = 0;
  6685. $post['purchase'] = $rk['purchase'];
  6686. $post['warehouse'] = $rk['warehouse'];
  6687. $post['retreatwarehouse'] = $rk['warehouse'];
  6688. $post['sku'] = $rk['sku'];
  6689. $post['number'] = $rk['number'];
  6690. $post['features'] = $rk['features'];
  6691. $post['title'] = $rk['title'];
  6692. $post['enter'] = $time;
  6693. $post['time'] = $time;
  6694. $post['bs'] = 1;
  6695. $post['shop'] = $rk['shop'];
  6696. $post['details'] = $rk['details'];
  6697. $post['cpid'] = $rk['cpid'];
  6698. $post['cpbz'] = $rk['cpbz'];
  6699. $warehouse = $this->warehouse->read($rk['warehouse']);
  6700. if ($warehouse['bdck'] == '') {
  6701. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6702. exit;
  6703. } else {
  6704. $bdck = $warehouse['bdck'];
  6705. }
  6706. $post['featurespp'] = $rk['featurespp'];
  6707. $this->db->trans_begin();
  6708. for ($i = 0; $i < $num; $i++) {
  6709. $post['label'] = time() . rand(100, 999) . $i;
  6710. $this->$bdck->insert($post);
  6711. }
  6712. /**
  6713. if($post['warehouse'] != 12)
  6714. {
  6715. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6716. }
  6717. **/
  6718. if ($this->db->trans_status() === TRUE) {
  6719. $this->db->trans_commit();
  6720. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6721. exit;
  6722. } else {
  6723. $this->db->trans_rollback();
  6724. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6725. exit;
  6726. }
  6727. } else {
  6728. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6729. exit;
  6730. }
  6731. }
  6732. }
  6733. public function _printck($arg_array)
  6734. {
  6735. $prc = array();
  6736. $purchase = $this->purchase->find_all();
  6737. foreach ($purchase as $k => $v) {
  6738. $prc[$v['id']] = $v['title'];
  6739. }
  6740. $post = $this->input->post(NULL, TRUE);
  6741. if (isset($post['page'])) {
  6742. $page = $this->input->post('page', true);
  6743. $perpage = $this->input->post('perpage', true);
  6744. $sku = $this->input->post('sku', true);
  6745. $bs = $this->input->post('bs', true);
  6746. $number = $this->input->post('number', true);
  6747. $warehouse = $this->input->post('warehouse', true);
  6748. $purchase = $this->input->post('purchase', true);
  6749. $orderinfo = $this->input->post('orderinfo', true);
  6750. $waybill = $this->input->post('waybill', true);
  6751. $category = $this->input->post('category', true);
  6752. $size = $this->input->post('size', true);
  6753. $grade = $this->input->post('grade', true);
  6754. $color = $this->input->post('color', true);
  6755. $lowe = $this->input->post('lowe', true);
  6756. $state = $this->input->post('state', true);
  6757. $label = $this->input->post('label', true);
  6758. $timetk = $this->input->post('ktime', true);
  6759. $timetj = $this->input->post('jtime', true);
  6760. $timetk = strtotime($timetk);
  6761. $timetj = strtotime($timetj);
  6762. $where = "state=1 ";
  6763. if ($timetk && $timetj) {
  6764. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6765. }
  6766. if ($sku) {
  6767. $where .= " and sku = '$sku'";
  6768. }
  6769. if ($bs != '') {
  6770. $where .= " and bs = '$bs'";
  6771. }
  6772. if ($number) {
  6773. $where .= " and number = '$number'";
  6774. }
  6775. if ($warehouse) {
  6776. $where .= " and warehouse = '$warehouse'";
  6777. }
  6778. if ($purchase) {
  6779. $where .= " and purchase = '$purchase'";
  6780. }
  6781. if ($orderinfo) {
  6782. $where .= " and orderinfo = '$orderinfo'";
  6783. }
  6784. if ($waybill) {
  6785. $where .= " and waybill = '$waybill'";
  6786. }
  6787. if ($category) {
  6788. $where .= " and features like '%-$category-%'";
  6789. }
  6790. if ($size) {
  6791. $where .= " and features like '%-$size-%'";
  6792. }
  6793. if ($grade) {
  6794. $where .= " and features like '%-$grade-%'";
  6795. }
  6796. if ($color) {
  6797. $where .= " and features like '%-$color-%'";
  6798. }
  6799. if ($lowe) {
  6800. $where .= " and features like '%-$lowe-%'";
  6801. }
  6802. if ($label) {
  6803. $where .= " and label = '$label'";
  6804. }
  6805. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6806. //数据排序
  6807. $order_str = "outk desc";
  6808. if (empty($page)) {
  6809. $start = 0;
  6810. $perpage = 1;
  6811. } else {
  6812. $start = ($page - 1) * $perpage;
  6813. }
  6814. //取得信息列表
  6815. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6816. foreach ($info_list as $key => $value) {
  6817. $warehouse = $this->warehouse->read($value['warehouse']);
  6818. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6820. if ($value['state'] == 0) {
  6821. $info_list[$key]['state'] = "在库";
  6822. } else if ($value['state'] == 1) {
  6823. $info_list[$key]['state'] = "出库";
  6824. } else if ($value['state'] == 2) {
  6825. $info_list[$key]['state'] = "退库";
  6826. } else if ($value['state'] == 3) {
  6827. $info_list[$key]['state'] = "调拨中";
  6828. } else if ($value['state'] == 4) {
  6829. $info_list[$key]['state'] = "再加工";
  6830. } else if ($value['state'] == 5) {
  6831. $info_list[$key]['state'] = "维修中";
  6832. } else if ($value['state'] == 6) {
  6833. $info_list[$key]['state'] = "盘亏";
  6834. } else if ($value['state'] == 7) {
  6835. $info_list[$key]['state'] = "更换标签";
  6836. } else if ($value['state'] == 8) {
  6837. $info_list[$key]['state'] = "其它";
  6838. } else if ($value['state'] == 9) {
  6839. $info_list[$key]['state'] = "预设";
  6840. } else if ($value['state'] == 10) {
  6841. $info_list[$key]['state'] = "美店零售";
  6842. }
  6843. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6844. }
  6845. $total = $this->$ck->find_count($where);
  6846. $pagenum = ceil($total / $perpage);
  6847. $over = $total - ($start + $perpage);
  6848. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6849. echo json_encode($rows);
  6850. exit;
  6851. }
  6852. if (isset($post['tmsku'])) {
  6853. $time = time();
  6854. $tmsku = $this->input->post('tmsku', true);
  6855. //$post['shop'] = $this->input->post('shop',true);
  6856. $num = $this->input->post('num', true);
  6857. $cktype = $this->input->post('cktype', true);
  6858. $label = $this->whlabellabel->get_label($tmsku);
  6859. if (!$cktype) {
  6860. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6861. }
  6862. if (!isset($label['warehouse'])) {
  6863. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6864. exit;
  6865. }
  6866. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6867. $extra_where = "";
  6868. if(!empty($label['details'])){
  6869. $extra_where .= " and details = '" . $label['details'] . "'";
  6870. }
  6871. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6872. if (stripos($label['features'], '-126-') !== false) {
  6873. $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);
  6874. } else {
  6875. $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);
  6876. }
  6877. $j = 0;
  6878. if (count($ck) >= $num) {
  6879. for ($i = 0; $i < $num; $i++) {
  6880. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6881. {
  6882. $j++;
  6883. }
  6884. }
  6885. $this->whlabelscanlog->insert([
  6886. 'shop'=>$label['shop'],
  6887. 'type'=>2,
  6888. 'purchase'=>$label['purchase'],
  6889. 'sku'=>$label['sku'],
  6890. 'features'=>$label['features'],
  6891. 'title'=>$label['title'],
  6892. 'label'=>$label['label'],
  6893. 'warehouse'=>$label['warehouse'],
  6894. 'wlid'=>$label['id'],
  6895. 'num'=>$num,
  6896. 'addtime'=>time()
  6897. ]);
  6898. if ($j == $num) {
  6899. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6900. exit;
  6901. } else {
  6902. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6903. exit;
  6904. }
  6905. } else {
  6906. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6907. exit;
  6908. }
  6909. }
  6910. if(isset($_SESSION['api']))
  6911. {
  6912. $user = $this->user->get_api($_SESSION['api']);
  6913. if(in_array($user['power'],[1,27])){
  6914. $vip = 1;
  6915. }
  6916. }
  6917. else
  6918. {
  6919. $vip = 0;
  6920. header('Location: /');exit;
  6921. }
  6922. $this->data['vip'] = $vip;
  6923. $this->_Template('whlabel_printck', $this->data);
  6924. }
  6925. public function _printexcel()
  6926. {
  6927. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  6928. $config['upload_path'] = '.' . $dir;
  6929. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  6930. $config['allowed_types'] = 'xls|xlsx|csv';
  6931. $config['max_size'] = 10240;
  6932. $this->load->library('upload', $config);
  6933. $this->upload->initialize($config);
  6934. if ($this->upload->do_upload('userfile')) {
  6935. $full_path = $dir . $this->upload->data('file_name');
  6936. $fileName = '.' . $full_path;
  6937. if (!file_exists($fileName)) {
  6938. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  6939. exit;
  6940. } else {
  6941. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  6942. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  6943. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  6944. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  6945. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  6946. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  6947. ++$column; //如果列数大于26行
  6948. $list = array();
  6949. for ($i = 2; $i <= $row; $i++) // 行数循环
  6950. {
  6951. $data = array();
  6952. for ($c = 'A'; $c != $column; $c++) // 列数循环
  6953. {
  6954. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  6955. }
  6956. $list[] = $data;
  6957. }
  6958. }
  6959. $ed = array();
  6960. $i = 0;
  6961. $j = 0;
  6962. $dcdata = array();
  6963. $yc = '';
  6964. $cmf_arr = array_column($list, '1');
  6965. array_multisort($cmf_arr, SORT_ASC, $list);
  6966. foreach ($list as $key => $value) {
  6967. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  6968. if ($typeclass) {
  6969. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  6970. } else {
  6971. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  6972. $i++;
  6973. continue;
  6974. }
  6975. }
  6976. if ($i > 0) {
  6977. $yc = $i . '条异常';
  6978. }
  6979. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  6980. exit;
  6981. }
  6982. }
  6983. public function _uck()
  6984. {
  6985. if (isset($_GET['excel'])) {
  6986. $tc = array();
  6987. $typeclass = $this->typeclass->find_all();
  6988. foreach ($typeclass as $v) {
  6989. $tc[$v['id']] = $v['zh'];
  6990. }
  6991. $data = array();
  6992. $t = array();
  6993. $rq = '';
  6994. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  6995. $ts = $ts / (24 * 3600);
  6996. for ($i = 0; $i < $ts; $i++) {
  6997. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  6998. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  6999. }
  7000. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7001. foreach ($info_list as $k => $v) {
  7002. $features = explode('-', trim($v['features'], '-'));
  7003. if (!isset($features[3]) || !isset($features[4])) {
  7004. continue;
  7005. }
  7006. $data[$k][0] = $tc[$features[0]]; //类型
  7007. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7008. $data[$k][2] = $tc[$features[4]]; //曲度
  7009. $data[$k][3] = '';
  7010. if (isset($data[$k][1])) {
  7011. $data[$k][3] .= $data[$k][1];
  7012. }
  7013. if (isset($data[$k][2])) {
  7014. $data[$k][3] .= $data[$k][2];
  7015. }
  7016. if (isset($features[5])) {
  7017. $data[$k][3] .= $tc[$features[5]];
  7018. }
  7019. if (isset($features[2])) {
  7020. $data[$k][3] .= $tc[$features[2]];
  7021. }
  7022. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7023. $data[$k][4] = $v['sku'];
  7024. $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())) . '))'); //月初库存
  7025. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7026. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7027. $ztrq = '';
  7028. $ztsl = '';
  7029. if (count($zt) > 0) {
  7030. foreach ($zt as $vv) {
  7031. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7032. $ztsl .= $vv['num'] . '<br>';
  7033. }
  7034. }
  7035. $data[$k][] = trim($ztsl, '<br>');
  7036. $data[$k][] = trim($ztrq, '<br>');
  7037. $byck = 0;
  7038. foreach ($t as $vv) {
  7039. $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));
  7040. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7041. $byck += $sl;
  7042. }
  7043. $data[$k][] = ($byck > 0) ? $byck : '';
  7044. }
  7045. $title = "详情 " . date("Y-m-d", time());
  7046. $titlename = "<table border=1>
  7047. <tr align='center'>
  7048. <td>类别</td>
  7049. <td>颜色</td>
  7050. <td>曲度</td>
  7051. <td>名称</td>
  7052. <td>SKU</td>
  7053. <td>月初库存</td>
  7054. <td>剩余库存</td>
  7055. <td>在途数量</td>
  7056. <td>预达日期</td>" .
  7057. $rq
  7058. . "<td>本月出库</td></tr>
  7059. </table>";
  7060. $filename = $title . ".xls";
  7061. $tail = "";
  7062. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7063. }
  7064. }
  7065. //梦体发现 用数字粘贴 会出现遗产给的数据
  7066. public function _whlabelexcelzh_ztsh()
  7067. {
  7068. if (isset($_GET['excel'])) {
  7069. $where = "sku != 'Preset'";
  7070. //数据排序
  7071. $order_str = "id desc";
  7072. if (empty($page)) {
  7073. $start = 0;
  7074. $perpage = 1;
  7075. } else {
  7076. $start = ($page - 1) * $perpage;
  7077. }
  7078. $category = $this->input->get('category', true);
  7079. $warehouse = $this->input->get('warehouse', true);
  7080. $excelid = $this->input->get('sid', true);
  7081. if ($category) {
  7082. $where .= " and features like '%-$category-%'";
  7083. }
  7084. if ($warehouse) {
  7085. $where .= " and warehouse = '$warehouse'";
  7086. }
  7087. $xzid = '';
  7088. if ($excelid) {
  7089. $excelid = explode(',', trim($excelid, ','));
  7090. foreach ($excelid as $key => $value) {
  7091. $xzid .= " id = " . $value . " or";
  7092. }
  7093. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7094. }
  7095. //取得信息列表
  7096. /**
  7097. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7098. $rows = array();$list = array();
  7099. foreach ($info_list as $key=>$value)
  7100. {
  7101. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7102. }
  7103. **/
  7104. $list = array();
  7105. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7106. foreach ($rows as $key => $value) {
  7107. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7108. $zh = '';
  7109. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7110. foreach ($zt as $v) {
  7111. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7112. }
  7113. $zt = array_sum(array_column($zt, 'num'));
  7114. $number = $value['number'];
  7115. $ftime = time() - 15 * 24 * 3600;
  7116. $warehouse = $this->warehouse->read($value['warehouse']);
  7117. $rows[$key]['warehouse'] = $warehouse['title'];
  7118. $rows[$key]['number'] = $c;
  7119. $rows[$key]['features'] = $zh;
  7120. $rows[$key]['hb'] = $c + $zt;
  7121. }
  7122. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7123. $titlename = "<table border=1>
  7124. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7125. <tr align='center'>
  7126. <td>仓库</td>
  7127. <td>SKU</td>
  7128. <td>产品</td>
  7129. <td>库存数量</td>
  7130. <td>在途数量及预达日期</td>
  7131. <td>在途+库存数量</td>
  7132. </tr>
  7133. </table>";
  7134. $filename = $title . ".xls";
  7135. $tail = "";
  7136. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7137. }
  7138. if (isset($_GET['excel'])) {
  7139. $warehouse = $this->input->get('warehouse', true);
  7140. $sku = $this->input->get('sku', true);
  7141. $cz = $this->input->get('cz', true);
  7142. $text = $this->input->post('text', true);
  7143. $xztime = $this->input->get('xztime', true);
  7144. $timetk = $this->input->get('timetk', true);
  7145. $timetj = $this->input->get('timetj', true);
  7146. $timetk = strtotime($timetk);
  7147. $timetj = strtotime($timetj);
  7148. $where = "time = '0' ";
  7149. if ($warehouse) {
  7150. $where .= " and warehouse = '$warehouse'";
  7151. }
  7152. if ($sku) {
  7153. $where .= " and sku = '$sku'";
  7154. }
  7155. if ($text) {
  7156. $where .= " and text like '%$text%'";
  7157. }
  7158. if ($cz != '') {
  7159. $where .= " and cz = '$cz'";
  7160. }
  7161. if ($timetk && $timetj) {
  7162. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7163. }
  7164. //数据排序
  7165. $order_str = $xztime . " desc";
  7166. //取得信息列表
  7167. $zh = array();
  7168. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7169. foreach ($info_list as $v) {
  7170. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7171. $warehouse = $this->warehouse->read($v['warehouse']);
  7172. $v['warehouse'] = $warehouse['title'];
  7173. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7174. $v['stime'] = date('Y-m-d', $v['stime']);
  7175. if (isset($zh[$v['features']])) {
  7176. $zh[$v['features']]['num'] += $v['num'];
  7177. } else {
  7178. $zh[$v['features']] = $v;
  7179. }
  7180. $zh[$v['features']]['features'] = $c;
  7181. }
  7182. $title = "在途数据" . date('Y-m-d', time());
  7183. $titlename = "<table border=1>
  7184. <tr align='center'>
  7185. <td>仓库</td>
  7186. <td>SKU</td>
  7187. <td>名称</td>
  7188. <td>在途数量</td>
  7189. <td>库存数量</td>
  7190. <td>添加在途日期</td>
  7191. <td>预达日期</td>
  7192. <td>备注</td>
  7193. </tr>
  7194. </table>";
  7195. $filename = $title . ".xls";
  7196. $tail = "";
  7197. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7198. }
  7199. }
  7200. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7201. public function _whlabelexcelzh()
  7202. {
  7203. $excelxml = function ($info_list, $headers, $numkeys, $filename) {
  7204. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7205. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7206. $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";
  7207. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7208. $str .= '<Table>' . "\n";
  7209. $str .= '<Row>' . "\n";
  7210. foreach ($headers as $h) {
  7211. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7212. }
  7213. $str .= '</Row>' . "\n";
  7214. foreach ($info_list as $row) {
  7215. $str .= '<Row>' . "\n";
  7216. foreach ($row as $ke => $va) {
  7217. $va = (string)$va;
  7218. $va = str_replace('<br>', "\n", $va);
  7219. if ($va === '') {
  7220. $str .= '<Cell><Data ss:Type="String"></Data></Cell>' . "\n";
  7221. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7222. $str .= '<Cell><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7223. } else {
  7224. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7225. }
  7226. }
  7227. $str .= '</Row>' . "\n";
  7228. }
  7229. $str .= '</Table>' . "\n";
  7230. $str .= '</Worksheet>' . "\n";
  7231. $str .= '</Workbook>' . "\n";
  7232. while (ob_get_level()) {
  7233. ob_end_clean();
  7234. }
  7235. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7236. header("Content-Disposition: attachment; filename=" . $filename);
  7237. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7238. header("Pragma: no-cache");
  7239. header("Expires: 0");
  7240. echo $str;
  7241. exit();
  7242. };
  7243. if (isset($_GET['excel'])) {
  7244. $where = "sku != 'Preset'";
  7245. //数据排序
  7246. $order_str = "id desc";
  7247. if (empty($page)) {
  7248. $start = 0;
  7249. $perpage = 1;
  7250. } else {
  7251. $start = ($page - 1) * $perpage;
  7252. }
  7253. $category = $this->input->get('category', true);
  7254. $warehouse = $this->input->get('warehouse', true);
  7255. $excelid = $this->input->get('sid', true);
  7256. if ($category) {
  7257. $where .= " and features like '%-$category-%'";
  7258. }
  7259. if ($warehouse) {
  7260. $where .= " and warehouse = '$warehouse'";
  7261. }
  7262. $xzid = '';
  7263. if ($excelid) {
  7264. $excelid = explode(',', trim($excelid, ','));
  7265. foreach ($excelid as $key => $value) {
  7266. $xzid .= " id = " . $value . " or";
  7267. }
  7268. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7269. }
  7270. $list = array();
  7271. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7272. foreach ($rows as $key => $value) {
  7273. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7274. $zh = '';
  7275. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7276. foreach ($zt as $v) {
  7277. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7278. }
  7279. $zt = array_sum(array_column($zt, 'num'));
  7280. $number = $value['number'];
  7281. $ftime = time() - 15 * 24 * 3600;
  7282. $warehouse = $this->warehouse->read($value['warehouse']);
  7283. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7284. $rows[$key] = array(
  7285. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7286. 'sku' => $value['sku'],
  7287. 'title' => isset($value['title']) ? $value['title'] : '',
  7288. 'number' => $c,
  7289. 'features' => $zh,
  7290. 'hb' => $c + $zt,
  7291. );
  7292. }
  7293. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7294. $filename = $title . ".xls";
  7295. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7296. $numkeys = array('number', 'hb');
  7297. $excelxml($rows, $headers, $numkeys, $filename);
  7298. }
  7299. if (isset($_GET['excel'])) {
  7300. $warehouse = $this->input->get('warehouse', true);
  7301. $sku = $this->input->get('sku', true);
  7302. $cz = $this->input->get('cz', true);
  7303. $text = $this->input->post('text', true);
  7304. $xztime = $this->input->get('xztime', true);
  7305. $timetk = $this->input->get('timetk', true);
  7306. $timetj = $this->input->get('timetj', true);
  7307. $timetk = strtotime($timetk);
  7308. $timetj = strtotime($timetj);
  7309. $where = "time = '0' ";
  7310. if ($warehouse) {
  7311. $where .= " and warehouse = '$warehouse'";
  7312. }
  7313. if ($sku) {
  7314. $where .= " and sku = '$sku'";
  7315. }
  7316. if ($text) {
  7317. $where .= " and text like '%$text%'";
  7318. }
  7319. if ($cz != '') {
  7320. $where .= " and cz = '$cz'";
  7321. }
  7322. if ($timetk && $timetj) {
  7323. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7324. }
  7325. //数据排序
  7326. $order_str = $xztime . " desc";
  7327. //取得信息列表
  7328. $zh = array();
  7329. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7330. foreach ($info_list as $v) {
  7331. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7332. $warehouse = $this->warehouse->read($v['warehouse']);
  7333. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7334. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7335. $v['stime'] = date('Y-m-d', $v['stime']);
  7336. if (isset($zh[$v['features']])) {
  7337. $zh[$v['features']]['num'] += $v['num'];
  7338. } else {
  7339. $zh[$v['features']] = $v;
  7340. }
  7341. $zh[$v['features']]['features'] = $c;
  7342. }
  7343. $title = "在途数据" . date('Y-m-d', time());
  7344. $filename = $title . ".xls";
  7345. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7346. $numkeys = array('num', 'features');
  7347. $excelxml($zh, $headers, $numkeys, $filename);
  7348. }
  7349. }
  7350. public function _fc()
  7351. {
  7352. $vip = 0;
  7353. if (isset($_SESSION['api'])) {
  7354. $user = $this->user->get_api($_SESSION['api']);
  7355. if ($user['vip'] == 1) {
  7356. $vip = 1;
  7357. }
  7358. } else {
  7359. header('Location: /');
  7360. exit;
  7361. }
  7362. $post = $this->input->post(NULL, TRUE);
  7363. if (isset($post['page'])) {
  7364. $page = $this->input->post('page', true);
  7365. $perpage = $this->input->post('perpage', true);
  7366. $category = $this->input->post('category', true);
  7367. $size = $this->input->post('size', true);
  7368. $grade = $this->input->post('grade', true);
  7369. $color = $this->input->post('color', true);
  7370. $lowe = $this->input->post('lowe', true);
  7371. $sku = $this->input->post('sku');
  7372. $title = $this->input->post('title');
  7373. $warehouse = $this->input->post('warehouse', true);
  7374. $usa = $this->input->post('usa', true);
  7375. $purchase = $this->input->post('purchase', true);
  7376. $lacetype = $this->input->post('lacetype', true);
  7377. $haircap = $this->input->post('haircap', true);
  7378. $density = $this->input->post('density', true);
  7379. $details = $this->input->post('details', true);
  7380. $state = $this->input->post('state', true);
  7381. $ktime = $this->input->post('ktime', true);
  7382. $jtime = $this->input->post('jtime', true);
  7383. $ktime = strtotime($ktime);
  7384. $jtime = strtotime($jtime);
  7385. $where = "state = '11'";
  7386. $gj = "";
  7387. $ck = "";
  7388. if ($lacetype) {
  7389. $where .= " and features like '%-$lacetype-%'";
  7390. }
  7391. if ($category) {
  7392. $where .= " and features like '%-$category-%'";
  7393. }
  7394. if ($size) {
  7395. $where .= " and features like '%-$size-%'";
  7396. }
  7397. if ($grade) {
  7398. $where .= " and features like '%-$grade-%'";
  7399. }
  7400. if ($color) {
  7401. $where .= " and features like '%-$color-%'";
  7402. }
  7403. if ($lowe) {
  7404. $where .= " and features like '%-$lowe-%'";
  7405. }
  7406. if ($haircap) {
  7407. $where .= " and features like '%-$haircap-%'";
  7408. }
  7409. if ($density) {
  7410. $where .= " and features like '%-$density-%'";
  7411. }
  7412. if ($usa) {
  7413. if (!$warehouse) {
  7414. $where .= " and (warehouse = '5' or warehouse = '8')";
  7415. }
  7416. }
  7417. if ($warehouse) {
  7418. $where .= " and warehouse = '$warehouse'";
  7419. }
  7420. if ($details) {
  7421. $where .= " and details = '$details'";
  7422. }
  7423. if ($purchase) {
  7424. $where .= " and purchase = '$purchase'";
  7425. }
  7426. if ($state) {
  7427. $where .= " and state = '$state'";
  7428. }
  7429. if ($ktime && $jtime) {
  7430. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7431. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7432. }
  7433. //数据排序
  7434. $order_str = "id desc";
  7435. if (empty($page)) {
  7436. $start = 0;
  7437. $perpage = 1;
  7438. } else {
  7439. $start = ($page - 1) * $perpage;
  7440. }
  7441. if ($sku) {
  7442. $sku = trim($sku, ' ');
  7443. $sku = trim($sku, ' ');
  7444. $where .= " and sku like '%$sku%'";
  7445. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7446. } else if ($title) {
  7447. $title = trim($title, ' ');
  7448. $title = trim($title, ' ');
  7449. $where .= " and title like '%$title%'";
  7450. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7451. } else {
  7452. //$where .= " and time > '$ktime' and time < '$jtime'";
  7453. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7454. }
  7455. //取得信息列表
  7456. $rows = array();
  7457. $list = array();
  7458. foreach ($info_list as $key => $value) {
  7459. $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'] . '"');
  7460. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7461. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7462. $warehouse = $this->warehouse->read($value['warehouse']);
  7463. $info_list[$key]['warehouse'] = $warehouse['title'];
  7464. $info_list[$key]['number'] = $g;
  7465. $info_list[$key]['features'] = $x;
  7466. $info_list[$key]['x'] = $s;
  7467. }
  7468. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7469. $pagenum = ceil($total / $perpage);
  7470. $over = $total - ($start + $perpage);
  7471. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7472. echo json_encode($rows);
  7473. exit;
  7474. }
  7475. $this->data['vip'] = $vip;
  7476. $this->_Template('whlabel_fc', $this->data);
  7477. }
  7478. public function _fcmb()
  7479. {
  7480. $where = "sku != 'Preset'";
  7481. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7482. foreach ($rows as $k => $v) {
  7483. $warehouse = $this->warehouse->read($v['warehouse']);
  7484. $rows[$k]['warehouse'] = $warehouse['title'];
  7485. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7486. $rows[$k]['t'] = '';
  7487. $rows[$k]['n'] = '';
  7488. }
  7489. $title = "封货产品数据导入模板";
  7490. $titlename = "<table border=1>
  7491. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7492. <tr align='center'>
  7493. <td>仓库</td>
  7494. <td>SKU</td>
  7495. <td>产品</td>
  7496. <td>封存产品总数量</td>
  7497. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7498. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7499. </tr>
  7500. </table>";
  7501. $filename = $title . ".xls";
  7502. $tail = "";
  7503. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7504. }
  7505. public function _fcexcel()
  7506. {
  7507. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7508. $config['upload_path'] = '.' . $dir;
  7509. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7510. $config['allowed_types'] = 'xls|xlsx|csv';
  7511. $config['max_size'] = 10240;
  7512. $this->load->library('upload', $config);
  7513. $this->upload->initialize($config);
  7514. if ($this->upload->do_upload('userfile')) {
  7515. $full_path = $dir . $this->upload->data('file_name');
  7516. $fileName = '.' . $full_path;
  7517. if (!file_exists($fileName)) {
  7518. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7519. exit;
  7520. } else {
  7521. libxml_use_internal_errors(true);
  7522. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7523. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7524. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7525. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7526. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7527. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7528. ++$column; //如果列数大于26行
  7529. $list = array();
  7530. for ($i = 2; $i <= $row; $i++) // 行数循环
  7531. {
  7532. $data = array();
  7533. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7534. {
  7535. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7536. }
  7537. $list[] = $data;
  7538. }
  7539. }
  7540. $i = 0;
  7541. $j = 0;
  7542. $ed = array();
  7543. foreach ($list as $key => $value) {
  7544. $time = time();
  7545. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7546. continue;
  7547. }
  7548. $warehouse = $this->warehouse->get_title($value['0']);
  7549. $sku = $value['1'];
  7550. $type = $value['4']; //调整方式0扣减1删除
  7551. $num = $value['5']; //调整数量
  7552. //$text = $value['4'];//扣减说明
  7553. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7554. if (!$d) //如果没有这个SKU
  7555. {
  7556. $ed[] = array($sku . '-库存中不存在此SKU');
  7557. $j++;
  7558. continue;
  7559. }
  7560. if (!isset($warehouse['id'])) {
  7561. $ed[] = array($sku . '-仓库名错误!');
  7562. $j++;
  7563. continue;
  7564. }
  7565. if ($type == 1 || $type == 2) //扣减库存
  7566. {
  7567. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7568. if (count($data) < abs($num)) {
  7569. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7570. $j++;
  7571. continue;
  7572. }
  7573. if ($type == 1) //转入库存
  7574. {
  7575. for ($i = 0; $i < abs($num); $i++) {
  7576. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7577. }
  7578. } else if ($type == 2) //删除
  7579. {
  7580. for ($i = 0; $i < abs($num); $i++) {
  7581. $this->whlabel->remove($data[$i]['id']);
  7582. }
  7583. }
  7584. } else if ($type == 0) //增加库存
  7585. {
  7586. $post['sku'] = $d['sku'];
  7587. $post['shop'] = '';
  7588. $post['warehouse'] = $warehouse['id'];
  7589. $post['purchase'] = $d['purchase'];
  7590. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7591. $post['state'] = 11;
  7592. $post['title'] = $d['title'];
  7593. $post['number'] = $d['number'];
  7594. $post['features'] = $d['features'];
  7595. $post['enter'] = $time;
  7596. $post['time'] = $time; //操作时间
  7597. for ($i = 0; $i < $num; $i++) {
  7598. $post['label'] = time() . rand(100, 999) . $i;
  7599. $this->whlabel->insert($post);
  7600. }
  7601. }
  7602. sleep(1); //防止入库时间一样,需要延迟1秒
  7603. }
  7604. if ($j > 0) {
  7605. $tt = date('Ymd', time());
  7606. $title = '库存导入错误信息-' . $tt;
  7607. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7608. $tail = "\n";
  7609. $filename = $title . ".xls";
  7610. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7611. $dir = '/data/excel/' . $time . '/';
  7612. $file_name = 'error_' . $time . rand(1000, 9999);
  7613. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7614. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7615. fwrite($myfile, $ecl);
  7616. fclose($myfile);
  7617. $error = $dir . $file_name . '.xls';
  7618. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7619. exit;
  7620. } else {
  7621. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7622. exit;
  7623. }
  7624. }
  7625. }
  7626. public function _fcjxc($arg_array)
  7627. {
  7628. if (isset($_GET['excel'])) {
  7629. $category = $this->input->get('category', true);
  7630. $size = $this->input->get('size', true);
  7631. $grade = $this->input->get('grade', true);
  7632. $color = $this->input->get('color', true);
  7633. $lowe = $this->input->get('lowe', true);
  7634. $sku = $this->input->get('sku');
  7635. $title = $this->input->get('title');
  7636. $warehouse = $arg_array[0];
  7637. $usa = $this->input->get('usa', true);
  7638. $purchase = $this->input->get('purchase', true);
  7639. $lacetype = $this->input->get('lacetype', true);
  7640. $haircap = $this->input->get('haircap', true);
  7641. $density = $this->input->get('density', true);
  7642. $title = $this->input->get('title', true);
  7643. $state = $this->input->get('state', true);
  7644. $ktime = $this->input->get('ktime', true);
  7645. $jtime = $this->input->get('jtime', true);
  7646. $where = "state=11";
  7647. $gj = "";
  7648. $ck = "";
  7649. if ($lacetype) {
  7650. $where .= " and features like '%-$lacetype-%'";
  7651. }
  7652. if ($category) {
  7653. $where .= " and features like '%-$category-%'";
  7654. }
  7655. if ($size) {
  7656. $where .= " and features like '%-$size-%'";
  7657. }
  7658. if ($grade) {
  7659. $where .= " and features like '%-$grade-%'";
  7660. }
  7661. if ($color) {
  7662. $where .= " and features like '%-$color-%'";
  7663. }
  7664. if ($lowe) {
  7665. $where .= " and features like '%-$lowe-%'";
  7666. }
  7667. if ($haircap) {
  7668. $where .= " and features like '%-$haircap-%'";
  7669. }
  7670. if ($density) {
  7671. $where .= " and features like '%-$density-%'";
  7672. }
  7673. if ($usa) {
  7674. if (!$warehouse) {
  7675. $where .= " and (warehouse = '5' or warehouse = '8')";
  7676. }
  7677. }
  7678. if ($warehouse) {
  7679. $where .= " and warehouse = '$warehouse'";
  7680. }
  7681. if ($purchase) {
  7682. $where .= " and purchase = '$purchase'";
  7683. }
  7684. if ($state) {
  7685. $where .= " and state = '$state'";
  7686. }
  7687. $order_str = "id desc";
  7688. if ($sku) {
  7689. $sku = trim($sku, ' ');
  7690. $sku = trim($sku, ' ');
  7691. $where .= " and sku like '%$sku%'";
  7692. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7693. } else if ($title) {
  7694. $title = trim($title, ' ');
  7695. $title = trim($title, ' ');
  7696. $where .= " and title like '%$title%'";
  7697. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7698. } else {
  7699. //$where .= " and time > '$ktime' and time < '$jtime'";
  7700. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7701. }
  7702. //取得信息列表
  7703. $rows = array();
  7704. $list = array();
  7705. foreach ($info_list as $key => $value) {
  7706. $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'] . '"');
  7707. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7708. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7709. $rows[$key] = $value;
  7710. $warehouse = $this->warehouse->read($value['warehouse']);
  7711. $rows[$key]['warehouse'] = $warehouse['title'];
  7712. $rows[$key]['features'] = $g;
  7713. $rows[$key]['a'] = $x;
  7714. $rows[$key]['b'] = $s;
  7715. }
  7716. $title = "总统计表";
  7717. $titlename = "<table border=1>
  7718. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7719. <tr align='center'>
  7720. <td>仓库</td>
  7721. <td>SKU</td>
  7722. <td>产品名称</td>
  7723. <td>录入总量</td>
  7724. <td>取出总量</td>
  7725. <td>剩余总量</td>
  7726. </tr>
  7727. </table>";
  7728. $filename = $title . ".xls";
  7729. $tail = "";
  7730. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7731. }
  7732. $vip = 0;
  7733. if (isset($_SESSION['api'])) {
  7734. $user = $this->user->get_api($_SESSION['api']);
  7735. if ($user['vip'] == 1) {
  7736. $vip = 1;
  7737. }
  7738. } else {
  7739. header('Location: /');
  7740. exit;
  7741. }
  7742. $post = $this->input->post(NULL, TRUE);
  7743. if (isset($post['page'])) {
  7744. $page = $this->input->post('page', true);
  7745. $perpage = $this->input->post('perpage', true);
  7746. $category = $this->input->post('category', true);
  7747. $size = $this->input->post('size', true);
  7748. $grade = $this->input->post('grade', true);
  7749. $color = $this->input->post('color', true);
  7750. $lowe = $this->input->post('lowe', true);
  7751. $sku = $this->input->post('sku');
  7752. $title = $this->input->post('title');
  7753. $warehouse = $arg_array[0];
  7754. $usa = $this->input->post('usa', true);
  7755. $purchase = $this->input->post('purchase', true);
  7756. $lacetype = $this->input->post('lacetype', true);
  7757. $haircap = $this->input->post('haircap', true);
  7758. $density = $this->input->post('density', true);
  7759. $title = $this->input->post('title', true);
  7760. $state = $this->input->post('state', true);
  7761. $ktime = $this->input->post('ktime', true);
  7762. $jtime = $this->input->post('jtime', true);
  7763. $ktime = strtotime($ktime);
  7764. $jtime = strtotime($jtime);
  7765. $where = "state=11";
  7766. $gj = "";
  7767. $ck = "";
  7768. if ($lacetype) {
  7769. $where .= " and features like '%-$lacetype-%'";
  7770. }
  7771. if ($category) {
  7772. $where .= " and features like '%-$category-%'";
  7773. }
  7774. if ($size) {
  7775. $where .= " and features like '%-$size-%'";
  7776. }
  7777. if ($grade) {
  7778. $where .= " and features like '%-$grade-%'";
  7779. }
  7780. if ($color) {
  7781. $where .= " and features like '%-$color-%'";
  7782. }
  7783. if ($lowe) {
  7784. $where .= " and features like '%-$lowe-%'";
  7785. }
  7786. if ($haircap) {
  7787. $where .= " and features like '%-$haircap-%'";
  7788. }
  7789. if ($density) {
  7790. $where .= " and features like '%-$density-%'";
  7791. }
  7792. if ($usa) {
  7793. if (!$warehouse) {
  7794. $where .= " and (warehouse = '5' or warehouse = '8')";
  7795. }
  7796. }
  7797. if ($warehouse) {
  7798. $where .= " and warehouse = '$warehouse'";
  7799. }
  7800. if ($purchase) {
  7801. $where .= " and purchase = '$purchase'";
  7802. }
  7803. if ($state) {
  7804. $where .= " and state = '$state'";
  7805. }
  7806. if ($ktime && $jtime) {
  7807. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7808. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7809. }
  7810. //数据排序
  7811. $order_str = "id desc";
  7812. $xs = 0;
  7813. $rows = array();
  7814. $list = array();
  7815. if (empty($page)) {
  7816. $start = 0;
  7817. $perpage = 1;
  7818. } else {
  7819. $start = ($page - 1) * $perpage;
  7820. }
  7821. if ($sku || $title) {
  7822. if ($title) {
  7823. $title = trim($title, ' ');
  7824. $title = trim($title, ' ');
  7825. $where .= " and title like '%$title%'";
  7826. } else {
  7827. $sku = trim($sku, ' ');
  7828. $sku = trim($sku, ' ');
  7829. $where .= " and sku like '%$sku%'";
  7830. }
  7831. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7832. foreach ($info_list as $key => $value) {
  7833. $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'] . '"');
  7834. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7835. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7836. $rows[$key] = $value;
  7837. $warehouse = $this->warehouse->read($value['warehouse']);
  7838. $rows[$key]['warehouse'] = $warehouse['title'];
  7839. $rows[$key]['features'] = $g;
  7840. $rows[$key]['a'] = $x;
  7841. $rows[$key]['b'] = $s;
  7842. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7843. $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天销量
  7844. $yj = $c / ($xl / 30);
  7845. if ($yj < 7) {
  7846. $rows[$key]['y'] = round($yj) . '天销量';
  7847. } else {
  7848. $rows[$key]['y'] = '正常';
  7849. }
  7850. }
  7851. } else {
  7852. //$where .= " and time > '$ktime' and time < '$jtime'";
  7853. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7854. foreach ($info_list as $key => $value) {
  7855. $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'] . '"');
  7856. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7857. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7858. $zs[$key] = $value;
  7859. $warehouse = $this->warehouse->read($value['warehouse']);
  7860. $zs[$key]['warehouse'] = $warehouse['title'];
  7861. $zs[$key]['features'] = $g;
  7862. $zs[$key]['a'] = $x;
  7863. $zs[$key]['b'] = $s;
  7864. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7865. $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天销量
  7866. $yj = $c / ($xl / 30);
  7867. if ($yj < 7) {
  7868. $zs[$key]['y'] = round($yj) . '天销量';
  7869. $rows[$key] = $zs[$key];
  7870. }
  7871. }
  7872. }
  7873. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7874. $pagenum = ceil($total / $perpage);
  7875. $over = $total - ($start + $perpage);
  7876. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7877. echo json_encode($rows);
  7878. exit;
  7879. }
  7880. $this->data['arg_array'] = $arg_array[0];
  7881. $this->_Template('whlabel_fcjxc', $this->data);
  7882. }
  7883. public function _0kcdel()
  7884. {
  7885. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7886. $config['upload_path'] = '.' . $dir;
  7887. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7888. $config['allowed_types'] = 'xls|xlsx|csv';
  7889. $config['max_size'] = 10240;
  7890. $this->load->library('upload', $config);
  7891. $this->upload->initialize($config);
  7892. if ($this->upload->do_upload('userfile')) {
  7893. $full_path = $dir . $this->upload->data('file_name');
  7894. $fileName = '.' . $full_path;
  7895. if (!file_exists($fileName)) {
  7896. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7897. exit;
  7898. } else {
  7899. require_once "./data/excel/PHPExcel/IOFactory.php";
  7900. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7901. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7902. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7903. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7904. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7905. ++$column; //如果列数大于26行
  7906. $list = array();
  7907. for ($i = 2; $i <= $row; $i++) // 行数循环
  7908. {
  7909. $data = array();
  7910. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7911. {
  7912. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7913. }
  7914. $list[] = $data;
  7915. }
  7916. }
  7917. $i = 0;
  7918. $j = 0;
  7919. $ed = array();
  7920. foreach ($list as $key => $value) {
  7921. $time = time();
  7922. if ($value['0'] == "" || $value['1'] == "") {
  7923. continue;
  7924. }
  7925. $warehouse = $this->warehouse->get_title($value['0']);
  7926. $sku = $value['1'];
  7927. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7928. if (!$d) //如果没有这个SKU
  7929. {
  7930. $ed[] = array($sku . '-库存中不存在此SKU');
  7931. $j++;
  7932. continue;
  7933. }
  7934. if (!isset($warehouse['id'])) {
  7935. $ed[] = array($sku . '-仓库名错误!');
  7936. $j++;
  7937. continue;
  7938. }
  7939. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  7940. if ($z < 1) {
  7941. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  7942. foreach ($z as $v) {
  7943. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  7944. if (count($zt) > 0) {
  7945. $ed[] = array($sku . '-有在途库存无法删除!');
  7946. $j++;
  7947. continue;
  7948. }
  7949. $this->whlabel->remove($v['id']);
  7950. }
  7951. } else {
  7952. $ed[] = array($sku . '-非0库存!');
  7953. $j++;
  7954. continue;
  7955. }
  7956. }
  7957. if ($j > 0) {
  7958. $tt = date('Ymd', time());
  7959. $title = '删除0库存错误信息-' . $tt;
  7960. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7961. $tail = "\n";
  7962. $filename = $title . ".xls";
  7963. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7964. $dir = '/data/excel/' . $time . '/';
  7965. $file_name = 'error_' . $time . rand(1000, 9999);
  7966. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7967. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7968. fwrite($myfile, $ecl);
  7969. fclose($myfile);
  7970. $error = $dir . $file_name . '.xls';
  7971. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7972. exit;
  7973. } else {
  7974. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7975. exit;
  7976. }
  7977. }
  7978. }
  7979. public function _gbhtype()
  7980. {
  7981. $post = $this->input->post(NULL, TRUE);
  7982. if (isset($post['s'])) {
  7983. $n = $this->input->post('n');
  7984. $d = $this->input->post('s');
  7985. if (!$d) {
  7986. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  7987. exit;
  7988. }
  7989. $d = explode(',', trim($d, ','));
  7990. $t = $this->whlabel_type->read($n);
  7991. //循环删除记录
  7992. foreach ($d as $v) {
  7993. $u = $this->whlabel->read($v);
  7994. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  7995. foreach ($data as $val) {
  7996. $this->whlabel->save(array('type' => $n), $val['id']);
  7997. }
  7998. }
  7999. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8000. }
  8001. }
  8002. //出库、退库导出
  8003. public function _dccrtype()
  8004. {
  8005. $classid = $this->classid->sku();
  8006. $pm = $classid;
  8007. $typeclass = array();
  8008. $tc = $this->typeclass->find_all();
  8009. foreach ($tc as $v) {
  8010. $typeclass[$v['id']] = $v;
  8011. }
  8012. $prc = array();
  8013. $purchase = $this->purchase->find_all();
  8014. foreach ($purchase as $k => $v) {
  8015. $prc[$v['id']] = $v['title'];
  8016. }
  8017. if (isset($_GET['sid'])) {
  8018. $wh = array();
  8019. $w = $this->warehouse->find_all('1=1', 'id,title');
  8020. foreach ($w as $v) {
  8021. $wh[$v['id']] = $v['title'];
  8022. }
  8023. $type = $this->input->get('excel', true);
  8024. $category = $this->input->get('category', true);
  8025. $size = $this->input->get('size', true);
  8026. $grade = $this->input->get('grade', true);
  8027. $color = $this->input->get('color', true);
  8028. $lowe = $this->input->get('lowe', true);
  8029. $sku = $this->input->get('sku', true);
  8030. $warehouse = $this->input->get('warehouse', true);
  8031. $lacetype = $this->input->get('lacetype', true);
  8032. $lacecolor = $this->input->get('lacecolor', true);
  8033. $density = $this->input->get('density', true);
  8034. $haircap = $this->input->get('haircap', true);
  8035. $purchase = $this->input->get('purchase', true);
  8036. $title = $this->input->get('title', true);
  8037. $state = $this->input->get('state', true);
  8038. $sid = $this->input->get('sid', true);
  8039. $ktime = $this->input->get('ktime', true);
  8040. $jtime = $this->input->get('jtime', true);
  8041. $ktime = strtotime($ktime);
  8042. $jtime = strtotime($jtime);
  8043. $where = "1=1";
  8044. $gj = "";
  8045. $ck = "";
  8046. if ($category) {
  8047. $where .= " and features like '%-$category-%'";
  8048. }
  8049. if ($size) {
  8050. $where .= " and features like '%-$size-%'";
  8051. }
  8052. if ($grade) {
  8053. $where .= " and features like '%-$grade-%'";
  8054. }
  8055. if ($color) {
  8056. $where .= " and features like '%-$color-%'";
  8057. }
  8058. if ($lowe) {
  8059. $where .= " and features like '%-$lowe-%'";
  8060. }
  8061. if ($warehouse) {
  8062. $where .= " and warehouse = '$warehouse'";
  8063. }
  8064. if ($purchase) {
  8065. $where .= " and purchase = '$purchase'";
  8066. }
  8067. if ($state) {
  8068. $where .= " and state = '$state'";
  8069. }
  8070. if ($lacetype) {
  8071. $where .= " and features like '%-$lacetype-%'";
  8072. }
  8073. if ($lacecolor) {
  8074. $where .= " and features like '%-$lacecolor-%'";
  8075. }
  8076. if ($density) {
  8077. $where .= " and features like '%-$density-%'";
  8078. }
  8079. if ($haircap) {
  8080. $where .= " and features like '%-$haircap-%'";
  8081. }
  8082. if ($title) {
  8083. $title = trim($title, ' ');
  8084. $title = trim($title, ' ');
  8085. $where .= " and title like '%$title%'";
  8086. }
  8087. if ($sku) {
  8088. $sku = trim($sku, ' ');
  8089. $sku = trim($sku, ' ');
  8090. $where .= " and sku like '%$sku%'";
  8091. }
  8092. if ($ktime && $jtime) {
  8093. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8094. }
  8095. $sidwhere = '';
  8096. if ($sid) {
  8097. $sd = "";
  8098. $s = explode(',', trim($sid, ','));
  8099. foreach ($s as $value) {
  8100. $sd .= " id = " . $value . " or";
  8101. }
  8102. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8103. }
  8104. //数据排序
  8105. $order_str = "time desc";
  8106. if (empty($page)) {
  8107. $start = 0;
  8108. $perpage = 1;
  8109. } else {
  8110. $start = ($page - 1) * $perpage;
  8111. }
  8112. $wh = array();
  8113. $w = $this->warehouse->find_all('1=1', 'id,title');
  8114. foreach ($w as $v) {
  8115. $wh[$v['id']] = $v['title'];
  8116. }
  8117. $wt = array();
  8118. $whlabel_type = $this->whlabel_type->find_all();
  8119. foreach ($whlabel_type as $v) {
  8120. $wt[$v['id']] = $v['title'];
  8121. }
  8122. $classid = $this->classid->sku();
  8123. $list = array();
  8124. $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');
  8125. foreach ($rows_r as $key => $value) {
  8126. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8127. $pm = $classid;
  8128. $jm = $classid;
  8129. $rows_r[$key]['enter'] = '入库';
  8130. $rows_r[$key]['time'] = $value['enter'];
  8131. if ($value['rktype'] == 1) {
  8132. $rows_r[$key]['rktype'] = '采购入库';
  8133. } else if ($value['rktype'] == 2) {
  8134. $rows_r[$key]['rktype'] = '盘盈调整';
  8135. } else if ($value['rktype'] == 3) {
  8136. $rows_r[$key]['rktype'] = '其他调整入库';
  8137. } else if ($value['rktype'] == 4) {
  8138. $rows_r[$key]['rktype'] = '其他调整入库';
  8139. } else if ($value['rktype'] == 5) {
  8140. $rows_r[$key]['rktype'] = '退库入库';
  8141. } else if ($value['rktype'] == 6) {
  8142. $rows_r[$key]['rktype'] = '退货可用入库';
  8143. } else if ($value['rktype'] == 7) {
  8144. $rows_r[$key]['rktype'] = '形态转换入库';
  8145. } else {
  8146. $rows_r[$key]['rktype'] = '';
  8147. }
  8148. $features = explode('-', trim($value['features'], '-'));
  8149. foreach ($features as $v) {
  8150. if (isset($typeclass[$v])) {
  8151. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8152. $pm[$typeclass[$v]['classid']] = $zh[0];
  8153. }
  8154. if (isset($typeclass[$v])) {
  8155. if (isset($jm[$typeclass[$v]['classid']])) {
  8156. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8157. }
  8158. }
  8159. }
  8160. $zh = implode(" ", $pm);
  8161. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8162. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8163. $rows_r[$key]['zh'] = $zh;
  8164. $jm = array_filter($jm);
  8165. $rows_r[$key]['features'] = implode("-", $jm);
  8166. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8167. }
  8168. $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');
  8169. foreach ($rows_c as $key => $value) {
  8170. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8171. $pm = $classid;
  8172. $jm = $classid;
  8173. $rows_c[$key]['time'] = $value['outk'];
  8174. $rows_c[$key]['outk'] = '出库';
  8175. if ($value['cktype'] == 1) {
  8176. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8177. } else if ($value['cktype'] == 2) {
  8178. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8179. } else if ($value['cktype'] == 3) {
  8180. $rows_c[$key]['cktype'] = '盘亏调整';
  8181. } else if ($value['cktype'] == 4) {
  8182. $rows_c[$key]['cktype'] = '其他调整出库';
  8183. } else if ($value['cktype'] == 5) {
  8184. $rows_c[$key]['cktype'] = '形态转换出库';
  8185. } else {
  8186. $rows_c[$key]['cktype'] = '';
  8187. }
  8188. unset($rows_c[$key]['state']);
  8189. $features = explode('-', trim($value['features'], '-'));
  8190. foreach ($features as $v) {
  8191. if (isset($typeclass[$v])) {
  8192. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8193. $pm[$typeclass[$v]['classid']] = $zh[0];
  8194. }
  8195. if (isset($typeclass[$v])) {
  8196. if (isset($jm[$typeclass[$v]['classid']])) {
  8197. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8198. }
  8199. }
  8200. }
  8201. $zh = implode(" ", $pm);
  8202. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8203. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8204. $rows_c[$key]['zh'] = $zh;
  8205. $jm = array_filter($jm);
  8206. $rows_c[$key]['features'] = implode("-", $jm);
  8207. $rows_c[$key]['number'] = 1;
  8208. }
  8209. $merged = $rows_r;
  8210. foreach ($rows_c as $key => $value) {
  8211. if (isset($merged[$key])) {
  8212. $merged[] = $value;
  8213. } else {
  8214. $merged[$key] = $value;
  8215. }
  8216. }
  8217. usort($merged, function ($a, $b) {
  8218. return $a['time'] - $b['time'];
  8219. });
  8220. foreach ($merged as $key => $value) {
  8221. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8222. }
  8223. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8224. $titlename = "<table border=1>
  8225. <tr align='center'>
  8226. <td>仓库</td>
  8227. <td>SKU</td>
  8228. <td>商品名称</td>
  8229. <td>仓库品名</td>
  8230. <td>料号</td>
  8231. <td>时间</td>
  8232. <td>操作</td>
  8233. <td>类型</td>
  8234. <td>数量</td>
  8235. <td>备注</td>
  8236. </tr>
  8237. </table>";
  8238. $filename = $title . ".xlsx";
  8239. $tail = "";
  8240. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8241. }
  8242. }
  8243. /*************************************处理exceljs导出****************************************************/
  8244. public function _excelrjs(){
  8245. if (isset($_GET['excel'])) {
  8246. $category = $this->input->get('category', true);
  8247. $size = $this->input->get('size', true);
  8248. $grade = $this->input->get('grade', true);
  8249. $color = $this->input->get('color', true);
  8250. $lowe = $this->input->get('lowe', true);
  8251. $sku = $this->input->get('sku', true);
  8252. $warehouse = $this->input->get('warehouse', true);
  8253. $purchase = $this->input->get('purchase', true);
  8254. $ktime = $this->input->get('ktime', true);
  8255. $jtime = $this->input->get('jtime', true);
  8256. $ktime = strtotime($ktime);
  8257. $jtime = strtotime($jtime);
  8258. $where = "1=1";
  8259. $gj = "";
  8260. $ck = "";
  8261. if ($category) {
  8262. $where .= " and features like '%-$category-%'";
  8263. }
  8264. if ($size) {
  8265. $where .= " and features like '%-$size-%'";
  8266. }
  8267. if ($grade) {
  8268. $where .= " and features like '%-$grade-%'";
  8269. }
  8270. if ($color) {
  8271. $where .= " and features like '%-$color-%'";
  8272. }
  8273. if ($lowe) {
  8274. $where .= " and features like '%-$lowe-%'";
  8275. }
  8276. if ($warehouse) {
  8277. $where .= " and warehouse = '$warehouse'";
  8278. }
  8279. if ($purchase) {
  8280. $where .= " and purchase = '$purchase'";
  8281. }
  8282. if ($sku) {
  8283. $where .= " and sku = '$sku'";
  8284. }
  8285. if ($ktime && $jtime) {
  8286. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8287. }
  8288. //数据排序
  8289. $order_str = "id desc";
  8290. if (empty($page)) {
  8291. $start = 0;
  8292. $perpage = 1;
  8293. } else {
  8294. $start = ($page - 1) * $perpage;
  8295. }
  8296. $list = array();
  8297. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8298. foreach ($rows as $value) {
  8299. $ck = $this->warehouse->read($value['warehouse']);
  8300. $warehouse = $ck['title'];
  8301. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8302. $retreatwarehouse = $tkck['title'];
  8303. $gy = $this->purchase->read($value['purchase']);
  8304. $purchase = $gy['title'];
  8305. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8306. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8307. }
  8308. if(empty($list)){
  8309. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8310. }else{
  8311. $final_list = [];
  8312. foreach($list as $v){
  8313. $final_list[] = array_values($v);
  8314. }
  8315. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8316. array_unshift($final_list,[
  8317. "仓库","SKU","商品名称","时间","数量"
  8318. ]);
  8319. array_unshift($final_list,[
  8320. $title,"","","",""
  8321. ]);
  8322. $merges = [
  8323. [
  8324. "s"=>["r"=>0,"c"=>0],
  8325. "e"=>["r"=>0,"c"=>4]
  8326. ]
  8327. ];
  8328. $cols = [
  8329. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8330. ];
  8331. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8332. }
  8333. }
  8334. }
  8335. //出库、退库导出
  8336. public function _excelctjs()
  8337. {
  8338. $classid = $this->classid->sku();
  8339. $pm = $classid;
  8340. $typeclass = array();
  8341. $tc = $this->typeclass->find_all();
  8342. foreach ($tc as $v) {
  8343. $typeclass[$v['id']] = $v;
  8344. }
  8345. $prc = array();
  8346. $purchase = $this->purchase->find_all();
  8347. foreach ($purchase as $k => $v) {
  8348. $prc[$v['id']] = $v['title'];
  8349. }
  8350. if (isset($_GET['excel'])) {
  8351. $wh = array();
  8352. $w = $this->warehouse->find_all('1=1', 'id,title');
  8353. foreach ($w as $v) {
  8354. $wh[$v['id']] = $v['title'];
  8355. }
  8356. $type = $this->input->get('excel', true);
  8357. $category = $this->input->get('category', true);
  8358. $size = $this->input->get('size', true);
  8359. $grade = $this->input->get('grade', true);
  8360. $color = $this->input->get('color', true);
  8361. $lowe = $this->input->get('lowe', true);
  8362. $sku = $this->input->get('sku', true);
  8363. $title = $this->input->get('title', true);
  8364. $warehouse = $this->input->get('warehouse', true);
  8365. $purchase = $this->input->get('purchase', true);
  8366. $lacetype = $this->input->get('lacetype', true);
  8367. $haircap = $this->input->get('haircap', true);
  8368. $lacecolor = $this->input->get('lacecolor', true);
  8369. $density = $this->input->get('density', true);
  8370. $details = $this->input->get('details', true);
  8371. $state = $this->input->get('state', true);
  8372. $shop = $this->input->get('shop', true);
  8373. $hairnumber = $this->input->get('hairnumber', true);
  8374. $type_leixi = $this->input->get('type', true);
  8375. $cpbz = $this->input->get('cpbz', true);
  8376. $sm = $this->input->get('sm', true);
  8377. $sid = $this->input->get('sid', true);
  8378. $ktime = $this->input->get('ktime', true);
  8379. $jtime = $this->input->get('jtime', true);
  8380. $ktime = strtotime($ktime);
  8381. $jtime = strtotime($jtime);
  8382. //$where = " 1=1 ";
  8383. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8384. $where = " sku != '' ";
  8385. $gj = "";
  8386. $ck = "";
  8387. if ($category) {
  8388. $where .= " and features like '%-$category-%'";
  8389. }
  8390. if ($size) {
  8391. $where .= " and features like '%-$size-%'";
  8392. }
  8393. if ($grade) {
  8394. $where .= " and features like '%-$grade-%'";
  8395. }
  8396. if ($color) {
  8397. $where .= " and features like '%-$color-%'";
  8398. }
  8399. if ($lowe) {
  8400. $where .= " and features like '%-$lowe-%'";
  8401. }
  8402. if ($warehouse) {
  8403. $where .= " and warehouse = '$warehouse'";
  8404. }
  8405. if ($purchase) {
  8406. $where .= " and purchase = '$purchase'";
  8407. }
  8408. if ($state) {
  8409. $where .= " and state = '$state'";
  8410. }
  8411. if ($lacetype) {
  8412. $where .= " and features like '%-$lacetype-%'";
  8413. }
  8414. if ($lacecolor) {
  8415. $where .= " and features like '%-$lacecolor-%'";
  8416. }
  8417. if ($density) {
  8418. $where .= " and features like '%-$density-%'";
  8419. }
  8420. if ($haircap) {
  8421. $where .= " and features like '%-$haircap-%'";
  8422. }
  8423. if ($details) {
  8424. $where .= " and details = '$details'";
  8425. }
  8426. if ($shop) {
  8427. $where .= " and shop like '%$shop%'";
  8428. }
  8429. if ($title) {
  8430. $title = trim($title, ' ');
  8431. $title = trim($title, ' ');
  8432. $where .= " and title like '%$title%'";
  8433. }
  8434. if (!empty($hairnumber)) {
  8435. $where .= " and features like '%-128-%' ";
  8436. if ($hairnumber < 0) {
  8437. $class_list = $this->typeclass->find_all('classid = 43');
  8438. foreach ($class_list as $v) {
  8439. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8440. }
  8441. } else {
  8442. $where .= " and features like '%-$hairnumber-%'";
  8443. }
  8444. }
  8445. if ($type_leixi) {
  8446. $where .= " and type = '$type_leixi'";
  8447. }
  8448. if ($cpbz) {
  8449. $where .= " and cpbz like '%$cpbz%' ";
  8450. }
  8451. if ($sm) {
  8452. $where .= " and sm like '%$sm%' ";
  8453. }
  8454. if ($sku) {
  8455. $sku = trim($sku, ' ');
  8456. $sku = trim($sku, ' ');
  8457. $where .= " and sku like '%$sku%'";
  8458. }
  8459. if ($ktime && $jtime) {
  8460. if ($type == 1) {
  8461. $tl = '出库';
  8462. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8463. } else if ($type == 2) {
  8464. $tl = '退库';
  8465. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8466. } else if ($type == 3) {
  8467. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8468. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8469. } else if ($type == 4) {
  8470. $tl = '出库+零售';
  8471. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8472. } else if ($type == 5) {
  8473. $tl = '零售';
  8474. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8475. }
  8476. }
  8477. $sidwhere = '';
  8478. if ($sid) {
  8479. $sd = "";
  8480. $s = explode(',', trim($sid, ','));
  8481. foreach ($s as $value) {
  8482. $sd .= " id = " . $value . " or";
  8483. }
  8484. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8485. }
  8486. //数据排序
  8487. $order_str = "time desc";
  8488. if (empty($page)) {
  8489. $start = 0;
  8490. $perpage = 1;
  8491. } else {
  8492. $start = ($page - 1) * $perpage;
  8493. }
  8494. //取得信息列表
  8495. if ($type != 3 && $type != 5) {
  8496. if ($type == 1 || $type == 4) {
  8497. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8498. foreach ($info_list as $key => $value) {
  8499. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8500. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8501. $warehouse = $this->warehouse->read($value['warehouse']);
  8502. $info_list[$key]['warehouse'] = $warehouse['title'];
  8503. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8504. $features = explode('-', trim($features, '-'));
  8505. $pm = $classid;
  8506. foreach ($features as $k => $v) {
  8507. if ($v != 0) {
  8508. if (!isset($typeclass[$v])) {
  8509. continue;
  8510. }
  8511. if (isset($pm[$typeclass[$v]['classid']])) {
  8512. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8513. $tz = explode('|', $typeclass[$v]['zh']);
  8514. $pm[$typeclass[$v]['classid']] = $tz[0];
  8515. } else {
  8516. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8517. }
  8518. }
  8519. }
  8520. }
  8521. $zh = implode(" ", $pm);
  8522. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8523. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8524. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8525. $info_list[$key]['features'] = $zh;
  8526. }
  8527. $final_list = [];
  8528. foreach($info_list as $k=>$v){
  8529. $number = "";
  8530. if(!empty($v['orderinfo'])){
  8531. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8532. if(!empty($tmp_info['number'])){
  8533. $number = $tmp_info['number'];
  8534. }
  8535. }
  8536. $final_list[] = [
  8537. 'warehouse'=>$v['warehouse'],
  8538. 'purchase'=>$v['purchase'],
  8539. 'sku'=>$v['sku'],
  8540. 'title'=>$v['title'],
  8541. 'features'=>$v['features'],
  8542. 'label'=>$v['label'],
  8543. 'orderinfo'=>$v['orderinfo'],
  8544. 'number'=>$number,
  8545. 'waybill'=>$v['waybill'],
  8546. 'outk'=>$v['outk'],
  8547. ];
  8548. }
  8549. } else {
  8550. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8551. foreach ($info_list as $key => $value) {
  8552. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8553. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8554. $warehouse = $this->warehouse->read($value['warehouse']);
  8555. $info_list[$key]['warehouse'] = $warehouse['title'];
  8556. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8557. $features = explode('-', trim($features, '-'));
  8558. $pm = $classid;
  8559. foreach ($features as $k => $v) {
  8560. if ($v != 0) {
  8561. if (!isset($typeclass[$v])) {
  8562. continue;
  8563. }
  8564. if (isset($pm[$typeclass[$v]['classid']])) {
  8565. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8566. $tz = explode('|', $typeclass[$v]['zh']);
  8567. $pm[$typeclass[$v]['classid']] = $tz[0];
  8568. } else {
  8569. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8570. }
  8571. }
  8572. }
  8573. }
  8574. $zh = implode(" ", $pm);
  8575. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8576. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8577. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8578. $info_list[$key]['features'] = $zh;
  8579. }
  8580. $final_list = [];
  8581. foreach($info_list as $k=>$v){
  8582. $number = "";
  8583. if(!empty($v['orderinfo'])){
  8584. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8585. if(!empty($tmp_info['number'])){
  8586. $number = $tmp_info['number'];
  8587. }
  8588. }
  8589. $final_list[] = [
  8590. 'warehouse'=>$v['warehouse'],
  8591. 'purchase'=>$v['purchase'],
  8592. 'sku'=>$v['sku'],
  8593. 'title'=>$v['title'],
  8594. 'features'=>$v['features'],
  8595. 'label'=>$v['label'],
  8596. 'orderinfo'=>$v['orderinfo'],
  8597. 'number'=>$number,
  8598. 'waybill'=>$v['waybill'],
  8599. 'retreat'=>$v['retreat'],
  8600. ];
  8601. }
  8602. }
  8603. if(empty($final_list)){
  8604. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8605. }else{
  8606. $end_list = [];
  8607. foreach($final_list as $v){
  8608. $end_list[] = array_values($v);
  8609. }
  8610. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8611. array_unshift($end_list,[
  8612. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8613. ]);
  8614. array_unshift($end_list,[
  8615. $title,"","","","","","","","",""
  8616. ]);
  8617. $merges = [
  8618. [
  8619. "s"=>["r"=>0,"c"=>0],
  8620. "e"=>["r"=>0,"c"=>9]
  8621. ]
  8622. ];
  8623. $cols = [
  8624. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8625. ];
  8626. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8627. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8628. ] )));
  8629. }
  8630. } else if ($type == 5) {
  8631. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8632. foreach ($info_list as $key => $value) {
  8633. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8634. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8635. $warehouse = $this->warehouse->read($value['warehouse']);
  8636. $info_list[$key]['warehouse'] = $warehouse['title'];
  8637. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8638. $features = explode('-', trim($features, '-'));
  8639. $pm = $classid;
  8640. foreach ($features as $k => $v) {
  8641. if ($v != 0) {
  8642. if (!isset($typeclass[$v])) {
  8643. continue;
  8644. }
  8645. if (isset($pm[$typeclass[$v]['classid']])) {
  8646. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8647. $tz = explode('|', $typeclass[$v]['zh']);
  8648. $pm[$typeclass[$v]['classid']] = $tz[0];
  8649. } else {
  8650. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8651. }
  8652. }
  8653. }
  8654. }
  8655. $zh = implode(" ", $pm);
  8656. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8657. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8658. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8659. $info_list[$key]['features'] = $zh;
  8660. }
  8661. if(empty($info_list)){
  8662. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8663. }else{
  8664. $final_list = [];
  8665. foreach($info_list as $v){
  8666. $final_list[] = array_values($v);
  8667. }
  8668. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8669. array_unshift($final_list,[
  8670. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8671. ]);
  8672. array_unshift($final_list,[
  8673. $title,"","","","","","",
  8674. ]);
  8675. $merges = [
  8676. [
  8677. "s"=>["r"=>0,"c"=>0],
  8678. "e"=>["r"=>0,"c"=>6]
  8679. ]
  8680. ];
  8681. $cols = [
  8682. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8683. ];
  8684. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8685. }
  8686. } else {
  8687. $wh = array();
  8688. $w = $this->warehouse->find_all('1=1', 'id,title');
  8689. foreach ($w as $v) {
  8690. $wh[$v['id']] = $v['title'];
  8691. }
  8692. $wt = array();
  8693. $whlabel_type = $this->whlabel_type->find_all();
  8694. foreach ($whlabel_type as $v) {
  8695. $wt[$v['id']] = $v['title'];
  8696. }
  8697. $classid = $this->classid->sku();
  8698. $list = array();
  8699. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8700. foreach ($rows as $key => $value) {
  8701. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8702. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8703. $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');
  8704. $details = array();
  8705. $cpid = array();
  8706. $cpbz = array();
  8707. $c = 0;
  8708. $g = 0;
  8709. $x = 0;
  8710. $t = 0;
  8711. $s = 0;
  8712. $q = 0;
  8713. foreach ($sd as $k => $v) {
  8714. if ($v['state'] == 0) {
  8715. $c++;
  8716. }
  8717. if ($v['state'] != 9) {
  8718. $g++;
  8719. }
  8720. if ($v['outk'] > 1) {
  8721. $x++;
  8722. }
  8723. if ($v['retreat'] > 0) {
  8724. $t++;
  8725. }
  8726. if ($v['state'] == 8) {
  8727. $s++;
  8728. }
  8729. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8730. $q++;
  8731. }
  8732. $details[$v['details']] = $v['details'];
  8733. if ($v['cpid'] != 0) {
  8734. $cpid[$v['cpid']] = $v['cpid'];
  8735. }
  8736. if ($v['cpbz'] != '') {
  8737. $cpbz[$v['cpbz']] = $v['cpbz'];
  8738. }
  8739. }
  8740. if (isset($wt[$value['type']])) {
  8741. $rows[$key]['type'] = $wt[$value['type']];
  8742. } else {
  8743. $rows[$key]['type'] = '未设置';
  8744. }
  8745. $rows[$key]['details'] = implode("、", $details);
  8746. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8747. $ftime = time() - 15 * 24 * 3600;
  8748. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8749. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8750. $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);
  8751. $rows[$key]['c'] = $c;
  8752. $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);
  8753. $rows[$key]['t'] = $t;
  8754. $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'] . '"');
  8755. $rows[$key]['z'] = $z;
  8756. // $jm = $classid;
  8757. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8758. $features = explode('-', trim($features, '-'));
  8759. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8760. }
  8761. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8762. $final_list =[];
  8763. foreach($tmp_list as $k=>$v){
  8764. $final_list[] = [
  8765. "warehouse"=>$v['warehouse'],
  8766. "purchase"=>$v['purchase'],
  8767. "details"=>$v['details'],
  8768. "cpid"=>$v['cpid'],
  8769. "sku"=>$v['sku'],
  8770. "title"=>$v['title'],
  8771. "features"=>$v['pm'],
  8772. "cpbz"=>$v['cpbz'],
  8773. "sm"=>$v['sm'],
  8774. "type"=>$v['type'],
  8775. "g"=>$v["g"],
  8776. "c"=>$v["c"],
  8777. "x"=>$v["x"],
  8778. "t"=>$v["t"],
  8779. "z"=>$v["z"],
  8780. "jm"=>$v["jm"],
  8781. "weight"=>$v["weight"],
  8782. "asd"=>$v["asd"],
  8783. ];
  8784. }
  8785. if(empty($final_list)){
  8786. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8787. }else{
  8788. $end_list = [];
  8789. foreach($final_list as $v){
  8790. $end_list[] = array_values($v);
  8791. }
  8792. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8793. array_unshift($end_list,[
  8794. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8795. ]);
  8796. array_unshift($end_list,[
  8797. $title,"","","","","","","","","","","","","","","","","",""
  8798. ]);
  8799. $merges = [
  8800. [
  8801. "s"=>["r"=>0,"c"=>0],
  8802. "e"=>["r"=>0,"c"=>6]
  8803. ]
  8804. ];
  8805. $cols = [
  8806. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8807. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8808. ];
  8809. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8810. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8811. ])));
  8812. }
  8813. }
  8814. }
  8815. }
  8816. public function _exceljxcjs(){
  8817. $classid = $this->classid->sku();
  8818. $pm = $classid;
  8819. $typeclass = array();
  8820. $tc = $this->typeclass->find_all();
  8821. foreach ($tc as $v) {
  8822. $typeclass[$v['id']] = $v;
  8823. }
  8824. $prc = array();
  8825. $purchase = $this->purchase->find_all();
  8826. foreach ($purchase as $k => $v) {
  8827. $prc[$v['id']] = $v['title'];
  8828. }
  8829. if(!isset($_GET['excel'])){
  8830. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8831. }
  8832. $where = "sku != 'Preset'";
  8833. //数据排序
  8834. $order_str = "id desc";
  8835. if (empty($page)) {
  8836. $start = 0;
  8837. $perpage = 1;
  8838. } else {
  8839. $start = ($page - 1) * $perpage;
  8840. }
  8841. $category = $this->input->get('category', true);
  8842. $warehouse = $this->input->get('warehouse', true);
  8843. $excelid = $this->input->get('sid', true);
  8844. if ($category) {
  8845. $where .= " and features like '%-$category-%'";
  8846. }
  8847. if ($warehouse) {
  8848. $where .= " and warehouse = '$warehouse'";
  8849. }
  8850. $xzid = '';
  8851. if ($excelid) {
  8852. $excelid = explode(',', trim($excelid, ','));
  8853. foreach ($excelid as $key => $value) {
  8854. $xzid .= " id = " . $value . " or";
  8855. }
  8856. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8857. }
  8858. $wt = array();
  8859. $whlabel_type = $this->whlabel_type->find_all();
  8860. foreach ($whlabel_type as $v) {
  8861. $wt[$v['id']] = $v['title'];
  8862. }
  8863. $wh = array();
  8864. $w = $this->warehouse->find_all('1=1', 'id,title');
  8865. foreach ($w as $v) {
  8866. $wh[$v['id']] = $v['title'];
  8867. }
  8868. $list = array();
  8869. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8870. foreach ($rows as $key => $value) {
  8871. if (isset($wt[$value['type']])) {
  8872. $rows[$key]['type'] = $wt[$value['type']];
  8873. } else {
  8874. $rows[$key]['type'] = '未设置';
  8875. }
  8876. $bm = '03';
  8877. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8878. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8879. $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');
  8880. $details = array();
  8881. $cpid = array();
  8882. $cpbz = array();
  8883. $c = 0;
  8884. $g = 0;
  8885. $x = 0;
  8886. $t = 0;
  8887. $s = 0;
  8888. $q = 0;
  8889. foreach ($sd as $k => $v) {
  8890. if ($v['state'] == 0) {
  8891. $c++;
  8892. if ($v['cpid'] != 0) {
  8893. $cpid[$v['cpid']] = $v['cpid'];
  8894. }
  8895. if ($v['cpbz'] != '') {
  8896. $cpbz[$v['cpbz']] = $v['cpbz'];
  8897. }
  8898. }
  8899. if ($v['state'] != 9) {
  8900. $g++;
  8901. }
  8902. if ($v['state'] == 1) {
  8903. $x++;
  8904. }
  8905. if ($v['state'] == 2) {
  8906. $t++;
  8907. }
  8908. if ($v['state'] == 8) {
  8909. $s++;
  8910. }
  8911. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8912. $q++;
  8913. }
  8914. $details[$v['details']] = $v['details'];
  8915. }
  8916. $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'] . '"');
  8917. $rows[$key]['details'] = implode("、", $details);
  8918. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8919. $number = $value['number'];
  8920. $ftime = time() - 15 * 24 * 3600;
  8921. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  8922. $rows[$key]['number'] = $g;
  8923. $rows[$key]['c'] = $c;
  8924. $rows[$key]['x'] = $x;
  8925. $rows[$key]['t'] = $t;
  8926. $rows[$key]['s'] = $s;
  8927. $rows[$key]['q'] = $q;
  8928. $rows[$key]['z'] = $z;
  8929. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8930. $features = explode('-', trim($features, '-'));
  8931. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  8932. }
  8933. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  8934. $final_list = [];
  8935. foreach ($list as $k => $v) {
  8936. if (empty($v['sku'])) {
  8937. continue;
  8938. }
  8939. $final_list[] = [
  8940. $v["warehouse"],
  8941. $v["purchase"],
  8942. $v["details"],
  8943. $v["cpid"],
  8944. $v["dbcontent"],
  8945. $v["sku"],
  8946. $v["bm"],
  8947. $v["jm"],
  8948. $v["title"],
  8949. $v["pm"],
  8950. $v["cpbz"],
  8951. $v["sm"],
  8952. $v["type"],
  8953. $v["number"],
  8954. $v["c"],
  8955. $v["x"],
  8956. $v["t"],
  8957. $v["s"],
  8958. $v["q"],
  8959. $v["z"],
  8960. $v['weight'],
  8961. ];
  8962. }
  8963. if(empty($final_list)){
  8964. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  8965. }
  8966. $title = "总进销存统计表";
  8967. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  8968. $merges = [
  8969. [
  8970. "s"=>["r"=>0,"c"=>0],
  8971. "e"=>["r"=>0,"c"=>21]
  8972. ]
  8973. ];
  8974. $cols = [
  8975. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  8976. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8977. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8978. ];
  8979. array_unshift($final_list, $first_row);
  8980. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  8981. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  8982. }
  8983. public function _summaryjs($arg_array)
  8984. {
  8985. $prc = array();
  8986. $purchase = $this->purchase->find_all();
  8987. foreach ($purchase as $k => $v) {
  8988. $prc[$v['id']] = $v['title'];
  8989. }
  8990. if (isset($_GET['excel'])) {
  8991. $ktime = $this->input->get('ktime', true);
  8992. $jtime = $this->input->get('jtime', true);
  8993. $ktime = strtotime($ktime);
  8994. $jtime = strtotime($jtime);
  8995. $where = "1=1";
  8996. if ($ktime && $jtime) {
  8997. $where .= " and outk > '$ktime' and outk < '$jtime'";
  8998. }
  8999. //数据排序
  9000. $order_str = "time desc";
  9001. if (empty($page)) {
  9002. $start = 0;
  9003. $perpage = 1;
  9004. } else {
  9005. $start = ($page - 1) * $perpage;
  9006. }
  9007. //取得信息列表
  9008. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9009. foreach ($info_list as $key => $value) {
  9010. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9011. $warehouse = $this->warehouse->read($value['warehouse']);
  9012. $info_list[$key]['warehouse'] = $warehouse['title'];
  9013. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9014. $details = array();
  9015. $cpid = array();
  9016. foreach ($x as $k => $v) {
  9017. if ($v['details'] != '') {
  9018. $details[$v['details']] = $v['details'];
  9019. }
  9020. if ($v['cpid'] != 0) {
  9021. $cpid[$v['cpid']] = $v['cpid'];
  9022. }
  9023. }
  9024. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9025. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9026. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9027. $info_list[$key]['s'] = $s;
  9028. $info_list[$key]['x'] = count($x);
  9029. }
  9030. if(empty($info_list)){
  9031. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9032. }
  9033. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9034. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9035. $merges = [
  9036. [
  9037. "s"=>["r"=>0,"c"=>0],
  9038. "e"=>["r"=>0,"c"=>7]
  9039. ]
  9040. ];
  9041. $cols = [
  9042. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9043. ];
  9044. $final_list = [];
  9045. foreach($info_list as $k => $v){
  9046. $final_list[] = array_values($v);
  9047. }
  9048. array_unshift($final_list, $first_row);
  9049. array_unshift($final_list,[
  9050. $title,"","","","","","","","",
  9051. ]);
  9052. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9053. $titlename = "<table border=1>
  9054. <tr align='center'>
  9055. <td>仓库</td>
  9056. <td>供应商</td>
  9057. <td>出库位置</td>
  9058. <td>出库编码</td>
  9059. <td>SKU</td>
  9060. <td>产品名</td>
  9061. <td>总剩余库存</td>
  9062. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9063. </tr>
  9064. </table>";
  9065. $filename = $title . ".xls";
  9066. $tail = "";
  9067. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9068. }
  9069. }
  9070. public function _uckjs()
  9071. {
  9072. if (isset($_GET['excel'])) {
  9073. $tc = array();
  9074. $typeclass = $this->typeclass->find_all();
  9075. foreach ($typeclass as $v) {
  9076. $tc[$v['id']] = $v['zh'];
  9077. }
  9078. $first_row = [
  9079. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9080. ];
  9081. $t = array();
  9082. $rq = '';
  9083. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9084. $ts = $ts / (24 * 3600);
  9085. for ($i = 0; $i < $ts; $i++) {
  9086. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9087. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9088. }
  9089. $day_len = count($t);
  9090. $first_row[] = "本月出库";
  9091. $merges = [
  9092. ];
  9093. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9094. $excel_key = 1;
  9095. $final_list = [];
  9096. foreach ($info_list as $k => $v) {
  9097. $features = explode('-', trim($v['features'], '-'));
  9098. if (!isset($features[3]) || !isset($features[4])) {
  9099. continue;
  9100. }
  9101. $tmp = [];
  9102. $tmp[0] = $tc[$features[0]]; //类型
  9103. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9104. $tmp[2] = $tc[$features[4]]; //曲度
  9105. $tmp[3] = '';
  9106. if (isset($data[$k][1])) {
  9107. $tmp[3] .=$tmp[1];
  9108. }
  9109. if (isset($data[$k][2])) {
  9110. $tmp[3] .= $tmp[2];
  9111. }
  9112. if (isset($features[5])) {
  9113. $tmp[3] .= $tc[$features[5]];
  9114. }
  9115. if (isset($features[2])) {
  9116. $tmp[3] .= $tc[$features[2]];
  9117. }
  9118. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9119. $tmp[4] = $v['sku'];
  9120. $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())) . '))'); //月初库存
  9121. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9122. $tmp[7] ="";
  9123. $tmp[8] ="";
  9124. $byck = 0;
  9125. foreach ($t as $vv) {
  9126. $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));
  9127. $tmp[] = ($sl > 0) ? $sl : '';
  9128. $byck += $sl;
  9129. }
  9130. $tmp[] = ($byck > 0) ? $byck : '';
  9131. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9132. // $ztrq = '';
  9133. // $ztsl = '';
  9134. // if (count($zt) > 0) {
  9135. // foreach ($zt as $vv) {
  9136. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9137. // $ztsl .= $vv['num'] . '<br>';
  9138. // }
  9139. // }
  9140. if(empty($zt)){
  9141. $final_list[] = $tmp;
  9142. $excel_key = $excel_key + 1;
  9143. }else{
  9144. $len = count($zt);
  9145. if($len == 1){
  9146. $tmp[7] = $zt[0]['num'] ;
  9147. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9148. $final_list[] = $tmp;
  9149. $excel_key = $excel_key + 1;
  9150. }else{
  9151. foreach($zt as $vv){
  9152. $tmp[7] = "";
  9153. $tmp[8] = "";
  9154. $tmp[7] = $vv['num'];
  9155. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9156. $final_list[] = $tmp;
  9157. }
  9158. $merges[] = [
  9159. "s"=>["r"=>$excel_key,"c"=>0],
  9160. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9161. ];
  9162. $merges[] = [
  9163. "s"=>["r"=>$excel_key,"c"=>1],
  9164. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9165. ];
  9166. $merges[] = [
  9167. "s"=>["r"=>$excel_key,"c"=>2],
  9168. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9169. ];
  9170. $merges[] = [
  9171. "s"=>["r"=>$excel_key,"c"=>3],
  9172. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9173. ];
  9174. $merges[] = [
  9175. "s"=>["r"=>$excel_key,"c"=>4],
  9176. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9177. ];
  9178. $merges[] = [
  9179. "s"=>["r"=>$excel_key,"c"=>5],
  9180. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9181. ];
  9182. $merges[] = [
  9183. "s"=>["r"=>$excel_key,"c"=>6],
  9184. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9185. ];
  9186. for($i=1;$i<=$day_len;$i++){
  9187. $merges[] = [
  9188. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9189. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9190. ];
  9191. }
  9192. $merges[] = [
  9193. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9194. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9195. ];
  9196. $excel_key = $excel_key + $len;
  9197. }
  9198. }
  9199. }
  9200. $title = "详情 " . date("Y-m-d", time());
  9201. if(empty($final_list)){
  9202. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9203. }
  9204. $cols = [
  9205. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9206. ];
  9207. array_unshift($final_list, $first_row);
  9208. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9209. }
  9210. }
  9211. public function _whlabelexcelzhjs(){
  9212. if(empty($_GET['excel'])){
  9213. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9214. }
  9215. $where = "sku != 'Preset' and sku != '' ";
  9216. //数据排序
  9217. $order_str = "id desc";
  9218. if (empty($page)) {
  9219. $start = 0;
  9220. $perpage = 1;
  9221. } else {
  9222. $start = ($page - 1) * $perpage;
  9223. }
  9224. $category = $this->input->get('category', true);
  9225. $warehouse = $this->input->get('warehouse', true);
  9226. $excelid = $this->input->get('sid', true);
  9227. if ($category) {
  9228. $where .= " and features like '%-$category-%'";
  9229. }
  9230. if ($warehouse) {
  9231. $where .= " and warehouse = '$warehouse'";
  9232. }
  9233. $xzid = '';
  9234. if ($excelid) {
  9235. $excelid = explode(',', trim($excelid, ','));
  9236. foreach ($excelid as $key => $value) {
  9237. $xzid .= " id = " . $value . " or";
  9238. }
  9239. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9240. }
  9241. $merges = [
  9242. [
  9243. "s"=>["r"=>0,"c"=>0],
  9244. "e"=>["r"=>0,"c"=>6]
  9245. ]
  9246. ];
  9247. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9248. $excel_index = 2;
  9249. $final_list = [];
  9250. foreach ($rows as $key => $value) {
  9251. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9252. $zh = '';
  9253. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9254. // foreach ($zt_list as $v) {
  9255. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9256. // }
  9257. $zt = array_sum(array_column($zt_list, 'num'));
  9258. $number = $value['number'];
  9259. $ftime = time() - 15 * 24 * 3600;
  9260. $warehouse = $this->warehouse->read($value['warehouse']);
  9261. // $rows[$key]['warehouse'] = $warehouse['title'];
  9262. // $rows[$key]['number'] = $c;
  9263. // $rows[$key]['features'] = $zh;
  9264. //$rows[$key]['hb'] = $c + $zt;
  9265. $tmp = [];
  9266. $tmp[0] = $warehouse['title'];
  9267. $tmp[1] = $value['sku'];
  9268. $tmp[2] = $value['title'];
  9269. $tmp[3] = $c;
  9270. $tmp[4] = "";
  9271. $tmp[5] = $c + $zt;
  9272. if(empty($zt_list)){
  9273. $tmp[4] = "";
  9274. $final_list[] = $tmp;
  9275. $excel_index = $excel_index + 1;
  9276. }else{
  9277. if(count($zt_list) == 1){
  9278. $tmp[4] = "";
  9279. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9280. $final_list[] = $tmp;
  9281. $excel_index = $excel_index + 1;
  9282. }else{
  9283. $len = count($zt_list);
  9284. foreach ($zt_list as $v){
  9285. $tmp[4] = "";
  9286. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9287. $final_list[] = $tmp;
  9288. }
  9289. $merges[] = [
  9290. "s"=>["r"=>$excel_index,"c"=>0],
  9291. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9292. ];
  9293. $merges[] = [
  9294. "s"=>["r"=>$excel_index,"c"=>1],
  9295. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9296. ];
  9297. $merges[] = [
  9298. "s"=>["r"=>$excel_index,"c"=>2],
  9299. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9300. ];
  9301. $merges[] = [
  9302. "s"=>["r"=>$excel_index,"c"=>3],
  9303. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9304. ];
  9305. $merges[] = [
  9306. "s"=>["r"=>$excel_index,"c"=>5],
  9307. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9308. ];
  9309. $excel_index = $excel_index + $len;
  9310. }
  9311. }
  9312. }
  9313. $first_row = [
  9314. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9315. ];
  9316. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9317. if(empty($final_list)){
  9318. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9319. }
  9320. $cols = [
  9321. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9322. ];
  9323. array_unshift($final_list, $first_row);
  9324. array_unshift($final_list, [
  9325. $title,"","","","",""
  9326. ]);
  9327. $end_list = [];
  9328. foreach ($final_list as $key => $value) {
  9329. $end_list[] = array_values($value);
  9330. }
  9331. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9332. }
  9333. //出库、退库导出
  9334. public function _dccrtypejs()
  9335. {
  9336. $classid = $this->classid->sku();
  9337. $pm = $classid;
  9338. $typeclass = array();
  9339. $tc = $this->typeclass->find_all();
  9340. foreach ($tc as $v) {
  9341. $typeclass[$v['id']] = $v;
  9342. }
  9343. $prc = array();
  9344. $purchase = $this->purchase->find_all();
  9345. foreach ($purchase as $k => $v) {
  9346. $prc[$v['id']] = $v['title'];
  9347. }
  9348. if (isset($_GET['sid'])) {
  9349. $wh = array();
  9350. $w = $this->warehouse->find_all('1=1', 'id,title');
  9351. foreach ($w as $v) {
  9352. $wh[$v['id']] = $v['title'];
  9353. }
  9354. $type = $this->input->get('excel', true);
  9355. $category = $this->input->get('category', true);
  9356. $size = $this->input->get('size', true);
  9357. $grade = $this->input->get('grade', true);
  9358. $color = $this->input->get('color', true);
  9359. $lowe = $this->input->get('lowe', true);
  9360. $sku = $this->input->get('sku', true);
  9361. $warehouse = $this->input->get('warehouse', true);
  9362. $lacetype = $this->input->get('lacetype', true);
  9363. $lacecolor = $this->input->get('lacecolor', true);
  9364. $density = $this->input->get('density', true);
  9365. $haircap = $this->input->get('haircap', true);
  9366. $purchase = $this->input->get('purchase', true);
  9367. $title = $this->input->get('title', true);
  9368. $state = $this->input->get('state', true);
  9369. $sid = $this->input->get('sid', true);
  9370. $ktime = $this->input->get('ktime', true);
  9371. $jtime = $this->input->get('jtime', true);
  9372. $ktime = strtotime($ktime);
  9373. $jtime = strtotime($jtime);
  9374. $where = "1=1";
  9375. $gj = "";
  9376. $ck = "";
  9377. if ($category) {
  9378. $where .= " and features like '%-$category-%'";
  9379. }
  9380. if ($size) {
  9381. $where .= " and features like '%-$size-%'";
  9382. }
  9383. if ($grade) {
  9384. $where .= " and features like '%-$grade-%'";
  9385. }
  9386. if ($color) {
  9387. $where .= " and features like '%-$color-%'";
  9388. }
  9389. if ($lowe) {
  9390. $where .= " and features like '%-$lowe-%'";
  9391. }
  9392. if ($warehouse) {
  9393. $where .= " and warehouse = '$warehouse'";
  9394. }
  9395. if ($purchase) {
  9396. $where .= " and purchase = '$purchase'";
  9397. }
  9398. if ($state) {
  9399. $where .= " and state = '$state'";
  9400. }
  9401. if ($lacetype) {
  9402. $where .= " and features like '%-$lacetype-%'";
  9403. }
  9404. if ($lacecolor) {
  9405. $where .= " and features like '%-$lacecolor-%'";
  9406. }
  9407. if ($density) {
  9408. $where .= " and features like '%-$density-%'";
  9409. }
  9410. if ($haircap) {
  9411. $where .= " and features like '%-$haircap-%'";
  9412. }
  9413. if ($title) {
  9414. $title = trim($title, ' ');
  9415. $title = trim($title, ' ');
  9416. $where .= " and title like '%$title%'";
  9417. }
  9418. if ($sku) {
  9419. $sku = trim($sku, ' ');
  9420. $sku = trim($sku, ' ');
  9421. $where .= " and sku like '%$sku%'";
  9422. }
  9423. if ($ktime && $jtime) {
  9424. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9425. }
  9426. $sidwhere = '';
  9427. if ($sid) {
  9428. $sd = "";
  9429. $s = explode(',', trim($sid, ','));
  9430. foreach ($s as $value) {
  9431. $sd .= " id = " . $value . " or";
  9432. }
  9433. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9434. }
  9435. //数据排序
  9436. $order_str = "time desc";
  9437. if (empty($page)) {
  9438. $start = 0;
  9439. $perpage = 1;
  9440. } else {
  9441. $start = ($page - 1) * $perpage;
  9442. }
  9443. $wh = array();
  9444. $w = $this->warehouse->find_all('1=1', 'id,title');
  9445. foreach ($w as $v) {
  9446. $wh[$v['id']] = $v['title'];
  9447. }
  9448. $wt = array();
  9449. $whlabel_type = $this->whlabel_type->find_all();
  9450. foreach ($whlabel_type as $v) {
  9451. $wt[$v['id']] = $v['title'];
  9452. }
  9453. $classid = $this->classid->sku();
  9454. $list = array();
  9455. $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');
  9456. foreach ($rows_r as $key => $value) {
  9457. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9458. $pm = $classid;
  9459. $jm = $classid;
  9460. $rows_r[$key]['enter'] = '入库';
  9461. $rows_r[$key]['time'] = $value['enter'];
  9462. if ($value['rktype'] == 1) {
  9463. $rows_r[$key]['rktype'] = '采购入库';
  9464. } else if ($value['rktype'] == 2) {
  9465. $rows_r[$key]['rktype'] = '盘盈调整';
  9466. } else if ($value['rktype'] == 3) {
  9467. $rows_r[$key]['rktype'] = '其他调整入库';
  9468. } else if ($value['rktype'] == 4) {
  9469. $rows_r[$key]['rktype'] = '其他调整入库';
  9470. } else if ($value['rktype'] == 5) {
  9471. $rows_r[$key]['rktype'] = '退库入库';
  9472. } else if ($value['rktype'] == 6) {
  9473. $rows_r[$key]['rktype'] = '退货可用入库';
  9474. } else if ($value['rktype'] == 7) {
  9475. $rows_r[$key]['rktype'] = '形态转换入库';
  9476. } else {
  9477. $rows_r[$key]['rktype'] = '';
  9478. }
  9479. $features = explode('-', trim($value['features'], '-'));
  9480. foreach ($features as $v) {
  9481. if (isset($typeclass[$v])) {
  9482. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9483. $pm[$typeclass[$v]['classid']] = $zh[0];
  9484. }
  9485. if (isset($typeclass[$v])) {
  9486. if (isset($jm[$typeclass[$v]['classid']])) {
  9487. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9488. }
  9489. }
  9490. }
  9491. $zh = implode(" ", $pm);
  9492. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9493. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9494. $rows_r[$key]['zh'] = $zh;
  9495. $jm = array_filter($jm);
  9496. $rows_r[$key]['features'] = implode("-", $jm);
  9497. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9498. }
  9499. $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');
  9500. foreach ($rows_c as $key => $value) {
  9501. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9502. $pm = $classid;
  9503. $jm = $classid;
  9504. $rows_c[$key]['time'] = $value['outk'];
  9505. $rows_c[$key]['outk'] = '出库';
  9506. if ($value['cktype'] == 1) {
  9507. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9508. } else if ($value['cktype'] == 2) {
  9509. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9510. } else if ($value['cktype'] == 3) {
  9511. $rows_c[$key]['cktype'] = '盘亏调整';
  9512. } else if ($value['cktype'] == 4) {
  9513. $rows_c[$key]['cktype'] = '其他调整出库';
  9514. } else if ($value['cktype'] == 5) {
  9515. $rows_c[$key]['cktype'] = '形态转换出库';
  9516. } else {
  9517. $rows_c[$key]['cktype'] = '';
  9518. }
  9519. unset($rows_c[$key]['state']);
  9520. $features = explode('-', trim($value['features'], '-'));
  9521. foreach ($features as $v) {
  9522. if (isset($typeclass[$v])) {
  9523. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9524. $pm[$typeclass[$v]['classid']] = $zh[0];
  9525. }
  9526. if (isset($typeclass[$v])) {
  9527. if (isset($jm[$typeclass[$v]['classid']])) {
  9528. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9529. }
  9530. }
  9531. }
  9532. $zh = implode(" ", $pm);
  9533. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9534. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9535. $rows_c[$key]['zh'] = $zh;
  9536. $jm = array_filter($jm);
  9537. $rows_c[$key]['features'] = implode("-", $jm);
  9538. $rows_c[$key]['number'] = 1;
  9539. }
  9540. $merged = $rows_r;
  9541. foreach ($rows_c as $key => $value) {
  9542. if (isset($merged[$key])) {
  9543. $merged[] = $value;
  9544. } else {
  9545. $merged[$key] = $value;
  9546. }
  9547. }
  9548. usort($merged, function ($a, $b) {
  9549. return $a['time'] - $b['time'];
  9550. });
  9551. foreach ($merged as $key => $value) {
  9552. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9553. }
  9554. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9555. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9556. $cols = [
  9557. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9558. ];
  9559. $final_list= [];
  9560. foreach($merged as $key => $value){
  9561. $final_list[] = array_values($value) ;
  9562. }
  9563. if(empty($merged)){
  9564. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9565. }
  9566. array_unshift($final_list, $first_row);
  9567. $end_list = [];
  9568. foreach ($final_list as $key => $value) {
  9569. $end_list[] = array_values($value);
  9570. }
  9571. $merges = [];
  9572. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9573. }
  9574. }
  9575. public function _errorexceljs()
  9576. {
  9577. $post = $this->input->post(NULL, TRUE);
  9578. if (isset($_GET['page'])) {
  9579. $page = $this->input->get('page', true);
  9580. $perpage = $this->input->get('perpage', true);
  9581. $sku = $this->input->get('sku', true);
  9582. $warehouse = $this->input->get('warehouse', true);
  9583. $ktime = $this->input->get('ktime', true);
  9584. $jtime = $this->input->get('jtime', true);
  9585. $ktime = strtotime($ktime);
  9586. $jtime = strtotime($jtime);
  9587. $where = "sku != 'Preset'";
  9588. $gj = '';
  9589. if ($sku) {
  9590. $where .= " and sku like '%$sku%'";
  9591. } else {
  9592. if ($ktime && $jtime) {
  9593. $gj = " and time > '$ktime' and time < '$jtime'";
  9594. }
  9595. }
  9596. if ($warehouse) {
  9597. $where .= " and warehouse = '$warehouse'";
  9598. }
  9599. //数据排序
  9600. $order_str = "id desc";
  9601. if (empty($page)) {
  9602. $start = 0;
  9603. $perpage = 1;
  9604. } else {
  9605. $start = ($page - 1) * $perpage;
  9606. }
  9607. //取得信息列表
  9608. $rows = array();
  9609. $list = array();
  9610. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9611. foreach ($info_list as $value) {
  9612. $warehouse = $this->warehouse->read($value['warehouse']);
  9613. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9614. $number = $value['number'];
  9615. $ftime = time() - 15 * 24 * 3600;
  9616. if ($c < 1) {
  9617. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9618. }
  9619. }
  9620. $title = "0库存汇总";
  9621. $first_row = ["仓库","SKU","产品","当前库存"];
  9622. $cols = [
  9623. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9624. ];
  9625. $final_list= [];
  9626. foreach($list as $key => $value){
  9627. $final_list[] = array_values($value) ;
  9628. }
  9629. if(empty($final_list)){
  9630. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9631. }
  9632. array_unshift($final_list, $first_row);
  9633. $merges = [];
  9634. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9635. }
  9636. }
  9637. }