Whlabel.php 342 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099
  1. <?php defined('BASEPATH') or exit('No direct script access allowed');
  2. class Whlabel extends Start_Controller
  3. {
  4. public function __construct()
  5. {
  6. parent::__construct();
  7. $this->load->library('session');
  8. $this->load->_model('Model_whlabel', 'whlabel');
  9. $this->load->_model('Model_warehouse', 'warehouse');
  10. $this->load->_model('Model_purchase', 'purchase');
  11. $this->load->_model('Model_excel', 'excel');
  12. $this->load->_model('Model_fullorder', 'fullorder');
  13. $this->load->_model('Model_fullordertt', 'fullordertt');
  14. $this->load->_model('Model_fullorderamz', 'fullorderamz');
  15. $this->load->_model('Model_fullorder_smt', 'fullorder_smt');
  16. $this->load->_model('Model_fullordersmt', 'fullordersmt');
  17. $this->load->_model('Model_express', 'express');
  18. $this->load->_model('Model_shop', 'shop');
  19. $this->load->_model('Model_typeclass', 'typeclass');
  20. $this->load->_model('Model_country', 'country');
  21. $this->load->_model('Model_warehouse', 'warehouse');
  22. $this->load->_model('Model_kdniao', 'kdniao');
  23. $this->load->_model('Model_notice', 'notice');
  24. $this->load->_model('Model_dhl', 'dhl');
  25. $this->load->_model('Model_shop', 'shop');
  26. $this->load->_model('Model_fullorderexcel', 'fullorderexcel');
  27. $this->load->_model('Model_ljg', 'ljg');
  28. $this->load->_model('Model_usps', 'usps');
  29. $this->load->_model('Model_specialstock', 'specialstock');
  30. $this->load->_model('Model_whlabellabel', 'whlabellabel');
  31. $this->load->_model('Model_whlabelwz', 'whlabelwz');
  32. $this->load->_model('Model_whlabelbarcode', 'whlabelbarcode');
  33. $this->load->_model('Model_whlabeltransport', 'whlabeltransport');
  34. $this->load->_model('Model_orderurl', 'orderurl');
  35. $this->load->_model('Model_brand', 'brand');
  36. $this->load->_model('Model_classid', 'classid');
  37. $this->load->_model('Model_apiyy', 'apiyy');
  38. $this->load->_model('Model_power', 'power');
  39. $this->load->_model('Model_whlabel_type', 'whlabel_type');
  40. $this->load->_model('Model_company', 'company');
  41. $this->load->_model('Model_whlabel_list', 'whlabel_list');
  42. $this->load->_model("Model_logic_whlabel", "logic_whlabel");
  43. $this->load->_model("Model_logic_order","logic_order");
  44. $this->load->_model("Model_logic_ding","logic_ding");
  45. $this->load->_model("Model_logic_u9tools","logic_u9tools");
  46. $this->load->_model("Model_whlabelscanlog","whlabelscanlog");
  47. $this->load->_model("Model_excel","excelxh");
  48. $this->load->_model("Model_whlabelscbf","whlabelscbf");
  49. }
  50. //定义方法的调用规则 获取URI第二段值
  51. public function _remap($arg, $arg_array)
  52. {
  53. if ($arg == 'existence') //在库标签
  54. {
  55. $this->_existence();
  56. } else if ($arg == 'cpbqdc') //在库标签
  57. {
  58. $this->_cpbqdc();
  59. } else if ($arg == 'type') //进销存浏览
  60. {
  61. $this->_type();
  62. }else if ($arg == 'typev1') //进销存浏览
  63. {
  64. $this->_typev1();
  65. } else if ($arg == 'typedy') //进销存浏览店员页面
  66. {
  67. $this->_typedy($arg_array);
  68. } else if ($arg == 'typedy_ck') //进销存浏览店员页面
  69. {
  70. $this->_typedy_ck($arg_array);
  71. } else if ($arg == 'typeck') {
  72. $this->_typeck($arg_array);
  73. } else if ($arg == 'whlabeckdc') {
  74. $this->_whlabeckdc($arg_array);
  75. } else if ($arg == 'usatype') //美仓进销存浏览
  76. {
  77. $this->_usatype();
  78. } else if ($arg == 'usatypeapp') //美仓APP进销存浏览
  79. {
  80. $this->_usatypeapp();
  81. } else if ($arg == 'enteradd') //入库操作
  82. {
  83. $this->_enteradd();
  84. } else if ($arg == 'enteredit') //修改
  85. {
  86. $this->_enteredit($arg_array);
  87. } else if ($arg == 'enter') //入库浏览
  88. {
  89. $this->_enter();
  90. } else if ($arg == 'out') //出库浏览
  91. {
  92. $this->_out();
  93. } else if ($arg == 'label') //出库标签浏览
  94. {
  95. $this->_label();
  96. } else if ($arg == 'outorder') //独立站出库订单
  97. {
  98. $this->_outorder();
  99. } else if ($arg == 'soutorder') //速卖通出库订单
  100. {
  101. $this->_soutorder();
  102. } else if ($arg == 'toutorder') //TT出库订单
  103. {
  104. $this->_toutorder();
  105. }else if ($arg == 'aoutorder') //amz出库订单
  106. {
  107. $this->_aoutorder();
  108. } else if ($arg == 'retreat') //退库订单
  109. {
  110. $this->_retreat();
  111. } else if ($arg == 'retreatlk') //退库订单
  112. {
  113. $this->_retreatlk();
  114. } else if ($arg == 'change') //更换标签
  115. {
  116. $this->_change();
  117. } else if ($arg == 'del') //删除
  118. {
  119. $this->_del();
  120. } else if ($arg == 'exceljxc') //进销存信息导出
  121. {
  122. $this->_exceljxc();
  123. } else if ($arg == 'excelr') //入库信息导出
  124. {
  125. $this->_excelr();
  126. } else if ($arg == 'excelct') //出库、退库信息导出
  127. {
  128. $this->_excelct();
  129. } else if ($arg == 'dccrtype') //根据出入库类型导出
  130. {
  131. $this->_dccrtype();
  132. } else if ($arg == 'excelcr') //出库、退库信息导出
  133. {
  134. $this->_excelcr();
  135. } else if ($arg == 'kcyz') //库存验证
  136. {
  137. $this->_kcyz();
  138. } else if ($arg == 'kj') //库存扣减
  139. {
  140. $this->_kj($arg_array);
  141. } else if ($arg == 'presetout') //预设库存导入
  142. {
  143. $this->_presetout($arg_array);
  144. } else if ($arg == 'presetedit') //预设库存导入
  145. {
  146. $this->_presetedit($arg_array);
  147. }else if ($arg == 'presetedittwo') //预设库存导入
  148. {
  149. $this->_presetedittwo($arg_array);
  150. } else if ($arg == 'summary') //汇总导出
  151. {
  152. $this->_summary($arg_array);
  153. } else if ($arg == 'manifest') //usps发货清单
  154. {
  155. $this->_manifest();
  156. } else if ($arg == 'abnormal') //占单异常
  157. {
  158. $this->_abnormal();
  159. } else if ($arg == 'error') //0库存SKU
  160. {
  161. $this->_error();
  162. } else if ($arg == 'errorexcel') //0库存SKU导出
  163. {
  164. $this->_errorexcel();
  165. } else if ($arg == 'db') {
  166. $this->_db();
  167. } else if ($arg == 'dbrk') {
  168. $this->_dbrk();
  169. } else if ($arg == 'whlabelczdc') {
  170. $this->_whlabelczdc();
  171. } else if ($arg == 'print') {
  172. $this->_print($arg_array);
  173. } else if ($arg == 'usaprint') {
  174. $this->_usaprint($arg_array);
  175. } else if ($arg == 'printck') {
  176. $this->_printck($arg_array);
  177. } else if ($arg == 'printrk') {
  178. $this->_printrk($arg_array);
  179. } else if ($arg == 'printxzrk') {
  180. $this->_printxzrk($arg_array);
  181. } else if ($arg == 'printexcel') {
  182. $this->_printexcel($arg_array);
  183. } else if ($arg == 'uck') {
  184. $this->_uck();
  185. } else if ($arg == 'whlabelexcelzh') {
  186. $this->_whlabelexcelzh();
  187. } else if ($arg == 'fc') {
  188. $this->_fc();
  189. } else if ($arg == 'fcmb') {
  190. $this->_fcmb();
  191. } else if ($arg == 'fcexcel') {
  192. $this->_fcexcel();
  193. } else if ($arg == 'fcjxc') {
  194. $this->_fcjxc($arg_array);
  195. } else if ($arg == '0kcdel') {
  196. $this->_0kcdel(); //导表删除0库存
  197. } else if ($arg == 'gbhtype') {
  198. $this->_gbhtype(); //更改备货状态
  199. } else if($arg == 'excelrjs'){
  200. $this->_excelrjs();
  201. } else if($arg == 'excelctjs'){
  202. $this->_excelctjs();
  203. }else if ($arg == 'exceljxcjs') //进销存信息导出
  204. {
  205. $this->_exceljxcjs();
  206. } else if ($arg == 'summaryjs') //汇总导出
  207. {
  208. $this->_summaryjs($arg_array);
  209. }else if($arg == 'uckjs'){
  210. $this->_uckjs();
  211. }else if ($arg == 'whlabelexcelzhjs') {
  212. $this->_whlabelexcelzhjs();
  213. }else if($arg == 'dccrtypejs'){
  214. $this->_dccrtypejs();
  215. }else if($arg == 'errorexceljs'){
  216. $this->_errorexceljs();
  217. }else if($arg == "w_t_cs"){
  218. $this->_w_t_cs(); //首页
  219. }else {
  220. $this->_index();
  221. }
  222. }
  223. public function _w_t_cs(){
  224. $vip = 0;
  225. if (isset($_SESSION['api'])) {
  226. $user = $this->user->get_api($_SESSION['api']);
  227. $fgshop = "";
  228. $sid = "";
  229. $usersp = explode('|', trim($user['shop'], '|'));
  230. foreach ($usersp as $value) {
  231. $fgshop .= " shop = " . $value . " or";
  232. $sid .= " id = " . $value . " or";
  233. }
  234. if ($user['vip'] == 1) {
  235. $vip = 1;
  236. }
  237. } else {
  238. header('Location: /');
  239. exit;
  240. }
  241. $prc = array();
  242. $purchase = $this->purchase->find_all();
  243. foreach ($purchase as $k => $v) {
  244. $prc[$v['id']] = $v['title'];
  245. }
  246. $company = array();
  247. $ct = $this->company->find_all();
  248. foreach ($ct as $k => $v) {
  249. $company[$v['id']] = $v['title'];
  250. }
  251. $sp = array();
  252. $s = $this->shop->find_all('1=1', 'id,shopname');
  253. foreach ($s as $v) {
  254. $sp[$v['id']] = $v['shopname'];
  255. }
  256. $wh = array();
  257. $w = $this->warehouse->find_all('1=1', 'id,title');
  258. foreach ($w as $v) {
  259. $wh[$v['id']] = $v['title'];
  260. }
  261. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  262. $this->data['shop'] = $wlshop;
  263. $this->data['vip'] = $vip;
  264. $this->_Template('whlabel_typejs', $this->data);
  265. }
  266. //管理
  267. public function _index()
  268. {
  269. $post = $this->input->post(NULL, TRUE);
  270. if (isset($post['page'])) {
  271. $page = $this->input->post('page', true);
  272. $perpage = $this->input->post('perpage', true);
  273. $sku = $this->input->post('sku', true);
  274. $number = $this->input->post('number', true);
  275. $warehouse = $this->input->post('warehouse', true);
  276. $purchase = $this->input->post('purchase', true);
  277. $orderinfo = $this->input->post('orderinfo', true);
  278. $waybill = $this->input->post('waybill', true);
  279. $category = $this->input->post('category', true);
  280. $size = $this->input->post('size', true);
  281. $grade = $this->input->post('grade', true);
  282. $color = $this->input->post('color', true);
  283. $lowe = $this->input->post('lowe', true);
  284. $state = $this->input->post('state', true);
  285. $label = $this->input->post('label', true);
  286. $timetk = $this->input->post('timetkk', true);
  287. $timetj = $this->input->post('timetjj', true);
  288. $timetk = strtotime($timetk);
  289. $timetj = strtotime($timetj);
  290. $where = "1=1 ";
  291. if ($timetk && $timetj) {
  292. $where .= " and time > '$timetk' and time < '$timetj'";
  293. }
  294. if ($sku) {
  295. $where .= " and sku = '$sku'";
  296. }
  297. if ($number) {
  298. $where .= " and number = '$number'";
  299. }
  300. if ($warehouse) {
  301. $where .= " and warehouse = '$warehouse'";
  302. }
  303. if ($purchase) {
  304. $where .= " and purchase = '$purchase'";
  305. }
  306. if ($orderinfo) {
  307. $where .= " and orderinfo = '$orderinfo'";
  308. }
  309. if ($waybill) {
  310. $where .= " and waybill = '$waybill'";
  311. }
  312. if ($category) {
  313. $where .= " and features like '%-$category-%'";
  314. }
  315. if ($size) {
  316. $where .= " and features like '%-$size-%'";
  317. }
  318. if ($grade) {
  319. $where .= " and features like '%-$grade-%'";
  320. }
  321. if ($color) {
  322. $where .= " and features like '%-$color-%'";
  323. }
  324. if ($lowe) {
  325. $where .= " and features like '%-$lowe-%'";
  326. }
  327. if ($label) {
  328. $where .= " and label = '$label'";
  329. }
  330. if ($state != '') {
  331. $where .= " and state = '$state'";
  332. }
  333. //数据排序
  334. $order_str = "time desc";
  335. if (empty($page)) {
  336. $start = 0;
  337. $perpage = 1;
  338. } else {
  339. $start = ($page - 1) * $perpage;
  340. }
  341. //取得信息列表
  342. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,label,printing,enter,warehouse,outk,orderinfo,waybill,text,time', $order_str, $start, $perpage);
  343. foreach ($info_list as $key => $value) {
  344. $warehouse = $this->warehouse->read($value['warehouse']);
  345. $info_list[$key]['warehouse'] = $warehouse['title'];
  346. $purchase = $this->purchase->read($value['purchase']);
  347. $info_list[$key]['purchase'] = $purchase['title'];
  348. if ($value['enter'] != 0) {
  349. $info_list[$key]['enter'] = '<p>' . date('Y-m-d', $value['enter']) . '</p><p>' . date('H:i:s', $value['enter']) . '</p>';
  350. } else {
  351. $info_list[$key]['enter'] = "";
  352. }
  353. if ($value['outk'] != 0) {
  354. $info_list[$key]['outk'] = '<p>' . date('Y-m-d', $value['outk']) . '</p><p>' . date('H:i:s', $value['outk']) . '</p>';
  355. } else {
  356. $info_list[$key]['outk'] = "";
  357. }
  358. if ($value['printing'] != 0) {
  359. $info_list[$key]['printing'] = '<p>' . date('Y-m-d', $value['printing']) . '</p><p>' . date('H:i:s', $value['printing']) . '</p>';
  360. } else {
  361. $info_list[$key]['printing'] = "";
  362. }
  363. if ($value['orderinfo'] == 0) {
  364. $info_list[$key]['orderinfo'] = "";
  365. }
  366. if ($value['waybill'] == 0) {
  367. $info_list[$key]['waybill'] = "";
  368. }
  369. if ($value['state'] == 0) {
  370. $info_list[$key]['state'] = "在库";
  371. } else if ($value['state'] == 1) {
  372. $info_list[$key]['state'] = "出库";
  373. } else if ($value['state'] == 2) {
  374. $info_list[$key]['state'] = "退库";
  375. } else if ($value['state'] == 3) {
  376. $info_list[$key]['state'] = "调拨中";
  377. } else if ($value['state'] == 4) {
  378. $info_list[$key]['state'] = "再加工";
  379. } else if ($value['state'] == 5) {
  380. $info_list[$key]['state'] = "维修中";
  381. } else if ($value['state'] == 6) {
  382. $info_list[$key]['state'] = "盘亏";
  383. } else if ($value['state'] == 7) {
  384. $info_list[$key]['state'] = "更换标签";
  385. } else if ($value['state'] == 8) {
  386. $info_list[$key]['state'] = "其它";
  387. } else if ($value['state'] == 9) {
  388. $info_list[$key]['state'] = "预设";
  389. } else if ($value['state'] == 10) {
  390. $info_list[$key]['state'] = "美店零售";
  391. }
  392. if ($value['text'] == "") {
  393. $info_list[$key]['text'] = "";
  394. }
  395. $info_list[$key]['time'] = '<p>' . date('Y-m-d', $value['time']) . '</p><p>' . date('H:i:s', $value['time']) . '</p>';
  396. }
  397. $total = $this->whlabel->find_count($where);
  398. $pagenum = ceil($total / $perpage);
  399. $over = $total - ($start + $perpage);
  400. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  401. echo json_encode($rows);
  402. exit;
  403. }
  404. if (isset($post['outsku'])) {
  405. //这种方法只针对美仓的 但是其实入库的录入 感觉怪怪的 不过存在即合理 就不在改动了
  406. $cz = $this->input->post('cz', true);
  407. if ($cz == '1') {
  408. $sku = $this->input->post('outsku', true);
  409. if ($sku) {
  410. $data = $this->whlabel->find_all("sku = '$sku' and zd = '' and state = '0' and warehouse = '5'");
  411. if (count($data) < 1) {
  412. echo json_encode(array('msg' => '库存不足!', 'success' => false));
  413. exit;
  414. }
  415. $this->whlabel->save(array('state' => 10, 'outk' => time(), 'time' => time(), 'cktype' => 2), $data[0]['id']);
  416. echo json_encode(array('success' => true));
  417. exit;
  418. }
  419. } else {
  420. $sku = $this->input->post('outsku', true);
  421. if ($sku) {
  422. $data = $this->whlabel->find_all("sku = '$sku' and state = '10' and warehouse = '5'");
  423. if (count($data) < 1) {
  424. echo json_encode(array('msg' => '没有此SKU出库数据!', 'success' => false));
  425. exit;
  426. }
  427. $this->whlabel->save(array('state' => 0, 'outk' => 0, 'time' => time()), $data[0]['id']);
  428. echo json_encode(array('success' => true));
  429. exit;
  430. }
  431. }
  432. }
  433. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  434. $this->_Template('whlabel', $this->data);
  435. }
  436. //在库标签
  437. public function _existence()
  438. {
  439. $post = $this->input->post(NULL, TRUE);
  440. if (isset($post['s'])) {
  441. $id_arr = $this->input->post('s');
  442. $id_arr = explode(',', $id_arr);
  443. if (!$id_arr) {
  444. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  445. exit;
  446. }
  447. //循环删除记录
  448. foreach ($id_arr as $v) {
  449. $sid = $this->whlabel->read($v);
  450. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  451. if ($count > 0) {
  452. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  453. exit;
  454. }
  455. $zt = $this->whlabeltransport->find_all('sku = "' . $sid['sku'] . '" and warehouse = "' . $sid['warehouse'] . '" and features = "' . $sid['features'] . '" and cz = "0"');
  456. if (count($zt) > 0) {
  457. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  458. exit;
  459. }
  460. $this->whlabel->remove($v);
  461. }
  462. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  463. exit;
  464. }
  465. if (isset($post['page'])) {
  466. $page = $this->input->post('page', true);
  467. $perpage = $this->input->post('perpage', true);
  468. $warehouse = $this->input->post('warehouse', true);
  469. $label = $this->input->post('label', true);
  470. $where = "1=1 and state = 0";
  471. if ($warehouse) {
  472. $where .= " and warehouse = '$warehouse'";
  473. }
  474. if ($label) {
  475. $where .= " and label = '$label'";
  476. }
  477. //数据排序
  478. $order_str = "time asc";
  479. if (empty($page)) {
  480. $start = 0;
  481. $perpage = 1;
  482. } else {
  483. $start = ($page - 1) * $perpage;
  484. }
  485. //取得信息列表
  486. $info_list = $this->whlabel->find_all($where, 'id,sku,title,label,printing,enter', $order_str, $start, $perpage);
  487. foreach ($info_list as $key => $value) {
  488. if ($value['enter'] != 0) {
  489. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  490. } else {
  491. $info_list[$key]['enter'] = "";
  492. }
  493. if ($value['printing'] != 0) {
  494. $info_list[$key]['printing'] = date('Y-m-d H:i:s', $value['printing']);
  495. } else {
  496. $info_list[$key]['printing'] = "";
  497. }
  498. }
  499. $total = $this->whlabel->find_count($where);
  500. $pagenum = ceil($total / $perpage);
  501. $over = $total - ($start + $perpage);
  502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  503. echo json_encode($rows);
  504. exit;
  505. }
  506. $this->_Template('whlabel_existence', $this->data);
  507. }
  508. //进销存浏览
  509. public function _typedy($arg_array)
  510. {
  511. $prc = array();
  512. $purchase = $this->purchase->find_all();
  513. foreach ($purchase as $k => $v) {
  514. $prc[$v['id']] = $v['title'];
  515. }
  516. $post = $this->input->post(NULL, TRUE);
  517. if (isset($post['page'])) {
  518. $page = $this->input->post('page', true);
  519. $perpage = $this->input->post('perpage', true);
  520. $category = $this->input->post('category', true);
  521. $size = $this->input->post('size', true);
  522. $grade = $this->input->post('grade', true);
  523. $color = $this->input->post('color', true);
  524. $lowe = $this->input->post('lowe', true);
  525. $sku = $this->input->post('sku');
  526. $title = $this->input->post('title');
  527. $warehouse = $this->input->post('warehouse', true);
  528. $usa = $this->input->post('usa', true);
  529. $purchase = $this->input->post('purchase', true);
  530. $lacetype = $this->input->post('lacetype', true);
  531. $haircap = $this->input->post('haircap', true);
  532. $density = $this->input->post('density', true);
  533. $details = $this->input->post('details', true);
  534. $state = $this->input->post('state', true);
  535. $lacecolor = $this->input->post('lacecolor', true);
  536. $hairnumber = $this->input->post('hairnumber', true);
  537. $cklx = $this->input->post('cklx', true);
  538. $ktime = $this->input->post('ktime', true);
  539. $jtime = $this->input->post('jtime', true);
  540. $sm = $this->input->post('sm', true);
  541. $cpbz = $this->input->post('cpbz', true);
  542. $type = $this->input->post('type', true);
  543. $ktime = strtotime($ktime);
  544. $jtime = strtotime($jtime);
  545. $where = "1=1";
  546. $gj = "";
  547. $ck = "";
  548. if ($usa) {
  549. if (!$warehouse) {
  550. $where .= " and (warehouse = '5' or warehouse = '8')";
  551. }
  552. }
  553. if ($warehouse) {
  554. $where .= " and warehouse = '$warehouse'";
  555. }
  556. if ($details) {
  557. $where .= " and details = '$details'";
  558. }
  559. if ($purchase) {
  560. $where .= " and purchase = '$purchase'";
  561. }
  562. if (isset($state)) {
  563. if($state >-1){
  564. $where .= " and state = '$state'";
  565. }
  566. }
  567. if ($lacetype) {
  568. $where .= " and features like '%-$lacetype-%'";
  569. }
  570. if ($category) {
  571. $where .= " and features like '%-$category-%'";
  572. }
  573. if ($size) {
  574. $where .= " and features like '%-$size-%'";
  575. }
  576. if ($grade) {
  577. $where .= " and features like '%-$grade-%'";
  578. }
  579. if ($color) {
  580. $where .= " and features like '%-$color-%'";
  581. }
  582. if ($lowe) {
  583. $where .= " and features like '%-$lowe-%'";
  584. }
  585. if ($haircap) {
  586. $where .= " and features like '%-$haircap-%'";
  587. }
  588. if ($density) {
  589. $where .= " and features like '%-$density-%'";
  590. }
  591. if ($lacecolor) {
  592. $where .= " and features like '%-$lacecolor-%'";
  593. }
  594. if($sm){
  595. $where .= " and sm like '%".$sm."%'";
  596. }
  597. if($cpbz){
  598. $where .= " and cpbz like '%".$cpbz."%'";
  599. }
  600. if($type){
  601. $where .= " and type = ".$type."";
  602. }
  603. if (!empty($hairnumber)) {
  604. $where .= " and features like '%-128-%' ";
  605. if ($hairnumber < 0) {
  606. $class_list = $this->typeclass->find_all('classid = 43');
  607. foreach ($class_list as $v) {
  608. $where .= " and features not like '%-" . $v['id'] . "-%'";
  609. }
  610. } else {
  611. $where .= " and features like '%-$hairnumber-%'";
  612. }
  613. }
  614. $where_add = '';
  615. if ($cklx) {
  616. $shop = $this->shop->read($cklx);
  617. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  618. }
  619. if ($ktime && $jtime) {
  620. $gj = " and enter > '$ktime' and enter < '$jtime'";
  621. $ck = " and outk > '$ktime' and outk < '$jtime'";
  622. }
  623. //数据排序
  624. $order_str = "id desc";
  625. if (empty($page)) {
  626. $start = 0;
  627. $perpage = 1;
  628. } else {
  629. $start = ($page - 1) * $perpage;
  630. }
  631. //这里为了对应前端界面的字段 新添加了label字段 后续代码会替换为sm字段
  632. if ($sku) {
  633. $sku = trim($sku, ' ');
  634. $sku = trim($sku, ' ');
  635. $where .= " and sku like '%$sku%'";
  636. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  637. } else if ($title) {
  638. $title = trim($title, ' ');
  639. $title = trim($title, ' ');
  640. $where .= " and title like '%$title%'";
  641. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  642. } else {
  643. //$where .= " and time > '$ktime' and time < '$jtime'";
  644. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,features,number,sm', $order_str, $start, $perpage);
  645. }
  646. //$this->logic_ding->sendToDing("仓库查询:".$where . $where_add);
  647. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  648. foreach ($info_list as $k => $v) {
  649. $info_list[$k]['title'] = $v['title'] . "<br/>" . $v['pm'];
  650. unset($info_list[$k]['pm']);
  651. unset($info_list[$k]['jm']);
  652. unset($info_list[$k]['bm']);
  653. }
  654. //取得信息列表
  655. $rows = array();
  656. $list = array();
  657. foreach ($info_list as $key => $value) {
  658. $warehouse = $this->warehouse->read($value['warehouse']);
  659. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  660. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  661. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  662. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  663. $info_list[$key]['label'] = $value['sm'];
  664. $number = $value['number'];
  665. $ftime = time() - 15 * 24 * 3600;
  666. $info_list[$key]['warehouse'] = $warehouse['title'];
  667. $info_list[$key]['features'] = count($c);
  668. $z = count($z); //查看订单号
  669. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  670. $ztdata = '';
  671. if (count($zt) > 0) {
  672. foreach ($zt as $vv) {
  673. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  674. }
  675. }
  676. $info_list[$key]['number'] = $ztdata;
  677. $info_list[$key]['sm'] = $z;
  678. $details = array();
  679. $cpid = array();
  680. foreach ($c as $k => $v) {
  681. $details[$v['details']] = $v['details'];
  682. if ($v['cpid'] != 0) {
  683. $cpid[$v['cpid']] = $v['cpid'];
  684. }
  685. }
  686. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  687. if ($value['shop'] != '') {
  688. $shop = explode(',', trim($value['shop'], ','));
  689. $shop = $this->shop->read($shop[0]);
  690. $info_list[$key]['shop'] = $shop['shopname'];
  691. }
  692. }
  693. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  694. $pagenum = ceil($total / $perpage);
  695. $over = $total - ($start + $perpage);
  696. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  697. echo json_encode($rows);
  698. exit;
  699. }
  700. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  701. $this->_Template('whlabel_typedy', $this->data);
  702. }
  703. //进销存浏览
  704. public function _typedy_ck($arg_array)
  705. {
  706. $prc = array();
  707. $purchase = $this->purchase->find_all();
  708. foreach ($purchase as $k => $v) {
  709. $prc[$v['id']] = $v['title'];
  710. }
  711. $post = $this->input->post(NULL, TRUE);
  712. if (isset($post['page'])) {
  713. $page = $this->input->post('page', true);
  714. $perpage = $this->input->post('perpage', true);
  715. $category = $this->input->post('category', true);
  716. $size = $this->input->post('size', true);
  717. $grade = $this->input->post('grade', true);
  718. $color = $this->input->post('color', true);
  719. $lowe = $this->input->post('lowe', true);
  720. $sku = $this->input->post('sku');
  721. $title = $this->input->post('title');
  722. $warehouse = $this->input->post('warehouse', true);
  723. $usa = $this->input->post('usa', true);
  724. $purchase = $this->input->post('purchase', true);
  725. $lacetype = $this->input->post('lacetype', true);
  726. $haircap = $this->input->post('haircap', true);
  727. $density = $this->input->post('density', true);
  728. $details = $this->input->post('details', true);
  729. $state = $this->input->post('state', true);
  730. $lacecolor = $this->input->post('lacecolor', true);
  731. $cklx = $this->input->post('cklx', true);
  732. $ktime = $this->input->post('ktime', true);
  733. $jtime = $this->input->post('jtime', true);
  734. $ktime = strtotime($ktime);
  735. $jtime = strtotime($jtime);
  736. $where = "1=1";
  737. $gj = "";
  738. $ck = "";
  739. if ($lacetype) {
  740. $where .= " and features like '%-$lacetype-%'";
  741. }
  742. if ($category) {
  743. $where .= " and features like '%-$category-%'";
  744. }
  745. if ($size) {
  746. $where .= " and features like '%-$size-%'";
  747. }
  748. if ($grade) {
  749. $where .= " and features like '%-$grade-%'";
  750. }
  751. if ($color) {
  752. $where .= " and features like '%-$color-%'";
  753. }
  754. if ($lowe) {
  755. $where .= " and features like '%-$lowe-%'";
  756. }
  757. if ($haircap) {
  758. $where .= " and features like '%-$haircap-%'";
  759. }
  760. if ($density) {
  761. $where .= " and features like '%-$density-%'";
  762. }
  763. if ($lacecolor) {
  764. $where .= " and features like '%-$lacecolor-%'";
  765. }
  766. if ($usa) {
  767. if (!$warehouse) {
  768. $where .= " and (warehouse = '5' or warehouse = '8')";
  769. }
  770. }
  771. if ($warehouse) {
  772. $where .= " and warehouse = '$warehouse'";
  773. }
  774. if ($details) {
  775. $where .= " and details = '$details'";
  776. }
  777. if ($purchase) {
  778. $where .= " and purchase = '$purchase'";
  779. }
  780. if ($state) {
  781. $where .= " and state = '$state'";
  782. }
  783. $where_add = '';
  784. if ($cklx) {
  785. $shop = $this->shop->read($cklx);
  786. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  787. }
  788. if ($ktime && $jtime) {
  789. $gj = " and enter > '$ktime' and enter < '$jtime'";
  790. $ck = " and outk > '$ktime' and outk < '$jtime'";
  791. }
  792. //数据排序
  793. $order_str = "id desc";
  794. if (empty($page)) {
  795. $start = 0;
  796. $perpage = 1;
  797. } else {
  798. $start = ($page - 1) * $perpage;
  799. }
  800. if ($sku) {
  801. $sku = trim($sku, ' ');
  802. $sku = trim($sku, ' ');
  803. $where .= " and sku like '%$sku%'";
  804. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  805. } else if ($title) {
  806. $title = trim($title, ' ');
  807. $title = trim($title, ' ');
  808. $where .= " and title like '%$title%'";
  809. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,number', $order_str, $start, $perpage);
  810. } else {
  811. //$where .= " and time > '$ktime' and time < '$jtime'";
  812. $info_list = $this->whlabel->find_pc($where . $where_add . ' and zd != ""', 'sku,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,features,zd,COUNT(CASE WHEN zd != "" and state = 0 THEN 1 ELSE NULL END) AS zd', 'zd desc', $start, $perpage);
  813. }
  814. //取得信息列表
  815. $rows = array();
  816. $list = array();
  817. foreach ($info_list as $key => $value) {
  818. $warehouse = $this->warehouse->read($value['warehouse']);
  819. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  820. $c = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,text');
  821. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  822. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $c[0]['text'] . '</p>';
  823. $ftime = time() - 15 * 24 * 3600;
  824. $info_list[$key]['warehouse'] = $warehouse['title'];
  825. $info_list[$key]['features'] = count($c) < 10 ? "<em style='color:#F00'>" . count($c) . "</em>" : count($c);
  826. //$z = count($z);//查看订单号
  827. //$info_list[$key]['zd'] = $z;
  828. $details = array();
  829. $cpid = array();
  830. foreach ($c as $k => $v) {
  831. $details[$v['details']] = $v['details'];
  832. if ($v['cpid'] != 0) {
  833. $cpid[$v['cpid']] = $v['cpid'];
  834. }
  835. }
  836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  837. if ($value['shop'] != '') {
  838. $shop = explode(',', trim($value['shop'], ','));
  839. $shop = $this->shop->read($shop[0]);
  840. $info_list[$key]['shop'] = $shop['shopname'];
  841. }
  842. }
  843. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  844. $pagenum = ceil($total / $perpage);
  845. $over = $total - ($start + $perpage);
  846. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  847. echo json_encode($rows);
  848. exit;
  849. }
  850. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  851. $this->_Template('whlabel_typedy_ck', $this->data);
  852. }
  853. public function _typeck($arg_array)
  854. {
  855. $prc = array();
  856. $purchase = $this->purchase->find_all();
  857. foreach ($purchase as $k => $v) {
  858. $prc[$v['id']] = $v['title'];
  859. }
  860. $post = $this->input->post(NULL, TRUE);
  861. if (isset($post['page'])) {
  862. $page = $this->input->post('page', true);
  863. $perpage = $this->input->post('perpage', true);
  864. $category = $this->input->post('category', true);
  865. $size = $this->input->post('size', true);
  866. $grade = $this->input->post('grade', true);
  867. $color = $this->input->post('color', true);
  868. $lacecolor = $this->input->post('lacecolor', true);
  869. $lowe = $this->input->post('lowe', true);
  870. $sku = $this->input->post('sku');
  871. $title = $this->input->post('title');
  872. $warehouse = 13;
  873. $usa = $this->input->post('usa', true);
  874. $purchase = $this->input->post('purchase', true);
  875. $lacetype = $this->input->post('lacetype', true);
  876. $haircap = $this->input->post('haircap', true);
  877. $density = $this->input->post('density', true);
  878. $details = $this->input->post('details', true);
  879. $state = $this->input->post('state', true);
  880. $ktime = $this->input->post('ktime', true);
  881. $jtime = $this->input->post('jtime', true);
  882. $ktime = strtotime($ktime);
  883. $jtime = strtotime($jtime);
  884. $where = "1=1";
  885. $gj = "";
  886. $ck = "";
  887. if ($lacetype) {
  888. $where .= " and features like '%-$lacetype-%'";
  889. }
  890. if ($category) {
  891. $where .= " and features like '%-$category-%'";
  892. }
  893. if ($size) {
  894. $where .= " and features like '%-$size-%'";
  895. }
  896. if ($grade) {
  897. $where .= " and features like '%-$grade-%'";
  898. }
  899. if ($color) {
  900. $where .= " and features like '%-$color-%'";
  901. }
  902. if ($lacecolor) {
  903. $where .= " and features like '%-$lacecolor-%'";
  904. }
  905. if ($lowe) {
  906. $where .= " and features like '%-$lowe-%'";
  907. }
  908. if ($haircap) {
  909. $where .= " and features like '%-$haircap-%'";
  910. }
  911. if ($density) {
  912. $where .= " and features like '%-$density-%'";
  913. }
  914. if ($warehouse) {
  915. $where .= " and warehouse = '$warehouse'";
  916. }
  917. if ($details) {
  918. $where .= " and details = '$details'";
  919. }
  920. if ($purchase) {
  921. $where .= " and purchase = '$purchase'";
  922. }
  923. if ($state) {
  924. $where .= " and state = '$state'";
  925. }
  926. if ($ktime && $jtime) {
  927. $gj = " and enter > '$ktime' and enter < '$jtime'";
  928. $ck = " and outk > '$ktime' and outk < '$jtime'";
  929. }
  930. //数据排序
  931. $order_str = "id desc";
  932. if (empty($page)) {
  933. $start = 0;
  934. $perpage = 1;
  935. } else {
  936. $start = ($page - 1) * $perpage;
  937. }
  938. if ($sku) {
  939. $sku = trim($sku, ' ');
  940. $sku = trim($sku, ' ');
  941. $where .= " and sku like '%$sku%'";
  942. } else if ($title) {
  943. $title = trim($title, ' ');
  944. $title = trim($title, ' ');
  945. $where .= " and title like '%$title%'";
  946. }
  947. $info_list = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,sm,details,cpbz,features,number,', $order_str, $start, $perpage);
  948. //取得信息列表
  949. $t = array();
  950. $typeclass = $this->typeclass->find_all();
  951. foreach ($typeclass as $v) {
  952. $t[$v['id']] = $v;
  953. }
  954. $rows = array();
  955. $list = array();
  956. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  957. foreach ($info_list as $key => $value) {
  958. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  959. $mc = $this->whlabel->find_all("sku = '" . $value['sku'] . "' and features = '" . $value['features'] . "' and warehouse = '" . $value['warehouse'] . "'", 'cpbz', 'id desc', 0, 1);
  960. $warehouse = $this->warehouse->read($value['warehouse']);
  961. $c = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid');
  962. $z = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  963. $info_list[$key]['cpbz'] = '<p>' . $value['cpbz'] . '</p><p>' . $value['sm'] . '</p>';
  964. $number = $value['number'];
  965. $ftime = time() - 15 * 24 * 3600;
  966. $z = count($z); //查看订单号
  967. $info_list[$key]['warehouse'] = $warehouse['title'];
  968. $info_list[$key]['features'] = count($c);
  969. $info_list[$key]['number'] = $z;
  970. //$info_list[$key]['cpbz'] = $mc[0]['cpbz'];
  971. $details = array();
  972. $cpid = array();
  973. foreach ($c as $k => $v) {
  974. $details[$v['details']] = $v['details'];
  975. if ($v['cpid'] != 0) {
  976. $cpid[$v['cpid']] = $v['cpid'];
  977. }
  978. }
  979. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  980. $info_list[$key]['sm'] = $info_list[$key]['pm'];
  981. unset($info_list[$key]['pm']);
  982. unset($info_list[$key]['jm']);
  983. unset($info_list[$key]['bm']);
  984. }
  985. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  986. $pagenum = ceil($total / $perpage);
  987. $over = $total - ($start + $perpage);
  988. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  989. echo json_encode($rows);
  990. exit;
  991. }
  992. $this->data['warehouse'] = (isset($arg_array[0])) ? $arg_array[0] : 5;
  993. $this->_Template('whlabel_typeck', $this->data);
  994. }
  995. //进销存导出
  996. public function _whlabeckdc()
  997. {
  998. $prc = array();
  999. $purchase = $this->purchase->find_all();
  1000. foreach ($purchase as $k => $v) {
  1001. $prc[$v['id']] = $v['title'];
  1002. }
  1003. if (isset($_GET['excel'])) {
  1004. $where = "sku != 'Preset'";
  1005. //数据排序
  1006. $order_str = "id desc";
  1007. if (empty($page)) {
  1008. $start = 0;
  1009. $perpage = 1;
  1010. } else {
  1011. $start = ($page - 1) * $perpage;
  1012. }
  1013. $category = $this->input->get('category', true);
  1014. $color = $this->input->get('color', true);
  1015. $lowe = $this->input->get('lowe', true);
  1016. $lacetype = $this->input->get('lacetype', true);
  1017. $size = $this->input->get('size', true);
  1018. $density = $this->input->get('density', true);
  1019. $haircap = $this->input->get('haircap', true);
  1020. $sku = $this->input->get('sku', true);
  1021. $details = $this->input->get('details', true);
  1022. $warehouse = 13;
  1023. $excelid = $this->input->get('sid', true);
  1024. if ($category) {
  1025. $where .= " and features like '%-$category-%'";
  1026. }
  1027. if ($color) {
  1028. $where .= " and features like '%-$color-%'";
  1029. }
  1030. if ($lowe) {
  1031. $where .= " and features like '%-$lowe-%'";
  1032. }
  1033. if ($lacetype) {
  1034. $where .= " and features like '%-$lacetype-%'";
  1035. }
  1036. if ($size) {
  1037. $where .= " and features like '%-$size-%'";
  1038. }
  1039. if ($density) {
  1040. $where .= " and features like '%-$density-%'";
  1041. }
  1042. if ($haircap) {
  1043. $where .= " and features like '%-$haircap-%'";
  1044. }
  1045. if ($warehouse) {
  1046. $where .= " and warehouse = '$warehouse'";
  1047. }
  1048. if ($sku) {
  1049. $where .= " and sku like '%$sku%'";
  1050. }
  1051. if ($details) {
  1052. $where .= " and details = '$details'";
  1053. }
  1054. $xzid = '';
  1055. if ($excelid) {
  1056. $excelid = explode(',', trim($excelid, ','));
  1057. foreach ($excelid as $key => $value) {
  1058. $xzid .= " id = " . $value . " or";
  1059. }
  1060. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  1061. }
  1062. //取得信息列表
  1063. /**
  1064. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  1065. $rows = array();$list = array();
  1066. foreach ($info_list as $key=>$value)
  1067. {
  1068. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  1069. }
  1070. **/
  1071. $wh = array();
  1072. $w = $this->warehouse->find_all('1=1', 'id,title');
  1073. foreach ($w as $v) {
  1074. $wh[$v['id']] = $v['title'];
  1075. }
  1076. $tc = array();
  1077. $tcdata = array();
  1078. $list = array();
  1079. $classid = $this->classid->sku();
  1080. $tcall = $this->typeclass->find_all();
  1081. $typeclass = array();
  1082. foreach ($tcall as $v)
  1083. {
  1084. //$tcjm[$v['id']] = array($v['jm'],$v['classid']);
  1085. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  1086. }
  1087. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse,details', "warehouse,purchase,details,cpid,sku,cpbz,cs,title,dbcontent,GROUP_CONCAT(NULLIF(cpbz, '') ORDER BY cpbz ASC SEPARATOR ', ') AS cpbzs,number,features ");
  1088. foreach ($rows as $key => $value) {
  1089. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1090. $u9_info = $this->logic_u9tools->getOneU9bm($value['features'],$classid,$typeclass);
  1091. $rows[$key]['dbcontent'] = $u9_info['zh'];
  1092. $rows[$key]['cpbz'] = $u9_info['bm'];
  1093. $rows[$key]['cs'] = $u9_info['jm'];
  1094. if(empty($value['details'])){
  1095. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = ""', 'details,cpid,cpbz,state');
  1096. }else{
  1097. $sd = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and details = "' . $value['details'] . '"', 'details,cpid,cpbz,state');
  1098. }
  1099. $details = array();
  1100. $cpid = array();
  1101. $cpbz = array();
  1102. $c = 0;
  1103. $g = 0;
  1104. $x = 0;
  1105. $t = 0;
  1106. $s = 0;
  1107. $q = 0;
  1108. foreach ($sd as $k => $v) {
  1109. if ($v['state'] == 0) {
  1110. $c++;
  1111. }
  1112. if ($v['state'] != 9) {
  1113. $g++;
  1114. }
  1115. if ($v['state'] == 1) {
  1116. $x++;
  1117. }
  1118. if ($v['state'] == 2) {
  1119. $t++;
  1120. }
  1121. if ($v['state'] == 8) {
  1122. $s++;
  1123. }
  1124. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  1125. $q++;
  1126. }
  1127. $details[$v['details']] = $v['details'];
  1128. if ($v['cpid'] != 0) {
  1129. $cpid[$v['cpid']] = $v['cpid'];
  1130. }
  1131. if ($v['cpbz'] != '') {
  1132. $cpbz[$v['cpbz']] = $v['cpbz'];
  1133. }
  1134. }
  1135. $rows[$key]['details'] = implode("、", $details);
  1136. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  1137. $number = $value['number'];
  1138. $ftime = time() - 15 * 24 * 3600;
  1139. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  1140. $rows[$key]['number'] = $g;
  1141. $rows[$key]['features'] = $c;
  1142. $rows[$key]['x'] = $x;
  1143. $rows[$key]['t'] = $t;
  1144. $rows[$key]['s'] = $s;
  1145. $rows[$key]['q'] = $q;
  1146. $rows[$key]['wzsl'] = count($details);
  1147. //cpbzs
  1148. $tmp_cpbzs = explode(',', $value['cpbzs']);
  1149. $unique_arr = array_unique($tmp_cpbzs);
  1150. $rows[$key]['cpbzs'] = implode(',', $unique_arr);
  1151. }
  1152. $title = "进销存统计表" . date('Y-m-d', time());
  1153. $titlename = "<table border=1>
  1154. <tr><th colspan='12' align='center'><h3>" . $title . "<h3></th></tr>
  1155. <tr align='center'>
  1156. <td>仓库</td>
  1157. <td>供应商</td>
  1158. <td>位置</td>
  1159. <td>库存编码</td>
  1160. <td>SKU</td>
  1161. <td>用友编码</td>
  1162. <td>用友料号</td>
  1163. <td>产品英文名</td>
  1164. <td>产品中文名</td>
  1165. <td>备注</td>
  1166. <td>入库总量</td>
  1167. <td>库存数量</td>
  1168. <td>销售数量</td>
  1169. <td>退货数量</td>
  1170. <td>删除数量</td>
  1171. <td>其它操作</td>
  1172. <td>位置数量</td>
  1173. </tr>
  1174. </table>";
  1175. $filename = $title . ".xls";
  1176. $tail = "";
  1177. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  1178. }
  1179. }
  1180. public function _type()
  1181. {
  1182. $vip = 0;
  1183. if (isset($_SESSION['api'])) {
  1184. $user = $this->user->get_api($_SESSION['api']);
  1185. $fgshop = "";
  1186. $sid = "";
  1187. $usersp = explode('|', trim($user['shop'], '|'));
  1188. foreach ($usersp as $value) {
  1189. $fgshop .= " shop = " . $value . " or";
  1190. $sid .= " id = " . $value . " or";
  1191. }
  1192. if ($user['vip'] == 1) {
  1193. $vip = 1;
  1194. }
  1195. } else {
  1196. header('Location: /');
  1197. exit;
  1198. }
  1199. $prc = array();
  1200. $purchase = $this->purchase->find_all();
  1201. foreach ($purchase as $k => $v) {
  1202. $prc[$v['id']] = $v['title'];
  1203. }
  1204. $company = array();
  1205. $ct = $this->company->find_all();
  1206. foreach ($ct as $k => $v) {
  1207. $company[$v['id']] = $v['title'];
  1208. }
  1209. $sp = array();
  1210. $s = $this->shop->find_all('1=1', 'id,shopname');
  1211. foreach ($s as $v) {
  1212. $sp[$v['id']] = $v['shopname'];
  1213. }
  1214. $wh = array();
  1215. $w = $this->warehouse->find_all('1=1', 'id,title');
  1216. foreach ($w as $v) {
  1217. $wh[$v['id']] = $v['title'];
  1218. }
  1219. $post = $this->input->post(NULL, TRUE);
  1220. if (isset($post['page'])) {
  1221. $page = $this->input->post('page', true);
  1222. $perpage = $this->input->post('perpage', true);
  1223. $category = $this->input->post('category', true);
  1224. $size = $this->input->post('size', true);
  1225. $grade = $this->input->post('grade', true);
  1226. $color = $this->input->post('color', true);
  1227. $lowe = $this->input->post('lowe', true);
  1228. $sku = $this->input->post('sku');
  1229. $title = $this->input->post('title');
  1230. $warehouse = $this->input->post('warehouse', true);
  1231. $usa = $this->input->post('usa', true);
  1232. $purchase = $this->input->post('purchase', true);
  1233. $lacetype = $this->input->post('lacetype', true);
  1234. $haircap = $this->input->post('haircap', true);
  1235. $density = $this->input->post('density', true);
  1236. $details = $this->input->post('details', true);
  1237. $state = $this->input->post('state', true);
  1238. $shop = $this->input->post('shop', true);
  1239. $lacecolor = $this->input->post('lacecolor', true);
  1240. $hairnumber = $this->input->post('hairnumber', true);
  1241. $type = $this->input->post('type', true);
  1242. $ktime = $this->input->post('ktime', true);
  1243. $jtime = $this->input->post('jtime', true);
  1244. $ktime = strtotime($ktime);
  1245. $jtime = strtotime($jtime);
  1246. $cpbz = $this->input->post('cpbz', true);
  1247. $sm = $this->input->post('sm', true);
  1248. $where = "1=1";
  1249. $gj = "";
  1250. $ck = "";
  1251. if ($usa) {
  1252. if (!$warehouse) {
  1253. $where .= " and (warehouse = '5' or warehouse = '8')";
  1254. }
  1255. }
  1256. if ($warehouse) {
  1257. $where .= " and warehouse = '$warehouse'";
  1258. }
  1259. if ($details) {
  1260. $where .= " and details = '$details'";
  1261. }
  1262. if ($purchase) {
  1263. $where .= " and purchase = '$purchase'";
  1264. }
  1265. if ($state) {
  1266. $where .= " and state = '$state'";
  1267. }
  1268. if ($shop) {
  1269. $where .= " and shop like '%$shop%'";
  1270. }
  1271. if ($type) {
  1272. $where .= " and type = '$type'";
  1273. }
  1274. if ($ktime && $jtime) {
  1275. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1276. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1277. }
  1278. if ($cpbz) {
  1279. $where .= " and cpbz like '%$cpbz%' ";
  1280. }
  1281. if ($sm) {
  1282. $where .= " and sm like '%$sm%' ";
  1283. }
  1284. if ($lacecolor) {
  1285. $where .= " and features like '%-$lacecolor-%'";
  1286. }
  1287. if ($lacetype) {
  1288. $where .= " and features like '%-$lacetype-%'";
  1289. }
  1290. if ($category) {
  1291. $where .= " and features like '%-$category-%'";
  1292. }
  1293. if ($size) {
  1294. $where .= " and features like '%-$size-%'";
  1295. }
  1296. if ($grade) {
  1297. $where .= " and features like '%-$grade-%'";
  1298. }
  1299. if ($color) {
  1300. $where .= " and features like '%-$color-%'";
  1301. }
  1302. if ($lowe) {
  1303. $where .= " and features like '%-$lowe-%'";
  1304. }
  1305. if ($haircap) {
  1306. $where .= " and features like '%-$haircap-%'";
  1307. }
  1308. if ($density) {
  1309. $where .= " and features like '%-$density-%'";
  1310. }
  1311. if (!empty($hairnumber)) {
  1312. $where .= " and features like '%-128-%' ";
  1313. if ($hairnumber < 0) {
  1314. $class_list = $this->typeclass->find_all('classid = 43');
  1315. foreach ($class_list as $v) {
  1316. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1317. }
  1318. } else {
  1319. $where .= " and features like '%-$hairnumber-%'";
  1320. }
  1321. }
  1322. //数据排序
  1323. $order_str = "id desc";
  1324. if (empty($page)) {
  1325. $start = 0;
  1326. $perpage = 1;
  1327. } else {
  1328. $start = ($page - 1) * $perpage;
  1329. }
  1330. $fjnr = '';
  1331. if ($sku) {
  1332. $sku = trim($sku, ' ');
  1333. $sku = trim($sku, ' ');
  1334. $fjnr .= " and sku like '%$sku%'";
  1335. }
  1336. if ($title) {
  1337. $title = trim($title, ' ');
  1338. $title = trim($title, ' ');
  1339. $fjnr .= " and title like '%$title%'";
  1340. }
  1341. $wt = array();
  1342. $whlabel_type = $this->whlabel_type->find_all();
  1343. foreach ($whlabel_type as $v) {
  1344. $wt[$v['id']] = $v['title'];
  1345. }
  1346. //$where .= " and time > '$ktime' and time < '$jtime'";
  1347. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage); //改这需要修改_gbhtype
  1348. //取得信息列表
  1349. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1350. $rows = array();
  1351. $list = array();
  1352. foreach ($info_list as $key => $value) {
  1353. if (isset($wt[$value['type']])) {
  1354. $info_list[$key]['type'] = $wt[$value['type']];
  1355. } else {
  1356. $info_list[$key]['type'] = '未设置';
  1357. }
  1358. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1359. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  1360. $ztdata = '';
  1361. if (count($zt) > 0) {
  1362. foreach ($zt as $vv) {
  1363. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1364. }
  1365. }
  1366. $qbdata = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  1367. $cdata = array_filter($qbdata, function ($item) {
  1368. return $item['state'] < 1;
  1369. });
  1370. $c = array_sum(array_column($cdata, 'jnum'));
  1371. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1372. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1373. });
  1374. $g = array_sum(array_column($gdata, 'jnum'));
  1375. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1376. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1377. });
  1378. $x = array_sum(array_column($xdata, 'jnum'));
  1379. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1380. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1381. });
  1382. $t = array_sum(array_column($tdata, 'jnum'));
  1383. // $zdata = array_filter($qbdata, function ($item) {
  1384. // return $item['zd'] != "" && $item['state'] < 1;
  1385. // });
  1386. // $z = array_sum(array_column($zdata, 'jnum'));
  1387. $zdata = array_filter($qbdata, function ($item) {
  1388. return $item['zd'] != "" && $item['state'] < 1;
  1389. });
  1390. $z = array_sum(array_column($zdata, 'jnum'));
  1391. //$c = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"','details,cpid');
  1392. //$g = $this->whlabel->find_count($where.$gj.' and sku = "'.$value['sku'].'" and state < 100 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1393. //$x = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and state = 1 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1394. //$t = $this->whlabel->find_count($where.$ck.' and sku = "'.$value['sku'].'" and retreat > 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'"');
  1395. //$z = $this->whlabel->find_all($where.' and sku = "'.$value['sku'].'" and zd != "" and state = 0 and purchase = "'.$value['purchase'].'" and warehouse = "'.$value['warehouse'].'" and features = "'.$value['features'].'"');
  1396. $details = array();
  1397. $cpid = array();
  1398. $od = array();
  1399. $odid = '';
  1400. $companytitle = '';
  1401. $shop_list = [];
  1402. foreach ($qbdata as $v) {
  1403. if ($v['zd'] != "" && $v['state'] < 1) {
  1404. if (!isset($od[$v['zd']])) {
  1405. $od[$v['zd']] = 1; //所有数据sku
  1406. } else {
  1407. $od[$v['zd']] = $od[$v['zd']] + 1;
  1408. }
  1409. }
  1410. if($v['state'] == 0){
  1411. $details[$v['details']] = $v['details'];
  1412. }
  1413. if ($v['state'] < 1) {
  1414. //$details[$v['details']] = $v['details'];
  1415. if ($v['cpid'] != 0) {
  1416. $cpid[$v['cpid']] = $v['cpid'];
  1417. }
  1418. }
  1419. if($v['state'] == 0){
  1420. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1421. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1422. }
  1423. if ($v['shop'] != '') {
  1424. $shop = explode(',', trim($v['shop'], ','));
  1425. foreach ($shop as $vv) {
  1426. if (!in_array($vv, $shop_list)) {
  1427. $shop_list[] = $vv;
  1428. }
  1429. }
  1430. }
  1431. }
  1432. }
  1433. foreach ($od as $k => $vv) {
  1434. $odid .= $k . '数量' . $vv;
  1435. }
  1436. $info_list[$key]['cpbz'] = $value['cpbz'] ;
  1437. $info_list[$key]['label'] = $value['sm'];
  1438. $number = $value['number'];
  1439. $ftime = time() - 15 * 24 * 3600;
  1440. $z = $z . '(' . $odid . ')'; //查看订单号
  1441. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1442. $info_list[$key]['features'] = $c;
  1443. $info_list[$key]['number'] = $ztdata;
  1444. $info_list[$key]['sm'] = $g;
  1445. $info_list[$key]['x'] = $x;
  1446. $info_list[$key]['t'] = $t;
  1447. $info_list[$key]['z'] = $z;
  1448. /**
  1449. foreach ($cdata as $k=>$v)
  1450. {
  1451. $details[$v['details']] = $v['details'];
  1452. if($v['cpid'] != 0)
  1453. {
  1454. $cpid[$v['cpid']] = $v['cpid'];
  1455. }
  1456. }
  1457. **/
  1458. $info_list[$key]['shop'] = '';
  1459. $info_list[$key]['details'] = ($cpid) ? implode(" ", $details) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $details);
  1460. // if ($value['shop'] != '') {
  1461. // $shop = explode(',', trim($value['shop'], ','));
  1462. // $info_list[$key]['shop'] = '<p>' . $sp[$shop[0]] . '</p>';
  1463. // }
  1464. $shop_list = array_unique($shop_list);
  1465. $shop_str = '';
  1466. foreach ($shop_list as $v) {
  1467. if(isset($sp[$v])){
  1468. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1469. }
  1470. }
  1471. $info_list[$key]['shop'] = $shop_str.$companytitle;
  1472. /**
  1473. $companytitle = $this->whlabel->find_pc($where.$fjnr,'companytitle','companytitle');
  1474. if(isset($companytitle[0]))
  1475. {
  1476. foreach ($companytitle as $k=>$v)
  1477. {
  1478. if($v['companytitle'] != '')
  1479. {
  1480. $info_list[$key]['shop'] .= '<p>'.$company[$v['companytitle']].'</p>';
  1481. }
  1482. }
  1483. }
  1484. **/
  1485. }
  1486. $final_all_list = [];
  1487. foreach ($info_list as $k => $v) {
  1488. $final_all_list[] = [
  1489. 'id' => $v['id'],
  1490. "warehouse" => $v["warehouse"],
  1491. "purchase" => $v["purchase"],
  1492. "sku" => $v["sku"],
  1493. "title" => $v["title"] . "<br/>" . $v["pm"],
  1494. "details" => $v["details"],
  1495. "shop" => $v["shop"],
  1496. "cpbz" => $v["cpbz"],
  1497. 'label' => $v['label'],
  1498. "type" => $v["type"],
  1499. "features" => $v["features"],
  1500. "number" => $v["number"],
  1501. "sm" => $v["sm"],
  1502. "x" => $v["x"],
  1503. "t" => $v["t"],
  1504. "z" => $v["z"]
  1505. ];
  1506. }
  1507. $total = count($this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,sku,title,features,number'));
  1508. $pagenum = ceil($total / $perpage);
  1509. $over = $total - ($start + $perpage);
  1510. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1511. echo json_encode($rows);
  1512. exit;
  1513. }
  1514. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1515. $this->data['shop'] = $wlshop;
  1516. $this->data['vip'] = $vip;
  1517. $this->_Template('whlabel_type', $this->data);
  1518. }
  1519. /**
  1520. * _type 优化版 v1
  1521. * 优化点:
  1522. * 1. 循环内 N+1 查询改为批量预取(方案 A),SQL 从 2+2P 降到固定 4 条
  1523. * 2. 总数统计改为只 COUNT 不传输明细字段(方案 C)
  1524. * 3. 批量 qbdata 查询去掉 features like 条件,走组合键 IN 精确匹配
  1525. * 4. 批量 transport 查询加 ORDER BY stime 保证顺序与原来一致
  1526. */
  1527. public function _typev1()
  1528. {
  1529. $vip = 0;
  1530. if (isset($_SESSION['api'])) {
  1531. $user = $this->user->get_api($_SESSION['api']);
  1532. $fgshop = "";
  1533. $sid = "";
  1534. $usersp = explode('|', trim($user['shop'], '|'));
  1535. foreach ($usersp as $value) {
  1536. $fgshop .= " shop = " . $value . " or";
  1537. $sid .= " id = " . $value . " or";
  1538. }
  1539. if ($user['vip'] == 1) {
  1540. $vip = 1;
  1541. }
  1542. } else {
  1543. header('Location: /');
  1544. exit;
  1545. }
  1546. $prc = array();
  1547. $purchase = $this->purchase->find_all();
  1548. foreach ($purchase as $k => $v) {
  1549. $prc[$v['id']] = $v['title'];
  1550. }
  1551. $company = array();
  1552. $ct = $this->company->find_all();
  1553. foreach ($ct as $k => $v) {
  1554. $company[$v['id']] = $v['title'];
  1555. }
  1556. $sp = array();
  1557. $s = $this->shop->find_all('1=1', 'id,shopname');
  1558. foreach ($s as $v) {
  1559. $sp[$v['id']] = $v['shopname'];
  1560. }
  1561. $wh = array();
  1562. $w = $this->warehouse->find_all('1=1', 'id,title');
  1563. foreach ($w as $v) {
  1564. $wh[$v['id']] = $v['title'];
  1565. }
  1566. $post = $this->input->post(NULL, TRUE);
  1567. if (isset($post['page'])) {
  1568. $page = $this->input->post('page', true);
  1569. $perpage = $this->input->post('perpage', true);
  1570. $category = $this->input->post('category', true);
  1571. $size = $this->input->post('size', true);
  1572. $grade = $this->input->post('grade', true);
  1573. $color = $this->input->post('color', true);
  1574. $lowe = $this->input->post('lowe', true);
  1575. $sku = $this->input->post('sku');
  1576. $title = $this->input->post('title');
  1577. $warehouse = $this->input->post('warehouse', true);
  1578. $usa = $this->input->post('usa', true);
  1579. $purchase = $this->input->post('purchase', true);
  1580. $lacetype = $this->input->post('lacetype', true);
  1581. $haircap = $this->input->post('haircap', true);
  1582. $density = $this->input->post('density', true);
  1583. $details = $this->input->post('details', true);
  1584. $state = $this->input->post('state', true);
  1585. $shop = $this->input->post('shop', true);
  1586. $lacecolor = $this->input->post('lacecolor', true);
  1587. $hairnumber = $this->input->post('hairnumber', true);
  1588. $type = $this->input->post('type', true);
  1589. $ktime = $this->input->post('ktime', true);
  1590. $jtime = $this->input->post('jtime', true);
  1591. $ktime = strtotime($ktime);
  1592. $jtime = strtotime($jtime);
  1593. $cpbz = $this->input->post('cpbz', true);
  1594. $sm = $this->input->post('sm', true);
  1595. $where = "1=1";
  1596. // $where_no_features 用于批量预取,去掉 features like 条件,靠组合键精确匹配
  1597. $where_no_features = "1=1";
  1598. if ($usa) {
  1599. if (!$warehouse) {
  1600. $where .= " and (warehouse = '5' or warehouse = '8')";
  1601. $where_no_features .= " and (warehouse = '5' or warehouse = '8')";
  1602. }
  1603. }
  1604. if ($warehouse) {
  1605. $where .= " and warehouse = '$warehouse'";
  1606. $where_no_features .= " and warehouse = '$warehouse'";
  1607. }
  1608. if ($details) {
  1609. $where .= " and details = '$details'";
  1610. $where_no_features .= " and details = '$details'";
  1611. }
  1612. if ($purchase) {
  1613. $where .= " and purchase = '$purchase'";
  1614. $where_no_features .= " and purchase = '$purchase'";
  1615. }
  1616. if ($state) {
  1617. $where .= " and state = '$state'";
  1618. $where_no_features .= " and state = '$state'";
  1619. }
  1620. if ($shop) {
  1621. $where .= " and shop like '%$shop%'";
  1622. $where_no_features .= " and shop like '%$shop%'";
  1623. }
  1624. if ($type) {
  1625. $where .= " and type = '$type'";
  1626. $where_no_features .= " and type = '$type'";
  1627. }
  1628. if ($cpbz) {
  1629. $where .= " and cpbz like '%$cpbz%' ";
  1630. $where_no_features .= " and cpbz like '%$cpbz%' ";
  1631. }
  1632. if ($sm) {
  1633. $where .= " and sm like '%$sm%' ";
  1634. $where_no_features .= " and sm like '%$sm%' ";
  1635. }
  1636. // features like 条件只加入 $where(列表分组用),不加入 $where_no_features
  1637. if ($lacecolor) {
  1638. $where .= " and features like '%-$lacecolor-%'";
  1639. }
  1640. if ($lacetype) {
  1641. $where .= " and features like '%-$lacetype-%'";
  1642. }
  1643. if ($category) {
  1644. $where .= " and features like '%-$category-%'";
  1645. }
  1646. if ($size) {
  1647. $where .= " and features like '%-$size-%'";
  1648. }
  1649. if ($grade) {
  1650. $where .= " and features like '%-$grade-%'";
  1651. }
  1652. if ($color) {
  1653. $where .= " and features like '%-$color-%'";
  1654. }
  1655. if ($lowe) {
  1656. $where .= " and features like '%-$lowe-%'";
  1657. }
  1658. if ($haircap) {
  1659. $where .= " and features like '%-$haircap-%'";
  1660. }
  1661. if ($density) {
  1662. $where .= " and features like '%-$density-%'";
  1663. }
  1664. if (!empty($hairnumber)) {
  1665. $where .= " and features like '%-128-%' ";
  1666. if ($hairnumber < 0) {
  1667. $class_list = $this->typeclass->find_all('classid = 43');
  1668. foreach ($class_list as $v) {
  1669. $where .= " and features not like '%-" . $v['id'] . "-%'";
  1670. }
  1671. } else {
  1672. $where .= " and features like '%-$hairnumber-%'";
  1673. }
  1674. }
  1675. //数据排序
  1676. $order_str = "id desc";
  1677. if (empty($page)) {
  1678. $start = 0;
  1679. $perpage = 1;
  1680. } else {
  1681. $start = ($page - 1) * $perpage;
  1682. }
  1683. $fjnr = '';
  1684. if ($sku) {
  1685. $sku = trim($sku, ' ');
  1686. $sku = trim($sku, ' ');
  1687. $fjnr .= " and sku like '%$sku%'";
  1688. }
  1689. if ($title) {
  1690. $title = trim($title, ' ');
  1691. $title = trim($title, ' ');
  1692. $fjnr .= " and title like '%$title%'";
  1693. }
  1694. $wt = array();
  1695. $whlabel_type = $this->whlabel_type->find_all();
  1696. foreach ($whlabel_type as $v) {
  1697. $wt[$v['id']] = $v['title'];
  1698. }
  1699. // 列表分组(与原来完全一致)
  1700. $info_list = $this->whlabel->find_pc($where . $fjnr, 'sku,purchase,features,warehouse', 'id,warehouse,purchase,sku,title,details,shop,cpbz,label,type,features,number,sm', $order_str, $start, $perpage);
  1701. //取得信息列表
  1702. $info_list = $this->logic_whlabel->dataTran($info_list, ['pm']);
  1703. // ========== 优化方案 A:批量预取 whlabel 组数据和 transport 数据 ==========
  1704. $keys = array();
  1705. foreach ($info_list as $v) {
  1706. $keys[] = "('" . addslashes($v['sku']) . "','" . addslashes($v['purchase'])
  1707. . "','" . addslashes($v['features']) . "','" . addslashes($v['warehouse']) . "')";
  1708. }
  1709. // 组合键函数,用于 PHP 端按分组索引
  1710. $comboKey = function ($r) {
  1711. return $r['sku'] . '|' . $r['purchase'] . '|' . $r['features'] . '|' . $r['warehouse'];
  1712. };
  1713. // 批量拉取 whlabel 组数据(使用 $where_no_features,不带 features like,靠 IN 元组精确匹配)
  1714. $all_qb = array();
  1715. if (!empty($keys)) {
  1716. $keyInSql = implode(',', $keys);
  1717. $qbAll = $this->whlabel->find_all(
  1718. $where_no_features . " and (sku,purchase,features,warehouse) IN (" . $keyInSql . ")"
  1719. );
  1720. foreach ($qbAll as $r) {
  1721. $all_qb[$comboKey($r)][] = $r;
  1722. }
  1723. }
  1724. // 批量拉取 transport 在途数据(3 列元组: sku,warehouse,features,与 IN 左侧列顺序一致)
  1725. $all_zt = array();
  1726. if (!empty($info_list)) {
  1727. $ztKeys = array();
  1728. foreach ($info_list as $v) {
  1729. $ztKeys[] = "('" . addslashes($v['sku']) . "','"
  1730. . addslashes($v['warehouse']) . "','"
  1731. . addslashes($v['features']) . "')";
  1732. }
  1733. $ztInSql = implode(',', $ztKeys);
  1734. $ztAll = $this->whlabeltransport->find_all(
  1735. "cz = '0' and (sku,warehouse,features) IN (" . $ztInSql . ")",
  1736. '*',
  1737. 'stime'
  1738. );
  1739. foreach ($ztAll as $r) {
  1740. $ck = $r['sku'] . '|' . $r['warehouse'] . '|' . $r['features'];
  1741. $all_zt[$ck][] = $r;
  1742. }
  1743. }
  1744. $rows = array();
  1745. $list = array();
  1746. foreach ($info_list as $key => $value) {
  1747. if (isset($wt[$value['type']])) {
  1748. $info_list[$key]['type'] = $wt[$value['type']];
  1749. } else {
  1750. $info_list[$key]['type'] = '未设置';
  1751. }
  1752. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  1753. // transport 在途数据:从预取数组中取
  1754. $ztCk = $value['sku'] . '|' . $value['warehouse'] . '|' . $value['features'];
  1755. $zt = isset($all_zt[$ztCk]) ? $all_zt[$ztCk] : array();
  1756. $ztdata = '';
  1757. if (count($zt) > 0) {
  1758. foreach ($zt as $vv) {
  1759. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  1760. }
  1761. }
  1762. // whlabel 组数据:从预取数组中取
  1763. $qbCk = $comboKey($value);
  1764. $qbdata = isset($all_qb[$qbCk]) ? $all_qb[$qbCk] : array();
  1765. $cdata = array_filter($qbdata, function ($item) {
  1766. return $item['state'] < 1;
  1767. });
  1768. $c = array_sum(array_column($cdata, 'jnum'));
  1769. $gdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1770. return $item['state'] < 100 && $item['enter'] > $ktime && $item['enter'] < $jtime;
  1771. });
  1772. $g = array_sum(array_column($gdata, 'jnum'));
  1773. $xdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1774. return $item['state'] == 1 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1775. });
  1776. $x = array_sum(array_column($xdata, 'jnum'));
  1777. $tdata = array_filter($qbdata, function ($item) use ($ktime, $jtime) {
  1778. return $item['retreat'] > 0 && $item['outk'] > $ktime && $item['outk'] < $jtime;
  1779. });
  1780. $t = array_sum(array_column($tdata, 'jnum'));
  1781. $zdata = array_filter($qbdata, function ($item) {
  1782. return $item['zd'] != "" && $item['state'] < 1;
  1783. });
  1784. $z = array_sum(array_column($zdata, 'jnum'));
  1785. $detailsArr = array();
  1786. $cpid = array();
  1787. $od = array();
  1788. $odid = '';
  1789. $companytitle = '';
  1790. $shop_list = [];
  1791. foreach ($qbdata as $v) {
  1792. if ($v['zd'] != "" && $v['state'] < 1) {
  1793. if (!isset($od[$v['zd']])) {
  1794. $od[$v['zd']] = 1;
  1795. } else {
  1796. $od[$v['zd']] = $od[$v['zd']] + 1;
  1797. }
  1798. }
  1799. if ($v['state'] == 0) {
  1800. $detailsArr[$v['details']] = $v['details'];
  1801. }
  1802. if ($v['state'] < 1) {
  1803. if ($v['cpid'] != 0) {
  1804. $cpid[$v['cpid']] = $v['cpid'];
  1805. }
  1806. }
  1807. if ($v['state'] == 0) {
  1808. if ($v['companytitle'] != '' && stripos($companytitle, $company[$v['companytitle']]) === false) {
  1809. $companytitle .= '<p>' . $company[$v['companytitle']] . '</p>';
  1810. }
  1811. if ($v['shop'] != '') {
  1812. $shopArr = explode(',', trim($v['shop'], ','));
  1813. foreach ($shopArr as $vv) {
  1814. if (!in_array($vv, $shop_list)) {
  1815. $shop_list[] = $vv;
  1816. }
  1817. }
  1818. }
  1819. }
  1820. }
  1821. foreach ($od as $k => $vv) {
  1822. $odid .= $k . '数量' . $vv;
  1823. }
  1824. $info_list[$key]['cpbz'] = $value['cpbz'];
  1825. $info_list[$key]['label'] = $value['sm'];
  1826. $number = $value['number'];
  1827. $z = $z . '(' . $odid . ')';
  1828. $info_list[$key]['warehouse'] = isset($wh[$value['warehouse']]) ? $wh[$value['warehouse']] : '无';
  1829. $info_list[$key]['features'] = $c;
  1830. $info_list[$key]['number'] = $ztdata;
  1831. $info_list[$key]['sm'] = $g;
  1832. $info_list[$key]['x'] = $x;
  1833. $info_list[$key]['t'] = $t;
  1834. $info_list[$key]['z'] = $z;
  1835. $info_list[$key]['shop'] = '';
  1836. $info_list[$key]['details'] = ($cpid) ? implode(" ", $detailsArr) . '<p>' . implode(" ", $cpid) . '</p>' : implode(" ", $detailsArr);
  1837. $shop_list = array_unique($shop_list);
  1838. $shop_str = '';
  1839. foreach ($shop_list as $v) {
  1840. if (isset($sp[$v])) {
  1841. $shop_str .= '<p>' . $sp[$v] . '</p>';
  1842. }
  1843. }
  1844. $info_list[$key]['shop'] = $shop_str . $companytitle;
  1845. }
  1846. $final_all_list = [];
  1847. foreach ($info_list as $k => $v) {
  1848. $final_all_list[] = [
  1849. 'id' => $v['id'],
  1850. "warehouse" => $v["warehouse"],
  1851. "purchase" => $v["purchase"],
  1852. "sku" => $v["sku"],
  1853. "title" => $v["title"] . "<br/>" . $v["pm"],
  1854. "details" => $v["details"],
  1855. "shop" => $v["shop"],
  1856. "cpbz" => $v["cpbz"],
  1857. 'label' => $v['label'],
  1858. "type" => $v["type"],
  1859. "features" => $v["features"],
  1860. "number" => $v["number"],
  1861. "sm" => $v["sm"],
  1862. "x" => $v["x"],
  1863. "t" => $v["t"],
  1864. "z" => $v["z"]
  1865. ];
  1866. }
  1867. // ========== 优化方案 C:总数统计只 COUNT,不传明细字段 ==========
  1868. // 原实现: count(find_pc(..., 'id,warehouse,sku,title,features,number')),传输了大量明细字段
  1869. // 优化为: SELECT COUNT(*) FROM (SELECT 1 FROM whlabel WHERE ... GROUP BY ...) t,只传一个数字
  1870. $countSql = "SELECT COUNT(*) AS cnt FROM (SELECT 1 FROM crowd_whlabel WHERE " . $where . $fjnr . " GROUP BY sku,purchase,features,warehouse) t";
  1871. $countResult = $this->whlabel->query($countSql)->result_array();
  1872. $total = isset($countResult[0]['cnt']) ? (int)$countResult[0]['cnt'] : 0;
  1873. $pagenum = ceil($total / $perpage);
  1874. $over = $total - ($start + $perpage);
  1875. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($final_all_list));
  1876. echo json_encode($rows);
  1877. exit;
  1878. }
  1879. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  1880. $this->data['shop'] = $wlshop;
  1881. $this->data['vip'] = $vip;
  1882. $this->_Template('whlabel_typev1', $this->data);
  1883. }
  1884. //美仓进销存浏览
  1885. public function _usatype()
  1886. {
  1887. if (isset($_SESSION['api'])) {
  1888. $user = $this->user->get_api($_SESSION['api']);
  1889. $usp = $user;
  1890. $fgshop = "";
  1891. $sid = "";
  1892. $wid = "";
  1893. $wtype = "";
  1894. $userwh = explode('|', trim($user['warehouse'], '|'));
  1895. foreach ($userwh as $value) {
  1896. $wid .= " id = " . $value . " or";
  1897. $wtype .= " type = " . $value . " or";
  1898. }
  1899. }
  1900. $prc = array();
  1901. $purchase = $this->purchase->find_all();
  1902. foreach ($purchase as $k => $v) {
  1903. $prc[$v['id']] = $v['title'];
  1904. }
  1905. $post = $this->input->post(NULL, TRUE);
  1906. if (isset($post['page'])) {
  1907. $page = $this->input->post('page', true);
  1908. $perpage = $this->input->post('perpage', true);
  1909. $category = $this->input->post('category', true);
  1910. $size = $this->input->post('size', true);
  1911. $grade = $this->input->post('grade', true);
  1912. $color = $this->input->post('color', true);
  1913. $lowe = $this->input->post('lowe', true);
  1914. $sku = $this->input->post('sku');
  1915. $title = $this->input->post('title');
  1916. $warehouse = $this->input->post('warehouse', true);
  1917. $usa = $this->input->post('usa', true);
  1918. $purchase = $this->input->post('purchase', true);
  1919. $lacetype = $this->input->post('lacetype', true);
  1920. $haircap = $this->input->post('haircap', true);
  1921. $density = $this->input->post('density', true);
  1922. $details = $this->input->post('details', true);
  1923. $state = $this->input->post('state', true);
  1924. $lacecolor = $this->input->post('lacecolor', true);
  1925. $cklx = $this->input->post('cklx', true);
  1926. $ktime = $this->input->post('ktime', true);
  1927. $jtime = $this->input->post('jtime', true);
  1928. $ktime = strtotime($ktime);
  1929. $jtime = strtotime($jtime);
  1930. $where = "1=1";
  1931. $gj = "";
  1932. $ck = "";
  1933. if ($lacetype) {
  1934. $where .= " and features like '%-$lacetype-%'";
  1935. }
  1936. if ($category) {
  1937. $where .= " and features like '%-$category-%'";
  1938. }
  1939. if ($size) {
  1940. $where .= " and features like '%-$size-%'";
  1941. }
  1942. if ($grade) {
  1943. $where .= " and features like '%-$grade-%'";
  1944. }
  1945. if ($color) {
  1946. $where .= " and features like '%-$color-%'";
  1947. }
  1948. if ($lowe) {
  1949. $where .= " and features like '%-$lowe-%'";
  1950. }
  1951. if ($haircap) {
  1952. $where .= " and features like '%-$haircap-%'";
  1953. }
  1954. if ($density) {
  1955. $where .= " and features like '%-$density-%'";
  1956. }
  1957. if ($lacecolor) {
  1958. $where .= " and features like '%-$lacecolor-%'";
  1959. }
  1960. if ($usa) {
  1961. if (!$warehouse) {
  1962. $where .= " and (warehouse = '5' or warehouse = '8')";
  1963. }
  1964. }
  1965. if ($warehouse) {
  1966. $where .= " and warehouse = '$warehouse'";
  1967. }
  1968. if ($details) {
  1969. $where .= " and details = '$details'";
  1970. }
  1971. if ($purchase) {
  1972. $where .= " and purchase = '$purchase'";
  1973. }
  1974. if ($state) {
  1975. $where .= " and state = '$state'";
  1976. }
  1977. $where_add = '';
  1978. if ($cklx) {
  1979. $shop = $this->shop->read($cklx);
  1980. $where_add .= " and zd like '" . $shop['shortname'] . "%' and state = 0";
  1981. }
  1982. if ($ktime && $jtime) {
  1983. $gj = " and enter > '$ktime' and enter < '$jtime'";
  1984. $ck = " and outk > '$ktime' and outk < '$jtime'";
  1985. }
  1986. //数据排序
  1987. $order_str = "id desc";
  1988. if (empty($page)) {
  1989. $start = 0;
  1990. $perpage = 1;
  1991. } else {
  1992. $start = ($page - 1) * $perpage;
  1993. }
  1994. if ($sku) {
  1995. $sku = trim($sku, ' ');
  1996. $sku = trim($sku, ' ');
  1997. $where .= " and sku like '%$sku%'";
  1998. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  1999. } else if ($title) {
  2000. $title = trim($title, ' ');
  2001. $title = trim($title, ' ');
  2002. $where .= " and title like '%$title%'";
  2003. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2004. } else {
  2005. //$where .= " and time > '$ktime' and time < '$jtime'";
  2006. $info_list = $this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,sku,title,features,warehouse', $order_str, $start, $perpage);
  2007. }
  2008. //取得信息列表
  2009. $rows = array();
  2010. $list = array();
  2011. foreach ($info_list as $key => $value) {
  2012. $warehouse = $this->warehouse->read($value['warehouse']);
  2013. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2014. $g = $this->whlabel->find_count($where . $gj . ' and sku = "' . $value['sku'] . '" and state < 100 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2015. $x = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2016. $t = $this->whlabel->find_count($where . $ck . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2017. $z = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  2018. $od = array();
  2019. $odid = '';
  2020. foreach ($z as $v) {
  2021. if (!isset($od[$v['zd']])) {
  2022. $od[$v['zd']] = 1; //所有数据sku
  2023. } else {
  2024. $od[$v['zd']] = $od[$v['zd']] + 1;
  2025. }
  2026. }
  2027. foreach ($od as $k => $vv) {
  2028. $odid .= $k . '数量' . $vv . ' ';
  2029. }
  2030. $z = count($z) . '(' . $odid . ')'; //查看订单号
  2031. $info_list[$key]['features'] = $c;
  2032. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and cz = "0"');
  2033. $ztdata = '';
  2034. if (count($zt) > 0) {
  2035. foreach ($zt as $vv) {
  2036. $ztdata .= '<p>' . $vv['num'] . ' - ' . date('Y-m-d', $vv['stime']) . '</p>';
  2037. }
  2038. }
  2039. $info_list[$key]['warehouse'] = $ztdata;
  2040. $info_list[$key]['g'] = $g;
  2041. $info_list[$key]['x'] = $x;
  2042. $info_list[$key]['t'] = $t;
  2043. $info_list[$key]['z'] = $z;
  2044. }
  2045. $total = count($this->whlabel->find_pc($where . $where_add, 'sku,features,warehouse', 'id,warehouse,sku,title'));
  2046. $pagenum = ceil($total / $perpage);
  2047. $over = $total - ($start + $perpage);
  2048. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list), 'CS' => $warehouse);
  2049. echo json_encode($rows);
  2050. exit;
  2051. }
  2052. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  2053. $this->data['warehouse'] = $warehouse;
  2054. $this->_Template('whlabel_typeusa', $this->data);
  2055. }
  2056. //美仓进销存浏览
  2057. public function _usatypeapp()
  2058. {
  2059. $post = $this->input->post(NULL, TRUE);
  2060. if (isset($post['page'])) {
  2061. $page = $this->input->post('page', true);
  2062. $perpage = $this->input->post('perpage', true);
  2063. $sku = $this->input->post('sku', true);
  2064. $warehouse = 5;
  2065. $title = $this->input->post('title', true);
  2066. $state = $this->input->post('state', true);
  2067. $ktime = $this->input->post('ktime', true);
  2068. $jtime = $this->input->post('jtime', true);
  2069. $ktime = strtotime($ktime);
  2070. $jtime = strtotime($jtime);
  2071. $where = "1=1";
  2072. $gj = "";
  2073. $ck = "";
  2074. if ($title) {
  2075. $st = explode(' ', trim($title, ' '));
  2076. foreach ($st as $v) {
  2077. $where .= " and title like '%$v%'";
  2078. }
  2079. }
  2080. if ($warehouse) {
  2081. $where .= " and warehouse = '$warehouse'";
  2082. }
  2083. if ($state) {
  2084. $where .= " and state = '$state'";
  2085. }
  2086. if ($sku) {
  2087. $where .= " and sku like '%$sku%'";
  2088. }
  2089. if ($ktime && $jtime) {
  2090. $gj = " and enter > '$ktime' and enter < '$jtime'";
  2091. $ck = " and outk > '$ktime' and outk < '$jtime'";
  2092. }
  2093. //数据排序
  2094. $order_str = "id desc";
  2095. if (empty($page)) {
  2096. $start = 0;
  2097. $perpage = 1;
  2098. } else {
  2099. $start = ($page - 1) * $perpage;
  2100. }
  2101. //取得信息列表
  2102. $info_list = $this->whlabel->find_all($where . ' and ' . rtrim($wid, 'or'), '*');
  2103. $rows = array();
  2104. $list = array();
  2105. foreach ($info_list as $key => $value) {
  2106. $rows[strtolower($value['sku']) . 'warehouse' . $value['warehouse']] = $value; //所有数据sku
  2107. }
  2108. $rowsdq = array_slice($rows, $start, $perpage);
  2109. foreach ($rowsdq as $value) {
  2110. $warehouse = $this->warehouse->read($value['warehouse']);
  2111. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '"');
  2112. $x = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and state = 1 and warehouse = "' . $value['warehouse'] . '"');
  2113. $t = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and retreat > 0 and warehouse = "' . $value['warehouse'] . '"');
  2114. $od = array();
  2115. $odid = '';
  2116. $list[] = array('id' => $value['id'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'x' => $x, 't' => $t);
  2117. }
  2118. $total = count($rows);
  2119. $pagenum = ceil($total / $perpage);
  2120. $over = $total - ($start + $perpage);
  2121. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2122. echo json_encode($rows);
  2123. exit;
  2124. }
  2125. $this->_Template('phone/p_usatypeapp', $this->data);
  2126. }
  2127. //入库操作
  2128. public function _enteradd()
  2129. {
  2130. $dt = 0;
  2131. if (isset($_SESSION['api'])) {
  2132. $user = $this->user->get_api($_SESSION['api']);
  2133. $usp = $user;
  2134. $fgshop = "";
  2135. $sid = "";
  2136. $user = explode('|', trim($user['shop'], '|'));
  2137. foreach ($user as $value) {
  2138. $fgshop .= " shop = " . $value . " or";
  2139. $sid .= " id = " . $value . " or";
  2140. }
  2141. }
  2142. $tc = $this->typeclass->find_all();
  2143. $typeclass = array();
  2144. foreach ($tc as $v) {
  2145. $tcjm[$v['id']] = array($v['jm'], $v['classid']);
  2146. $typeclass[$v['id']] = array('zh' => $v['zh'], 'classid' => $v['classid'], 'bm' => $v['bm'], 'title' => $v['title'], 'bqsku' => $v['bqsku']);
  2147. }
  2148. $post = $this->input->post(NULL, TRUE);
  2149. if (isset($post['sku'])) {
  2150. $list = array();
  2151. $num = "";
  2152. $title = "";
  2153. $features = "";
  2154. $order = $this->input->post('order', true);
  2155. $shop = $this->input->post('shop', true);
  2156. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2157. $sku = $this->input->post('sku', true);
  2158. $post['sm'] = $this->input->post('sm', true);
  2159. $post['warehouse'] = $this->input->post('warehouse', true);
  2160. $post['purchase'] = $this->input->post('purchase', true);
  2161. $post['retreatwarehouse'] = $post['warehouse'];
  2162. $post['state'] = $this->input->post('state', true);
  2163. $post['rktype'] = $this->input->post('rktype', true);
  2164. $post['text'] = $this->input->post('text', true);
  2165. $category = $this->input->post('category', true);
  2166. $list['category'] = $category;
  2167. $list['hairtype'] = $this->input->post('hairtype', true);
  2168. $list['grade'] = $this->input->post('grade', true);
  2169. $size = $this->input->post('size', true);
  2170. $xzsku = $this->input->post('xzsku', true);
  2171. $list['size'] = rtrim($size, ',');
  2172. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2173. $list['extension'] = $this->input->post('extension', true);
  2174. if ($category == 1297) {
  2175. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2176. }
  2177. if ($category == 1702) {
  2178. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2179. $list['syother'] = $this->input->post('syother', true);
  2180. }
  2181. if ($category == 133) {
  2182. $list['fittype'] = $this->input->post('fittype', true);
  2183. $list['acother'] = $this->input->post('acother', true);
  2184. }
  2185. $list['color'] = $this->input->post('color', true);
  2186. $list['lowe'] = $this->input->post('lowe', true);
  2187. if (!$post['purchase']) {
  2188. $post['purchase'] = 1;
  2189. }
  2190. if ($category == 127) {
  2191. $list['type'] = $this->input->post('type', true);
  2192. $list['headroad'] = $this->input->post('headroad', true);
  2193. $list['density'] = $this->input->post('density', true);
  2194. $list['lacesize'] = $this->input->post('lacesize', true);
  2195. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2196. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2197. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  2198. }
  2199. if ($category == 128) {
  2200. $list['lacetype'] = $this->input->post('lacetype', true);
  2201. $list['haircap'] = $this->input->post('haircap', true);
  2202. $list['density'] = $this->input->post('density', true);
  2203. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2204. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2205. $list['wigother'] = $this->input->post('wigother', true);
  2206. $list['wigother1'] = $this->input->post('wigother1', true);
  2207. $list['wigother2'] = $this->input->post('wigother2', true);
  2208. $list['product_related'] = $this->input->post('product_related', true);
  2209. }
  2210. if ($category == 129) {
  2211. $list['wide'] = $this->input->post('wide', true);
  2212. }
  2213. if ($category == 131) {
  2214. $list['gifttype'] = $this->input->post('gifttype', true);
  2215. $list['giftother'] = $this->input->post('giftother', true);
  2216. }
  2217. if ($category == 134) {
  2218. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2219. }
  2220. if ($category == 1297) {
  2221. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2222. $list['sywigother'] = $this->input->post('sywigother', true);
  2223. }
  2224. if ($category == 130 || $category == 133 || $category == 1702) {
  2225. $list['items'] = $this->input->post('items', true);
  2226. $list['weight'] = $this->input->post('weight', true);
  2227. }
  2228. if($category == 130){
  2229. $list['jfother'] = $this->input->post('jfother', true);
  2230. }
  2231. if ($category == 1702) {
  2232. $list['syhairther'] = $this->input->post('syhairther', true);
  2233. }
  2234. $classid = $this->classid->sku();
  2235. $scsku = $classid;
  2236. $pm = $classid;
  2237. foreach ($list as $k => $v) {
  2238. if ($v != 0) {
  2239. $num .= $v;
  2240. $features .= $v . '-';
  2241. $post[$k] = $v;
  2242. if($k == 'hairtype'){
  2243. if(!in_array($v,[163,164,165,166])){
  2244. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2245. }
  2246. }else{
  2247. $scsku[$typeclass[$v]['classid']] = $typeclass[$v]['bqsku'];
  2248. }
  2249. if ($k != 'size') {
  2250. $title .= $typeclass[$v]['title'] . " ";
  2251. }
  2252. if (isset($pm[$typeclass[$v]['classid']])) {
  2253. if ($typeclass[$v]['title'] == '9A') {
  2254. $pm[$typeclass[$v]['classid']] = '9A';
  2255. } else if ($typeclass[$v]['title'] == '10A') {
  2256. $pm[$typeclass[$v]['classid']] = '10A';
  2257. } else {
  2258. $clzh = $typeclass[$v]['zh'];
  2259. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  2260. $clzh = explode('|', rtrim($typeclass[$v]['zh'], '|'));
  2261. $clzh = $clzh[0];
  2262. }
  2263. if($k == 'hairtype'){
  2264. if(!in_array($v,[163,164,165,166])){
  2265. $pm[$typeclass[$v]['classid']] = $clzh;
  2266. }
  2267. }else{
  2268. $pm[$typeclass[$v]['classid']] = $clzh;
  2269. }
  2270. }
  2271. }
  2272. }
  2273. }
  2274. $zh = implode(" ", $pm);
  2275. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  2276. $zh = preg_replace("/\r\n|\r|\n/", '', trim($zh, ' '));
  2277. if ($list['size']) {
  2278. $typeclass = $this->typeclass->read($list['size']);
  2279. $title .= $typeclass['title'];
  2280. }
  2281. $time = time();
  2282. if ($xzsku) {
  2283. $scsku = implode("-", $scsku);
  2284. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  2285. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  2286. $post['sku'] = trim($scsku, ' ');
  2287. } else {
  2288. $post['sku'] = $sku;
  2289. }
  2290. //$post['sku'] = trim($sku,' ');
  2291. $post['title'] = rtrim($title, ' ');
  2292. $post['number'] = $num;
  2293. $post['features'] = '-' . $features;
  2294. $post['enter'] = $time;
  2295. $post['time'] = $time; //操作时间
  2296. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2297. if ($yza) {
  2298. if ($post['features'] != $yza[0]['features']) {
  2299. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'success' => false));
  2300. exit;
  2301. }
  2302. }
  2303. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  2304. if ($yzb) {
  2305. if ($post['sku'] != $yzb[0]['sku']) {
  2306. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'success' => false));
  2307. exit;
  2308. }
  2309. }
  2310. if (isset($yza[0]) && $post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2311. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2312. exit;
  2313. }
  2314. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2315. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2316. exit;
  2317. }
  2318. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2319. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2320. exit;
  2321. }
  2322. $yz = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'", 'type');
  2323. if (isset($yz[0]['type'])) {
  2324. $post['type'] = $yz[0]['type'];
  2325. }
  2326. if ($post['state'] == 9) //如果选择预设库存
  2327. {
  2328. $this->whlabel->insert($post);
  2329. } else {
  2330. /**
  2331. $ljg = $this->ljg->get_enteradd(array('sku'=>$post['sku'],'title'=>$post['title'],'number'=>$order));
  2332. if($ljg == 1)
  2333. {
  2334. for($i=0;$i<$order;$i++)
  2335. {
  2336. $post['label'] = time().rand(100,999).$i;//产品标签 辨别各个产品,暂不使用
  2337. $this->whlabel->insert($post);
  2338. }
  2339. }
  2340. **/
  2341. //if($post['warehouse'] == '5')
  2342. //{
  2343. //}
  2344. $yydata = $post;
  2345. $yydata['zh'] = $zh;
  2346. /**
  2347. $wl = $this->apiyy->get_cjlp($yydata);
  2348. if(!isset($wl['Data'][0]['m_isSucess']) || $wl['Data'][0]['m_isSucess'] != 1)
  2349. {
  2350. echo json_encode(array('msg'=>'用友ERP写入失败,请重试','success'=>false));exit;
  2351. }
  2352. if($wl['Data'][0]['m_isSucess'] != 1)
  2353. {
  2354. echo json_encode(array('msg'=>$wl['Data'][0]['m_errorMsg'],'success'=>false));exit;
  2355. }
  2356. **/
  2357. for ($i = 0; $i < $order; $i++) {
  2358. $post['label'] = time() . rand(100, 999) . $i; //产品标签 辨别各个产品,暂不使用
  2359. $this->whlabel->insert($post);
  2360. }
  2361. }
  2362. echo json_encode(array('msg' => '入库成功', 'success' => true));
  2363. exit;
  2364. }
  2365. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2366. $this->data['wlshop'] = $wlshop;
  2367. $this->_Template('whlabel_enteradd', $this->data);
  2368. }
  2369. //修改产品
  2370. public function _enteredit($arg_array)
  2371. {
  2372. $dt = 0;
  2373. if (isset($_SESSION['api'])) {
  2374. $user = $this->user->get_api($_SESSION['api']);
  2375. $usp = $user;
  2376. $fgshop = "";
  2377. $sid = "";
  2378. $user = explode('|', trim($user['shop'], '|'));
  2379. foreach ($user as $value) {
  2380. $fgshop .= " shop = " . $value . " or";
  2381. $sid .= " id = " . $value . " or";
  2382. }
  2383. }
  2384. $post = $this->input->post(NULL, TRUE);
  2385. if (isset($post['sku'])) {
  2386. $list = array();
  2387. $num = "";
  2388. $title = "";
  2389. $features = "";
  2390. $id = $this->input->post('id', true);
  2391. $order = $this->input->post('order', true);
  2392. $shop = $this->input->post('shop', true);
  2393. $post['shop'] = ($shop != "") ? ',' . $shop : "";
  2394. $post['sku'] = $this->input->post('sku', true);
  2395. $post['sm'] = $this->input->post('sm', true);
  2396. $post['warehouse'] = $this->input->post('warehouse', true);
  2397. $post['purchase'] = $this->input->post('purchase', true);
  2398. $post['retreatwarehouse'] = $post['warehouse'];
  2399. $category = $this->input->post('category', true);
  2400. $list['category'] = $category;
  2401. $list['hairtype'] = $this->input->post('hairtype', true);
  2402. $list['grade'] = $this->input->post('grade', true);
  2403. $size = $this->input->post('size', true);
  2404. $list['size'] = rtrim($size, ',');
  2405. $post['rktype'] = $this->input->post('rktype', true);
  2406. $post['text'] = $this->input->post('text', true);
  2407. $list['hairnumber'] = $this->input->post('hairnumber', true);
  2408. $list['extension'] = $this->input->post('extension', true);
  2409. if ($category == 1297) {
  2410. $list['sywignumber'] = $this->input->post('sywignumber', true);
  2411. }
  2412. if ($category == 1702) {
  2413. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  2414. $list['syother'] = $this->input->post('syother', true);
  2415. }
  2416. if ($category == 133) {
  2417. $list['fittype'] = $this->input->post('fittype', true);
  2418. $list['acother'] = $this->input->post('acother', true);
  2419. }
  2420. $list['color'] = $this->input->post('color', true);
  2421. $list['lowe'] = $this->input->post('lowe', true);
  2422. if (!$post['purchase']) {
  2423. $post['purchase'] = 1;
  2424. }
  2425. if ($category == 127) {
  2426. $list['type'] = $this->input->post('type', true);
  2427. $list['headroad'] = $this->input->post('headroad', true);
  2428. $list['density'] = $this->input->post('density', true);
  2429. $list['lacesize'] = $this->input->post('lacesize', true);
  2430. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2431. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2432. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  2433. }
  2434. if ($category == 128) {
  2435. $list['lacetype'] = $this->input->post('lacetype', true);
  2436. $list['haircap'] = $this->input->post('haircap', true);
  2437. $list['density'] = $this->input->post('density', true);
  2438. $list['lacecolor'] = $this->input->post('lacecolor', true);
  2439. $list['lacetypes'] = $this->input->post('lacetypes', true);
  2440. $list['wigother'] = $this->input->post('wigother', true);
  2441. $list['wigother1'] = $this->input->post('wigother1', true);
  2442. $list['wigother2'] = $this->input->post('wigother2', true);
  2443. $list['product_related'] = $this->input->post('product_related', true);
  2444. }
  2445. if ($category == 129) {
  2446. $list['wide'] = $this->input->post('wide', true);
  2447. }
  2448. if ($category == 131) {
  2449. $list['gifttype'] = $this->input->post('gifttype', true);
  2450. $list['giftother'] = $this->input->post('giftother', true);
  2451. }
  2452. if ($category == 134) {
  2453. $list['pieceweight'] = $this->input->post('pieceweight', true);
  2454. }
  2455. if ($category == 1297) {
  2456. $list['synthetictype'] = $this->input->post('synthetictype', true);
  2457. $list['sywigother'] = $this->input->post('sywigother', true);
  2458. }
  2459. if ($category == 130 || $category == 133 || $category == 1702) {
  2460. $list['items'] = $this->input->post('items', true);
  2461. $list['weight'] = $this->input->post('weight', true);
  2462. }
  2463. if($category == 130){
  2464. $list['jfother'] = $this->input->post('jfother', true);
  2465. }
  2466. if ($category == 1702) {
  2467. $list['syhairther'] = $this->input->post('syhairther', true);
  2468. }
  2469. foreach ($list as $k => $v) {
  2470. if ($v != 0) {
  2471. $num .= $v;
  2472. $features .= $v . '-';
  2473. $typeclass = $this->typeclass->read($v);
  2474. if ($k != 'size') {
  2475. $title .= $typeclass['title'] . " ";
  2476. }
  2477. }
  2478. }
  2479. $typeclass = $this->typeclass->read($list['size']);
  2480. $title .= $typeclass['title'];
  2481. $time = time();
  2482. $post['title'] = rtrim($title, ' ');
  2483. $post['number'] = $num;
  2484. $post['features'] = '-' . $features;
  2485. $post['time'] = $time; //操作时间
  2486. if ($post['rktype'] == '' && $post['warehouse'] == 5) {
  2487. echo json_encode(array('msg' => '美仓必须填写入库分类!', 'success' => false));
  2488. exit;
  2489. }
  2490. if ($post['rktype'] != 1 && $post['text'] == '' && $post['warehouse'] == 5) {
  2491. echo json_encode(array('msg' => '非采购入库必须填写入库分类备注!', 'success' => false));
  2492. exit;
  2493. }
  2494. $uid = $this->whlabel->read($id);
  2495. $datanum = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2496. if ($datanum > 0) {
  2497. echo json_encode(array('msg' => '此SKU有占单,请解除占单后再修改!', 'success' => false));
  2498. exit;
  2499. }
  2500. if ($post['warehouse'] != '99999') //现在所有仓都检测,之前只有美仓5检测
  2501. {
  2502. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2503. if ($yza) {
  2504. if ($post['features'] != $yza[0]['features']) {
  2505. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'success' => false));
  2506. exit;
  2507. }
  2508. }
  2509. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "'");
  2510. if ($yzb) {
  2511. if ($post['sku'] != $yzb[0]['sku']) {
  2512. echo json_encode(array('msg' => '此产品信息的SKU和现有不一致!', 'success' => false));
  2513. exit;
  2514. }
  2515. }
  2516. if ($post['warehouse'] == 5 && $yza[0]['shop'] != $post['shop']) {
  2517. echo json_encode(array('msg' => '此产品店铺信息和现有不一致!', 'success' => false));
  2518. exit;
  2519. }
  2520. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2521. foreach ($data as $v) {
  2522. $post['id'] = $v['id'];
  2523. $this->whlabel->save($post, $v['id']);
  2524. }
  2525. } else {
  2526. $data = $this->whlabel->find_count("state = 0 and sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "' and zd != ''");
  2527. if ($data > 0) {
  2528. echo json_encode(array('msg' => '此产品有占单,无法修改!', 'success' => false));
  2529. exit;
  2530. } else {
  2531. $data = $this->whlabel->find_all("sku = '" . $uid['sku'] . "' and warehouse = '" . $uid['warehouse'] . "'"); // and enter = '".$uid['enter']."'
  2532. foreach ($data as $v) {
  2533. $post['id'] = $v['id'];
  2534. $this->whlabel->save($post, $v['id']);
  2535. }
  2536. }
  2537. }
  2538. echo json_encode(array('msg' => '修改成功', 'success' => true));
  2539. exit;
  2540. }
  2541. $uid = $this->whlabel->read($arg_array[0]);
  2542. $uid['order'] = $this->whlabel->find_count('enter = "' . $uid['enter'] . '" and sku = "' . $uid['sku'] . '" and state = "0"');
  2543. $this->data['enter'] = $uid;
  2544. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2545. $this->data['wlshop'] = $wlshop;
  2546. $this->_Template('whlabel_enteredit', $this->data);
  2547. }
  2548. //入库浏览
  2549. public function _enter()
  2550. {
  2551. $post = $this->input->post(NULL, TRUE);
  2552. if (isset($post['s'])) {
  2553. $id_arr = $this->input->post('s');
  2554. $id_arr = explode(',', $id_arr);
  2555. if (!$id_arr) {
  2556. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  2557. exit;
  2558. }
  2559. //循环删除记录
  2560. foreach ($id_arr as $v) {
  2561. $sid = $this->whlabel->read($v);
  2562. $count = $this->whlabel->find_count("state = 0 and sku = '" . $sid['sku'] . "' and warehouse = '" . $sid['warehouse'] . "' and zd != ''");
  2563. if ($count > 0) {
  2564. echo json_encode(array('msg' => '有占单,需要先解除占单!', 'success' => true));
  2565. exit;
  2566. }
  2567. $info_list = $this->whlabel->find_all('enter =' . $sid['enter']);
  2568. foreach ($info_list as $va) {
  2569. $this->whlabel->remove($va['id']);
  2570. }
  2571. }
  2572. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  2573. exit;
  2574. }
  2575. $sp = array();
  2576. $s = $this->shop->find_all('1=1', 'id,shopname');
  2577. foreach ($s as $v) {
  2578. $sp[$v['id']] = $v['shopname'];
  2579. }
  2580. $wh = array();
  2581. $w = $this->warehouse->find_all('1=1', 'id,title');
  2582. foreach ($w as $v) {
  2583. $wh[$v['id']] = $v['title'];
  2584. }
  2585. if (isset($post['page'])) {
  2586. $page = $this->input->post('page', true);
  2587. $perpage = $this->input->post('perpage', true);
  2588. $category = $this->input->post('category', true);
  2589. $size = $this->input->post('size', true);
  2590. $grade = $this->input->post('grade', true);
  2591. $color = $this->input->post('color', true);
  2592. $lowe = $this->input->post('lowe', true);
  2593. $sku = $this->input->post('sku', true);
  2594. $warehouse = $this->input->post('warehouse', true);
  2595. $purchase = $this->input->post('purchase', true);
  2596. $ktime = $this->input->post('ktime', true);
  2597. $jtime = $this->input->post('jtime', true);
  2598. $ktime = strtotime($ktime);
  2599. $jtime = strtotime($jtime);
  2600. $where = "1=1";
  2601. $gj = "";
  2602. $ck = "";
  2603. if ($category) {
  2604. $where .= " and features like '%-$category-%'";
  2605. }
  2606. if ($size) {
  2607. $where .= " and features like '%-$size-%'";
  2608. }
  2609. if ($grade) {
  2610. $where .= " and features like '%-$grade-%'";
  2611. }
  2612. if ($color) {
  2613. $where .= " and features like '%-$color-%'";
  2614. }
  2615. if ($lowe) {
  2616. $where .= " and features like '%-$lowe-%'";
  2617. }
  2618. if ($warehouse) {
  2619. $where .= " and warehouse = '$warehouse'";
  2620. }
  2621. if ($purchase) {
  2622. $where .= " and purchase = '$purchase'";
  2623. }
  2624. if ($sku) {
  2625. $where .= " and sku like '%$sku%'";
  2626. }
  2627. if ($ktime && $jtime) {
  2628. $where .= " and enter > '$ktime' and enter < '$jtime'";
  2629. }
  2630. //数据排序
  2631. $order_str = "enter desc";
  2632. if (empty($page)) {
  2633. $start = 0;
  2634. $perpage = 1;
  2635. } else {
  2636. $start = ($page - 1) * $perpage;
  2637. }
  2638. //取得信息列表
  2639. $info_list = $this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,shop,sku,title,enter', $order_str, $start, $perpage);
  2640. foreach ($info_list as $k => $v) {
  2641. $info_list[$k]['warehouse'] = $wh[$v['warehouse']];
  2642. if ($v['shop'] == '') {
  2643. $s = '通用';
  2644. } else {
  2645. $info_list[$k]['shop'] = '';
  2646. foreach (explode(',', trim($v['shop'], ',')) as $val) {
  2647. $info_list[$k]['shop'] .= $sp[$val] . '</br>';
  2648. }
  2649. }
  2650. $info_list[$k]['enter'] = date('Y-m-d H:i:s', $v['enter']);
  2651. $g = $this->whlabel->find_count($where . ' and enter = "' . $v['enter'] . '" and sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '"');
  2652. $info_list[$k]['g'] = $g;
  2653. }
  2654. //$total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  2655. $total = count($this->whlabel->find_pc($where, 'warehouse,sku,enter', 'id,warehouse,sku,title,features,number'));
  2656. $pagenum = ceil($total / $perpage);
  2657. $over = $total - ($start + $perpage);
  2658. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2659. echo json_encode($rows);
  2660. exit;
  2661. }
  2662. $this->_Template('whlabel_enter', $this->data);
  2663. }
  2664. //出库浏览
  2665. public function _out()
  2666. {
  2667. $post = $this->input->post(NULL, TRUE);
  2668. if (isset($post['page'])) {
  2669. $page = $this->input->post('page', true);
  2670. $perpage = $this->input->post('perpage', true);
  2671. $category = $this->input->post('category', true);
  2672. $size = $this->input->post('size', true);
  2673. $grade = $this->input->post('grade', true);
  2674. $color = $this->input->post('color', true);
  2675. $lowe = $this->input->post('lowe', true);
  2676. $sku = $this->input->post('sku', true);
  2677. $warehouse = $this->input->post('warehouse', true);
  2678. $purchase = $this->input->post('purchase', true);
  2679. $state = $this->input->post('state', true);
  2680. $ktime = $this->input->post('ktime', true);
  2681. $jtime = $this->input->post('jtime', true);
  2682. $ktime = strtotime($ktime);
  2683. $jtime = strtotime($jtime);
  2684. $where = "state=3";
  2685. $gj = "";
  2686. $ck = "";
  2687. if ($category) {
  2688. $where .= " and features like '%-$category-%'";
  2689. }
  2690. if ($size) {
  2691. $where .= " and features like '%-$size-%'";
  2692. }
  2693. if ($grade) {
  2694. $where .= " and features like '%-$grade-%'";
  2695. }
  2696. if ($color) {
  2697. $where .= " and features like '%-$color-%'";
  2698. }
  2699. if ($lowe) {
  2700. $where .= " and features like '%-$lowe-%'";
  2701. }
  2702. if ($state) {
  2703. $where .= " and state = '$state'";
  2704. }
  2705. if ($warehouse) {
  2706. $where .= " and warehouse = '$warehouse'";
  2707. }
  2708. if ($purchase) {
  2709. $where .= " and purchase = '$purchase'";
  2710. }
  2711. if ($sku) {
  2712. $where .= " and sku = '$sku'";
  2713. }
  2714. if ($ktime && $jtime) {
  2715. $where .= " and outk > '$ktime' and outk < '$jtime'";
  2716. }
  2717. //数据排序
  2718. $order_str = "id desc";
  2719. if (empty($page)) {
  2720. $start = 0;
  2721. $perpage = 1;
  2722. } else {
  2723. $start = ($page - 1) * $perpage;
  2724. }
  2725. //取得信息列表
  2726. $info_list = $this->whlabel->find_all($where, 'sku');
  2727. $rows = array();
  2728. $list = array();
  2729. foreach ($info_list as $key => $value) {
  2730. $rows[] = $value['sku'] . 'warehouse' . $value['warehouse']; //所有数据sku
  2731. }
  2732. $rows = array_unique($rows); //删除重复记录
  2733. foreach ($rows as $key => $value) {
  2734. $data = $this->whlabel->get_sku($value); //获取目前sku的所有数据
  2735. $ck = $this->warehouse->read($data['warehouse']);
  2736. $warehouse = $ck['title'];
  2737. $gy = $this->purchase->read($data['purchase']);
  2738. $purchase = $gy['purchase'];
  2739. $g = $this->whlabel->find_count($where . ' and sku = "' . $value . '" and state = 3');
  2740. $list[] = array('id' => $data['id'], 'warehouse' => $warehouse, 'purchase' => $purchase, 'sku' => $data['sku'], 'title' => $data['title'], 'time' => date('Y-m-d H:i:s', $data['enter']), 'number' => $g);
  2741. }
  2742. $total = count($list);
  2743. $pagenum = ceil($total / $perpage);
  2744. $over = $total - ($start + $perpage);
  2745. $list = array_slice($list, $start, $perpage); //数组中提取分页指定的内容 +true key排序不变
  2746. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($list));
  2747. echo json_encode($rows);
  2748. exit;
  2749. }
  2750. $this->_Template('whlabel_out', $this->data);
  2751. }
  2752. //出库标签浏览
  2753. public function _label()
  2754. {
  2755. $post = $this->input->post(NULL, TRUE);
  2756. if (isset($post['page'])) {
  2757. $page = $this->input->post('page', true);
  2758. $perpage = $this->input->post('perpage', true);
  2759. $sku = $this->input->post('sku', true);
  2760. $warehouse = $this->input->post('warehouse', true);
  2761. $purchase = $this->input->post('purchase', true);
  2762. $orderinfo = $this->input->post('orderinfo', true);
  2763. $waybill = $this->input->post('waybill', true);
  2764. $category = $this->input->post('category', true);
  2765. $size = $this->input->post('size', true);
  2766. $grade = $this->input->post('grade', true);
  2767. $color = $this->input->post('color', true);
  2768. $lowe = $this->input->post('lowe', true);
  2769. $where = "state=1";
  2770. if ($sku) {
  2771. $where .= " and sku = '$sku'";
  2772. }
  2773. if ($warehouse) {
  2774. $where .= " and warehouse = '$warehouse'";
  2775. }
  2776. if ($purchase) {
  2777. $where .= " and purchase = '$purchase'";
  2778. }
  2779. if ($orderinfo) {
  2780. $where .= " and orderinfo = '$orderinfo'";
  2781. }
  2782. if ($waybill) {
  2783. $where .= " and waybill = '$waybill'";
  2784. }
  2785. if ($category) {
  2786. $where .= " and features like '%-$category-%'";
  2787. }
  2788. if ($size) {
  2789. $where .= " and features like '%-$size-%'";
  2790. }
  2791. if ($grade) {
  2792. $where .= " and features like '%-$grade-%'";
  2793. }
  2794. if ($color) {
  2795. $where .= " and features like '%-$color-%'";
  2796. }
  2797. if ($lowe) {
  2798. $where .= " and features like '%-$lowe-%'";
  2799. }
  2800. //数据排序
  2801. $order_str = "outk desc";
  2802. if (empty($page)) {
  2803. $start = 0;
  2804. $perpage = 1;
  2805. } else {
  2806. $start = ($page - 1) * $perpage;
  2807. }
  2808. //取得信息列表
  2809. $info_list = $this->whlabel->find_all($where, 'id,warehouse,sku,title,label,purchase,orderinfo,waybill,outk', $order_str, $start, $perpage);
  2810. foreach ($info_list as $key => $value) {
  2811. $warehouse = $this->warehouse->read($value['warehouse']);
  2812. $info_list[$key]['warehouse'] = $warehouse['title'];
  2813. $purchase = $this->purchase->read($value['purchase']);
  2814. $info_list[$key]['purchase'] = $purchase['title'];
  2815. if ($value['outk'] != 0) {
  2816. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  2817. } else {
  2818. $info_list[$key]['outk'] = "";
  2819. }
  2820. if ($value['orderinfo'] == 0) {
  2821. $info_list[$key]['orderinfo'] = "";
  2822. }
  2823. if ($value['waybill'] == 0) {
  2824. $info_list[$key]['waybill'] = "";
  2825. }
  2826. }
  2827. $total = $this->whlabel->find_count($where);
  2828. $pagenum = ceil($total / $perpage);
  2829. $over = $total - ($start + $perpage);
  2830. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2831. echo json_encode($rows);
  2832. exit;
  2833. }
  2834. $this->_Template('whlabel_label', $this->data);
  2835. }
  2836. //独立站出库订单
  2837. public function _outorder()
  2838. {
  2839. if (isset($_SESSION['api'])) {
  2840. $user = $this->user->get_api($_SESSION['api']);
  2841. $usp = $user;
  2842. $fgshop = "";
  2843. $sid = "";
  2844. $user = explode('|', trim($user['shop'], '|'));
  2845. foreach ($user as $value) {
  2846. $fgshop .= " shop = " . $value . " or";
  2847. $sid .= " id = " . $value . " or";
  2848. }
  2849. } else {
  2850. echo "请重新登录";
  2851. }
  2852. $post = $this->input->post(NULL, TRUE);
  2853. if (isset($post['page'])) {
  2854. $page = $this->input->post('page', true);
  2855. $perpage = $this->input->post('perpage', true);
  2856. $warehouse = $this->input->post('warehouse', true);
  2857. $xztime = $this->input->post('xztime', true);
  2858. $timetk = $this->input->post('timetkk', true);
  2859. $timetj = $this->input->post('timetjj', true);
  2860. $shop = $this->input->post('shop', true);
  2861. $source = $this->input->post('source', true);
  2862. $orderinfo = $this->input->post('orderinfo', true);
  2863. $number = $this->input->post('number', true);
  2864. $sfxh = $this->input->post('sfxh', true);
  2865. $express = $this->input->post('express', true);
  2866. $waybill = $this->input->post('waybill', true);
  2867. $library = $this->input->post('library', true);
  2868. $country = $this->input->post('country', true);
  2869. $so = $this->input->post('so', true);
  2870. $libraryconfirm = $this->input->post('libraryconfirm', true);
  2871. $print = $this->input->post('print', true);
  2872. $state = $this->input->post('state', true);
  2873. $orderurl = $this->input->post('orderurl', true);
  2874. $productid = $this->input->post('productid', true);
  2875. $timetk = strtotime($timetk);
  2876. $timetj = strtotime($timetj);
  2877. /**
  2878. $sj = $this->input->post('sj',true);
  2879. if($sj)
  2880. {
  2881. $sj = $this->input->post('sj',true);
  2882. }
  2883. else
  2884. {
  2885. $sj = "fullorder";
  2886. }
  2887. **/
  2888. $sj = "fullorder";
  2889. $where = "1=1";
  2890. if ($warehouse) {
  2891. $where .= " and type = '$warehouse'";
  2892. }
  2893. if ($timetk && $timetj) {
  2894. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  2895. }
  2896. if ($orderinfo) {
  2897. $where .= " and orderinfo = '$orderinfo'";
  2898. }
  2899. if ($number) {
  2900. $where .= " and number = '$number'";
  2901. }
  2902. if ($express) {
  2903. $where .= " and express = '$express'";
  2904. }
  2905. if ($waybill) {
  2906. $where .= " and waybill = '$waybill'";
  2907. }
  2908. if ($library) {
  2909. $where .= " and library = '$library'";
  2910. }
  2911. if ($print) {
  2912. $where .= " and print = '$print'";
  2913. }
  2914. if ($libraryconfirm) {
  2915. $where .= " and libraryconfirm = '$libraryconfirm'";
  2916. }
  2917. if ($state) {
  2918. $where .= " and state = '$state'";
  2919. }
  2920. if ($shop) {
  2921. $where .= " and shop = '$shop'";
  2922. }
  2923. if ($country) {
  2924. $where .= " and country = '$country'";
  2925. }
  2926. if ($sfxh != '') {
  2927. $where .= " and sfxh = '$sfxh'";
  2928. }
  2929. if ($so) {
  2930. $where .= " and shipremarks like '%$so%'";
  2931. }
  2932. if ($source) {
  2933. if ($source == '2d') {
  2934. $where .= " and source >= '2'";
  2935. } else {
  2936. $where .= " and source = '$source'";
  2937. }
  2938. }
  2939. if (isset($_SESSION['api'])) {
  2940. foreach ($user as $value) {
  2941. $fgshop .= " shop = " . $value . " or";
  2942. }
  2943. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  2944. }
  2945. if ($orderurl) {
  2946. $url = $this->orderurl->read($orderurl);
  2947. $where .= " and link like '%" . $url['url'] . "%'";
  2948. }
  2949. if($productid){
  2950. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  2951. }
  2952. //数据排序
  2953. $order_str = "librarytime desc";
  2954. if (empty($page)) {
  2955. $start = 0;
  2956. $perpage = 1;
  2957. } else {
  2958. $start = ($page - 1) * $perpage;
  2959. }
  2960. //取得信息列表
  2961. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  2962. //格式化数据
  2963. foreach ($info_list as $key => $value) {
  2964. $shop = $this->shop->read($value['shop']);
  2965. $info_list[$key]['shop'] = $shop['shopname'];
  2966. $express = $this->express->read($value['express']);
  2967. $info_list[$key]['express'] = $express['servicename'];
  2968. $warehouse = $this->warehouse->read($value['type']);
  2969. $info_list[$key]['type'] = $warehouse['title'];
  2970. if ($value['librarytime'] == '0') {
  2971. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  2972. } else {
  2973. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  2974. }
  2975. }
  2976. $total = $this->$sj->find_count($where);
  2977. $pagenum = ceil($total / $perpage);
  2978. $over = $total - ($start + $perpage);
  2979. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  2980. echo json_encode($rows);
  2981. exit;
  2982. }
  2983. $this->data['express'] = $this->express->find_all();
  2984. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  2985. $this->data['wlshop'] = $wlshop;
  2986. $user = $this->user->get_api($_SESSION['api']);
  2987. $powerid = $this->power->read($user['power']);
  2988. $powertext = explode('|', trim($powerid['excelid'], '|'));
  2989. $pid = '';
  2990. foreach ($powertext as $v) {
  2991. $pid .= " id = " . $v . " or";
  2992. }
  2993. $fullorderexcel = $this->fullorderexcel->find_all("type = '100002' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  2994. $this->data['fullorderexcel'] = $fullorderexcel;
  2995. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  2996. $this->data['orderurl'] = $orderurl;
  2997. $this->_Template('whlabel_outorder', $this->data);
  2998. }
  2999. //tt出库
  3000. public function _toutorder()
  3001. {
  3002. $fgshop = "";
  3003. $sid = "";
  3004. if (isset($_SESSION['api'])) {
  3005. $user = $this->user->get_api($_SESSION['api']);
  3006. $usp = $user;
  3007. $user = explode('|', trim($user['shop'], '|'));
  3008. foreach ($user as $value) {
  3009. $fgshop .= " shop = " . $value . " or";
  3010. $sid .= " id = " . $value . " or";
  3011. }
  3012. } else {
  3013. echo "请重新登录";
  3014. die;
  3015. }
  3016. $post = $this->input->post(NULL, TRUE);
  3017. if (isset($post['page'])) {
  3018. $page = $this->input->post('page', true);
  3019. $perpage = $this->input->post('perpage', true);
  3020. $warehouse = $this->input->post('warehouse', true);
  3021. $xztime = $this->input->post('xztime', true);
  3022. $timetk = $this->input->post('timetkk', true);
  3023. $timetj = $this->input->post('timetjj', true);
  3024. $shop = $this->input->post('shop', true);
  3025. $source = $this->input->post('source', true);
  3026. $orderinfo = $this->input->post('orderinfo', true);
  3027. $number = $this->input->post('number', true);
  3028. $sfxh = $this->input->post('sfxh', true);
  3029. $express = $this->input->post('express', true);
  3030. $waybill = $this->input->post('waybill', true);
  3031. $library = $this->input->post('library', true);
  3032. $country = $this->input->post('country', true);
  3033. $so = $this->input->post('so', true);
  3034. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3035. $print = $this->input->post('print', true);
  3036. $state = $this->input->post('state', true);
  3037. $orderurl = $this->input->post('orderurl', true);
  3038. $timetk = strtotime($timetk);
  3039. $timetj = strtotime($timetj);
  3040. /**
  3041. $sj = $this->input->post('sj',true);
  3042. if($sj)
  3043. {
  3044. $sj = $this->input->post('sj',true);
  3045. }
  3046. else
  3047. {
  3048. $sj = "fullorder";
  3049. }
  3050. **/
  3051. $sj = "fullordertt";
  3052. $where = "1=1";
  3053. if ($warehouse) {
  3054. $where .= " and type = '$warehouse'";
  3055. }
  3056. if ($timetk && $timetj) {
  3057. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3058. }
  3059. if ($orderinfo) {
  3060. $where .= " and orderinfo = '$orderinfo'";
  3061. }
  3062. if ($number) {
  3063. $where .= " and number = '$number'";
  3064. }
  3065. if ($express) {
  3066. $where .= " and express = '$express'";
  3067. }
  3068. if ($waybill) {
  3069. $where .= " and waybill = '$waybill'";
  3070. }
  3071. if ($library) {
  3072. $where .= " and library = '$library'";
  3073. }
  3074. if ($print) {
  3075. $where .= " and print = '$print'";
  3076. }
  3077. if ($libraryconfirm) {
  3078. $where .= " and libraryconfirm = '$libraryconfirm'";
  3079. }
  3080. if ($state) {
  3081. $where .= " and state = '$state'";
  3082. }
  3083. if ($shop) {
  3084. $where .= " and shop = '$shop'";
  3085. }
  3086. if ($country) {
  3087. $where .= " and country = '$country'";
  3088. }
  3089. if ($sfxh != '') {
  3090. $where .= " and sfxh = '$sfxh'";
  3091. }
  3092. if ($so) {
  3093. $where .= " and shipremarks like '%$so%'";
  3094. }
  3095. if ($source) {
  3096. if ($source == '2d') {
  3097. $where .= " and source >= '2'";
  3098. } else {
  3099. $where .= " and source = '$source'";
  3100. }
  3101. }
  3102. if (isset($_SESSION['api'])) {
  3103. foreach ($user as $value) {
  3104. $fgshop .= " shop = " . $value . " or";
  3105. }
  3106. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3107. }
  3108. if ($orderurl) {
  3109. $url = $this->orderurl->read($orderurl);
  3110. $where .= " and link like '%" . $url['url'] . "%'";
  3111. }
  3112. //数据排序
  3113. $order_str = "librarytime desc";
  3114. if (empty($page)) {
  3115. $start = 0;
  3116. $perpage = 1;
  3117. } else {
  3118. $start = ($page - 1) * $perpage;
  3119. }
  3120. //取得信息列表
  3121. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3122. //格式化数据
  3123. foreach ($info_list as $key => $value) {
  3124. $shop = $this->shop->read($value['shop']);
  3125. $info_list[$key]['shop'] = $shop['shopname'];
  3126. $express = $this->express->read($value['express']);
  3127. $info_list[$key]['express'] = $express['servicename'];
  3128. $warehouse = $this->warehouse->read($value['type']);
  3129. $info_list[$key]['type'] = $warehouse['title'];
  3130. if ($value['librarytime'] == '0') {
  3131. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3132. } else {
  3133. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3134. }
  3135. }
  3136. $total = $this->$sj->find_count($where);
  3137. $pagenum = ceil($total / $perpage);
  3138. $over = $total - ($start + $perpage);
  3139. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3140. echo json_encode($rows);
  3141. exit;
  3142. }
  3143. $this->data['express'] = $this->express->find_all();
  3144. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3145. $this->data['wlshop'] = $wlshop;
  3146. $user = $this->user->get_api($_SESSION['api']);
  3147. $powerid = $this->power->read($user['power']);
  3148. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3149. $pid = '';
  3150. foreach ($powertext as $v) {
  3151. $pid .= " id = " . $v . " or";
  3152. }
  3153. $fullorderexcel = $this->fullorderexcel->find_all("type = '100007' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3154. $this->data['fullorderexcel'] = $fullorderexcel;
  3155. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3156. $this->data['orderurl'] = $orderurl;
  3157. $this->_Template('whlabel_toutorder', $this->data);
  3158. }
  3159. //tt出库
  3160. public function _aoutorder()
  3161. {
  3162. if (isset($_SESSION['api'])) {
  3163. $user = $this->user->get_api($_SESSION['api']);
  3164. $usp = $user;
  3165. $fgshop = "";
  3166. $sid = "";
  3167. $user = explode('|', trim($user['shop'], '|'));
  3168. foreach ($user as $value) {
  3169. $fgshop .= " shop = " . $value . " or";
  3170. $sid .= " id = " . $value . " or";
  3171. }
  3172. } else {
  3173. echo "请重新登录";
  3174. }
  3175. $post = $this->input->post(NULL, TRUE);
  3176. if (isset($post['page'])) {
  3177. $page = $this->input->post('page', true);
  3178. $perpage = $this->input->post('perpage', true);
  3179. $warehouse = $this->input->post('warehouse', true);
  3180. $xztime = $this->input->post('xztime', true);
  3181. $timetk = $this->input->post('timetkk', true);
  3182. $timetj = $this->input->post('timetjj', true);
  3183. $shop = $this->input->post('shop', true);
  3184. $source = $this->input->post('source', true);
  3185. $orderinfo = $this->input->post('orderinfo', true);
  3186. $number = $this->input->post('number', true);
  3187. $sfxh = $this->input->post('sfxh', true);
  3188. $express = $this->input->post('express', true);
  3189. $waybill = $this->input->post('waybill', true);
  3190. $library = $this->input->post('library', true);
  3191. $country = $this->input->post('country', true);
  3192. $so = $this->input->post('so', true);
  3193. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3194. $print = $this->input->post('print', true);
  3195. $state = $this->input->post('state', true);
  3196. $orderurl = $this->input->post('orderurl', true);
  3197. $timetk = strtotime($timetk);
  3198. $timetj = strtotime($timetj);
  3199. /**
  3200. $sj = $this->input->post('sj',true);
  3201. if($sj)
  3202. {
  3203. $sj = $this->input->post('sj',true);
  3204. }
  3205. else
  3206. {
  3207. $sj = "fullorder";
  3208. }
  3209. **/
  3210. $sj = "fullorderamz";
  3211. $where = "1=1";
  3212. if ($warehouse) {
  3213. $where .= " and type = '$warehouse'";
  3214. }
  3215. if ($timetk && $timetj) {
  3216. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3217. }
  3218. if ($orderinfo) {
  3219. $where .= " and orderinfo = '$orderinfo'";
  3220. }
  3221. if ($number) {
  3222. $where .= " and number = '$number'";
  3223. }
  3224. if ($express) {
  3225. $where .= " and express = '$express'";
  3226. }
  3227. if ($waybill) {
  3228. $where .= " and waybill = '$waybill'";
  3229. }
  3230. if ($library) {
  3231. $where .= " and library = '$library'";
  3232. }
  3233. if ($print) {
  3234. $where .= " and print = '$print'";
  3235. }
  3236. if ($libraryconfirm) {
  3237. $where .= " and libraryconfirm = '$libraryconfirm'";
  3238. }
  3239. if ($state) {
  3240. $where .= " and state = '$state'";
  3241. }
  3242. if ($shop) {
  3243. $where .= " and shop = '$shop'";
  3244. }
  3245. if ($country) {
  3246. $where .= " and country = '$country'";
  3247. }
  3248. if ($sfxh != '') {
  3249. $where .= " and sfxh = '$sfxh'";
  3250. }
  3251. if ($so) {
  3252. $where .= " and shipremarks like '%$so%'";
  3253. }
  3254. if ($source) {
  3255. if ($source == '2d') {
  3256. $where .= " and source >= '2'";
  3257. } else {
  3258. $where .= " and source = '$source'";
  3259. }
  3260. }
  3261. if (isset($_SESSION['api'])) {
  3262. foreach ($user as $value) {
  3263. $fgshop .= " shop = " . $value . " or";
  3264. }
  3265. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3266. }
  3267. if ($orderurl) {
  3268. $url = $this->orderurl->read($orderurl);
  3269. $where .= " and link like '%" . $url['url'] . "%'";
  3270. }
  3271. //数据排序
  3272. $order_str = "librarytime desc";
  3273. if (empty($page)) {
  3274. $start = 0;
  3275. $perpage = 1;
  3276. } else {
  3277. $start = ($page - 1) * $perpage;
  3278. }
  3279. //取得信息列表
  3280. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3281. //格式化数据
  3282. foreach ($info_list as $key => $value) {
  3283. $shop = $this->shop->read($value['shop']);
  3284. $info_list[$key]['shop'] = $shop['shopname'];
  3285. $express = $this->express->read($value['express']);
  3286. $info_list[$key]['express'] = $express['servicename'];
  3287. $warehouse = $this->warehouse->read($value['type']);
  3288. $info_list[$key]['type'] = $warehouse['title'];
  3289. if ($value['librarytime'] == '0') {
  3290. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3291. } else {
  3292. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3293. }
  3294. }
  3295. $total = $this->$sj->find_count($where);
  3296. $pagenum = ceil($total / $perpage);
  3297. $over = $total - ($start + $perpage);
  3298. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3299. echo json_encode($rows);
  3300. exit;
  3301. }
  3302. $this->data['express'] = $this->express->find_all();
  3303. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3304. $this->data['wlshop'] = $wlshop;
  3305. $user = $this->user->get_api($_SESSION['api']);
  3306. $powerid = $this->power->read($user['power']);
  3307. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3308. $pid = '';
  3309. foreach ($powertext as $v) {
  3310. $pid .= " id = " . $v . " or";
  3311. }
  3312. $fullorderexcel = $this->fullorderexcel->find_all("type = '100010' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3313. $this->data['fullorderexcel'] = $fullorderexcel;
  3314. $orderurl = $this->orderurl->find_all(rtrim($fgshop, 'or'));
  3315. $this->data['orderurl'] = $orderurl;
  3316. $this->_Template('whlabel_aoutorder', $this->data);
  3317. }
  3318. //速卖通出库订单
  3319. public function _soutorder()
  3320. {
  3321. if (isset($_SESSION['api'])) {
  3322. $user = $this->user->get_api($_SESSION['api']);
  3323. $usp = $user;
  3324. $fgshop = "";
  3325. $sid = "";
  3326. $user = explode('|', trim($user['shop'], '|'));
  3327. foreach ($user as $value) {
  3328. $sid .= " id = " . $value . " or";
  3329. }
  3330. }
  3331. $post = $this->input->post(NULL, TRUE);
  3332. if (isset($post['page'])) {
  3333. $page = $this->input->post('page', true);
  3334. $perpage = $this->input->post('perpage', true);
  3335. $warehouse = $this->input->post('warehouse', true);
  3336. $xztime = $this->input->post('xztime', true);
  3337. $timetk = $this->input->post('timetkk', true);
  3338. $timetj = $this->input->post('timetjj', true);
  3339. $shop = $this->input->post('shop', true);
  3340. $source = $this->input->post('source', true);
  3341. $orderinfo = $this->input->post('orderinfo', true);
  3342. $number = $this->input->post('number', true);
  3343. $express = $this->input->post('express', true);
  3344. $waybill = $this->input->post('waybill', true);
  3345. $library = $this->input->post('library', true);
  3346. $country = $this->input->post('country', true);
  3347. $sfxh = $this->input->post('sfxh', true);
  3348. $libraryconfirm = $this->input->post('libraryconfirm', true);
  3349. $print = $this->input->post('print', true);
  3350. $state = $this->input->post('state', true);
  3351. $so = $this->input->post('so', true);
  3352. $timetk = strtotime($timetk);
  3353. $timetj = strtotime($timetj);
  3354. /**
  3355. $sj = $this->input->post('sj',true);
  3356. if($sj)
  3357. {
  3358. $sj = $this->input->post('sj',true);
  3359. }
  3360. else
  3361. {
  3362. $sj = "fullorder";
  3363. }
  3364. **/
  3365. $sj = "fullordersmt";
  3366. $where = "1=1";
  3367. if ($warehouse) {
  3368. $where .= " and type = '$warehouse'";
  3369. }
  3370. if ($timetk && $timetj) {
  3371. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  3372. }
  3373. if ($orderinfo) {
  3374. $where .= " and orderinfo = '$orderinfo'";
  3375. }
  3376. if ($number) {
  3377. $where .= " and number = '$number'";
  3378. }
  3379. if ($express) {
  3380. $where .= " and express = '$express'";
  3381. }
  3382. if ($waybill) {
  3383. $where .= " and waybill = '$waybill'";
  3384. }
  3385. if ($library) {
  3386. $where .= " and library = '$library'";
  3387. }
  3388. if ($print) {
  3389. $where .= " and print = '$print'";
  3390. }
  3391. if ($libraryconfirm) {
  3392. $where .= " and libraryconfirm = '$libraryconfirm'";
  3393. }
  3394. if ($state) {
  3395. $where .= " and state = '$state'";
  3396. }
  3397. if ($shop) {
  3398. $where .= " and shop = '$shop'";
  3399. }
  3400. if ($sfxh != '') {
  3401. $where .= " and sfxh = '$sfxh'";
  3402. }
  3403. if ($so) {
  3404. $where .= " and shipremarks like '%$so%'";
  3405. }
  3406. if ($source) {
  3407. $where .= " and source = '$source'";
  3408. }
  3409. if ($country) {
  3410. $where .= " and country = '$country'";
  3411. } else {
  3412. if (isset($_SESSION['api'])) {
  3413. foreach ($user as $value) {
  3414. $fgshop .= " shop = " . $value . " or";
  3415. }
  3416. $where .= " and (" . rtrim($fgshop, 'or') . ")";
  3417. }
  3418. }
  3419. //数据排序
  3420. $order_str = "librarytime desc";
  3421. if (empty($page)) {
  3422. $start = 0;
  3423. $perpage = 1;
  3424. } else {
  3425. $start = ($page - 1) * $perpage;
  3426. }
  3427. //取得信息列表
  3428. $info_list = $this->$sj->find_all($where, 'id,shop,type,orderinfo,number,waybill,express,librarytime', $order_str, $start, $perpage);
  3429. //格式化数据
  3430. foreach ($info_list as $key => $value) {
  3431. $shop = $this->shop->read($value['shop']);
  3432. $info_list[$key]['shop'] = $shop['shopname'];
  3433. $express = $this->express->read($value['express']);
  3434. $info_list[$key]['express'] = $express['servicename'];
  3435. $warehouse = $this->warehouse->read($value['type']);
  3436. $info_list[$key]['type'] = $warehouse['title'];
  3437. if ($value['librarytime'] == '0') {
  3438. $info_list[$key]['librarytime'] = '<em class="t"></em>';
  3439. } else {
  3440. $info_list[$key]['librarytime'] = '<em class="t">' . date('Y-m-d H:i:s', $value['librarytime']) . '</em>';
  3441. }
  3442. }
  3443. $total = $this->$sj->find_count($where);
  3444. $pagenum = ceil($total / $perpage);
  3445. $over = $total - ($start + $perpage);
  3446. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3447. echo json_encode($rows);
  3448. exit;
  3449. }
  3450. $this->data['express'] = $this->express->find_all();
  3451. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  3452. $this->data['wlshop'] = $wlshop;
  3453. $user = $this->user->get_api($_SESSION['api']);
  3454. $powerid = $this->power->read($user['power']);
  3455. $powertext = explode('|', trim($powerid['excelid'], '|'));
  3456. $pid = '';
  3457. foreach ($powertext as $v) {
  3458. $pid .= " id = " . $v . " or";
  3459. }
  3460. $fullorderexcel = $this->fullorderexcel->find_all("type = '100005' and (" . rtrim($pid, 'or') . ")", '*', 'idorder desc'); //导出模板
  3461. $this->data['fullorderexcel'] = $fullorderexcel;
  3462. $this->_Template('whlabel_soutorder', $this->data);
  3463. }
  3464. //订单退库
  3465. public function _retreat()
  3466. {
  3467. $post = $this->input->post(NULL, TRUE);
  3468. if (isset($post['page'])) {
  3469. $page = $this->input->post('page', true);
  3470. $perpage = $this->input->post('perpage', true);
  3471. $warehouse = $this->input->post('warehouse', true);
  3472. $timetk = $this->input->post('timetk', true);
  3473. $timetj = $this->input->post('timetj', true);
  3474. $shop = $this->input->post('shop', true);
  3475. $source = $this->input->post('source', true);
  3476. $state = $this->input->post('state', true);
  3477. $review = $this->input->post('review', true);
  3478. $state = $this->input->post('state', true);
  3479. $express = $this->input->post('express', true);
  3480. $orderinfo = $this->input->post('orderinfo', true);
  3481. $user = $this->input->post('user', true);
  3482. $name = $this->input->post('name', true);
  3483. $waybill = $this->input->post('waybill', true);
  3484. $timetk = strtotime($timetk);
  3485. $timetj = strtotime($timetj);
  3486. $where = "(state=206 or state=210) and mergeid = 0";
  3487. if ($warehouse) {
  3488. $where .= " and state = '$warehouse'";
  3489. }
  3490. if ($timetk && $timetj) {
  3491. $where .= " and buytime > '$timetk' and buytime < '$timetj'";
  3492. }
  3493. if ($shop) {
  3494. $where .= " and shop = '$shop'";
  3495. }
  3496. if ($source) {
  3497. $where .= " and source = '$source'";
  3498. }
  3499. if ($state) {
  3500. $where .= " and state = '$state'";
  3501. }
  3502. if ($review) {
  3503. $where .= " and review = '$review'";
  3504. }
  3505. if ($state) {
  3506. $where .= " and state = '$state'";
  3507. }
  3508. if ($express) {
  3509. $where .= " and express = '$express'";
  3510. }
  3511. if ($orderinfo) {
  3512. $where .= " and orderinfo = '$orderinfo'";
  3513. }
  3514. if ($user) {
  3515. $where .= " and user = '$user'";
  3516. }
  3517. if ($name) {
  3518. $where .= " and name = '$name'";
  3519. }
  3520. if ($waybill) {
  3521. $where .= " and waybill = '$waybill'";
  3522. }
  3523. //数据排序
  3524. $order_str = "id desc";
  3525. if (empty($page)) {
  3526. $start = 0;
  3527. $perpage = 1;
  3528. } else {
  3529. $start = ($page - 1) * $perpage;
  3530. }
  3531. //取得信息列表
  3532. $info_list = $this->fullorder->find_all($where, 'id,shop,warehouse,orderinfo,number,express,waybill,state,buytime', $order_str, $start, $perpage);
  3533. //格式化数据
  3534. foreach ($info_list as $key => $value) {
  3535. $shop = $this->shop->read($value['shop']);
  3536. $info_list[$key]['shop'] = $shop['shopname'];
  3537. $warehouse = $this->warehouse->read($value['warehouse']);
  3538. $info_list[$key]['warehouse'] = $warehouse['title'];
  3539. $info_list[$key]['orderinfo'] = "<a href='/fullorder/editoff/" . $value['id'] . "'>" . $value['orderinfo'] . "</a>";
  3540. $info_list[$key]['buytime'] = '<p>' . date('Y-m-d', $value['buytime']) . '</p><p>' . date('H:i:s', $value['buytime']) . '</p>';
  3541. if ($value['waybill'] == 0) {
  3542. $info_list[$key]['waybill'] = "";
  3543. }
  3544. $express = $this->express->read($value['express']);
  3545. $info_list[$key]['express'] = $express['title'];
  3546. $typeclass = $this->typeclass->read($value['state']);
  3547. $info_list[$key]['state'] = $typeclass['title'];
  3548. }
  3549. $total = $this->fullorder->find_count($where);
  3550. $pagenum = ceil($total / $perpage);
  3551. $over = $total - ($start + $perpage);
  3552. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3553. echo json_encode($rows);
  3554. exit;
  3555. }
  3556. $this->data['express'] = $this->express->find_all();
  3557. $this->_Template('whlabel_retreat', $this->data);
  3558. }
  3559. //退库标签浏览
  3560. public function _retreatlk()
  3561. {
  3562. $post = $this->input->post(NULL, TRUE);
  3563. if (isset($post['page'])) {
  3564. $page = $this->input->post('page', true);
  3565. $perpage = $this->input->post('perpage', true);
  3566. $timetk = $this->input->post('timetk', true);
  3567. $timetj = $this->input->post('timetj', true);
  3568. $sku = $this->input->post('sku', true);
  3569. $warehouse = $this->input->post('warehouse', true);
  3570. $purchase = $this->input->post('purchase', true);
  3571. $orderinfo = $this->input->post('orderinfo', true);
  3572. $waybill = $this->input->post('waybill', true);
  3573. $category = $this->input->post('category', true);
  3574. $size = $this->input->post('size', true);
  3575. $grade = $this->input->post('grade', true);
  3576. $color = $this->input->post('color', true);
  3577. $lowe = $this->input->post('lowe', true);
  3578. $state = $this->input->post('state', true);
  3579. $timetk = strtotime($timetk);
  3580. $timetj = strtotime($timetj);
  3581. $where = "state=2";
  3582. if ($timetk && $timetj) {
  3583. $where .= " and retreat > '$timetk' and retreat < '$timetj'";
  3584. }
  3585. if ($sku) {
  3586. $where .= " and sku = '$sku'";
  3587. }
  3588. if ($warehouse) {
  3589. $where .= " and warehouse = '$warehouse'";
  3590. }
  3591. if ($purchase) {
  3592. $where .= " and purchase = '$purchase'";
  3593. }
  3594. if ($orderinfo) {
  3595. $where .= " and orderinfo = '$orderinfo'";
  3596. }
  3597. if ($waybill) {
  3598. $where .= " and waybill = '$waybill'";
  3599. }
  3600. if ($category) {
  3601. $where .= " and features like '%-$category-%'";
  3602. }
  3603. if ($size) {
  3604. $where .= " and features like '%-$size-%'";
  3605. }
  3606. if ($grade) {
  3607. $where .= " and features like '%-$grade-%'";
  3608. }
  3609. if ($color) {
  3610. $where .= " and features like '%-$color-%'";
  3611. }
  3612. if ($lowe) {
  3613. $where .= " and features like '%-$lowe-%'";
  3614. }
  3615. //数据排序
  3616. $order_str = "time desc";
  3617. if (empty($page)) {
  3618. $start = 0;
  3619. $perpage = 1;
  3620. } else {
  3621. $start = ($page - 1) * $perpage;
  3622. }
  3623. //取得信息列表
  3624. $info_list = $this->whlabel->find_all($where, 'id,warehouse,retreatwarehouse,sku,title,label,purchase,orderinfo,waybill,retreat,outk', $order_str, $start, $perpage);
  3625. foreach ($info_list as $key => $value) {
  3626. $warehouse = $this->warehouse->read($value['warehouse']);
  3627. $info_list[$key]['warehouse'] = $warehouse['title'];
  3628. $retreatwarehouse = $this->warehouse->read($value['retreatwarehouse']);
  3629. $info_list[$key]['retreatwarehouse'] = $retreatwarehouse['title'];
  3630. $purchase = $this->purchase->read($value['purchase']);
  3631. $info_list[$key]['purchase'] = $purchase['title'];
  3632. if ($value['outk'] != 0) {
  3633. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  3634. } else {
  3635. $info_list[$key]['outk'] = "";
  3636. }
  3637. if ($value['retreat'] != 0) {
  3638. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']);
  3639. } else {
  3640. $info_list[$key]['retreat'] = "";
  3641. }
  3642. if ($value['orderinfo'] == 0) {
  3643. $info_list[$key]['orderinfo'] = "";
  3644. }
  3645. if ($value['waybill'] == 0) {
  3646. $info_list[$key]['waybill'] = "";
  3647. }
  3648. }
  3649. $total = $this->whlabel->find_count($where);
  3650. $pagenum = ceil($total / $perpage);
  3651. $over = $total - ($start + $perpage);
  3652. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3653. echo json_encode($rows);
  3654. exit;
  3655. }
  3656. $this->_Template('whlabel_retreatlk', $this->data);
  3657. }
  3658. //更换标签及浏览
  3659. public function _change()
  3660. {
  3661. $post = $this->input->post(NULL, TRUE);
  3662. if (isset($post['page'])) {
  3663. $page = $this->input->post('page', true);
  3664. $perpage = $this->input->post('perpage', true);
  3665. $timetk = $this->input->post('timetk', true);
  3666. $timetj = $this->input->post('timetj', true);
  3667. $label = $this->input->post('label', true);
  3668. $oldlabel = $this->input->post('oldlabel', true);
  3669. $timetk = strtotime($timetk);
  3670. $timetj = strtotime($timetj);
  3671. $where = "state=10 ";
  3672. if ($timetk && $timetj) {
  3673. $where .= " and labeltime > '$timetk' and labeltime < '$timetj'";
  3674. }
  3675. if ($label) {
  3676. $where .= " and label = '$label'";
  3677. }
  3678. if ($oldlabel) {
  3679. $where .= " and oldlabel = '$oldlabel'";
  3680. }
  3681. //数据排序
  3682. $order_str = "time asc";
  3683. if (empty($page)) {
  3684. $start = 0;
  3685. $perpage = 1;
  3686. } else {
  3687. $start = ($page - 1) * $perpage;
  3688. }
  3689. //取得信息列表
  3690. $info_list = $this->whlabel->find_all($where, 'id,oldlabel,oldtitle,label,title, labeltime', $order_str, $start, $perpage);
  3691. foreach ($info_list as $key => $value) {
  3692. $info_list[$key]['labeltime'] = date('Y-m-d H:i:s', $value['labeltime']);
  3693. }
  3694. $total = $this->whlabel->find_count($where);
  3695. $pagenum = ceil($total / $perpage);
  3696. $over = $total - ($start + $perpage);
  3697. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  3698. echo json_encode($rows);
  3699. exit;
  3700. }
  3701. $this->_Template('whlabel_change', $this->data);
  3702. }
  3703. //产品标签
  3704. public function _cpbqdc()
  3705. {
  3706. if (isset($_GET['excel'])) {
  3707. $where = "1=1";
  3708. //数据排序
  3709. $order_str = "id desc";
  3710. if (empty($page)) {
  3711. $start = 0;
  3712. $perpage = 1;
  3713. } else {
  3714. $start = ($page - 1) * $perpage;
  3715. }
  3716. $warehouse = $this->input->get('warehouse', true);
  3717. $state = $this->input->get('state', true);
  3718. $timetk = $this->input->get('timetkk', true);
  3719. $timetj = $this->input->get('timetjj', true);
  3720. $timetk = strtotime($timetk);
  3721. $timetj = strtotime($timetj);
  3722. if ($warehouse) {
  3723. $where .= " and warehouse = '$warehouse'";
  3724. }
  3725. if ($state || $state == 0) {
  3726. $where .= " and state = '$state'";
  3727. }
  3728. if ($timetk && $timetj) {
  3729. $where .= " and time > '$timetk' and time < '$timetj'";
  3730. }
  3731. //取得信息列表
  3732. $info_list = $this->whlabel->find_all($where, '*');
  3733. $rows = array();
  3734. $list = array();
  3735. foreach ($info_list as $key => $value) {
  3736. $rows[$value['time']] = $value; //所有数据sku
  3737. }
  3738. foreach ($rows as $value) {
  3739. $warehouse = $this->warehouse->read($value['warehouse']);
  3740. $s = $this->whlabel->find_count($where . ' and time = "' . $value['time'] . '"');
  3741. $list[] = array($warehouse['title'], $value['sku'], $value['title'], date('Y-m-d H:i:s', $value['enter']), date('Y-m-d H:i:s', $value['time']), $value['text'], $s);
  3742. }
  3743. $title = "产品标签统计表";
  3744. $titlename = "<table border=1>
  3745. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  3746. <tr align='center'>
  3747. <td>仓库</td>
  3748. <td>SKU</td>
  3749. <td>产品</td>
  3750. <td>入库时间</td>
  3751. <td>操作时间</td>
  3752. <td>备注</td>
  3753. <td>数量</td>
  3754. </tr>
  3755. </table>";
  3756. $filename = $title . ".xls";
  3757. $tail = "";
  3758. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  3759. }
  3760. }
  3761. //进销存导出
  3762. public function _exceljxc()
  3763. {
  3764. $classid = $this->classid->sku();
  3765. $pm = $classid;
  3766. $typeclass = array();
  3767. $tc = $this->typeclass->find_all();
  3768. foreach ($tc as $v) {
  3769. $typeclass[$v['id']] = $v;
  3770. }
  3771. $prc = array();
  3772. $purchase = $this->purchase->find_all();
  3773. foreach ($purchase as $k => $v) {
  3774. $prc[$v['id']] = $v['title'];
  3775. }
  3776. if (isset($_GET['excel'])) {
  3777. $where = "sku != 'Preset'";
  3778. //数据排序
  3779. $order_str = "id desc";
  3780. if (empty($page)) {
  3781. $start = 0;
  3782. $perpage = 1;
  3783. } else {
  3784. $start = ($page - 1) * $perpage;
  3785. }
  3786. $category = $this->input->get('category', true);
  3787. $warehouse = $this->input->get('warehouse', true);
  3788. $excelid = $this->input->get('sid', true);
  3789. if ($category) {
  3790. $where .= " and features like '%-$category-%'";
  3791. }
  3792. if ($warehouse) {
  3793. $where .= " and warehouse = '$warehouse'";
  3794. }
  3795. $xzid = '';
  3796. if ($excelid) {
  3797. $excelid = explode(',', trim($excelid, ','));
  3798. foreach ($excelid as $key => $value) {
  3799. $xzid .= " id = " . $value . " or";
  3800. }
  3801. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  3802. }
  3803. //取得信息列表
  3804. /**
  3805. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  3806. $rows = array();$list = array();
  3807. foreach ($info_list as $key=>$value)
  3808. {
  3809. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  3810. }
  3811. **/
  3812. $wt = array();
  3813. $whlabel_type = $this->whlabel_type->find_all();
  3814. foreach ($whlabel_type as $v) {
  3815. $wt[$v['id']] = $v['title'];
  3816. }
  3817. $wh = array();
  3818. $w = $this->warehouse->find_all('1=1', 'id,title');
  3819. foreach ($w as $v) {
  3820. $wh[$v['id']] = $v['title'];
  3821. }
  3822. $list = array();
  3823. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  3824. foreach ($rows as $key => $value) {
  3825. if (isset($wt[$value['type']])) {
  3826. $rows[$key]['type'] = $wt[$value['type']];
  3827. } else {
  3828. $rows[$key]['type'] = '未设置';
  3829. }
  3830. $bm = '03';
  3831. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  3832. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  3833. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state');
  3834. $details = array();
  3835. $cpid = array();
  3836. $cpbz = array();
  3837. $c = 0;
  3838. $g = 0;
  3839. $x = 0;
  3840. $t = 0;
  3841. $s = 0;
  3842. $q = 0;
  3843. foreach ($sd as $k => $v) {
  3844. if ($v['state'] == 0) {
  3845. $c++;
  3846. if ($v['cpid'] != 0) {
  3847. $cpid[$v['cpid']] = $v['cpid'];
  3848. }
  3849. if ($v['cpbz'] != '') {
  3850. $cpbz[$v['cpbz']] = $v['cpbz'];
  3851. }
  3852. }
  3853. if ($v['state'] != 9) {
  3854. $g++;
  3855. }
  3856. if ($v['state'] == 1) {
  3857. $x++;
  3858. }
  3859. if ($v['state'] == 2) {
  3860. $t++;
  3861. }
  3862. if ($v['state'] == 8) {
  3863. $s++;
  3864. }
  3865. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  3866. $q++;
  3867. }
  3868. $details[$v['details']] = $v['details'];
  3869. }
  3870. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  3871. $rows[$key]['details'] = implode("、", $details);
  3872. $rows[$key]['details'] = trim($rows[$key]['details'], "、");
  3873. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  3874. $number = $value['number'];
  3875. $ftime = time() - 15 * 24 * 3600;
  3876. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  3877. $rows[$key]['number'] = $g;
  3878. $rows[$key]['c'] = $c;
  3879. $rows[$key]['x'] = $x;
  3880. $rows[$key]['t'] = $t;
  3881. $rows[$key]['s'] = $s;
  3882. $rows[$key]['q'] = $q;
  3883. $rows[$key]['z'] = $z;
  3884. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  3885. $features = explode('-', trim($features, '-'));
  3886. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  3887. // $pm = $classid;
  3888. // $jm = $classid;
  3889. // foreach($features as $k=>$v)
  3890. // {
  3891. // if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  3892. // {
  3893. // if($typeclass[$v]['bm'] != '')
  3894. // {
  3895. // $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  3896. // }
  3897. // }
  3898. // if($v != 0)
  3899. // {
  3900. // if(!isset($typeclass[$v]))
  3901. // {
  3902. // continue;
  3903. // }
  3904. // if(isset($pm[$typeclass[$v]['classid']]))
  3905. // {
  3906. // if(stripos($typeclass[$v]['zh'],'|') !== false)
  3907. // {
  3908. // $tz = explode('|',$typeclass[$v]['zh']);
  3909. // $pm[$typeclass[$v]['classid']] = $tz[0];
  3910. // }
  3911. // else
  3912. // {
  3913. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  3914. // }
  3915. // }
  3916. // if(isset($jm[$typeclass[$v]['classid']]))
  3917. // {
  3918. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  3919. // }
  3920. // }
  3921. // }
  3922. // $jm = array_filter($jm);
  3923. // $rows[$key]['bs'] = implode("-",$jm);
  3924. // $rows[$key]['cs'] = $bm.implode("",$bmpx);
  3925. // $zh = implode(" ",$pm);
  3926. // $zh = str_replace('自然色 ','',trim($zh,' '));
  3927. // $zh = str_replace(array(' ',' ',' ',' ',' ',' ',' '),' ',$zh);
  3928. // $zh = preg_replace("/\r\n|\r|\n/",'',$zh);
  3929. // $rows[$key]['features'] = $zh;
  3930. }
  3931. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  3932. $final_list = [];
  3933. foreach ($list as $k => $v) {
  3934. if (empty($v['sku'])) {
  3935. continue;
  3936. }
  3937. $final_list[] = [
  3938. "warehouse" => $v["warehouse"],
  3939. "purchase" => $v["purchase"],
  3940. "details" => $v["details"],
  3941. "cpid" => $v["cpid"],
  3942. "dbcontent" => $v["dbcontent"],
  3943. "sku" => $v["sku"],
  3944. "cs" => $v["bm"],
  3945. "bs" => $v["jm"],
  3946. "title" => $v["title"],
  3947. "features" => $v["pm"],
  3948. "cpbz" => $v["cpbz"],
  3949. "sm" => $v["sm"],
  3950. "type" => $v["type"],
  3951. "number" => $v["number"],
  3952. "c" => $v["c"],
  3953. "x" => $v["x"],
  3954. "t" => $v["t"],
  3955. "s" => $v["s"],
  3956. "q" => $v["q"],
  3957. "z" => $v["z"],
  3958. "weight" => $v['weight'],
  3959. ];
  3960. }
  3961. $title = "总进销存统计表";
  3962. $titlename = "<table border=1>
  3963. <tr><th colspan='21' align='center'><h3>" . $title . "<h3></th></tr>
  3964. <tr align='center'>
  3965. <td>仓库</td>
  3966. <td>供应商</td>
  3967. <td>位置</td>
  3968. <td>库存编码</td>
  3969. <td>类目</td>
  3970. <td>SKU</td>
  3971. <td>用友编码</td>
  3972. <td>用友料号</td>
  3973. <td>商品名称</td>
  3974. <td>商品中文</td>
  3975. <td>产品备注</td>
  3976. <td>库位负责人</td>
  3977. <td>类型</td>
  3978. <td>入库总量</td>
  3979. <td>库存数量</td>
  3980. <td>销售数量</td>
  3981. <td>退货数量</td>
  3982. <td>删除数量</td>
  3983. <td>其它操作</td>
  3984. <td>占单数量</td>
  3985. <td>重量(g)</td>
  3986. </tr>
  3987. </table>";
  3988. $filename = $title . ".xls";
  3989. $tail = "";
  3990. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  3991. }
  3992. }
  3993. //入库导出
  3994. public function _excelr()
  3995. {
  3996. if (isset($_GET['excel'])) {
  3997. $category = $this->input->get('category', true);
  3998. $size = $this->input->get('size', true);
  3999. $grade = $this->input->get('grade', true);
  4000. $color = $this->input->get('color', true);
  4001. $lowe = $this->input->get('lowe', true);
  4002. $sku = $this->input->get('sku', true);
  4003. $warehouse = $this->input->get('warehouse', true);
  4004. $purchase = $this->input->get('purchase', true);
  4005. $ktime = $this->input->get('ktime', true);
  4006. $jtime = $this->input->get('jtime', true);
  4007. $rktype = $this->input->get('rktype',true);
  4008. $ktime = strtotime($ktime);
  4009. $jtime = strtotime($jtime);
  4010. $where = "1=1";
  4011. $gj = "";
  4012. $ck = "";
  4013. if ($category) {
  4014. $where .= " and features like '%-$category-%'";
  4015. }
  4016. if ($size) {
  4017. $where .= " and features like '%-$size-%'";
  4018. }
  4019. if ($grade) {
  4020. $where .= " and features like '%-$grade-%'";
  4021. }
  4022. if ($color) {
  4023. $where .= " and features like '%-$color-%'";
  4024. }
  4025. if ($lowe) {
  4026. $where .= " and features like '%-$lowe-%'";
  4027. }
  4028. if ($warehouse) {
  4029. $where .= " and warehouse = '$warehouse'";
  4030. }
  4031. if ($purchase) {
  4032. $where .= " and purchase = '$purchase'";
  4033. }
  4034. if ($sku) {
  4035. $where .= " and sku = '$sku'";
  4036. }
  4037. if($rktype){
  4038. $where .= " and rktype = '$rktype' ";
  4039. }
  4040. if ($ktime && $jtime) {
  4041. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  4042. }
  4043. //数据排序
  4044. $order_str = "id desc";
  4045. if (empty($page)) {
  4046. $start = 0;
  4047. $perpage = 1;
  4048. } else {
  4049. $start = ($page - 1) * $perpage;
  4050. }
  4051. $list = array();
  4052. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  4053. $three_month = strtotime('-3 months');
  4054. $rows_d = $this->whlabelscbf->find_pc($where." and del_time > ".$three_month, 'enter,sku,warehouse', '*', $order_str);
  4055. $rows_d = array_map(function ($item) {
  4056. unset($item['del_time']); // 删除 age 字段
  4057. return $item;
  4058. }, $rows_d);
  4059. $rows = array_merge($rows, $rows_d);
  4060. foreach ($rows as $value) {
  4061. $ck = $this->warehouse->read($value['warehouse']);
  4062. $warehouse = $ck['title'];
  4063. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  4064. $retreatwarehouse = $tkck['title'];
  4065. $gy = $this->purchase->read($value['purchase']);
  4066. $purchase = $gy['title'];
  4067. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  4068. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  4069. }
  4070. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  4071. $titlename = "<table border=1>
  4072. <tr><th colspan='5' align='center'><h3>" . $title . "<h3></th></tr>
  4073. <tr align='center'>
  4074. <td>仓库</td>
  4075. <td>SKU</td>
  4076. <td>产品</td>
  4077. <td>时间</td>
  4078. <td>数量</td>
  4079. </tr>
  4080. </table>";
  4081. $filename = $title . ".xls";
  4082. $tail = "";
  4083. $this->excelxh->get_fz2($list, $titlename, $filename, $tail);
  4084. }
  4085. }
  4086. //出库、退库导出
  4087. public function _excelct()
  4088. {
  4089. $classid = $this->classid->sku();
  4090. $pm = $classid;
  4091. $typeclass = array();
  4092. $tc = $this->typeclass->find_all();
  4093. foreach ($tc as $v) {
  4094. $typeclass[$v['id']] = $v;
  4095. }
  4096. $prc = array();
  4097. $purchase = $this->purchase->find_all();
  4098. foreach ($purchase as $k => $v) {
  4099. $prc[$v['id']] = $v['title'];
  4100. }
  4101. if (isset($_GET['excel'])) {
  4102. $wh = array();
  4103. $w = $this->warehouse->find_all('1=1', 'id,title');
  4104. foreach ($w as $v) {
  4105. $wh[$v['id']] = $v['title'];
  4106. }
  4107. $type = $this->input->get('excel', true);
  4108. $category = $this->input->get('category', true);
  4109. $size = $this->input->get('size', true);
  4110. $grade = $this->input->get('grade', true);
  4111. $color = $this->input->get('color', true);
  4112. $lowe = $this->input->get('lowe', true);
  4113. $sku = $this->input->get('sku', true);
  4114. $title = $this->input->get('title', true);
  4115. $warehouse = $this->input->get('warehouse', true);
  4116. $purchase = $this->input->get('purchase', true);
  4117. $lacetype = $this->input->get('lacetype', true);
  4118. $haircap = $this->input->get('haircap', true);
  4119. $lacecolor = $this->input->get('lacecolor', true);
  4120. $density = $this->input->get('density', true);
  4121. $details = $this->input->get('details', true);
  4122. $state = $this->input->get('state', true);
  4123. $shop = $this->input->get('shop', true);
  4124. $hairnumber = $this->input->get('hairnumber', true);
  4125. $type_leixi = $this->input->get('type', true);
  4126. $cpbz = $this->input->get('cpbz', true);
  4127. $sm = $this->input->get('sm', true);
  4128. $sid = $this->input->get('sid', true);
  4129. $ktime = $this->input->get('ktime', true);
  4130. $jtime = $this->input->get('jtime', true);
  4131. $ktime = strtotime($ktime);
  4132. $jtime = strtotime($jtime);
  4133. //$where = " 1=1 ";
  4134. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  4135. $where = " sku != '' ";
  4136. $gj = "";
  4137. $ck = "";
  4138. if ($category) {
  4139. $where .= " and features like '%-$category-%'";
  4140. }
  4141. if ($size) {
  4142. $where .= " and features like '%-$size-%'";
  4143. }
  4144. if ($grade) {
  4145. $where .= " and features like '%-$grade-%'";
  4146. }
  4147. if ($color) {
  4148. $where .= " and features like '%-$color-%'";
  4149. }
  4150. if ($lowe) {
  4151. $where .= " and features like '%-$lowe-%'";
  4152. }
  4153. if ($warehouse) {
  4154. $where .= " and warehouse = '$warehouse'";
  4155. }
  4156. if ($purchase) {
  4157. $where .= " and purchase = '$purchase'";
  4158. }
  4159. if ($state) {
  4160. $where .= " and state = '$state'";
  4161. }
  4162. if ($lacetype) {
  4163. $where .= " and features like '%-$lacetype-%'";
  4164. }
  4165. if ($lacecolor) {
  4166. $where .= " and features like '%-$lacecolor-%'";
  4167. }
  4168. if ($density) {
  4169. $where .= " and features like '%-$density-%'";
  4170. }
  4171. if ($haircap) {
  4172. $where .= " and features like '%-$haircap-%'";
  4173. }
  4174. if ($details) {
  4175. $where .= " and details = '$details'";
  4176. }
  4177. if ($shop) {
  4178. $where .= " and shop like '%$shop%'";
  4179. }
  4180. if ($title) {
  4181. $title = trim($title, ' ');
  4182. $title = trim($title, ' ');
  4183. $where .= " and title like '%$title%'";
  4184. }
  4185. if (!empty($hairnumber)) {
  4186. $where .= " and features like '%-128-%' ";
  4187. if ($hairnumber < 0) {
  4188. $class_list = $this->typeclass->find_all('classid = 43');
  4189. foreach ($class_list as $v) {
  4190. $where .= " and features not like '%-" . $v['id'] . "-%'";
  4191. }
  4192. } else {
  4193. $where .= " and features like '%-$hairnumber-%'";
  4194. }
  4195. }
  4196. if ($type_leixi) {
  4197. $where .= " and type = '$type_leixi'";
  4198. }
  4199. if ($cpbz) {
  4200. $where .= " and cpbz like '%$cpbz%' ";
  4201. }
  4202. if ($sm) {
  4203. $where .= " and sm like '%$sm%' ";
  4204. }
  4205. if ($sku) {
  4206. $sku = trim($sku, ' ');
  4207. $sku = trim($sku, ' ');
  4208. $where .= " and sku like '%$sku%'";
  4209. }
  4210. if ($ktime && $jtime) {
  4211. if ($type == 1) {
  4212. $tl = '出库';
  4213. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  4214. } else if ($type == 2) {
  4215. $tl = '退库';
  4216. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  4217. } else if ($type == 3) {
  4218. $gj = " and enter > '$ktime' and enter < '$jtime'";
  4219. $ck = " and outk > '$ktime' and outk < '$jtime'";
  4220. } else if ($type == 4) {
  4221. $tl = '出库+零售';
  4222. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  4223. } else if ($type == 5) {
  4224. $tl = '零售';
  4225. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  4226. }
  4227. }
  4228. $sidwhere = '';
  4229. if ($sid) {
  4230. $sd = "";
  4231. $s = explode(',', trim($sid, ','));
  4232. foreach ($s as $value) {
  4233. $sd .= " id = " . $value . " or";
  4234. }
  4235. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  4236. }
  4237. //数据排序
  4238. $order_str = "time desc";
  4239. if (empty($page)) {
  4240. $start = 0;
  4241. $perpage = 1;
  4242. } else {
  4243. $start = ($page - 1) * $perpage;
  4244. }
  4245. //取得信息列表
  4246. if ($type != 3 && $type != 5) {
  4247. if ($type == 1 || $type == 4) {
  4248. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4249. $three_month = strtotime('-3 months');
  4250. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  4251. $info_list_d = array_map(function ($item) {
  4252. unset($item['del_time']); // 删除 age 字段
  4253. return $item;
  4254. }, $info_list_d);
  4255. $info_list = array_merge($info_list, $info_list_d);
  4256. foreach ($info_list as $key => $value) {
  4257. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4258. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4259. $warehouse = $this->warehouse->read($value['warehouse']);
  4260. $info_list[$key]['warehouse'] = $warehouse['title'];
  4261. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4262. $features = explode('-', trim($features, '-'));
  4263. $pm = $classid;
  4264. foreach ($features as $k => $v) {
  4265. if ($v != 0) {
  4266. if (!isset($typeclass[$v])) {
  4267. continue;
  4268. }
  4269. if (isset($pm[$typeclass[$v]['classid']])) {
  4270. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4271. $tz = explode('|', $typeclass[$v]['zh']);
  4272. $pm[$typeclass[$v]['classid']] = $tz[0];
  4273. } else {
  4274. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4275. }
  4276. }
  4277. }
  4278. }
  4279. $zh = implode(" ", $pm);
  4280. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4281. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4282. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4283. $info_list[$key]['features'] = $zh;
  4284. }
  4285. $final_list = [];
  4286. foreach($info_list as $k=>$v){
  4287. $number = "";
  4288. if(!empty($v['orderinfo'])){
  4289. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4290. if(!empty($tmp_info['number'])){
  4291. $number = $tmp_info['number'];
  4292. }
  4293. }
  4294. $final_list[] = [
  4295. 'warehouse'=>$v['warehouse'],
  4296. 'purchase'=>$v['purchase'],
  4297. 'sku'=>$v['sku'],
  4298. 'title'=>$v['title'],
  4299. 'features'=>$v['features'],
  4300. 'label'=>$v['label'],
  4301. 'orderinfo'=>$v['orderinfo'],
  4302. 'number'=>$number,
  4303. 'waybill'=>$v['waybill'],
  4304. 'outk'=>$v['outk'],
  4305. ];
  4306. }
  4307. } else {
  4308. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  4309. foreach ($info_list as $key => $value) {
  4310. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4311. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  4312. $warehouse = $this->warehouse->read($value['warehouse']);
  4313. $info_list[$key]['warehouse'] = $warehouse['title'];
  4314. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4315. $features = explode('-', trim($features, '-'));
  4316. $pm = $classid;
  4317. foreach ($features as $k => $v) {
  4318. if ($v != 0) {
  4319. if (!isset($typeclass[$v])) {
  4320. continue;
  4321. }
  4322. if (isset($pm[$typeclass[$v]['classid']])) {
  4323. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4324. $tz = explode('|', $typeclass[$v]['zh']);
  4325. $pm[$typeclass[$v]['classid']] = $tz[0];
  4326. } else {
  4327. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4328. }
  4329. }
  4330. }
  4331. }
  4332. $zh = implode(" ", $pm);
  4333. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4334. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4335. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4336. $info_list[$key]['features'] = $zh;
  4337. }
  4338. $final_list = [];
  4339. foreach($info_list as $k=>$v){
  4340. $number = "";
  4341. if(!empty($v['orderinfo'])){
  4342. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  4343. if(!empty($tmp_info['number'])){
  4344. $number = $tmp_info['number'];
  4345. }
  4346. }
  4347. $final_list[] = [
  4348. 'warehouse'=>$v['warehouse'],
  4349. 'purchase'=>$v['purchase'],
  4350. 'sku'=>$v['sku'],
  4351. 'title'=>$v['title'],
  4352. 'features'=>$v['features'],
  4353. 'label'=>$v['label'],
  4354. 'orderinfo'=>$v['orderinfo'],
  4355. 'number'=>$number,
  4356. 'waybill'=>$v['waybill'],
  4357. 'retreat'=>$v['retreat'],
  4358. ];
  4359. }
  4360. }
  4361. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4362. $titlename = "<table border=1>
  4363. <tr><th colspan='10' align='center'><h3>" . $title . "<h3></th></tr>
  4364. <tr align='center'>
  4365. <td>仓库</td>
  4366. <td>供应商</td>
  4367. <td>SKU</td>
  4368. <td>商品名称</td>
  4369. <td>商品中文</td>
  4370. <td>标签</td>
  4371. <td>订单号</td>
  4372. <td>订单编码</td>
  4373. <td>运单号</td>
  4374. <td>" . $tl . "时间(中国时间)</td>
  4375. </tr>
  4376. </table>";
  4377. $filename = $title . ".xls";
  4378. $tail = "";
  4379. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4380. } else if ($type == 5) {
  4381. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4382. $three_month = strtotime('-3 months');
  4383. $info_list_d = $this->whlabelscbf->find_all($where." and del_time > ".$three_month, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  4384. $info_list_d = array_map(function ($item) {
  4385. unset($item['del_time']); // 删除 age 字段
  4386. return $item;
  4387. }, $info_list_d);
  4388. $info_list = array_merge($info_list, $info_list_d);
  4389. foreach ($info_list as $key => $value) {
  4390. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4391. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  4392. $warehouse = $this->warehouse->read($value['warehouse']);
  4393. $info_list[$key]['warehouse'] = $warehouse['title'];
  4394. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4395. $features = explode('-', trim($features, '-'));
  4396. $pm = $classid;
  4397. foreach ($features as $k => $v) {
  4398. if ($v != 0) {
  4399. if (!isset($typeclass[$v])) {
  4400. continue;
  4401. }
  4402. if (isset($pm[$typeclass[$v]['classid']])) {
  4403. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4404. $tz = explode('|', $typeclass[$v]['zh']);
  4405. $pm[$typeclass[$v]['classid']] = $tz[0];
  4406. } else {
  4407. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4408. }
  4409. }
  4410. }
  4411. }
  4412. $zh = implode(" ", $pm);
  4413. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4414. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4415. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4416. $info_list[$key]['features'] = $zh;
  4417. }
  4418. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . $tl . '详情';
  4419. $titlename = "<table border=1>
  4420. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  4421. <tr align='center'>
  4422. <td>仓库</td>
  4423. <td>供应商</td>
  4424. <td>SKU</td>
  4425. <td>商品名称</td>
  4426. <td>商品中文</td>
  4427. <td>标签</td>
  4428. <td>" . $tl . "时间(中国时间)</td>
  4429. </tr>
  4430. </table>";
  4431. $filename = $title . ".xls";
  4432. $tail = "";
  4433. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  4434. } else {
  4435. /**
  4436. $info_list = $this->whlabel->find_all($where.$sidwhere,'*');
  4437. $rows = array();$list = array();
  4438. foreach ($info_list as $key=>$value)
  4439. {
  4440. $rows[strtolower($value['sku']).'warehouse'.$value['warehouse']] = $value;//所有数据sku
  4441. }
  4442. **/
  4443. $wh = array();
  4444. $w = $this->warehouse->find_all('1=1', 'id,title');
  4445. foreach ($w as $v) {
  4446. $wh[$v['id']] = $v['title'];
  4447. }
  4448. $wt = array();
  4449. $whlabel_type = $this->whlabel_type->find_all();
  4450. foreach ($whlabel_type as $v) {
  4451. $wt[$v['id']] = $v['title'];
  4452. }
  4453. $classid = $this->classid->sku();
  4454. $list = array();
  4455. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  4456. foreach ($rows as $key => $value) {
  4457. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4458. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  4459. $sd = $this->whlabel->find_all($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid,cpbz,state,outk,retreat');
  4460. $details = array();
  4461. $cpid = array();
  4462. $cpbz = array();
  4463. $c = 0;
  4464. $g = 0;
  4465. $x = 0;
  4466. $t = 0;
  4467. $s = 0;
  4468. $q = 0;
  4469. foreach ($sd as $k => $v) {
  4470. if ($v['state'] == 0) {
  4471. $c++;
  4472. }
  4473. if ($v['state'] != 9) {
  4474. $g++;
  4475. }
  4476. if ($v['outk'] > 1) {
  4477. $x++;
  4478. }
  4479. if ($v['retreat'] > 0) {
  4480. $t++;
  4481. }
  4482. if ($v['state'] == 8) {
  4483. $s++;
  4484. }
  4485. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  4486. $q++;
  4487. }
  4488. $details[$v['details']] = $v['details'];
  4489. if($v['state'] == 0){
  4490. if ($v['cpid'] != 0) {
  4491. $cpid[$v['cpid']] = $v['cpid'];
  4492. }
  4493. if ($v['cpbz'] != '') {
  4494. $cpbz[$v['cpbz']] = $v['cpbz'];
  4495. }
  4496. }
  4497. }
  4498. if (isset($wt[$value['type']])) {
  4499. $rows[$key]['type'] = $wt[$value['type']];
  4500. } else {
  4501. $rows[$key]['type'] = '未设置';
  4502. }
  4503. $rows[$key]['details'] = implode("、", $details);
  4504. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  4505. $ftime = time() - 15 * 24 * 3600;
  4506. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  4507. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  4508. $rows[$key]['g'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state != 9' . $gj);
  4509. $rows[$key]['c'] = $c;
  4510. $rows[$key]['x'] = $this->whlabel->find_count($where . ' and purchase = "' . $value['purchase'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '" and state = 1' . $ck);
  4511. $rows[$key]['t'] = $t;
  4512. $z = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and zd != "" and state = 0 and purchase = "' . $value['purchase'] . '" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"');
  4513. $rows[$key]['z'] = $z;
  4514. // $jm = $classid;
  4515. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  4516. $features = explode('-', trim($features, '-'));
  4517. // $pm = $classid;
  4518. // foreach ($features as $k => $v) {
  4519. // if ($v != 0) {
  4520. // if (!isset($typeclass[$v])) {
  4521. // continue;
  4522. // }
  4523. // if (isset($pm[$typeclass[$v]['classid']])) {
  4524. // if (stripos($typeclass[$v]['zh'], '|') !== false) {
  4525. // $tz = explode('|', $typeclass[$v]['zh']);
  4526. // $pm[$typeclass[$v]['classid']] = $tz[0];
  4527. // } else {
  4528. // $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  4529. // }
  4530. // if (isset($jm[$typeclass[$v]['classid']])) {
  4531. // if ($typeclass[$v]['jm']) {
  4532. // $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  4533. // }
  4534. // }
  4535. // }
  4536. // }
  4537. // }
  4538. // $zh = implode(" ", $pm);
  4539. // $zh = str_replace('自然色 ', '', trim($zh, ' '));
  4540. // $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  4541. // $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  4542. // $rows[$key]['features'] = $zh;
  4543. // $jm = array_filter($jm); //去除空值
  4544. // $jm = implode("-", $jm);
  4545. // $rows[$key]['jm'] = $jm;
  4546. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  4547. }
  4548. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  4549. // echo "<pre>";
  4550. // print_r($tmp_list);
  4551. // die;
  4552. $final_list =[];
  4553. foreach($tmp_list as $k=>$v){
  4554. $final_list[] = [
  4555. "warehouse"=>$v['warehouse'],
  4556. "purchase"=>$v['purchase'],
  4557. "details"=>trim($v['details'],'、'),
  4558. "cpid"=>$v['cpid'],
  4559. "sku"=>$v['sku'],
  4560. "title"=>$v['title'],
  4561. "features"=>$v['pm'],
  4562. "cpbz"=>$v['cpbz'],
  4563. "sm"=>$v['sm'],
  4564. "type"=>$v['type'],
  4565. "g"=>$v["g"],
  4566. "c"=>$v["c"],
  4567. "x"=>$v["x"],
  4568. "t"=>$v["t"],
  4569. "z"=>$v["z"],
  4570. "jm"=>$v["jm"],
  4571. "weight"=>$v["weight"],
  4572. "asd"=>$v["asd"],
  4573. ];
  4574. }
  4575. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  4576. $titlename = "<table border=1>
  4577. <tr><th colspan='18' align='center'><h3>" . $title . "<h3></th></tr>
  4578. <tr align='center'>
  4579. <td>仓库</td>
  4580. <td>供应商</td>
  4581. <td>位置</td>
  4582. <td>库存编码</td>
  4583. <td>SKU</td>
  4584. <td>商品名称</td>
  4585. <td>商品中文</td>
  4586. <td>产品备注</td>
  4587. <td>说明</td>
  4588. <td>类型</td>
  4589. <td>入库总量</td>
  4590. <td>库存数量</td>
  4591. <td>销售数量</td>
  4592. <td>退货数量</td>
  4593. <td>占单数量</td>
  4594. <td>料号</td>
  4595. <td>重量</td>
  4596. <td>类目</td>
  4597. </tr>
  4598. </table>";
  4599. $filename = $title . ".xls";
  4600. $tail = "";
  4601. $this->excelxh->get_fz2($final_list, $titlename, $filename, $tail);
  4602. }
  4603. }
  4604. }
  4605. //出库+入库数据整合
  4606. public function _excelcr()
  4607. {
  4608. if (isset($_GET['excel'])) {
  4609. $type = $this->input->get('excel', true);
  4610. $category = $this->input->get('category', true);
  4611. $size = $this->input->get('size', true);
  4612. $grade = $this->input->get('grade', true);
  4613. $color = $this->input->get('color', true);
  4614. $lowe = $this->input->get('lowe', true);
  4615. $sku = $this->input->get('sku', true);
  4616. $warehouse = $this->input->get('warehouse', true);
  4617. $purchase = $this->input->get('purchase', true);
  4618. $state = $this->input->get('state', true);
  4619. $sid = $this->input->get('sid', true);
  4620. $ktime = $this->input->get('ktime', true);
  4621. $jtime = $this->input->get('jtime', true);
  4622. $ktime = strtotime($ktime);
  4623. $jtime = strtotime($jtime);
  4624. $where = "1=1";
  4625. $gj = "";
  4626. $ck = "";
  4627. if ($category) {
  4628. $where .= " and features like '%-$category-%'";
  4629. }
  4630. if ($size) {
  4631. $where .= " and features like '%-$size-%'";
  4632. }
  4633. if ($grade) {
  4634. $where .= " and features like '%-$grade-%'";
  4635. }
  4636. if ($color) {
  4637. $where .= " and features like '%-$color-%'";
  4638. }
  4639. if ($lowe) {
  4640. $where .= " and features like '%-$lowe-%'";
  4641. }
  4642. if ($warehouse) {
  4643. $where .= " and warehouse = '$warehouse'";
  4644. }
  4645. if ($purchase) {
  4646. $where .= " and purchase = '$purchase'";
  4647. }
  4648. if ($state) {
  4649. $where .= " and state = '$state'";
  4650. }
  4651. if ($sku) {
  4652. $where .= " and sku like '%$sku%'";
  4653. }
  4654. if ($ktime && $jtime) {
  4655. $where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  4656. }
  4657. $sidwhere = '';
  4658. if ($sid) {
  4659. $sd = "";
  4660. $s = explode(',', trim($sid, ','));
  4661. foreach ($s as $value) {
  4662. $sd .= " id = " . $value . " or";
  4663. }
  4664. $sidwhere .= " and (" . rtrim($sd, 'or') . ")";
  4665. }
  4666. //取得信息列表
  4667. $timeread = $ktime;
  4668. $timenum = ceil(($jtime - $ktime) / (24 * 3600));
  4669. $timelist = array();
  4670. for ($i = 0; $i < $timenum; $i++) {
  4671. $timeread = ($i > 0) ? $ktime + $i * 24 * 3600 : $ktime;
  4672. $timelist[date('Y-m-d', $timeread)] = array('c' => 0, 'r' => 0);
  4673. }
  4674. $info_list = $this->whlabel->find_all($where . $sidwhere, 'outk,enter,sku,state');
  4675. //echo "<pre>";
  4676. //print_r($info_list);
  4677. //exit();
  4678. $rows = array();
  4679. $list = array();
  4680. foreach ($info_list as $key => $value) {
  4681. $thistime = $timelist;
  4682. if (isset($rows[strtolower($value['sku'])])) {
  4683. if ($value['outk'] > $ktime && $value['state'] < $jtime) {
  4684. if(isset($rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])])){
  4685. $rows[strtolower($value['sku'])][date('Y-m-d', $value['outk'])]['c'] += 1;
  4686. }
  4687. }
  4688. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4689. if(isset($rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])])){
  4690. $rows[strtolower($value['sku'])][date('Y-m-d', $value['enter'])]['r'] += 1;
  4691. }
  4692. }
  4693. } else {
  4694. if ($value['outk'] > $ktime && $value['outk'] < $jtime) {
  4695. if(isset($thistime[date('Y-m-d', $value['outk'])])){
  4696. $thistime[date('Y-m-d', $value['outk'])]['c'] += 1;
  4697. }
  4698. }
  4699. if ($value['enter'] > $ktime && $value['enter'] < $jtime) {
  4700. if(isset($thistime[date('Y-m-d', $value['enter'])])){
  4701. $thistime[date('Y-m-d', $value['enter'])]['r'] += 1;
  4702. }
  4703. }
  4704. $rows[strtolower($value['sku'])] = $thistime;
  4705. }
  4706. }
  4707. $str = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">
  4708. <head>
  4709. <!--[if gte mso 9]><xml>
  4710. <x:ExcelWorkbook>
  4711. <x:ExcelWorksheets>
  4712. <x:ExcelWorksheet>
  4713. <x:Name>EXCEL</x:Name>
  4714. <x:WorksheetOptions>
  4715. <x:Print>
  4716. <x:ValidPrinterInfo />
  4717. </x:Print>
  4718. </x:WorksheetOptions>
  4719. </x:ExcelWorksheet>
  4720. </x:ExcelWorksheets>
  4721. </x:ExcelWorkbook>
  4722. </xml>
  4723. <![endif]-->
  4724. </head><body>";
  4725. $str .= "<table border=1><tr><td>SKU</td>";
  4726. foreach ($timelist as $k => $v) {
  4727. $str .= "<td>" . $k . "出库</td>";
  4728. $str .= "<td>" . $k . "入库</td>";
  4729. }
  4730. $str .= "</tr></table>";
  4731. $str .= "<table border=1 style='font-family: Microsoft Yahei;font-size: 13px;'>";
  4732. foreach ($rows as $key => $val) {
  4733. $str .= "<tr><td>" . strtoupper($key) . "</td>";
  4734. foreach ($val as $k => $v) {
  4735. $str .= "<td>" . $val[$k]['c'] . "</td>";
  4736. if ($val[$k]['r'] > 0) {
  4737. $str .= "<td style='color:#f00'>-" . $val[$k]['r'] . "</td>";
  4738. } else {
  4739. $str .= "<td>" . $val[$k]['r'] . "</td>";
  4740. }
  4741. }
  4742. $str .= "</tr>";
  4743. }
  4744. $str .= "</table>";
  4745. $str .= "</body></html>";
  4746. header("Content-Type: application/vnd.ms-excel; name='excel'");
  4747. header("Content-type: application/octet-stream");
  4748. header("Content-Disposition: attachment; filename=" . time() . '.xls');
  4749. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  4750. header("Pragma: no-cache");
  4751. header("Expires: 0");
  4752. exit($str);
  4753. }
  4754. }
  4755. //数量调整模板导出
  4756. public function _presetout()
  4757. {
  4758. if (isset($_GET['excel'])) {
  4759. $where = "sku != 'Preset' and purchase != 0";
  4760. //数据排序
  4761. $order_str = "id desc";
  4762. if (empty($page)) {
  4763. $start = 0;
  4764. $perpage = 1;
  4765. } else {
  4766. $start = ($page - 1) * $perpage;
  4767. }
  4768. //取得信息列表
  4769. $info_list = $this->whlabel->find_pc($where, 'warehouse,purchase,sku', '*', 'id desc', 0, 1);
  4770. $rows = array();
  4771. $list = array();
  4772. foreach ($info_list as $value) {
  4773. $warehouse = $this->warehouse->read($value['warehouse']);
  4774. $number = $value['number'];
  4775. $ftime = time() - 15 * 24 * 3600;
  4776. $purchase = $this->purchase->read($value['purchase']);
  4777. $list[] = array($warehouse['title'], $purchase['bm'], $value['sku'], '0', '', '', '', '');
  4778. }
  4779. $title = "库存模板";
  4780. $titlename = "<table border=1>
  4781. <tr align='center'>
  4782. <td>仓库</td>
  4783. <td>供应商编码</td>
  4784. <td>SKU</td>
  4785. <td>增减数量(正数或负数)</td>
  4786. <td>增减备注</td>
  4787. <td>库位</td>
  4788. <td>增加类型(增加为必填,填数字):1.采购入库2.盘盈调整3.其他调整入库4.退库入库5.退货可用入库6.形态转换入库</td>
  4789. <td>扣减类型(扣减为必填,填数字):1.销售出库2.美国销售调货出库3.盘亏调整4.其他调整出库5.形态转换出库</td>
  4790. </tr>
  4791. </table>";
  4792. $filename = $title . ".xls";
  4793. $tail = "";
  4794. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  4795. }
  4796. }
  4797. //数量调整模板导入
  4798. public function _presetedit()
  4799. {
  4800. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  4801. $config['upload_path'] = '.' . $dir;
  4802. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  4803. $config['allowed_types'] = 'xls|xlsx|csv';
  4804. $config['max_size'] = 10240;
  4805. $this->load->library('upload', $config);
  4806. $this->upload->initialize($config);
  4807. if ($this->upload->do_upload('userfile')) {
  4808. $full_path = $dir . $this->upload->data('file_name');
  4809. $fileName = '.' . $full_path;
  4810. if (!file_exists($fileName)) {
  4811. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  4812. exit;
  4813. } else {
  4814. require_once "./data/excel/PHPExcel/IOFactory.php";
  4815. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  4816. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  4817. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  4818. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  4819. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  4820. ++$column; //如果列数大于26行
  4821. $list = array();
  4822. for ($i = 2; $i <= $row; $i++) // 行数循环
  4823. {
  4824. $data = array();
  4825. for ($c = 'A'; $c != $column; $c++) // 列数循环
  4826. {
  4827. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  4828. }
  4829. $list[] = $data;
  4830. }
  4831. }
  4832. $i = 0;
  4833. $j = 0;
  4834. $ed = array();
  4835. foreach ($list as $key => $value) {
  4836. $time = time();
  4837. if ($value['0'] == "") {
  4838. continue;
  4839. }
  4840. $warehouse = $this->warehouse->get_title($value['0']);
  4841. $purchase = $this->purchase->get_bm($value['1']);
  4842. $sku = $value['2'];
  4843. $num = $value['3']; //调整数量
  4844. $text = $value['4']; //扣减说明
  4845. $type = $value['5']; //调整方式0扣减1删除
  4846. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4847. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4848. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  4849. if (!$purchase) //如果没有这个SKU
  4850. {
  4851. $ed[] = array($purchase . '-不存在此供应商编码');
  4852. $j++;
  4853. continue;
  4854. }
  4855. if (!$d) //如果没有这个SKU
  4856. {
  4857. $ed[] = array($sku . '-库存中不存在此SKU');
  4858. $j++;
  4859. continue;
  4860. }
  4861. if (!isset($warehouse['id'])) {
  4862. $ed[] = array($sku . '-仓库名错误!');
  4863. $j++;
  4864. continue;
  4865. }
  4866. if ($type != '0' && $type != '1') {
  4867. $ed[] = array($sku . '-扣减方式填写错误!');
  4868. $j++;
  4869. continue;
  4870. }
  4871. if ($num < 0) //扣减库存
  4872. {
  4873. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  4874. $ed[] = array($sku . '-扣减必须填写扣减类型,非类型1必须填写备注');
  4875. $j++;
  4876. continue;
  4877. }
  4878. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and zd = "" and state = 0');
  4879. if (count($data) < abs($num)) {
  4880. $ed[] = array($sku . '-扣减数量大于库存剩余数量!');
  4881. $j++;
  4882. continue;
  4883. }
  4884. if ($type == 0) //如果扣减方式为 扣减库存
  4885. {
  4886. for ($i = 0; $i < abs($num); $i++) {
  4887. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  4888. }
  4889. } else if ($type == 1) {
  4890. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  4891. if (count($zt) > 0) {
  4892. $ed[] = array($sku . '-有在途库存无法删除!');
  4893. $j++;
  4894. continue;
  4895. }
  4896. for ($i = 0; $i < abs($num); $i++) {
  4897. $this->whlabel->remove($data[$i]['id']);
  4898. }
  4899. }
  4900. } else if ($num > 0) //增加库存
  4901. {
  4902. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  4903. $ed[] = array($sku . '-增加必须填写增加类型,非类型1必须填写备注');
  4904. $j++;
  4905. continue;
  4906. }
  4907. $post['sku'] = $d['sku'];
  4908. $post['shop'] = $d['shop'];
  4909. $post['warehouse'] = $warehouse['id'];
  4910. $post['purchase'] = $purchase['id'];
  4911. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  4912. $post['state'] = 0;
  4913. $post['title'] = $d['title'];
  4914. $post['number'] = $d['number'];
  4915. $post['features'] = $d['features'];
  4916. $post['enter'] = $time;
  4917. $post['time'] = $time; //操作时间
  4918. $post['rktype'] = $rktype;
  4919. for ($i = 0; $i < $num; $i++) {
  4920. $post['label'] = time() . rand(100, 999) . $i;
  4921. $this->whlabel->insert($post);
  4922. }
  4923. }
  4924. sleep(1); //防止入库时间一样,需要延迟1秒
  4925. }
  4926. if ($j > 0) {
  4927. $tt = date('Ymd', time());
  4928. $title = '库存导入错误信息-' . $tt;
  4929. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  4930. $tail = "\n";
  4931. $filename = $title . ".xls";
  4932. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  4933. $dir = '/data/excel/' . $time . '/';
  4934. $file_name = 'error_' . $time . rand(1000, 9999);
  4935. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  4936. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  4937. fwrite($myfile, $ecl);
  4938. fclose($myfile);
  4939. $error = $dir . $file_name . '.xls';
  4940. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  4941. exit;
  4942. } else {
  4943. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  4944. exit;
  4945. }
  4946. }
  4947. }
  4948. public function _presetedittwo(){
  4949. $data = $this->input->post(NULL, TRUE);
  4950. if(empty($list)){
  4951. $raw_data = $this->input->raw_input_stream;
  4952. // 解码 JSON
  4953. $data = json_decode($raw_data, true);
  4954. }
  4955. if(empty($data)){
  4956. echo json_encode(array('msg' => '传输数据异常!', 'error' => 1, 'success' => false));
  4957. exit;
  4958. }
  4959. $list = [];
  4960. if(isset($data['list'])){
  4961. $list = $data['list'];
  4962. }
  4963. $i = 0;
  4964. $j = 0;
  4965. $ed = array();
  4966. foreach ($list as $key => $value) {
  4967. $time = time();
  4968. if ($value['0'] == "") {
  4969. $ed[] = ['msg'=>'第'.($key+1). '行-仓库未填写!'] ;
  4970. $j++;
  4971. continue;
  4972. }
  4973. $warehouse = $this->warehouse->get_title($value['0']);
  4974. if(empty($warehouse)){
  4975. $ed[] = ['msg'=>'第'.($key+1). '行-仓库名错误!'] ;
  4976. $j++;
  4977. continue;
  4978. }
  4979. $purchase = $this->purchase->get_bm($value['1']);
  4980. $sku = $value['2'];
  4981. $num = $value['3']; //调整数量
  4982. $text = $value['4']; //扣减说明
  4983. $type = 0; //调整方式0扣减1删除
  4984. $details = empty($value['5'])?'':$value['5']; //库位
  4985. $rktype = $value['6'] != '' ? $value['6'] : 0; //增加库存
  4986. $cktype = $value['7'] != '' ? $value['7'] : 0; //减少库存
  4987. $d = $this->whlabel->get_warehouseSkuByDesc($warehouse['id'], $sku);
  4988. if (!$purchase) //如果没有这个SKU
  4989. {
  4990. $ed[] = ['msg'=>$value['1'] . '-不存在此供应商编码'] ;
  4991. $j++;
  4992. continue;
  4993. }
  4994. if (!$d) //如果没有这个SKU
  4995. {
  4996. $ed[] = ['msg'=>$sku . '-库存中不存在此SKU'] ;
  4997. $j++;
  4998. continue;
  4999. }
  5000. if (!isset($warehouse['id'])) {
  5001. $ed[] = ['msg'=>$sku . '-仓库名错误!'] ;
  5002. $j++;
  5003. continue;
  5004. }
  5005. if ($type != '0' && $type != '1') {
  5006. $ed[] = ['msg'=>$sku . '-扣减方式填写错误!'] ;
  5007. $j++;
  5008. continue;
  5009. }
  5010. if ($num < 0) //扣减库存
  5011. {
  5012. if ($warehouse['id'] == 5 && ($cktype == '' || ($cktype > 1 && $text == ''))) {
  5013. $ed[] = ['msg'=>$sku . '-扣减必须填写扣减类型,非类型1必须填写备注.'] ;
  5014. $j++;
  5015. continue;
  5016. }
  5017. if(!empty($details)){
  5018. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0 and details = "'. $details .'"');
  5019. }else{
  5020. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (zd = "" or zd is null) and state = 0');
  5021. }
  5022. if (count($data) < abs($num)) {
  5023. $ed[] = ['msg'=>$sku . '-扣减数量大于库存剩余数量!'] ;
  5024. $j++;
  5025. continue;
  5026. }
  5027. if ($type == 0) //如果扣减方式为 扣减库存
  5028. {
  5029. for ($i = 0; $i < abs($num); $i++) {
  5030. $this->whlabel->save(array('state' => 8, 'textout' => $text, 'deltime' => $time, 'cktype' => $cktype, 'time' => $time, 'outk' => $time), $data[$i]['id']);
  5031. }
  5032. } else if ($type == 1) {
  5033. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  5034. if (count($zt) > 0) {
  5035. $ed[] = array('msg'=>$sku . '-有在途库存无法删除!');
  5036. $j++;
  5037. continue;
  5038. }
  5039. for ($i = 0; $i < abs($num); $i++) {
  5040. $this->whlabel->remove($data[$i]['id']);
  5041. }
  5042. }
  5043. } else if ($num > 0) //增加库存
  5044. {
  5045. if ($warehouse['id'] == 5 && ($rktype == '' || ($rktype > 1 && $text == ''))) {
  5046. $ed[] = array('msg'=>$sku . '-增加必须填写增加类型,非类型1必须填写备注');
  5047. $j++;
  5048. continue;
  5049. }
  5050. if(empty($details)){
  5051. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and (details != "" or details is not null) ','*','id desc');
  5052. if(empty($tmp_info)){
  5053. $details = '';
  5054. }else{
  5055. $details = $tmp_info['details'];
  5056. }
  5057. }else{
  5058. if($details == 'DZ001'){
  5059. }else{
  5060. $tmp_info = $this->whlabel->find('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and details = "'.$details.'" ','*','id desc');
  5061. if(empty($tmp_info)){
  5062. $ed[] = array('msg'=>$sku . '-的库位' . $details . '不存在!');
  5063. $j++;
  5064. continue;
  5065. }
  5066. }
  5067. }
  5068. $post['sku'] = $d['sku'];
  5069. $post['shop'] = $d['shop'];
  5070. $post['warehouse'] = $warehouse['id'];
  5071. $post['purchase'] = $purchase['id'];
  5072. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  5073. $post['state'] = 0;
  5074. $post['title'] = $d['title'];
  5075. $post['number'] = $d['number'];
  5076. $post['features'] = $d['features'];
  5077. $post['details'] = $details;
  5078. $post['enter'] = $time;
  5079. $post['time'] = $time; //操作时间
  5080. $post['rktype'] = $rktype;
  5081. $post['sku_master_id'] = $d['sku_master_id'];
  5082. $post['sku_shop_id'] = $d['sku_shop_id'];
  5083. for ($i = 0; $i < $num; $i++) {
  5084. $post['label'] = time() . rand(100, 999) . $i;
  5085. $this->whlabel->insert($post);
  5086. }
  5087. }
  5088. sleep(1); //防止入库时间一样,需要延迟1秒
  5089. }
  5090. if ($j > 0) {
  5091. $tt = date('Ymd', time());
  5092. $title = '库存导入错误信息-' . $tt;
  5093. $error = $title . '.xls';
  5094. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true),JSON_UNESCAPED_UNICODE));
  5095. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'ed' => $ed, 'success' => true));
  5096. exit;
  5097. } else {
  5098. //$this->logic_ding->sendToDing("进销存库存导入的返回数据【".date('Y-m-d H:i:s',time())."】".json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true),JSON_UNESCAPED_UNICODE));
  5099. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  5100. exit;
  5101. }
  5102. }
  5103. //笛卡儿积
  5104. function cp($ps, $sets, $list)
  5105. {
  5106. $result = array();
  5107. $j = 0;
  5108. for ($i = 0, $count = count($sets); $i < $count - 1; $i++) {
  5109. if ($i == 0) {
  5110. $result = $sets[$i];
  5111. }
  5112. $tmp = array();
  5113. foreach ($result as $res) {
  5114. foreach ($sets[$i + 1] as $set) {
  5115. $tmp[] = $res . ',' . $set;
  5116. }
  5117. }
  5118. $result = $tmp;
  5119. }
  5120. $this->db->trans_begin();
  5121. foreach ($result as $v) {
  5122. $post = array();
  5123. $title = "";
  5124. $num = "";
  5125. $data = explode(',', $v);
  5126. for ($i = 0; $i < count($list); $i++) {
  5127. $post[$list[$i]] = $data[$i];
  5128. $typeclass = $this->typeclass->read($data[$i]);
  5129. $title = $title . $typeclass['title'] . " ";
  5130. if ($data[$i] != 0) {
  5131. $num .= $data[$i]; //所有数据ID拼接
  5132. }
  5133. }
  5134. foreach ($ps as $kp => $vp) {
  5135. $post[$kp] = $vp;
  5136. }
  5137. $post['number'] = $num;
  5138. $info_list = $this->whlabel->get_number($num); //查询whlabel是否存在此拼接的数据ID
  5139. if ($info_list) {
  5140. $j++;
  5141. } else {
  5142. $skunum = $this->whlabel->find_count();
  5143. $post['sku'] = 'LY' . substr(strval($skunum + 1 + 10000000), 1, 7);
  5144. $post['title'] = rtrim($title, ' ');
  5145. $this->whlabel->insert($post);
  5146. }
  5147. }
  5148. if ($this->db->trans_status() === FALSE) {
  5149. $this->db->trans_commit();
  5150. return NULL;
  5151. } else {
  5152. $this->db->trans_commit();
  5153. return $j;
  5154. }
  5155. }
  5156. public function _kj($arg_array)
  5157. {
  5158. if (isset($_POST['sku'])) {
  5159. $time = time();
  5160. $sku = $this->input->post('sku', true);
  5161. $warehouse = $this->input->post('warehouse', true);
  5162. $num = $this->input->post('num', true);
  5163. $text = $this->input->post('text', true);
  5164. $purchase = $this->input->post('purchase', true);
  5165. $cktype = $this->input->post('cktype', true);
  5166. $order = $this->whlabel->find_all("purchase = '$purchase' and sku = '$sku' and warehouse = '$warehouse' and zd = '' and state = 0");
  5167. if ($cktype != 1 && $text == '') {
  5168. echo json_encode(array('msg' => "非销售出库必须填写备注!", 'success' => false));
  5169. exit;
  5170. }
  5171. if ($num > count($order)) {
  5172. echo json_encode(array('msg' => "扣减数量大于剩余库存数量!", 'success' => false));
  5173. exit;
  5174. } else {
  5175. for ($i = 0; $i < $num; $i++) {
  5176. $this->whlabel->save(array('state' => 8, 'cktype' => $cktype, 'textout' => $text, 'deltime' => $time, 'time' => $time, 'outk' => $time), $order[$i]['id']);
  5177. }
  5178. }
  5179. echo json_encode(array('msg' => "扣减成功!", 'success' => false));
  5180. exit;
  5181. }
  5182. $uid = $this->whlabel->read($arg_array[0]);
  5183. $uid['num'] = $this->whlabel->find_count('purchase = "' . $uid['purchase'] . '" and sku = "' . $uid['sku'] . '" and warehouse = "' . $uid['warehouse'] . '" and zd = "" and state = 0');
  5184. $this->data['data'] = $uid;
  5185. $this->_Template('whlabel_kj', $this->data);
  5186. }
  5187. public function _summary($arg_array)
  5188. {
  5189. $prc = array();
  5190. $purchase = $this->purchase->find_all();
  5191. foreach ($purchase as $k => $v) {
  5192. $prc[$v['id']] = $v['title'];
  5193. }
  5194. if (isset($_GET['excel'])) {
  5195. $ktime = $this->input->get('ktime', true);
  5196. $jtime = $this->input->get('jtime', true);
  5197. $ktime = strtotime($ktime);
  5198. $jtime = strtotime($jtime);
  5199. $where = "1=1";
  5200. if ($ktime && $jtime) {
  5201. $where .= " and outk > '$ktime' and outk < '$jtime'";
  5202. }
  5203. //数据排序
  5204. $order_str = "time desc";
  5205. if (empty($page)) {
  5206. $start = 0;
  5207. $perpage = 1;
  5208. } else {
  5209. $start = ($page - 1) * $perpage;
  5210. }
  5211. //取得信息列表
  5212. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  5213. foreach ($info_list as $key => $value) {
  5214. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  5215. $warehouse = $this->warehouse->read($value['warehouse']);
  5216. $info_list[$key]['warehouse'] = $warehouse['title'];
  5217. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid,status');
  5218. $details = array();
  5219. $cpid = array();
  5220. foreach ($x as $k => $v) {
  5221. if($v['status'] == 0){
  5222. if ($v['details'] != '') {
  5223. $details[$v['details']] = $v['details'];
  5224. }
  5225. if ($v['cpid'] != 0) {
  5226. $cpid[$v['cpid']] = $v['cpid'];
  5227. }
  5228. }
  5229. }
  5230. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  5231. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  5232. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  5233. $info_list[$key]['s'] = $s;
  5234. $info_list[$key]['x'] = count($x);
  5235. }
  5236. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  5237. $titlename = "<table border=1>
  5238. <tr align='center'>
  5239. <td>仓库</td>
  5240. <td>供应商</td>
  5241. <td>出库位置</td>
  5242. <td>出库编码</td>
  5243. <td>SKU</td>
  5244. <td>产品名</td>
  5245. <td>总剩余库存</td>
  5246. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  5247. </tr>
  5248. </table>";
  5249. $filename = $title . ".xls";
  5250. $tail = "";
  5251. $this->excelxh->get_fz2($info_list, $titlename, $filename, $tail);
  5252. }
  5253. }
  5254. //usps发货清单
  5255. public function _manifest()
  5256. {
  5257. if (isset($_POST['manifest'])) {
  5258. $wltext = $this->input->post('wltext', true);
  5259. $time = time() - 16 * 3600;
  5260. $ptime = strtotime(date('Y-m-d', $time));
  5261. $waybill = array();
  5262. $fullorder = $this->fullorder->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5263. foreach ($fullorder as $v) {
  5264. $waybill[$v['waybill']] = $v['waybill'];
  5265. }
  5266. $fullordersmt = $this->fullordersmt->find_all("printtime > '$ptime' and librarytime > '$ptime' and library = 2 and waybill != '' and (type = 5 or type = 8)", 'number,waybill');
  5267. foreach ($fullordersmt as $v) {
  5268. $waybill[$v['waybill']] = $v['waybill'];
  5269. }
  5270. $wltext = explode(';', $wltext);
  5271. foreach ($wltext as $v) {
  5272. if (isset($waybill[$v])) {
  5273. unset($waybill[$v]);
  5274. }
  5275. }
  5276. $data = $this->usps->get_manifest($waybill);
  5277. if (isset($data['Description'])) {
  5278. echo json_encode(array('msg' => $data['Description'], 'success' => false));
  5279. exit;
  5280. } else if (isset($data['SCANFormImage']) && isset($data['SCANFormNumber'])) {
  5281. $bctime = date('Ymd', time());
  5282. $pdf = $this->_pdf($data['SCANFormImage'], $data['SCANFormNumber'], $bctime);
  5283. echo json_encode(array('msg' => $pdf, 'success' => true));
  5284. exit;
  5285. } else {
  5286. echo json_encode(array('msg' => $data, 'success' => false));
  5287. exit;
  5288. }
  5289. }
  5290. }
  5291. public function _pdf($pdf, $title, $bctime)
  5292. {
  5293. $pdf_path = './data/pdf/' . $bctime . '/';
  5294. $file_base64 = $pdf;
  5295. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  5296. $file_base64 = base64_decode($file_base64);
  5297. if (!is_dir($pdf_path)) mkdir($pdf_path, 0777); //上传目录不存在则创建
  5298. file_put_contents($pdf_path . $title . '.pdf', $file_base64);
  5299. return 'http://' . $_SERVER['HTTP_HOST'] . '/data/pdf/' . $bctime . '/' . $title . '.pdf';
  5300. }
  5301. /**
  5302. *
  5303. *
  5304. *
  5305. 进销存占单异常索引
  5306. *
  5307. *
  5308. *
  5309. **/
  5310. public function _abnormal()
  5311. {
  5312. $post = $this->input->post(NULL, TRUE);
  5313. if (isset($post['page'])) {
  5314. $page = $this->input->post('page', true);
  5315. $perpage = $this->input->post('perpage', true);
  5316. $sku = $this->input->post('sku', true);
  5317. $where = "1=1";
  5318. //数据排序
  5319. $order_str = "id desc";
  5320. if (empty($page)) {
  5321. $start = 0;
  5322. $perpage = 1;
  5323. } else {
  5324. $start = ($page - 1) * $perpage;
  5325. }
  5326. //取得信息列表
  5327. $info_list = $this->whlabel->find_all($where, '*');
  5328. $rows = array();
  5329. $list = array();
  5330. foreach ($info_list as $key => $value) {
  5331. $rows[strtolower($value['sku'])] = $value; //所有数据sku
  5332. }
  5333. foreach ($rows as $value) {
  5334. $warehouse = $this->warehouse->read($value['warehouse']);
  5335. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "5"');
  5336. $number = $value['number'];
  5337. $ftime = time() - 15 * 24 * 3600;
  5338. if ($value['shop'] != '') {
  5339. $shop = $value['shop'];
  5340. $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');
  5341. $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');
  5342. $order = array_merge($orderdlz, $ordersmt);
  5343. $od = 0;
  5344. $a = '';
  5345. $orid = '';
  5346. foreach ($order as $v) {
  5347. $or = explode('|', ltrim($v['whlabel'], '|'));
  5348. for ($i = 0; $i < count($or); $i++) {
  5349. $orod = explode('-', $or[$i]);
  5350. if ($orod[0] == $number) {
  5351. $od += $orod[1];
  5352. }
  5353. }
  5354. $orid .= $v['number'] . '-';
  5355. }
  5356. } else {
  5357. $orderdlz = $this->fullorder->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5358. $ordersmt = $this->fullordersmt->find_all("time > '$ftime' and type = '5' and library = '1' and state = '207' and whlabel like '%|$number-%'", 'whlabel,shop,orderinfo,number');
  5359. $order = array_merge($orderdlz, $ordersmt);
  5360. $od = 0;
  5361. $a = '';
  5362. $orid = '';
  5363. $qt = array();
  5364. foreach ($order as $v) {
  5365. $or = explode('|', ltrim($v['whlabel'], '|'));
  5366. for ($i = 0; $i < count($or); $i++) {
  5367. $orod = explode('-', $or[$i]);
  5368. if ($orod[0] == $number) {
  5369. $czzs = $this->whlabel->find_count("number = '$number' and warehouse = '5' and shop = '" . $v['shop'] . "' and state = 0");
  5370. if ($czzs > 0) {
  5371. if (isset($qt[$v['shop']])) {
  5372. if ($qt[$v['shop']] < $orod[1]) {
  5373. $od += $orod[1]; //专属小于单量不计算剩余直接归入通用
  5374. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5375. } else {
  5376. $qt[$v['shop']] -= $orod[1];
  5377. }
  5378. } else {
  5379. $qt[$v['shop']] = $czzs;
  5380. }
  5381. } else {
  5382. $od += $orod[1];
  5383. $orid .= $v['number'] . '+数量' . $orod[1] . '-';
  5384. }
  5385. }
  5386. }
  5387. }
  5388. }
  5389. $z = $od . '(' . $orid . ')'; //查看订单号
  5390. //$z = $od;
  5391. if ($od > $c) {
  5392. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c, 'z' => $z);
  5393. }
  5394. }
  5395. $listdata = array_slice($list, $start, $perpage);
  5396. $total = count($list);
  5397. $pagenum = ceil($total / $perpage);
  5398. $over = $total - ($start + $perpage);
  5399. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5400. echo json_encode($rows);
  5401. exit;
  5402. }
  5403. $this->_Template('whlabel_abnormal', $this->data);
  5404. }
  5405. /**
  5406. *
  5407. *
  5408. *
  5409. 进销存占单异常索引
  5410. *
  5411. *
  5412. *
  5413. **/
  5414. public function _error()
  5415. {
  5416. $post = $this->input->post(NULL, TRUE);
  5417. if (isset($post['page'])) {
  5418. $page = $this->input->post('page', true);
  5419. $perpage = $this->input->post('perpage', true);
  5420. $sku = $this->input->post('sku', true);
  5421. $warehouse = $this->input->post('warehouse', true);
  5422. $ktime = $this->input->post('ktime', true);
  5423. $jtime = $this->input->post('jtime', true);
  5424. $ktime = strtotime($ktime);
  5425. $jtime = strtotime($jtime);
  5426. $where = "sku != 'Preset'";
  5427. $gj = '';
  5428. if ($sku) {
  5429. $where .= " and sku like '%$sku%'";
  5430. } else {
  5431. if ($ktime && $jtime) {
  5432. $gj = " and time > '$ktime' and time < '$jtime'";
  5433. }
  5434. }
  5435. if ($warehouse) {
  5436. $where .= " and warehouse = '$warehouse'";
  5437. }
  5438. //数据排序
  5439. $order_str = "id desc";
  5440. if (empty($page)) {
  5441. $start = 0;
  5442. $perpage = 1;
  5443. } else {
  5444. $start = ($page - 1) * $perpage;
  5445. }
  5446. //取得信息列表
  5447. //$info_list = $this->whlabel->find_all($where.$gj,'*');
  5448. $rows = array();
  5449. $list = array();
  5450. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5451. // foreach ($info_list as $value)
  5452. // {
  5453. // $warehouse = $this->warehouse->read($value['warehouse']);
  5454. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5455. // $number = $value['number'];$ftime = time()-15*24*3600;
  5456. // if($c < 1)
  5457. // {
  5458. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5459. // }
  5460. // }
  5461. $warehouse_list = $this->warehouse->find_all();
  5462. $warehouse_list = array_column($warehouse_list, null, 'id');
  5463. foreach ($info_list as $value) {
  5464. $warehouse = isset($warehouse_list[$value['warehouse']]) ? $warehouse_list[$value['warehouse']] : [
  5465. 'title' => "",
  5466. ];
  5467. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5468. $number = $value['number'];
  5469. $ftime = time() - 15 * 24 * 3600;
  5470. if ($c < 1) {
  5471. $list[] = array('id' => $value['id'], 'warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5472. }
  5473. }
  5474. // $sql = "select id,warehouse,features,sku,number,title from crowd_whlabel where ".$where;
  5475. // $query = $this->db->query($sql);
  5476. // $info_list = $query->result_array();
  5477. // $sql_two = "select title,id from crowd_warehouse";
  5478. // $query_two = $this->db->query($sql_two);
  5479. // $warehouse_list = $query_two->result_array();
  5480. // $warehouse_arr = array_column($warehouse_list,null,'id');
  5481. // foreach ($info_list as $value)
  5482. // {
  5483. // if(isset($warehouse_arr[$value['warehouse']])){
  5484. // $warehouse = $warehouse_arr[$value['warehouse']];
  5485. // }else{
  5486. // $warehouse = [
  5487. // 'id'=>0,
  5488. // 'title'=>"异常",
  5489. // ];
  5490. // }
  5491. // $c = $this->whlabel->find_count('sku = "'.$value['sku'].'" and state = "0" and warehouse = "'.$value['warehouse'].'"');
  5492. // $number = $value['number'];$ftime = time()-15*24*3600;
  5493. // if($c < 1)
  5494. // {
  5495. // $list[] = array('id'=>$value['id'],'warehouse'=>$warehouse['title'],'sku'=>$value['sku'],'title'=>$value['title'],'c'=>$c);
  5496. // }
  5497. // }
  5498. $listdata = array_slice($list, $start, $perpage);
  5499. $total = count($list);
  5500. $pagenum = ceil($total / $perpage);
  5501. $over = $total - ($start + $perpage);
  5502. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($listdata));
  5503. echo json_encode($rows);
  5504. exit;
  5505. }
  5506. if (isset($post['s'])) {
  5507. $id_arr = $this->input->post('s');
  5508. $id_arr = explode(',', trim($id_arr, ','));
  5509. if (!$id_arr) {
  5510. echo json_encode(array('msg' => '参数错误!', 'success' => false));
  5511. exit;
  5512. }
  5513. //循环删除记录
  5514. foreach ($id_arr as $v) {
  5515. $dd = $this->whlabel->read($v);
  5516. if (!isset($dd['id'])) {
  5517. echo json_encode(array('msg' => $dd['sku'] . '已被删除,请刷新页面', 'success' => false));
  5518. exit;
  5519. }
  5520. $zt = $this->whlabeltransport->find_all('sku = "' . $dd['sku'] . '" and warehouse = "' . $dd['warehouse'] . '" and features = "' . $dd['features'] . '" and cz = "0"');
  5521. if (isset($zt[0])) {
  5522. echo json_encode(array('msg' => '有在途库存无法删除!', 'success' => false));
  5523. exit;
  5524. }
  5525. $deldd = $this->whlabel->find_all("sku = '" . $dd['sku'] . "' and warehouse = '" . $dd['warehouse'] . "'");
  5526. foreach ($deldd as $vv) {
  5527. $tmp_info = $vv;
  5528. $tmp_info['del_time'] = time();
  5529. $this->db->insert('whlabelscbf',$tmp_info);
  5530. $this->whlabel->remove($vv['id']);
  5531. }
  5532. }
  5533. echo json_encode(array('del' => $id_arr, 'msg' => '删除记录成功!', 'success' => true));
  5534. exit;
  5535. }
  5536. $this->_Template('whlabel_error', $this->data);
  5537. }
  5538. public function _errorexcel()
  5539. {
  5540. $post = $this->input->post(NULL, TRUE);
  5541. if (isset($_GET['page'])) {
  5542. $page = $this->input->get('page', true);
  5543. $perpage = $this->input->get('perpage', true);
  5544. $sku = $this->input->get('sku', true);
  5545. $warehouse = $this->input->get('warehouse', true);
  5546. $ktime = $this->input->get('ktime', true);
  5547. $jtime = $this->input->get('jtime', true);
  5548. $ktime = strtotime($ktime);
  5549. $jtime = strtotime($jtime);
  5550. $where = "sku != 'Preset'";
  5551. $gj = '';
  5552. if ($sku) {
  5553. $where .= " and sku like '%$sku%'";
  5554. } else {
  5555. if ($ktime && $jtime) {
  5556. $gj = " and time > '$ktime' and time < '$jtime'";
  5557. }
  5558. }
  5559. if ($warehouse) {
  5560. $where .= " and warehouse = '$warehouse'";
  5561. }
  5562. //数据排序
  5563. $order_str = "id desc";
  5564. if (empty($page)) {
  5565. $start = 0;
  5566. $perpage = 1;
  5567. } else {
  5568. $start = ($page - 1) * $perpage;
  5569. }
  5570. //取得信息列表
  5571. $rows = array();
  5572. $list = array();
  5573. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  5574. foreach ($info_list as $value) {
  5575. $warehouse = $this->warehouse->read($value['warehouse']);
  5576. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  5577. $number = $value['number'];
  5578. $ftime = time() - 15 * 24 * 3600;
  5579. if ($c < 1) {
  5580. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  5581. }
  5582. }
  5583. $title = "0库存汇总";
  5584. $titlename = "<table border=1>
  5585. <tr align='center'>
  5586. <td>仓库</td>
  5587. <td>SKU</td>
  5588. <td>产品</td>
  5589. <td>当前库存</td>
  5590. </tr>
  5591. </table>";
  5592. $filename = $title . ".xls";
  5593. $tail = "";
  5594. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  5595. }
  5596. }
  5597. /**
  5598. *
  5599. *
  5600. * 占单
  5601. *
  5602. *
  5603. **/
  5604. public function _kcyz()
  5605. {
  5606. $post = $this->input->post(NULL, TRUE);
  5607. if (isset($post['warehouse'])) {
  5608. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请更新浏览器缓存!', 'success' => false)));
  5609. exit; //不再使用
  5610. $warehouse = $this->input->post('warehouse', true);
  5611. $whlabel = $this->input->post('whlabel', true);
  5612. $id = $this->input->post('id', true);
  5613. $shop = $this->input->post('shop', true);
  5614. $number = $this->input->post('number', true);
  5615. if (!$whlabel || $whlabel == '|') {
  5616. return array('t' => 1, 'm' => json_encode(array('t' => 1, 'msg' => '请先添加产品信息!', 'success' => false)));
  5617. exit;
  5618. }
  5619. $pp = explode('|', trim($whlabel, '|'));
  5620. $x = 0;
  5621. $save = array();
  5622. foreach ($pp as $va) {
  5623. $num = explode('-', $va);
  5624. if ($number) {
  5625. $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 = '')"); //通用
  5626. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%," . $shop . ",%'"); //专属
  5627. } else {
  5628. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')"); //通用
  5629. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%," . $shop . ",%'"); //专属
  5630. }
  5631. $x++;
  5632. if (count($whlabel) + count($shopwhlabel) < $num[1]) {
  5633. $save[] = $x - 1;
  5634. continue; //提前先加X不然出错,所以要减1
  5635. }
  5636. }
  5637. if (isset($save[0])) {
  5638. echo json_encode(array('t' => 2, 'msg' => "红色商品名库存匹配错误或库存不够扣减", 'error' => $save, 'success' => false));
  5639. exit;
  5640. } else {
  5641. echo json_encode(array('success' => true));
  5642. exit;
  5643. }
  5644. }
  5645. }
  5646. public function _db()
  5647. {
  5648. $post = $this->input->post(NULL, TRUE);
  5649. if (isset($post['page'])) {
  5650. $page = $this->input->post('page', true);
  5651. $perpage = $this->input->post('perpage', true);
  5652. $sku = $this->input->post('sku', true);
  5653. $number = $this->input->post('number', true);
  5654. $warehouse = $this->input->post('warehouse', true);
  5655. $purchase = $this->input->post('purchase', true);
  5656. $orderinfo = $this->input->post('orderinfo', true);
  5657. $waybill = $this->input->post('waybill', true);
  5658. $category = $this->input->post('category', true);
  5659. $size = $this->input->post('size', true);
  5660. $grade = $this->input->post('grade', true);
  5661. $color = $this->input->post('color', true);
  5662. $lowe = $this->input->post('lowe', true);
  5663. $state = $this->input->post('state', true);
  5664. $label = $this->input->post('label', true);
  5665. $timetk = $this->input->post('timetkk', true);
  5666. $timetj = $this->input->post('timetjj', true);
  5667. $timetk = strtotime($timetk);
  5668. $timetj = strtotime($timetj);
  5669. $where = "dbtime > 0";
  5670. if ($timetk && $timetj) {
  5671. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5672. }
  5673. if ($sku) {
  5674. $where .= " and sku = '$sku'";
  5675. }
  5676. if ($warehouse) {
  5677. $where .= " and warehouse = '$warehouse'";
  5678. if ($warehouse == 12) {
  5679. $w = 'specialstock';
  5680. } else {
  5681. $w = 'whlabel';
  5682. }
  5683. }
  5684. if ($purchase) {
  5685. $where .= " and purchase = '$purchase'";
  5686. }
  5687. if ($category) {
  5688. $where .= " and features like '%-$category-%'";
  5689. }
  5690. if ($size) {
  5691. $where .= " and features like '%-$size-%'";
  5692. }
  5693. if ($grade) {
  5694. $where .= " and features like '%-$grade-%'";
  5695. }
  5696. if ($color) {
  5697. $where .= " and features like '%-$color-%'";
  5698. }
  5699. if ($lowe) {
  5700. $where .= " and features like '%-$lowe-%'";
  5701. }
  5702. if ($state != '') {
  5703. $where .= " and state = '$state'";
  5704. }
  5705. //数据排序
  5706. $order_str = "dbtime desc";
  5707. if (empty($page)) {
  5708. $start = 0;
  5709. $perpage = 1;
  5710. } else {
  5711. $start = ($page - 1) * $perpage;
  5712. }
  5713. //取得信息列表
  5714. $info_list = $this->$w->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5715. foreach ($info_list as $key => $value) {
  5716. $warehouse = $this->$w->read($value['warehouse']);
  5717. $info_list[$key]['warehouse'] = $warehouse['title'];
  5718. $purchase = $this->purchase->read($value['purchase']);
  5719. $info_list[$key]['purchase'] = $purchase['title'];
  5720. if ($value['enter'] != 0) {
  5721. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5722. } else {
  5723. $info_list[$key]['enter'] = "";
  5724. }
  5725. if ($value['dbtime'] != 0) {
  5726. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5727. } else {
  5728. $info_list[$key]['dbtime'] = "";
  5729. }
  5730. if ($value['state'] == 0) {
  5731. $info_list[$key]['state'] = "在库";
  5732. } else if ($value['state'] == 1) {
  5733. $info_list[$key]['state'] = "出库";
  5734. } else if ($value['state'] == 2) {
  5735. $info_list[$key]['state'] = "退库";
  5736. } else if ($value['state'] == 3) {
  5737. $info_list[$key]['state'] = "调拨中";
  5738. } else if ($value['state'] == 4) {
  5739. $info_list[$key]['state'] = "再加工";
  5740. } else if ($value['state'] == 5) {
  5741. $info_list[$key]['state'] = "维修中";
  5742. } else if ($value['state'] == 6) {
  5743. $info_list[$key]['state'] = "盘亏";
  5744. } else if ($value['state'] == 7) {
  5745. $info_list[$key]['state'] = "更换标签";
  5746. } else if ($value['state'] == 8) {
  5747. $info_list[$key]['state'] = "其它";
  5748. } else if ($value['state'] == 9) {
  5749. $info_list[$key]['state'] = "预设";
  5750. }
  5751. }
  5752. $total = $this->whlabel->find_count($where);
  5753. $pagenum = ceil($total / $perpage);
  5754. $over = $total - ($start + $perpage);
  5755. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5756. echo json_encode($rows);
  5757. exit;
  5758. }
  5759. if (isset($post['outsku'])) {
  5760. $time = time();
  5761. $cz = $this->input->post('cz', true);
  5762. $label = $this->input->post('outsku', true);
  5763. $sl = $this->input->post('sl', true);
  5764. $num = $this->input->post('num', true);
  5765. //$warehouse = $this->input->post('warehouse',true);
  5766. if (!$sl) {
  5767. $sl = 1;
  5768. }
  5769. if (!$warehouse) {
  5770. echo json_encode(array('msg' => '请选择调拨到的仓库', 'success' => false));
  5771. exit;
  5772. }
  5773. $dblabel = $this->whlabellabel->get_label($label);
  5774. if ($dblabel) {
  5775. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '0' and zd = ''");
  5776. if (count($data) < 1) {
  5777. echo json_encode(array('msg' => '没有此产品数据!', 'success' => false));
  5778. exit;
  5779. }
  5780. if (count($data) < $num) {
  5781. echo json_encode(array('msg' => '库存数量少于调拨数量!', 'success' => false));
  5782. exit;
  5783. }
  5784. for ($i = 0; $i < $sl; $i++) {
  5785. $this->whlabel->save(array('state' => 3, 'dbtime' => $dbtime, 'dbcontent' => $data[$i]['warehouse'] . '-' . $time . '|', 'time' => $time), $data[$i]['id']);
  5786. }
  5787. echo json_encode(array('success' => true));
  5788. exit;
  5789. } else {
  5790. echo json_encode(array('msg' => '未找到此条码产品!', 'success' => false));
  5791. exit;
  5792. }
  5793. }
  5794. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5795. $this->_Template('whlabel_db', $this->data);
  5796. }
  5797. public function _dbrk()
  5798. {
  5799. $post = $this->input->post(NULL, TRUE);
  5800. if (isset($post['page'])) {
  5801. $page = $this->input->post('page', true);
  5802. $perpage = $this->input->post('perpage', true);
  5803. $sku = $this->input->post('sku', true);
  5804. $number = $this->input->post('number', true);
  5805. $warehouse = $this->input->post('warehouse', true);
  5806. $purchase = $this->input->post('purchase', true);
  5807. $orderinfo = $this->input->post('orderinfo', true);
  5808. $waybill = $this->input->post('waybill', true);
  5809. $category = $this->input->post('category', true);
  5810. $size = $this->input->post('size', true);
  5811. $grade = $this->input->post('grade', true);
  5812. $color = $this->input->post('color', true);
  5813. $lowe = $this->input->post('lowe', true);
  5814. $state = $this->input->post('state', true);
  5815. $label = $this->input->post('label', true);
  5816. $ctime = $this->input->post('ctime', true);
  5817. $timetk = $this->input->post('timetkk', true);
  5818. $timetj = $this->input->post('timetjj', true);
  5819. $timetk = strtotime($timetk);
  5820. $timetj = strtotime($timetj);
  5821. $where = "dbtime > 0";
  5822. if ($timetk && $timetj) {
  5823. $where .= " and " . $ctime . " > '$timetk' and " . $ctime . " < '$timetj'";
  5824. }
  5825. if ($sku) {
  5826. $where .= " and sku = '$sku'";
  5827. }
  5828. if ($warehouse) {
  5829. $where .= " and warehouse = '$warehouse'";
  5830. }
  5831. if ($purchase) {
  5832. $where .= " and purchase = '$purchase'";
  5833. }
  5834. if ($category) {
  5835. $where .= " and features like '%-$category-%'";
  5836. }
  5837. if ($size) {
  5838. $where .= " and features like '%-$size-%'";
  5839. }
  5840. if ($grade) {
  5841. $where .= " and features like '%-$grade-%'";
  5842. }
  5843. if ($color) {
  5844. $where .= " and features like '%-$color-%'";
  5845. }
  5846. if ($lowe) {
  5847. $where .= " and features like '%-$lowe-%'";
  5848. }
  5849. if ($state != '') {
  5850. $where .= " and state = '$state'";
  5851. }
  5852. //数据排序
  5853. $order_str = "dbtime desc";
  5854. if (empty($page)) {
  5855. $start = 0;
  5856. $perpage = 1;
  5857. } else {
  5858. $start = ($page - 1) * $perpage;
  5859. }
  5860. //取得信息列表
  5861. $info_list = $this->whlabel->find_all($where, 'id,state,purchase,sku,title,warehouse,dbtime,enter', $order_str, $start, $perpage);
  5862. foreach ($info_list as $key => $value) {
  5863. $warehouse = $this->warehouse->read($value['warehouse']);
  5864. $info_list[$key]['warehouse'] = $warehouse['title'];
  5865. $purchase = $this->purchase->read($value['purchase']);
  5866. $info_list[$key]['purchase'] = $purchase['title'];
  5867. if ($value['enter'] != 0) {
  5868. $info_list[$key]['enter'] = '<p>' . date('Y-m-d H:i:s', $value['enter']) . '</p>';
  5869. } else {
  5870. $info_list[$key]['enter'] = "";
  5871. }
  5872. if ($value['dbtime'] != 0) {
  5873. $info_list[$key]['dbtime'] = '<p>' . date('Y-m-d H:i:s', $value['dbtime']) . '</p>';
  5874. } else {
  5875. $info_list[$key]['dbtime'] = "";
  5876. }
  5877. if ($value['state'] == 0) {
  5878. $info_list[$key]['state'] = "在库";
  5879. } else if ($value['state'] == 1) {
  5880. $info_list[$key]['state'] = "出库";
  5881. } else if ($value['state'] == 2) {
  5882. $info_list[$key]['state'] = "退库";
  5883. } else if ($value['state'] == 3) {
  5884. $info_list[$key]['state'] = "调拨中";
  5885. } else if ($value['state'] == 4) {
  5886. $info_list[$key]['state'] = "再加工";
  5887. } else if ($value['state'] == 5) {
  5888. $info_list[$key]['state'] = "维修中";
  5889. } else if ($value['state'] == 6) {
  5890. $info_list[$key]['state'] = "盘亏";
  5891. } else if ($value['state'] == 7) {
  5892. $info_list[$key]['state'] = "更换标签";
  5893. } else if ($value['state'] == 8) {
  5894. $info_list[$key]['state'] = "其它";
  5895. } else if ($value['state'] == 9) {
  5896. $info_list[$key]['state'] = "预设";
  5897. }
  5898. }
  5899. $total = $this->whlabel->find_count($where);
  5900. $pagenum = ceil($total / $perpage);
  5901. $over = $total - ($start + $perpage);
  5902. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  5903. echo json_encode($rows);
  5904. exit;
  5905. }
  5906. if (isset($post['rsku'])) {
  5907. $cz = $this->input->post('cz', true);
  5908. $label = $this->input->post('rsku', true);
  5909. $sl = $this->input->post('sl', true);
  5910. $warehouse = $this->input->post('warehouse', true);
  5911. if (!$sl) {
  5912. $sl = 1;
  5913. }
  5914. if (!$warehouse) {
  5915. echo json_encode(array('msg' => '请选择入库仓库', 'success' => false));
  5916. exit;
  5917. }
  5918. $dblabel = $this->whlabellabel->get_label($label);
  5919. if ($dblabel) {
  5920. $data = $this->whlabel->find_all("features = '" . $dblabel['features'] . "' and warehouse = '" . $dblabel['warehouse'] . "' and shop = '" . $dblabel['shop'] . "' and state = '3' and zd = ''");
  5921. if (count($data) < 1) {
  5922. echo json_encode(array('msg' => '没有此SKU调拨数据!', 'success' => false));
  5923. exit;
  5924. }
  5925. if ($sl > count($data)) {
  5926. echo json_encode(array('msg' => '入库数量大于调拨数量!', 'success' => false));
  5927. exit;
  5928. }
  5929. $time = time();
  5930. for ($i = 0; $i < $sl; $i++) {
  5931. $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']);
  5932. }
  5933. echo json_encode(array('success' => true));
  5934. exit;
  5935. } else {
  5936. echo json_encode(array('msg' => '没有此条码的库存信息!', 'success' => false));
  5937. exit;
  5938. }
  5939. }
  5940. $this->data['url'] = str_replace('/', '', $this->uri->slash_segment(2));
  5941. $this->_Template('whlabel_dbrk', $this->data);
  5942. }
  5943. public function _whlabelczdc()
  5944. {
  5945. if (isset($_GET['excel'])) {
  5946. //数据排序
  5947. $order_str = "id desc";
  5948. if (empty($page)) {
  5949. $start = 0;
  5950. $perpage = 1;
  5951. } else {
  5952. $start = ($page - 1) * $perpage;
  5953. }
  5954. $state = $this->input->get('state', true);
  5955. $sku = $this->input->get('sku', true);
  5956. $ctime = $this->input->get('ctime', true);
  5957. $category = $this->input->get('category', true);
  5958. $size = $this->input->get('size', true);
  5959. $grade = $this->input->get('grade', true);
  5960. $color = $this->input->get('color', true);
  5961. $lowe = $this->input->get('lowe', true);
  5962. $timetk = $this->input->get('timetkk', true);
  5963. $timetj = $this->input->get('timetjj', true);
  5964. $timetk = strtotime($timetk);
  5965. $timetj = strtotime($timetj);
  5966. $where = "dbtime > 0";
  5967. if ($timetk && $timetj) {
  5968. $where .= " and dbtime > '$timetk' and dbtime < '$timetj'";
  5969. }
  5970. if ($category) {
  5971. $where .= " and features like '%-$category-%'";
  5972. }
  5973. if ($size) {
  5974. $where .= " and features like '%-$size-%'";
  5975. }
  5976. if ($grade) {
  5977. $where .= " and features like '%-$grade-%'";
  5978. }
  5979. if ($color) {
  5980. $where .= " and features like '%-$color-%'";
  5981. }
  5982. if ($lowe) {
  5983. $where .= " and features like '%-$lowe-%'";
  5984. }
  5985. //取得信息列表
  5986. $info_list = $this->whlabel->find_all($where, '*');
  5987. $rows = array();
  5988. $list = array();
  5989. foreach ($info_list as $key => $value) {
  5990. $rows[$value['sku']] = $value; //所有数据sku
  5991. }
  5992. foreach ($rows as $value) {
  5993. $warehouse = $this->warehouse->read($value['warehouse']);
  5994. $db = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '"');
  5995. $rk = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and enter > 0');
  5996. if ($value['orderinfo'] == 0) {
  5997. $info_list[$key]['orderinfo'] = "";
  5998. }
  5999. if ($value['waybill'] == 0) {
  6000. $info_list[$key]['waybill'] = "";
  6001. }
  6002. if ($value['state'] == 0) {
  6003. $value['state'] = "在库";
  6004. } else if ($value['state'] == 3) {
  6005. $value['state'] = "调拨中";
  6006. }
  6007. $list[] = array($value['sku'], $value['title'], $db, $rk);
  6008. }
  6009. $title = date('Y-m-d', $timetk) . '至' . date('Y-m-d', $timetj) . "统计表";
  6010. $titlename = "<table border=1>
  6011. <tr><th colspan='4' align='center'><h3>" . $title . "<h3></th></tr>
  6012. <tr align='center'>
  6013. <td>SKU</td>
  6014. <td>产品</td>
  6015. <td>调拨数量</td>
  6016. <td>入库数量</td>
  6017. </tr>
  6018. </table>";
  6019. $filename = $title . ".xls";
  6020. $tail = "";
  6021. $this->excel->get_fz2($list, $titlename, $filename, $tail);
  6022. }
  6023. }
  6024. public function _print($arg_array)
  6025. {
  6026. if (isset($_SESSION['api'])) {
  6027. $user = $this->user->get_api($_SESSION['api']);
  6028. $usp = $user;
  6029. $fgshop = "";
  6030. $sid = "";
  6031. $wid = "";
  6032. $wtype = "";
  6033. $usersp = explode('|', trim($user['shop'], '|'));
  6034. $userwh = explode('|', trim($user['warehouse'], '|'));
  6035. foreach ($usersp as $value) {
  6036. $fgshop .= " shop = " . $value . " or";
  6037. $sid .= " id = " . $value . " or";
  6038. }
  6039. foreach ($userwh as $value) {
  6040. $wid .= " id = " . $value . " or";
  6041. $wtype .= " type = " . $value . " or";
  6042. }
  6043. }
  6044. $post = $this->input->post(NULL, TRUE);
  6045. if (isset($post['tmsku'])) {
  6046. $tmsku = $this->input->post('tmsku', true);
  6047. if (is_numeric($tmsku)) {
  6048. $yyh = $this->whlabellabel->get_label($tmsku);
  6049. } else {
  6050. $yyh = $this->whlabellabel->get_sku($tmsku);
  6051. if(empty($yyh)){
  6052. $r = $this->logic_u9tools->getErpSkuByU9Lp($tmsku);
  6053. if($r['code'] == -1 ){
  6054. echo json_encode(array('success' => false));
  6055. exit;
  6056. }else{
  6057. echo json_encode(array('features' => $r['data'], 'success' => true));
  6058. exit;
  6059. }
  6060. }
  6061. }
  6062. if ($yyh) {
  6063. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6064. exit;
  6065. } else {
  6066. echo json_encode(array('success' => false));
  6067. exit;
  6068. }
  6069. }
  6070. $classid = $this->classid->sku();
  6071. $pm = $classid;
  6072. $scsku = $classid;
  6073. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6074. if (isset($post['warehouse'])) {
  6075. if ($post['warehouse']) {
  6076. $list = array();
  6077. $num = "";
  6078. $title = "";
  6079. $features = "";
  6080. $order = 0;
  6081. $post['shop'] = '';
  6082. $brand = $this->input->post('brand', true);
  6083. if ($brand != '0,') {
  6084. $b = $this->brand->read(rtrim($brand, ','));
  6085. if ($b) {
  6086. $post['shop'] = str_replace('|', ',', $b['shop']);
  6087. }
  6088. }
  6089. $post['details'] = $this->input->post('details', true); //打印数量
  6090. $xbqnum = $this->input->post('xbqnum', true);
  6091. $post['purchase'] = $this->input->post('purchase', true);
  6092. $post['warehouse'] = $this->input->post('warehouse', true);
  6093. $post['purchase'] = $this->input->post('purchase', true);
  6094. $post['retreatwarehouse'] = $post['warehouse'];
  6095. $post['cpbz'] = $this->input->post('cpbz', true);
  6096. $post['state'] = 9;
  6097. $category = $this->input->post('category', true);
  6098. $list['category'] = $category;
  6099. $list['hairtype'] = $this->input->post('hairtype', true);
  6100. $list['grade'] = $this->input->post('grade', true);
  6101. $size = $this->input->post('size', true);
  6102. $list['size'] = rtrim($size, ',');
  6103. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6104. $list['extension'] = $this->input->post('extension', true);
  6105. if ($category == 1297) {
  6106. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6107. }
  6108. if ($category == 1702) {
  6109. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6110. $list['syother'] = $this->input->post('syother', true);
  6111. }
  6112. if ($category == 133) {
  6113. $list['fittype'] = $this->input->post('fittype', true);
  6114. $list['acother'] = $this->input->post('acother', true);
  6115. }
  6116. $list['color'] = $this->input->post('color', true);
  6117. $list['lowe'] = $this->input->post('lowe', true);
  6118. if ($category == 127) {
  6119. $list['type'] = $this->input->post('type', true);
  6120. $list['headroad'] = $this->input->post('headroad', true);
  6121. $list['density'] = $this->input->post('density', true);
  6122. $list['lacesize'] = $this->input->post('lacesize', true);
  6123. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6124. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6125. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6126. }
  6127. if ($category == 128) {
  6128. $list['lacetype'] = $this->input->post('lacetype', true);
  6129. $list['haircap'] = $this->input->post('haircap', true);
  6130. $list['density'] = $this->input->post('density', true);
  6131. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6132. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6133. $list['wigother'] = $this->input->post('wigother', true);
  6134. $list['wigother1'] = $this->input->post('wigother1', true);
  6135. $list['wigother2'] = $this->input->post('wigother2', true);
  6136. $list['product_related'] = $this->input->post('product_related', true);
  6137. }
  6138. if ($category == 129) {
  6139. $list['wide'] = $this->input->post('wide', true);
  6140. }
  6141. if ($category == 131) {
  6142. $list['gifttype'] = $this->input->post('gifttype', true);
  6143. $list['giftother'] = $this->input->post('giftother', true);
  6144. }
  6145. if ($category == 134) {
  6146. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6147. }
  6148. if ($category == 1297) {
  6149. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6150. $list['sywigother'] = $this->input->post('sywigother', true);
  6151. }
  6152. if ($category == 130 || $category == 133 || $category == 1702) {
  6153. $list['items'] = $this->input->post('items', true);
  6154. $list['weight'] = $this->input->post('weight', true);
  6155. }
  6156. if ($category == 1702) {
  6157. $list['syhairther'] = $this->input->post('syhairther', true);
  6158. }
  6159. if($category == 130){
  6160. $list['jfother'] = $this->input->post('jfother', true);
  6161. }
  6162. foreach ($list as $k => $v) {
  6163. if ($v != 0) {
  6164. $num .= $v;
  6165. $features .= $v . '-';
  6166. $post[$k] = $v;
  6167. $typeclass = $this->typeclass->read($v);
  6168. if (isset($pm[$typeclass['classid']])) {
  6169. if (stripos($typeclass['zh'], '|') !== false) {
  6170. $exzh = explode('|', $typeclass['zh']);
  6171. if($k == 'hairtype'){
  6172. if(!in_array($v,[163,164,165,166])){
  6173. $pm[$typeclass['classid']] = $exzh[0];
  6174. }
  6175. }else{
  6176. $pm[$typeclass['classid']] = $exzh[0];
  6177. }
  6178. } else {
  6179. if($k == 'hairtype'){
  6180. if(!in_array($v,[163,164,165,166])){
  6181. $pm[$typeclass['classid']] = $typeclass['zh'];
  6182. }
  6183. }else{
  6184. $pm[$typeclass['classid']] = $typeclass['zh'];
  6185. }
  6186. }
  6187. }
  6188. if($k == 'hairtype'){
  6189. if(!in_array($v,[163,164,165,166])){
  6190. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6191. }
  6192. }else{
  6193. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6194. }
  6195. if ($k != 'size') {
  6196. $title .= $typeclass['title'] . " ";
  6197. }
  6198. }
  6199. }
  6200. $typeclass = $this->typeclass->read($list['size']);
  6201. $title .= $typeclass['title'];
  6202. $time = time();
  6203. $post['title'] = rtrim($title, ' ');
  6204. $post['number'] = $num;
  6205. $post['features'] = '-' . $features;
  6206. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6207. $featurespp = explode('-', trim($featurespp, '-'));
  6208. if (isset($featurespp[5])) {
  6209. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6210. } else {
  6211. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6212. }
  6213. $post['enter'] = $time;
  6214. $post['time'] = $time; //操作时间
  6215. $scsku = implode("-", $scsku);
  6216. $zh = implode(" ", $pm);
  6217. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6218. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6219. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6220. $post['sku'] = $bqsku;
  6221. $label = time() . rand(0, 9);
  6222. $post['label'] = $label;
  6223. $cpid = $this->whlabellabel->find_count();
  6224. $post['cpid'] = $cpid + 1;
  6225. $cpid = $post['cpid'];
  6226. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6227. //if($whlabelbarcode)
  6228. //{
  6229. //$post['label'] = $whlabelbarcode['label'];
  6230. //if(!$this->whlabellabel->insert($post))
  6231. //{
  6232. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6233. //}
  6234. //}
  6235. //else
  6236. //{
  6237. $this->db->trans_begin();
  6238. $this->whlabellabel->insert($post);
  6239. //$this->whlabelbarcode->insert($post);
  6240. if ($this->db->trans_status() === TRUE) {
  6241. $this->db->trans_commit();
  6242. } else {
  6243. $this->db->trans_rollback();
  6244. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6245. exit;
  6246. }
  6247. //}
  6248. $warehouse_name = "";
  6249. $warehouse = $post['warehouse'];
  6250. if($warehouse == 12){
  6251. $warehouse_name = "特殊库存库";
  6252. }
  6253. // if($warehouse == 13){
  6254. // $warehouse_name = "许昌仓";
  6255. // }
  6256. // if($warehouse == 5){
  6257. // $warehouse_name = "美国店";
  6258. // }
  6259. // if($warehouse == 16){
  6260. // $warehouse_name = "定制头套仓";
  6261. // }
  6262. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6263. if(!empty($warehouse_name)){
  6264. $details = ' <b style="font-size: 18px;">'.$warehouse_name."</b> ".$details;
  6265. }
  6266. $purchase = $this->purchase->read($post['purchase']);
  6267. 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));
  6268. exit; //特殊仓目前不需要仓库选项
  6269. }
  6270. }
  6271. if (isset($_SESSION['api'])) {
  6272. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6273. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6274. $this->data['wlshop'] = $wlshop;
  6275. $this->data['warehouse'] = $warehouse;
  6276. }
  6277. $whlabelwz = $this->whlabelwz->find_all();
  6278. $this->data['whlabelwz'] = $whlabelwz;
  6279. $this->_Template('whlabel_print', $this->data);
  6280. }
  6281. public function _usaprint($arg_array)
  6282. {
  6283. if (isset($_SESSION['api'])) {
  6284. $user = $this->user->get_api($_SESSION['api']);
  6285. $usp = $user;
  6286. $fgshop = "";
  6287. $sid = "";
  6288. $wid = "";
  6289. $wtype = "";
  6290. $usersp = explode('|', trim($user['shop'], '|'));
  6291. $userwh = explode('|', trim($user['warehouse'], '|'));
  6292. foreach ($usersp as $value) {
  6293. $fgshop .= " shop = " . $value . " or";
  6294. $sid .= " id = " . $value . " or";
  6295. }
  6296. foreach ($userwh as $value) {
  6297. $wid .= " id = " . $value . " or";
  6298. $wtype .= " type = " . $value . " or";
  6299. }
  6300. }
  6301. $post = $this->input->post(NULL, TRUE);
  6302. if (isset($post['tmsku'])) {
  6303. $tmsku = $this->input->post('tmsku', true);
  6304. if (is_numeric($tmsku)) {
  6305. $yyh = $this->whlabellabel->get_label($tmsku);
  6306. } else {
  6307. $yyh = $this->whlabellabel->get_sku($tmsku);
  6308. }
  6309. if ($yyh) {
  6310. echo json_encode(array('features' => $yyh['features'], 'success' => true));
  6311. exit;
  6312. } else {
  6313. echo json_encode(array('success' => false));
  6314. exit;
  6315. }
  6316. }
  6317. $classid = $this->classid->sku();
  6318. $pm = $classid;
  6319. $scsku = $classid;
  6320. //等级-真人发类型-颜色-花型-蕾丝头套种类-多尺寸-单尺寸-Clip类型-礼物类型-马尾类型-重量-长度-头路设计-蕾丝尺寸25-蕾丝尺寸26-类型-密度-发帽大小-蕾丝颜色-头套其它属性-头套属性 100为头套额外
  6321. if (isset($post['warehouse'])) {
  6322. if ($post['warehouse']) {
  6323. $list = array();
  6324. $num = "";
  6325. $title = "";
  6326. $features = "";
  6327. $order = 0;
  6328. $post['shop'] = '';
  6329. $brand = $this->input->post('brand', true);
  6330. if ($brand != '0,') {
  6331. $b = $this->brand->read(rtrim($brand, ','));
  6332. if ($b) {
  6333. $post['shop'] = str_replace('|', ',', $b['shop']);
  6334. }
  6335. }
  6336. $post['details'] = $this->input->post('details', true); //打印数量
  6337. $xbqnum = $this->input->post('xbqnum', true);
  6338. $post['purchase'] = $this->input->post('purchase', true);
  6339. $post['warehouse'] = $this->input->post('warehouse', true);
  6340. $post['purchase'] = $this->input->post('purchase', true);
  6341. $post['retreatwarehouse'] = $post['warehouse'];
  6342. $post['cpbz'] = $this->input->post('cpbz', true);
  6343. $post['state'] = 9;
  6344. $category = $this->input->post('category', true);
  6345. $list['category'] = $category;
  6346. $list['hairtype'] = $this->input->post('hairtype', true);
  6347. $list['grade'] = $this->input->post('grade', true);
  6348. $size = $this->input->post('size', true);
  6349. $list['size'] = rtrim($size, ',');
  6350. $list['hairnumber'] = $this->input->post('hairnumber', true);
  6351. $list['extension'] = $this->input->post('extension', true);
  6352. if ($category == 1297) {
  6353. $list['sywignumber'] = $this->input->post('sywignumber', true);
  6354. }
  6355. if ($category == 1702) {
  6356. $list['syhairnumber'] = $this->input->post('syhairnumber', true);
  6357. $list['syother'] = $this->input->post('syother', true);
  6358. }
  6359. if ($category == 133) {
  6360. $list['fittype'] = $this->input->post('fittype', true);
  6361. $list['acother'] = $this->input->post('acother', true);
  6362. }
  6363. $list['color'] = $this->input->post('color', true);
  6364. $list['lowe'] = $this->input->post('lowe', true);
  6365. if ($category == 127) {
  6366. $list['type'] = $this->input->post('type', true);
  6367. $list['headroad'] = $this->input->post('headroad', true);
  6368. $list['density'] = $this->input->post('density', true);
  6369. $list['lacesize'] = $this->input->post('lacesize', true);
  6370. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6371. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6372. $list['lacetypestwo'] = $this->input->post('lacetypestwo', true);
  6373. }
  6374. if ($category == 128) {
  6375. $list['lacetype'] = $this->input->post('lacetype', true);
  6376. $list['haircap'] = $this->input->post('haircap', true);
  6377. $list['density'] = $this->input->post('density', true);
  6378. $list['lacecolor'] = $this->input->post('lacecolor', true);
  6379. $list['lacetypes'] = $this->input->post('lacetypes', true);
  6380. $list['wigother'] = $this->input->post('wigother', true);
  6381. $list['wigother1'] = $this->input->post('wigother1', true);
  6382. $list['wigother2'] = $this->input->post('wigother2', true);
  6383. $list['product_related'] = $this->input->post('product_related', true);
  6384. }
  6385. if ($category == 129) {
  6386. $list['wide'] = $this->input->post('wide', true);
  6387. }
  6388. if ($category == 131) {
  6389. $list['gifttype'] = $this->input->post('gifttype', true);
  6390. $list['giftother'] = $this->input->post('giftother', true);
  6391. }
  6392. if ($category == 134) {
  6393. $list['pieceweight'] = $this->input->post('pieceweight', true);
  6394. }
  6395. if ($category == 1297) {
  6396. $list['synthetictype'] = $this->input->post('synthetictype', true);
  6397. $list['sywigother'] = $this->input->post('sywigother', true);
  6398. }
  6399. if ($category == 130 || $category == 133 || $category == 1702) {
  6400. $list['items'] = $this->input->post('items', true);
  6401. $list['weight'] = $this->input->post('weight', true);
  6402. }
  6403. if ($category == 1702) {
  6404. $list['syhairther'] = $this->input->post('syhairther', true);
  6405. }
  6406. foreach ($list as $k => $v) {
  6407. if ($v != 0) {
  6408. $num .= $v;
  6409. $features .= $v . '-';
  6410. $post[$k] = $v;
  6411. $typeclass = $this->typeclass->read($v);
  6412. if (isset($pm[$typeclass['classid']])) {
  6413. if (stripos($typeclass['zh'], '|') !== false) {
  6414. $exzh = explode('|', $typeclass['zh']);
  6415. if($k == 'hairtype'){
  6416. if(!in_array($v,[163,164,165,166])){
  6417. $pm[$typeclass['classid']] = $exzh[0];
  6418. }
  6419. }else{
  6420. $pm[$typeclass['classid']] = $exzh[0];
  6421. }
  6422. } else {
  6423. if($k == 'hairtype'){
  6424. if(!in_array($v,[163,164,165,166])){
  6425. $pm[$typeclass['classid']] = $typeclass['zh'];
  6426. }
  6427. }else{
  6428. $pm[$typeclass['classid']] = $typeclass['zh'];
  6429. }
  6430. }
  6431. }
  6432. if($k == 'hairtype'){
  6433. if(!in_array($v,[163,164,165,166])){
  6434. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6435. }
  6436. }else{
  6437. $scsku[$typeclass['classid']] = $typeclass['bqsku'];
  6438. }
  6439. if ($k != 'size') {
  6440. $title .= $typeclass['title'] . " ";
  6441. }
  6442. }
  6443. }
  6444. $typeclass = $this->typeclass->read($list['size']);
  6445. $title .= $typeclass['title'];
  6446. $time = time();
  6447. $post['title'] = rtrim($title, ' ');
  6448. $post['number'] = $num;
  6449. $post['features'] = '-' . $features;
  6450. $fp = $this->whlabel->get_features($post['features']);
  6451. if (!$fp) {
  6452. echo json_encode(array('msg' => '美仓无此产品,需要添加后才可打印', 'success' => false));
  6453. exit;
  6454. }
  6455. $featurespp = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $features);
  6456. $featurespp = explode('-', trim($featurespp, '-'));
  6457. if (isset($featurespp[5])) {
  6458. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4] . '-' . $featurespp[5];
  6459. } else {
  6460. $post['featurespp'] = $featurespp[0] . '-' . $featurespp[3] . '-' . $featurespp[4];
  6461. }
  6462. $post['enter'] = $time;
  6463. $post['time'] = $time; //操作时间
  6464. $scsku = implode("-", $scsku);
  6465. $zh = implode(" ", $pm);
  6466. $scsku = str_replace('- ', '-', trim($scsku, '-'));
  6467. $scsku = str_replace(array('--------', '-------', '------', '-----', '----', '---', '--'), '-', $scsku);
  6468. $bqsku = (isset($b['title'])) ? $b['title'] . '-' . $scsku : $scsku;;
  6469. $post['sku'] = $fp['sku'];
  6470. $post['label'] = $fp['sku'];
  6471. $cpid = $this->whlabellabel->find_count();
  6472. $post['cpid'] = $cpid + 1;
  6473. $cpid = $post['cpid'];
  6474. //$whlabelbarcode = $this->whlabelbarcode->get_number($post['number'],$post['warehouse']);
  6475. //if($whlabelbarcode)
  6476. //{
  6477. //$post['label'] = $whlabelbarcode['label'];
  6478. //if(!$this->whlabellabel->insert($post))
  6479. //{
  6480. // echo json_encode(array('msg'=>'错误,请重试!','success'=>false));exit;
  6481. //}
  6482. //}
  6483. //else
  6484. //{
  6485. $this->db->trans_begin();
  6486. $this->whlabellabel->insert($post);
  6487. //$this->whlabelbarcode->insert($post);
  6488. if ($this->db->trans_status() === TRUE) {
  6489. $this->db->trans_commit();
  6490. } else {
  6491. $this->db->trans_rollback();
  6492. echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
  6493. exit;
  6494. }
  6495. //}
  6496. $details = ($post['details'] != '') ? '位置:(' . $post['details'] . ') <font style="font-size: 18px;">' . $cpid . '</font>' : '';
  6497. $purchase = $this->purchase->read($post['purchase']);
  6498. 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));
  6499. exit; //特殊仓目前不需要仓库选项
  6500. }
  6501. }
  6502. if (isset($_SESSION['api'])) {
  6503. $wlshop = $this->shop->find_all('1=1 and ' . rtrim($sid, 'or'));
  6504. $warehouse = $this->warehouse->find_all('1=1 and ' . rtrim($wid, 'or'), "*", "px asc");
  6505. $this->data['wlshop'] = $wlshop;
  6506. $this->data['warehouse'] = $warehouse;
  6507. }
  6508. $whlabelwz = $this->whlabelwz->find_all();
  6509. $this->data['whlabelwz'] = $whlabelwz;
  6510. $this->_Template('whlabel_usaprint', $this->data);
  6511. }
  6512. public function _printrk($arg_array)
  6513. {
  6514. $prc = array();
  6515. $purchase = $this->purchase->find_all();
  6516. foreach ($purchase as $k => $v) {
  6517. $prc[$v['id']] = $v['title'];
  6518. }
  6519. $post = $this->input->post(NULL, TRUE);
  6520. if (isset($post['page'])) {
  6521. $page = $this->input->post('page', true);
  6522. $perpage = $this->input->post('perpage', true);
  6523. $sku = $this->input->post('sku', true);
  6524. $bs = $this->input->post('bs', true);
  6525. $number = $this->input->post('number', true);
  6526. $warehouse = $this->input->post('warehouse', true);
  6527. $purchase = $this->input->post('purchase', true);
  6528. $orderinfo = $this->input->post('orderinfo', true);
  6529. $waybill = $this->input->post('waybill', true);
  6530. $category = $this->input->post('category', true);
  6531. $size = $this->input->post('size', true);
  6532. $grade = $this->input->post('grade', true);
  6533. $color = $this->input->post('color', true);
  6534. $lowe = $this->input->post('lowe', true);
  6535. $state = $this->input->post('state', true);
  6536. $label = $this->input->post('label', true);
  6537. $timetk = $this->input->post('ktime', true);
  6538. $timetj = $this->input->post('jtime', true);
  6539. $timetk = strtotime($timetk);
  6540. $timetj = strtotime($timetj);
  6541. $where = "1=1 ";
  6542. if ($timetk && $timetj) {
  6543. $where .= " and enter > '$timetk' and enter < '$timetj'";
  6544. }
  6545. if ($sku) {
  6546. $where .= " and sku = '$sku'";
  6547. }
  6548. if ($bs != '') {
  6549. $where .= " and bs = '$bs'";
  6550. }
  6551. if ($number) {
  6552. $where .= " and number = '$number'";
  6553. }
  6554. if ($warehouse) {
  6555. $where .= " and warehouse = '$warehouse'";
  6556. }
  6557. if ($purchase) {
  6558. $where .= " and purchase = '$purchase'";
  6559. }
  6560. if ($orderinfo) {
  6561. $where .= " and orderinfo = '$orderinfo'";
  6562. }
  6563. if ($waybill) {
  6564. $where .= " and waybill = '$waybill'";
  6565. }
  6566. if ($category) {
  6567. $where .= " and features like '%-$category-%'";
  6568. }
  6569. if ($size) {
  6570. $where .= " and features like '%-$size-%'";
  6571. }
  6572. if ($grade) {
  6573. $where .= " and features like '%-$grade-%'";
  6574. }
  6575. if ($color) {
  6576. $where .= " and features like '%-$color-%'";
  6577. }
  6578. if ($lowe) {
  6579. $where .= " and features like '%-$lowe-%'";
  6580. }
  6581. if ($label) {
  6582. $where .= " and label = '$label'";
  6583. }
  6584. // if ($state || $state == 0) {
  6585. // $where .= " and state = '$state'";
  6586. // }
  6587. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6588. //数据排序
  6589. $order_str = "enter desc";
  6590. if (empty($page)) {
  6591. $start = 0;
  6592. $perpage = 1;
  6593. } else {
  6594. $start = ($page - 1) * $perpage;
  6595. }
  6596. //取得信息列表
  6597. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,enter,details', $order_str, $start, $perpage);
  6598. foreach ($info_list as $key => $value) {
  6599. $warehouse = $this->warehouse->read($value['warehouse']);
  6600. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6601. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6602. if ($value['state'] == 0) {
  6603. $info_list[$key]['state'] = "在库";
  6604. } else if ($value['state'] == 1) {
  6605. $info_list[$key]['state'] = "出库";
  6606. } else if ($value['state'] == 2) {
  6607. $info_list[$key]['state'] = "退库";
  6608. } else if ($value['state'] == 3) {
  6609. $info_list[$key]['state'] = "调拨中";
  6610. } else if ($value['state'] == 4) {
  6611. $info_list[$key]['state'] = "再加工";
  6612. } else if ($value['state'] == 5) {
  6613. $info_list[$key]['state'] = "维修中";
  6614. } else if ($value['state'] == 6) {
  6615. $info_list[$key]['state'] = "盘亏";
  6616. } else if ($value['state'] == 7) {
  6617. $info_list[$key]['state'] = "更换标签";
  6618. } else if ($value['state'] == 8) {
  6619. $info_list[$key]['state'] = "其它";
  6620. } else if ($value['state'] == 9) {
  6621. $info_list[$key]['state'] = "预设";
  6622. } else if ($value['state'] == 10) {
  6623. $info_list[$key]['state'] = "美店零售";
  6624. }
  6625. $info_list[$key]['enter'] = date('Y-m-d H:i:s', $value['enter']);
  6626. }
  6627. $total = $this->$ck->find_count($where);
  6628. $pagenum = ceil($total / $perpage);
  6629. $over = $total - ($start + $perpage);
  6630. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6631. echo json_encode($rows);
  6632. exit;
  6633. }
  6634. if (isset($post['tmsku'])) {
  6635. $time = time();
  6636. $tmsku = $this->input->post('tmsku', true);
  6637. //$post['shop'] = $this->input->post('shop',true);
  6638. $num = $this->input->post('num', true);
  6639. $rktype = $this->input->post('rktype', true);
  6640. if ($num > 200) {
  6641. echo json_encode(array('msg' => '入库数量不允许超过200!', 'c' => 0, 'success' => false));
  6642. exit;
  6643. }
  6644. if (!$rktype) {
  6645. //echo json_encode(array('msg'=>'请选择入库类型!','c'=>0,'success'=>false));exit;
  6646. }
  6647. $rk = $this->whlabellabel->find_all("label = '$tmsku'", "*", "id desc");
  6648. /**
  6649. $wz = array();
  6650. foreach ($rk as $key=>$value)
  6651. {
  6652. $wz[$value['details']] = array('details'=>$value['details'],'id'=>$value['id']);
  6653. }
  6654. if(count($wz) > 1)
  6655. {
  6656. $wz = array_values($wz);
  6657. echo json_encode(array('msg'=>'此条码有多个位置,请选择','wz'=>$wz,'c'=>1,'success'=>false));exit;
  6658. }
  6659. **/
  6660. if (isset($rk[0]['purchase'])) {
  6661. $rk = $rk[0];
  6662. $j = 0;
  6663. $post['purchase'] = $rk['purchase'];
  6664. $post['warehouse'] = $rk['warehouse'];
  6665. $post['retreatwarehouse'] = $rk['warehouse'];
  6666. $post['sku'] = $rk['sku'];
  6667. $post['number'] = $rk['number'];
  6668. $post['features'] = $rk['features'];
  6669. $post['title'] = $rk['title'];
  6670. $post['enter'] = $time;
  6671. $post['time'] = $time;
  6672. $post['bs'] = 1;
  6673. $post['shop'] = $rk['shop'];
  6674. $post['details'] = $rk['details'];
  6675. $post['cpid'] = $rk['cpid'];
  6676. $post['cpbz'] = $rk['cpbz'];
  6677. $post['rktype'] = $rktype;
  6678. $warehouse = $this->warehouse->read($rk['warehouse']);
  6679. if ($warehouse['bdck'] == '') {
  6680. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'c' => 0, 'success' => false));
  6681. exit;
  6682. } else {
  6683. $bdck = $warehouse['bdck'];
  6684. }
  6685. $pdwz = $this->whlabel->get_warehousesku($post['warehouse'], $post['sku']);
  6686. if (isset($pdwz['details'])) {
  6687. if ($pdwz['details'] != $post['details']) {
  6688. if(($post['warehouse'] == 13)&&($post['details'] == 'DZ001')){
  6689. }else{
  6690. echo json_encode(array('msg' => '此产品位置应为:' . $pdwz['details'], 'c' => 0, 'cs' => $pdwz['details'] . ' - ' . $post['details'], 'success' => false));
  6691. exit;
  6692. }
  6693. }
  6694. }
  6695. $post['featurespp'] = $rk['featurespp'];
  6696. if ($post['warehouse'] == '5') {
  6697. $yza = $this->whlabel->find_all("sku = '" . $post['sku'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6698. if ($yza) {
  6699. if ($post['features'] != $yza[0]['features']) {
  6700. echo json_encode(array('msg' => '此SKU的产品信息和现有不一致!', 'new' => $post['features'] . '-' . $post['sku'], 'old' => $yza[0]['features'], 'c' => 0, 'success' => false));
  6701. exit;
  6702. }
  6703. }
  6704. $yzb = $this->whlabel->find_all("features = '" . $post['features'] . "' and warehouse = '" . $post['warehouse'] . "' and shop = '" . $post['shop'] . "'");
  6705. if ($yzb) {
  6706. if ($post['sku'] != $yzb[0]['sku']) {
  6707. echo json_encode(array('msg' => '此产品信息的SKU和现有' . $yzb[0]['sku'] . '不一致!', 'c' => 0, 'success' => false));
  6708. exit;
  6709. }
  6710. }
  6711. }
  6712. for ($i = 0; $i < $num; $i++) {
  6713. $post['label'] = time() . rand(100, 999) . $i;
  6714. if ($this->$bdck->insert($post)) {
  6715. $j++;
  6716. }
  6717. }
  6718. /**
  6719. if($post['warehouse'] != 12)
  6720. {
  6721. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6722. }
  6723. **/
  6724. $this->whlabelscanlog->insert([
  6725. 'shop'=>$rk['shop'],
  6726. 'type'=>1,
  6727. 'purchase'=>$rk['purchase'],
  6728. 'sku'=>$rk['sku'],
  6729. 'features'=>$rk['features'],
  6730. 'title'=>$rk['title'],
  6731. 'label'=>$rk['label'],
  6732. 'warehouse'=>$rk['warehouse'],
  6733. 'wlid'=>$rk['id'],
  6734. 'num'=>$num,
  6735. 'addtime'=>time()
  6736. ]);
  6737. if ($j == $num) {
  6738. echo json_encode(array('msg' => '入库成功!', 'success' => true));
  6739. exit;
  6740. } else {
  6741. echo json_encode(array('msg' => '未成功入库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6742. exit;
  6743. }
  6744. } else {
  6745. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6746. exit;
  6747. }
  6748. }
  6749. $this->_Template('whlabel_printrk', $this->data);
  6750. }
  6751. public function _printxzrk($arg_array)
  6752. {
  6753. $post = $this->input->post(NULL, TRUE);
  6754. if (isset($post['wzid'])) {
  6755. $time = time();
  6756. $id = $this->input->post('wzid', true);
  6757. //$post['shop'] = $this->input->post('shop',true);
  6758. $num = 1;
  6759. $rk = $this->whlabellabel->read($id);
  6760. if (isset($rk['purchase'])) {
  6761. $x = 0;
  6762. $post['purchase'] = $rk['purchase'];
  6763. $post['warehouse'] = $rk['warehouse'];
  6764. $post['retreatwarehouse'] = $rk['warehouse'];
  6765. $post['sku'] = $rk['sku'];
  6766. $post['number'] = $rk['number'];
  6767. $post['features'] = $rk['features'];
  6768. $post['title'] = $rk['title'];
  6769. $post['enter'] = $time;
  6770. $post['time'] = $time;
  6771. $post['bs'] = 1;
  6772. $post['shop'] = $rk['shop'];
  6773. $post['details'] = $rk['details'];
  6774. $post['cpid'] = $rk['cpid'];
  6775. $post['cpbz'] = $rk['cpbz'];
  6776. $warehouse = $this->warehouse->read($rk['warehouse']);
  6777. if ($warehouse['bdck'] == '') {
  6778. echo json_encode(array('msg' => '此仓库没有设置现货,无法入库!', 'success' => false));
  6779. exit;
  6780. } else {
  6781. $bdck = $warehouse['bdck'];
  6782. }
  6783. $post['featurespp'] = $rk['featurespp'];
  6784. $this->db->trans_begin();
  6785. for ($i = 0; $i < $num; $i++) {
  6786. $post['label'] = time() . rand(100, 999) . $i;
  6787. $this->$bdck->insert($post);
  6788. }
  6789. /**
  6790. if($post['warehouse'] != 12)
  6791. {
  6792. echo json_encode(array('msg'=>'目前非特殊仓不能入库!','success'=>true));exit;
  6793. }
  6794. **/
  6795. if ($this->db->trans_status() === TRUE) {
  6796. $this->db->trans_commit();
  6797. echo json_encode(array('msg' => '入库成功!', 'cs' => $post, 'cs2' => $warehouse, 'success' => true));
  6798. exit;
  6799. } else {
  6800. $this->db->trans_rollback();
  6801. echo json_encode(array('msg' => '入库失败,请重试', 'c' => 0, 'success' => false));
  6802. exit;
  6803. }
  6804. } else {
  6805. echo json_encode(array('msg' => '未找到此条码数据!', 'c' => 0, 'success' => false));
  6806. exit;
  6807. }
  6808. }
  6809. }
  6810. public function _printck($arg_array)
  6811. {
  6812. $prc = array();
  6813. $purchase = $this->purchase->find_all();
  6814. foreach ($purchase as $k => $v) {
  6815. $prc[$v['id']] = $v['title'];
  6816. }
  6817. $post = $this->input->post(NULL, TRUE);
  6818. if (isset($post['page'])) {
  6819. $page = $this->input->post('page', true);
  6820. $perpage = $this->input->post('perpage', true);
  6821. $sku = $this->input->post('sku', true);
  6822. $bs = $this->input->post('bs', true);
  6823. $number = $this->input->post('number', true);
  6824. $warehouse = $this->input->post('warehouse', true);
  6825. $purchase = $this->input->post('purchase', true);
  6826. $orderinfo = $this->input->post('orderinfo', true);
  6827. $waybill = $this->input->post('waybill', true);
  6828. $category = $this->input->post('category', true);
  6829. $size = $this->input->post('size', true);
  6830. $grade = $this->input->post('grade', true);
  6831. $color = $this->input->post('color', true);
  6832. $lowe = $this->input->post('lowe', true);
  6833. $state = $this->input->post('state', true);
  6834. $label = $this->input->post('label', true);
  6835. $timetk = $this->input->post('ktime', true);
  6836. $timetj = $this->input->post('jtime', true);
  6837. $timetk = strtotime($timetk);
  6838. $timetj = strtotime($timetj);
  6839. $where = "state=1 ";
  6840. if ($timetk && $timetj) {
  6841. $where .= " and outk > '$timetk' and outk < '$timetj'";
  6842. }
  6843. if ($sku) {
  6844. $where .= " and sku = '$sku'";
  6845. }
  6846. if ($bs != '') {
  6847. $where .= " and bs = '$bs'";
  6848. }
  6849. if ($number) {
  6850. $where .= " and number = '$number'";
  6851. }
  6852. if ($warehouse) {
  6853. $where .= " and warehouse = '$warehouse'";
  6854. }
  6855. if ($purchase) {
  6856. $where .= " and purchase = '$purchase'";
  6857. }
  6858. if ($orderinfo) {
  6859. $where .= " and orderinfo = '$orderinfo'";
  6860. }
  6861. if ($waybill) {
  6862. $where .= " and waybill = '$waybill'";
  6863. }
  6864. if ($category) {
  6865. $where .= " and features like '%-$category-%'";
  6866. }
  6867. if ($size) {
  6868. $where .= " and features like '%-$size-%'";
  6869. }
  6870. if ($grade) {
  6871. $where .= " and features like '%-$grade-%'";
  6872. }
  6873. if ($color) {
  6874. $where .= " and features like '%-$color-%'";
  6875. }
  6876. if ($lowe) {
  6877. $where .= " and features like '%-$lowe-%'";
  6878. }
  6879. if ($label) {
  6880. $where .= " and label = '$label'";
  6881. }
  6882. $ck = ($warehouse == '12') ? 'specialstock' : 'whlabel';
  6883. //数据排序
  6884. $order_str = "outk desc";
  6885. if (empty($page)) {
  6886. $start = 0;
  6887. $perpage = 1;
  6888. } else {
  6889. $start = ($page - 1) * $perpage;
  6890. }
  6891. //取得信息列表
  6892. $info_list = $this->$ck->find_all($where, 'id,warehouse,purchase,sku,title,state,outk,details', $order_str, $start, $perpage);
  6893. foreach ($info_list as $key => $value) {
  6894. $warehouse = $this->warehouse->read($value['warehouse']);
  6895. $info_list[$key]['warehouse'] = ($ck == 'specialstock') ? '特殊仓' : $warehouse['title'];
  6896. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  6897. if ($value['state'] == 0) {
  6898. $info_list[$key]['state'] = "在库";
  6899. } else if ($value['state'] == 1) {
  6900. $info_list[$key]['state'] = "出库";
  6901. } else if ($value['state'] == 2) {
  6902. $info_list[$key]['state'] = "退库";
  6903. } else if ($value['state'] == 3) {
  6904. $info_list[$key]['state'] = "调拨中";
  6905. } else if ($value['state'] == 4) {
  6906. $info_list[$key]['state'] = "再加工";
  6907. } else if ($value['state'] == 5) {
  6908. $info_list[$key]['state'] = "维修中";
  6909. } else if ($value['state'] == 6) {
  6910. $info_list[$key]['state'] = "盘亏";
  6911. } else if ($value['state'] == 7) {
  6912. $info_list[$key]['state'] = "更换标签";
  6913. } else if ($value['state'] == 8) {
  6914. $info_list[$key]['state'] = "其它";
  6915. } else if ($value['state'] == 9) {
  6916. $info_list[$key]['state'] = "预设";
  6917. } else if ($value['state'] == 10) {
  6918. $info_list[$key]['state'] = "美店零售";
  6919. }
  6920. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']);
  6921. }
  6922. $total = $this->$ck->find_count($where);
  6923. $pagenum = ceil($total / $perpage);
  6924. $over = $total - ($start + $perpage);
  6925. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  6926. echo json_encode($rows);
  6927. exit;
  6928. }
  6929. if (isset($post['tmsku'])) {
  6930. $time = time();
  6931. $tmsku = $this->input->post('tmsku', true);
  6932. //$post['shop'] = $this->input->post('shop',true);
  6933. $num = $this->input->post('num', true);
  6934. $cktype = $this->input->post('cktype', true);
  6935. $label = $this->whlabellabel->get_label($tmsku);
  6936. if (!$cktype) {
  6937. //echo json_encode(array('msg'=>'请选择出库类型!','success'=>false));exit;
  6938. }
  6939. if (!isset($label['warehouse'])) {
  6940. echo json_encode(array('msg' => '没有此条码信息!', 'success' => false));
  6941. exit;
  6942. }
  6943. //处理一个bug 就是 需要根据标签的库位去进行 出库
  6944. $extra_where = "";
  6945. if(!empty($label['details'])){
  6946. $extra_where .= " and details = '" . $label['details'] . "'";
  6947. }
  6948. $xzck = ($label['warehouse'] == '12') ? 'specialstock' : 'whlabel';
  6949. if (stripos($label['features'], '-126-') !== false) {
  6950. $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);
  6951. } else {
  6952. $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);
  6953. }
  6954. $j = 0;
  6955. if (count($ck) >= $num) {
  6956. for ($i = 0; $i < $num; $i++) {
  6957. if ($this->$xzck->save(array('state' => 1, 'outk' => $time, 'time' => $time), $ck[$i]['id'])) //,'cktype'=>$cktype
  6958. {
  6959. $j++;
  6960. }
  6961. }
  6962. $this->whlabelscanlog->insert([
  6963. 'shop'=>$label['shop'],
  6964. 'type'=>2,
  6965. 'purchase'=>$label['purchase'],
  6966. 'sku'=>$label['sku'],
  6967. 'features'=>$label['features'],
  6968. 'title'=>$label['title'],
  6969. 'label'=>$label['label'],
  6970. 'warehouse'=>$label['warehouse'],
  6971. 'wlid'=>$label['id'],
  6972. 'num'=>$num,
  6973. 'addtime'=>time()
  6974. ]);
  6975. if ($j == $num) {
  6976. echo json_encode(array('msg' => '出库成功!', 'success' => true));
  6977. exit;
  6978. } else {
  6979. echo json_encode(array('msg' => '未成功出库数量:' . $num - $j . ',请补入', 'c' => 0, 'success' => false));
  6980. exit;
  6981. }
  6982. } else {
  6983. echo json_encode(array('msg' => '没有足够的库存!', 'cs' => $label['sku'] . ' - ' . $label['purchase'], 'success' => false));
  6984. exit;
  6985. }
  6986. }
  6987. if(isset($_SESSION['api']))
  6988. {
  6989. $user = $this->user->get_api($_SESSION['api']);
  6990. if(in_array($user['power'],[1,27])){
  6991. $vip = 1;
  6992. }
  6993. }
  6994. else
  6995. {
  6996. $vip = 0;
  6997. header('Location: /');exit;
  6998. }
  6999. $this->data['vip'] = $vip;
  7000. $this->_Template('whlabel_printck', $this->data);
  7001. }
  7002. public function _printexcel()
  7003. {
  7004. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7005. $config['upload_path'] = '.' . $dir;
  7006. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7007. $config['allowed_types'] = 'xls|xlsx|csv';
  7008. $config['max_size'] = 10240;
  7009. $this->load->library('upload', $config);
  7010. $this->upload->initialize($config);
  7011. if ($this->upload->do_upload('userfile')) {
  7012. $full_path = $dir . $this->upload->data('file_name');
  7013. $fileName = '.' . $full_path;
  7014. if (!file_exists($fileName)) {
  7015. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7016. exit;
  7017. } else {
  7018. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7019. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7020. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7021. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7022. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7023. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7024. ++$column; //如果列数大于26行
  7025. $list = array();
  7026. for ($i = 2; $i <= $row; $i++) // 行数循环
  7027. {
  7028. $data = array();
  7029. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7030. {
  7031. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7032. }
  7033. $list[] = $data;
  7034. }
  7035. }
  7036. $ed = array();
  7037. $i = 0;
  7038. $j = 0;
  7039. $dcdata = array();
  7040. $yc = '';
  7041. $cmf_arr = array_column($list, '1');
  7042. array_multisort($cmf_arr, SORT_ASC, $list);
  7043. foreach ($list as $key => $value) {
  7044. $typeclass = $this->typeclass->get_bqsku($value['1'], $value['2']);
  7045. if ($typeclass) {
  7046. $this->typeclass->save(array('bqsku' => $value['3']), $typeclass['id']);
  7047. } else {
  7048. $ed[] = array($value['1'] . '-系统未找到此订单信息');
  7049. $i++;
  7050. continue;
  7051. }
  7052. }
  7053. if ($i > 0) {
  7054. $yc = $i . '条异常';
  7055. }
  7056. echo json_encode(array('msg' => '操作成功 ' . $yc, 'yc' => $ed, 'success' => true));
  7057. exit;
  7058. }
  7059. }
  7060. public function _uck()
  7061. {
  7062. if (isset($_GET['excel'])) {
  7063. $tc = array();
  7064. $typeclass = $this->typeclass->find_all();
  7065. foreach ($typeclass as $v) {
  7066. $tc[$v['id']] = $v['zh'];
  7067. }
  7068. $data = array();
  7069. $t = array();
  7070. $rq = '';
  7071. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  7072. $ts = $ts / (24 * 3600);
  7073. for ($i = 0; $i < $ts; $i++) {
  7074. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  7075. $rq .= "<td>" . date("Y-m-d", strtotime('-' . ($ts - $i) . ' day')) . "</td>";
  7076. }
  7077. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  7078. foreach ($info_list as $k => $v) {
  7079. $features = explode('-', trim($v['features'], '-'));
  7080. if (!isset($features[3]) || !isset($features[4])) {
  7081. continue;
  7082. }
  7083. $data[$k][0] = $tc[$features[0]]; //类型
  7084. $data[$k][1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  7085. $data[$k][2] = $tc[$features[4]]; //曲度
  7086. $data[$k][3] = '';
  7087. if (isset($data[$k][1])) {
  7088. $data[$k][3] .= $data[$k][1];
  7089. }
  7090. if (isset($data[$k][2])) {
  7091. $data[$k][3] .= $data[$k][2];
  7092. }
  7093. if (isset($features[5])) {
  7094. $data[$k][3] .= $tc[$features[5]];
  7095. }
  7096. if (isset($features[2])) {
  7097. $data[$k][3] .= $tc[$features[2]];
  7098. }
  7099. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  7100. $data[$k][4] = $v['sku'];
  7101. $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())) . '))'); //月初库存
  7102. $data[$k][] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  7103. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  7104. $ztrq = '';
  7105. $ztsl = '';
  7106. if (count($zt) > 0) {
  7107. foreach ($zt as $vv) {
  7108. $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  7109. $ztsl .= $vv['num'] . '<br>';
  7110. }
  7111. }
  7112. $data[$k][] = trim($ztsl, '<br>');
  7113. $data[$k][] = trim($ztrq, '<br>');
  7114. $byck = 0;
  7115. foreach ($t as $vv) {
  7116. $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));
  7117. $data[$k][] = ($sl > 0) ? '<b>' . $sl . '</b>' : '';
  7118. $byck += $sl;
  7119. }
  7120. $data[$k][] = ($byck > 0) ? $byck : '';
  7121. }
  7122. $title = "详情 " . date("Y-m-d", time());
  7123. $titlename = "<table border=1>
  7124. <tr align='center'>
  7125. <td>类别</td>
  7126. <td>颜色</td>
  7127. <td>曲度</td>
  7128. <td>名称</td>
  7129. <td>SKU</td>
  7130. <td>月初库存</td>
  7131. <td>剩余库存</td>
  7132. <td>在途数量</td>
  7133. <td>预达日期</td>" .
  7134. $rq
  7135. . "<td>本月出库</td></tr>
  7136. </table>";
  7137. $filename = $title . ".xls";
  7138. $tail = "";
  7139. $this->excelxh->get_fz2($data, $titlename, $filename, $tail);
  7140. }
  7141. }
  7142. //梦体发现 用数字粘贴 会出现遗产给的数据
  7143. public function _whlabelexcelzh_ztsh()
  7144. {
  7145. if (isset($_GET['excel'])) {
  7146. $where = "sku != 'Preset'";
  7147. //数据排序
  7148. $order_str = "id desc";
  7149. if (empty($page)) {
  7150. $start = 0;
  7151. $perpage = 1;
  7152. } else {
  7153. $start = ($page - 1) * $perpage;
  7154. }
  7155. $category = $this->input->get('category', true);
  7156. $warehouse = $this->input->get('warehouse', true);
  7157. $excelid = $this->input->get('sid', true);
  7158. if ($category) {
  7159. $where .= " and features like '%-$category-%'";
  7160. }
  7161. if ($warehouse) {
  7162. $where .= " and warehouse = '$warehouse'";
  7163. }
  7164. $xzid = '';
  7165. if ($excelid) {
  7166. $excelid = explode(',', trim($excelid, ','));
  7167. foreach ($excelid as $key => $value) {
  7168. $xzid .= " id = " . $value . " or";
  7169. }
  7170. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  7171. }
  7172. //取得信息列表
  7173. /**
  7174. $info_list = $this->whlabel->find_all($where.$xzid,'*');
  7175. $rows = array();$list = array();
  7176. foreach ($info_list as $key=>$value)
  7177. {
  7178. $rows[strtolower($value['sku']).$value['features'].$value['warehouse']] = $value;//所有数据sku
  7179. }
  7180. **/
  7181. $list = array();
  7182. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  7183. foreach ($rows as $key => $value) {
  7184. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7185. $zh = '';
  7186. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7187. foreach ($zt as $v) {
  7188. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7189. }
  7190. $zt = array_sum(array_column($zt, 'num'));
  7191. $number = $value['number'];
  7192. $ftime = time() - 15 * 24 * 3600;
  7193. $warehouse = $this->warehouse->read($value['warehouse']);
  7194. $rows[$key]['warehouse'] = $warehouse['title'];
  7195. $rows[$key]['number'] = $c;
  7196. $rows[$key]['features'] = $zh;
  7197. $rows[$key]['hb'] = $c + $zt;
  7198. }
  7199. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7200. $titlename = "<table border=1>
  7201. <tr><th colspan='6' align='center'><h3>导出库存数据及在途中数据<h3></th></tr>
  7202. <tr align='center'>
  7203. <td>仓库</td>
  7204. <td>SKU</td>
  7205. <td>产品</td>
  7206. <td>库存数量</td>
  7207. <td>在途数量及预达日期</td>
  7208. <td>在途+库存数量</td>
  7209. </tr>
  7210. </table>";
  7211. $filename = $title . ".xls";
  7212. $tail = "";
  7213. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7214. }
  7215. if (isset($_GET['excel'])) {
  7216. $warehouse = $this->input->get('warehouse', true);
  7217. $sku = $this->input->get('sku', true);
  7218. $cz = $this->input->get('cz', true);
  7219. $text = $this->input->post('text', true);
  7220. $xztime = $this->input->get('xztime', true);
  7221. $timetk = $this->input->get('timetk', true);
  7222. $timetj = $this->input->get('timetj', true);
  7223. $timetk = strtotime($timetk);
  7224. $timetj = strtotime($timetj);
  7225. $where = "time = '0' ";
  7226. if ($warehouse) {
  7227. $where .= " and warehouse = '$warehouse'";
  7228. }
  7229. if ($sku) {
  7230. $where .= " and sku = '$sku'";
  7231. }
  7232. if ($text) {
  7233. $where .= " and text like '%$text%'";
  7234. }
  7235. if ($cz != '') {
  7236. $where .= " and cz = '$cz'";
  7237. }
  7238. if ($timetk && $timetj) {
  7239. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7240. }
  7241. //数据排序
  7242. $order_str = $xztime . " desc";
  7243. //取得信息列表
  7244. $zh = array();
  7245. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7246. foreach ($info_list as $v) {
  7247. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7248. $warehouse = $this->warehouse->read($v['warehouse']);
  7249. $v['warehouse'] = $warehouse['title'];
  7250. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7251. $v['stime'] = date('Y-m-d', $v['stime']);
  7252. if (isset($zh[$v['features']])) {
  7253. $zh[$v['features']]['num'] += $v['num'];
  7254. } else {
  7255. $zh[$v['features']] = $v;
  7256. }
  7257. $zh[$v['features']]['features'] = $c;
  7258. }
  7259. $title = "在途数据" . date('Y-m-d', time());
  7260. $titlename = "<table border=1>
  7261. <tr align='center'>
  7262. <td>仓库</td>
  7263. <td>SKU</td>
  7264. <td>名称</td>
  7265. <td>在途数量</td>
  7266. <td>库存数量</td>
  7267. <td>添加在途日期</td>
  7268. <td>预达日期</td>
  7269. <td>备注</td>
  7270. </tr>
  7271. </table>";
  7272. $filename = $title . ".xls";
  7273. $tail = "";
  7274. $this->excel->get_fz2($zh, $titlename, $filename, $tail);
  7275. }
  7276. }
  7277. //用XML(SpreadsheetML)格式导出excel,逻辑与_whlabelexcelzh一致,仅输出格式不同
  7278. public function _whlabelexcelzh()
  7279. {
  7280. //$colwidths:按表头顺序设置各列宽度(单位≈字符数);$wrapcols:需要自动换行的列下标(从0开始)
  7281. $excelxml = function ($info_list, $headers, $numkeys, $filename, $colwidths = array(), $wrapcols = array()) {
  7282. $str = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  7283. $str .= '<?mso-application progid="Excel.Sheet"?>' . "\n";
  7284. $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";
  7285. $str .= '<Styles>' . "\n";
  7286. $str .= '<Style ss:ID="wrap"><Alignment ss:Vertical="Center" ss:WrapText="1"/></Style>' . "\n";
  7287. $str .= '</Styles>' . "\n";
  7288. $str .= '<Worksheet ss:Name="Sheet1">' . "\n";
  7289. $str .= '<Table>' . "\n";
  7290. foreach ($colwidths as $w) {
  7291. $str .= '<Column ss:Width="' . $w . '"/>' . "\n";
  7292. }
  7293. $str .= '<Row>' . "\n";
  7294. foreach ($headers as $h) {
  7295. $str .= '<Cell><Data ss:Type="String">' . htmlspecialchars($h, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7296. }
  7297. $str .= '</Row>' . "\n";
  7298. foreach ($info_list as $row) {
  7299. $str .= '<Row>' . "\n";
  7300. $j = 0;
  7301. foreach ($row as $ke => $va) {
  7302. $va = (string)$va;
  7303. $va = str_replace('<br>', "\n", $va);
  7304. $wrapattr = in_array($j, $wrapcols) ? ' ss:StyleID="wrap"' : '';
  7305. if ($va === '') {
  7306. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String"></Data></Cell>' . "\n";
  7307. } else if (in_array($ke, $numkeys) && is_numeric($va)) {
  7308. $str .= '<Cell' . $wrapattr . '><Data ss:Type="Number">' . $va . '</Data></Cell>' . "\n";
  7309. } else {
  7310. $str .= '<Cell' . $wrapattr . '><Data ss:Type="String">' . htmlspecialchars($va, ENT_QUOTES, 'UTF-8') . '</Data></Cell>' . "\n";
  7311. }
  7312. $j++;
  7313. }
  7314. $str .= '</Row>' . "\n";
  7315. }
  7316. $str .= '</Table>' . "\n";
  7317. $str .= '</Worksheet>' . "\n";
  7318. $str .= '</Workbook>' . "\n";
  7319. while (ob_get_level()) {
  7320. ob_end_clean();
  7321. }
  7322. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  7323. header("Content-Disposition: attachment; filename=" . $filename);
  7324. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  7325. header("Pragma: no-cache");
  7326. header("Expires: 0");
  7327. echo $str;
  7328. exit();
  7329. };
  7330. if (isset($_GET['excel'])) {
  7331. $where = "sku != 'Preset'";
  7332. //数据排序
  7333. $order_str = "id desc";
  7334. if (empty($page)) {
  7335. $start = 0;
  7336. $perpage = 1;
  7337. } else {
  7338. $start = ($page - 1) * $perpage;
  7339. }
  7340. $category = $this->input->get('category', true);
  7341. $warehouse = $this->input->get('warehouse', true);
  7342. $excelid = $this->input->get('sid', true);
  7343. if ($category) {
  7344. $where .= " and features like '%-$category-%'";
  7345. }
  7346. if ($warehouse) {
  7347. $where .= " and warehouse = '$warehouse'";
  7348. }
  7349. $xzid = '';
  7350. if ($excelid) {
  7351. $excelid = explode(',', trim($excelid, ','));
  7352. foreach ($excelid as $key => $value) {
  7353. $xzid .= " id = " . $value . " or";
  7354. }
  7355. $xzid = " and (" . rtrim($xzid, 'or') . ");";
  7356. }
  7357. $list = array();
  7358. $rows = $this->whlabel->find_pc($where, 'sku,title,features,warehouse', 'warehouse,sku,title,number,features');
  7359. foreach ($rows as $key => $value) {
  7360. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  7361. $zh = '';
  7362. $zt = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  7363. foreach ($zt as $v) {
  7364. $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  7365. }
  7366. $zt = array_sum(array_column($zt, 'num'));
  7367. $number = $value['number'];
  7368. $ftime = time() - 15 * 24 * 3600;
  7369. $warehouse = $this->warehouse->read($value['warehouse']);
  7370. //按表头顺序输出:仓库 | SKU | 产品 | 库存数量 | 在途数量及预达日期 | 在途+库存数量
  7371. $rows[$key] = array(
  7372. 'warehouse' => ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $value['warehouse'],
  7373. 'sku' => $value['sku'],
  7374. 'title' => isset($value['title']) ? $value['title'] : '',
  7375. 'number' => $c,
  7376. 'features' => $zh,
  7377. 'hb' => $c + $zt,
  7378. );
  7379. }
  7380. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  7381. $filename = $title . ".xls";
  7382. $headers = array('仓库', 'SKU', '产品', '库存数量', '在途数量及预达日期', '在途+库存数量');
  7383. $numkeys = array('number', 'hb');
  7384. //列宽与表头一一对应(单位≈字符数);SKU(1)、产品(2)、在途列(4)超宽自动换行
  7385. $colwidths = array(80, 300,450, 50, 120, 80);
  7386. $wrapcols = array(1, 2, 4);
  7387. $excelxml($rows, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7388. }
  7389. if (isset($_GET['excel'])) {
  7390. $warehouse = $this->input->get('warehouse', true);
  7391. $sku = $this->input->get('sku', true);
  7392. $cz = $this->input->get('cz', true);
  7393. $text = $this->input->post('text', true);
  7394. $xztime = $this->input->get('xztime', true);
  7395. $timetk = $this->input->get('timetk', true);
  7396. $timetj = $this->input->get('timetj', true);
  7397. $timetk = strtotime($timetk);
  7398. $timetj = strtotime($timetj);
  7399. $where = "time = '0' ";
  7400. if ($warehouse) {
  7401. $where .= " and warehouse = '$warehouse'";
  7402. }
  7403. if ($sku) {
  7404. $where .= " and sku = '$sku'";
  7405. }
  7406. if ($text) {
  7407. $where .= " and text like '%$text%'";
  7408. }
  7409. if ($cz != '') {
  7410. $where .= " and cz = '$cz'";
  7411. }
  7412. if ($timetk && $timetj) {
  7413. $where .= " and " . $xztime . " > '$timetk' and " . $xztime . " < '$timetj'";
  7414. }
  7415. //数据排序
  7416. $order_str = $xztime . " desc";
  7417. //取得信息列表
  7418. $zh = array();
  7419. $info_list = $this->whlabeltransport->find_all($where, 'warehouse,sku,title,num,features,enter,stime,text');
  7420. foreach ($info_list as $v) {
  7421. $c = $this->whlabel->find_count('state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"');
  7422. $warehouse = $this->warehouse->read($v['warehouse']);
  7423. $v['warehouse'] = ($warehouse !== false && isset($warehouse['title'])) ? $warehouse['title'] : $v['warehouse'];
  7424. $v['enter'] = date('Y-m-d H:i:s', $v['enter']);
  7425. $v['stime'] = date('Y-m-d', $v['stime']);
  7426. if (isset($zh[$v['features']])) {
  7427. $zh[$v['features']]['num'] += $v['num'];
  7428. } else {
  7429. $zh[$v['features']] = $v;
  7430. }
  7431. $zh[$v['features']]['features'] = $c;
  7432. }
  7433. $title = "在途数据" . date('Y-m-d', time());
  7434. $filename = $title . ".xls";
  7435. $headers = array('仓库', 'SKU', '名称', '在途数量', '库存数量', '添加在途日期', '预达日期', '备注');
  7436. $numkeys = array('num', 'features');
  7437. //列宽与表头一一对应(单位≈字符数);SKU(1)、名称(2)、备注(7)超宽自动换行
  7438. $colwidths = array(18, 20, 50, 12, 12, 20, 12, 40);
  7439. $wrapcols = array(1, 2, 7);
  7440. $excelxml($zh, $headers, $numkeys, $filename, $colwidths, $wrapcols);
  7441. }
  7442. }
  7443. public function _fc()
  7444. {
  7445. $vip = 0;
  7446. if (isset($_SESSION['api'])) {
  7447. $user = $this->user->get_api($_SESSION['api']);
  7448. if ($user['vip'] == 1) {
  7449. $vip = 1;
  7450. }
  7451. } else {
  7452. header('Location: /');
  7453. exit;
  7454. }
  7455. $post = $this->input->post(NULL, TRUE);
  7456. if (isset($post['page'])) {
  7457. $page = $this->input->post('page', true);
  7458. $perpage = $this->input->post('perpage', true);
  7459. $category = $this->input->post('category', true);
  7460. $size = $this->input->post('size', true);
  7461. $grade = $this->input->post('grade', true);
  7462. $color = $this->input->post('color', true);
  7463. $lowe = $this->input->post('lowe', true);
  7464. $sku = $this->input->post('sku');
  7465. $title = $this->input->post('title');
  7466. $warehouse = $this->input->post('warehouse', true);
  7467. $usa = $this->input->post('usa', true);
  7468. $purchase = $this->input->post('purchase', true);
  7469. $lacetype = $this->input->post('lacetype', true);
  7470. $haircap = $this->input->post('haircap', true);
  7471. $density = $this->input->post('density', true);
  7472. $details = $this->input->post('details', true);
  7473. $state = $this->input->post('state', true);
  7474. $ktime = $this->input->post('ktime', true);
  7475. $jtime = $this->input->post('jtime', true);
  7476. $ktime = strtotime($ktime);
  7477. $jtime = strtotime($jtime);
  7478. $where = "state = '11'";
  7479. $gj = "";
  7480. $ck = "";
  7481. if ($lacetype) {
  7482. $where .= " and features like '%-$lacetype-%'";
  7483. }
  7484. if ($category) {
  7485. $where .= " and features like '%-$category-%'";
  7486. }
  7487. if ($size) {
  7488. $where .= " and features like '%-$size-%'";
  7489. }
  7490. if ($grade) {
  7491. $where .= " and features like '%-$grade-%'";
  7492. }
  7493. if ($color) {
  7494. $where .= " and features like '%-$color-%'";
  7495. }
  7496. if ($lowe) {
  7497. $where .= " and features like '%-$lowe-%'";
  7498. }
  7499. if ($haircap) {
  7500. $where .= " and features like '%-$haircap-%'";
  7501. }
  7502. if ($density) {
  7503. $where .= " and features like '%-$density-%'";
  7504. }
  7505. if ($usa) {
  7506. if (!$warehouse) {
  7507. $where .= " and (warehouse = '5' or warehouse = '8')";
  7508. }
  7509. }
  7510. if ($warehouse) {
  7511. $where .= " and warehouse = '$warehouse'";
  7512. }
  7513. if ($details) {
  7514. $where .= " and details = '$details'";
  7515. }
  7516. if ($purchase) {
  7517. $where .= " and purchase = '$purchase'";
  7518. }
  7519. if ($state) {
  7520. $where .= " and state = '$state'";
  7521. }
  7522. if ($ktime && $jtime) {
  7523. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7524. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7525. }
  7526. //数据排序
  7527. $order_str = "id desc";
  7528. if (empty($page)) {
  7529. $start = 0;
  7530. $perpage = 1;
  7531. } else {
  7532. $start = ($page - 1) * $perpage;
  7533. }
  7534. if ($sku) {
  7535. $sku = trim($sku, ' ');
  7536. $sku = trim($sku, ' ');
  7537. $where .= " and sku like '%$sku%'";
  7538. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7539. } else if ($title) {
  7540. $title = trim($title, ' ');
  7541. $title = trim($title, ' ');
  7542. $where .= " and title like '%$title%'";
  7543. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7544. } else {
  7545. //$where .= " and time > '$ktime' and time < '$jtime'";
  7546. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,number,features', $order_str, $start, $perpage);
  7547. }
  7548. //取得信息列表
  7549. $rows = array();
  7550. $list = array();
  7551. foreach ($info_list as $key => $value) {
  7552. $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'] . '"');
  7553. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7554. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7555. $warehouse = $this->warehouse->read($value['warehouse']);
  7556. $info_list[$key]['warehouse'] = $warehouse['title'];
  7557. $info_list[$key]['number'] = $g;
  7558. $info_list[$key]['features'] = $x;
  7559. $info_list[$key]['x'] = $s;
  7560. }
  7561. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features,number'));
  7562. $pagenum = ceil($total / $perpage);
  7563. $over = $total - ($start + $perpage);
  7564. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($info_list));
  7565. echo json_encode($rows);
  7566. exit;
  7567. }
  7568. $this->data['vip'] = $vip;
  7569. $this->_Template('whlabel_fc', $this->data);
  7570. }
  7571. public function _fcmb()
  7572. {
  7573. $where = "sku != 'Preset'";
  7574. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title');
  7575. foreach ($rows as $k => $v) {
  7576. $warehouse = $this->warehouse->read($v['warehouse']);
  7577. $rows[$k]['warehouse'] = $warehouse['title'];
  7578. $rows[$k]['num'] = $this->whlabel->find_count('warehouse = "' . $v['warehouse'] . '" and sku = "' . $v['sku'] . '" and state = 11');
  7579. $rows[$k]['t'] = '';
  7580. $rows[$k]['n'] = '';
  7581. }
  7582. $title = "封货产品数据导入模板";
  7583. $titlename = "<table border=1>
  7584. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7585. <tr align='center'>
  7586. <td>仓库</td>
  7587. <td>SKU</td>
  7588. <td>产品</td>
  7589. <td>封存产品总数量</td>
  7590. <td>类型(0.增加封存数量 1.转入产品库存 2.删除封存数量 留空导入时自动跳过此行)</td>
  7591. <td>数量(填写正整数,留空导入时自动跳过此行)</td>
  7592. </tr>
  7593. </table>";
  7594. $filename = $title . ".xls";
  7595. $tail = "";
  7596. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7597. }
  7598. public function _fcexcel()
  7599. {
  7600. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7601. $config['upload_path'] = '.' . $dir;
  7602. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7603. $config['allowed_types'] = 'xls|xlsx|csv';
  7604. $config['max_size'] = 10240;
  7605. $this->load->library('upload', $config);
  7606. $this->upload->initialize($config);
  7607. if ($this->upload->do_upload('userfile')) {
  7608. $full_path = $dir . $this->upload->data('file_name');
  7609. $fileName = '.' . $full_path;
  7610. if (!file_exists($fileName)) {
  7611. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7612. exit;
  7613. } else {
  7614. libxml_use_internal_errors(true);
  7615. require_once "../Documents/data/excel/PHPExcel/IOFactory.php";
  7616. $phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7617. $phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7618. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7619. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7620. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7621. ++$column; //如果列数大于26行
  7622. $list = array();
  7623. for ($i = 2; $i <= $row; $i++) // 行数循环
  7624. {
  7625. $data = array();
  7626. for ($c = 'A'; $c != $column; $c++) // 列数循环
  7627. {
  7628. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  7629. }
  7630. $list[] = $data;
  7631. }
  7632. }
  7633. $i = 0;
  7634. $j = 0;
  7635. $ed = array();
  7636. foreach ($list as $key => $value) {
  7637. $time = time();
  7638. if ($value['0'] == "" || !is_numeric($value['3']) || !is_numeric($value['4'])) {
  7639. continue;
  7640. }
  7641. $warehouse = $this->warehouse->get_title($value['0']);
  7642. $sku = $value['1'];
  7643. $type = $value['4']; //调整方式0扣减1删除
  7644. $num = $value['5']; //调整数量
  7645. //$text = $value['4'];//扣减说明
  7646. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  7647. if (!$d) //如果没有这个SKU
  7648. {
  7649. $ed[] = array($sku . '-库存中不存在此SKU');
  7650. $j++;
  7651. continue;
  7652. }
  7653. if (!isset($warehouse['id'])) {
  7654. $ed[] = array($sku . '-仓库名错误!');
  7655. $j++;
  7656. continue;
  7657. }
  7658. if ($type == 1 || $type == 2) //扣减库存
  7659. {
  7660. $data = $this->whlabel->find_all('warehouse = "' . $warehouse['id'] . '" and sku = "' . $sku . '" and state = 11');
  7661. if (count($data) < abs($num)) {
  7662. $ed[] = array($sku . '-数量大于封存产品剩余数量!');
  7663. $j++;
  7664. continue;
  7665. }
  7666. if ($type == 1) //转入库存
  7667. {
  7668. for ($i = 0; $i < abs($num); $i++) {
  7669. $this->whlabel->save(array('state' => 0, 'oldstate' => 11, 'time' => $time), $data[$i]['id']);
  7670. }
  7671. } else if ($type == 2) //删除
  7672. {
  7673. for ($i = 0; $i < abs($num); $i++) {
  7674. $this->whlabel->remove($data[$i]['id']);
  7675. }
  7676. }
  7677. } else if ($type == 0) //增加库存
  7678. {
  7679. $post['sku'] = $d['sku'];
  7680. $post['shop'] = '';
  7681. $post['warehouse'] = $warehouse['id'];
  7682. $post['purchase'] = $d['purchase'];
  7683. $post['retreatwarehouse'] = $d['retreatwarehouse'];
  7684. $post['state'] = 11;
  7685. $post['title'] = $d['title'];
  7686. $post['number'] = $d['number'];
  7687. $post['features'] = $d['features'];
  7688. $post['enter'] = $time;
  7689. $post['time'] = $time; //操作时间
  7690. for ($i = 0; $i < $num; $i++) {
  7691. $post['label'] = time() . rand(100, 999) . $i;
  7692. $this->whlabel->insert($post);
  7693. }
  7694. }
  7695. sleep(1); //防止入库时间一样,需要延迟1秒
  7696. }
  7697. if ($j > 0) {
  7698. $tt = date('Ymd', time());
  7699. $title = '库存导入错误信息-' . $tt;
  7700. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  7701. $tail = "\n";
  7702. $filename = $title . ".xls";
  7703. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  7704. $dir = '/data/excel/' . $time . '/';
  7705. $file_name = 'error_' . $time . rand(1000, 9999);
  7706. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  7707. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  7708. fwrite($myfile, $ecl);
  7709. fclose($myfile);
  7710. $error = $dir . $file_name . '.xls';
  7711. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  7712. exit;
  7713. } else {
  7714. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  7715. exit;
  7716. }
  7717. }
  7718. }
  7719. public function _fcjxc($arg_array)
  7720. {
  7721. if (isset($_GET['excel'])) {
  7722. $category = $this->input->get('category', true);
  7723. $size = $this->input->get('size', true);
  7724. $grade = $this->input->get('grade', true);
  7725. $color = $this->input->get('color', true);
  7726. $lowe = $this->input->get('lowe', true);
  7727. $sku = $this->input->get('sku');
  7728. $title = $this->input->get('title');
  7729. $warehouse = $arg_array[0];
  7730. $usa = $this->input->get('usa', true);
  7731. $purchase = $this->input->get('purchase', true);
  7732. $lacetype = $this->input->get('lacetype', true);
  7733. $haircap = $this->input->get('haircap', true);
  7734. $density = $this->input->get('density', true);
  7735. $title = $this->input->get('title', true);
  7736. $state = $this->input->get('state', true);
  7737. $ktime = $this->input->get('ktime', true);
  7738. $jtime = $this->input->get('jtime', true);
  7739. $where = "state=11";
  7740. $gj = "";
  7741. $ck = "";
  7742. if ($lacetype) {
  7743. $where .= " and features like '%-$lacetype-%'";
  7744. }
  7745. if ($category) {
  7746. $where .= " and features like '%-$category-%'";
  7747. }
  7748. if ($size) {
  7749. $where .= " and features like '%-$size-%'";
  7750. }
  7751. if ($grade) {
  7752. $where .= " and features like '%-$grade-%'";
  7753. }
  7754. if ($color) {
  7755. $where .= " and features like '%-$color-%'";
  7756. }
  7757. if ($lowe) {
  7758. $where .= " and features like '%-$lowe-%'";
  7759. }
  7760. if ($haircap) {
  7761. $where .= " and features like '%-$haircap-%'";
  7762. }
  7763. if ($density) {
  7764. $where .= " and features like '%-$density-%'";
  7765. }
  7766. if ($usa) {
  7767. if (!$warehouse) {
  7768. $where .= " and (warehouse = '5' or warehouse = '8')";
  7769. }
  7770. }
  7771. if ($warehouse) {
  7772. $where .= " and warehouse = '$warehouse'";
  7773. }
  7774. if ($purchase) {
  7775. $where .= " and purchase = '$purchase'";
  7776. }
  7777. if ($state) {
  7778. $where .= " and state = '$state'";
  7779. }
  7780. $order_str = "id desc";
  7781. if ($sku) {
  7782. $sku = trim($sku, ' ');
  7783. $sku = trim($sku, ' ');
  7784. $where .= " and sku like '%$sku%'";
  7785. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7786. } else if ($title) {
  7787. $title = trim($title, ' ');
  7788. $title = trim($title, ' ');
  7789. $where .= " and title like '%$title%'";
  7790. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7791. } else {
  7792. //$where .= " and time > '$ktime' and time < '$jtime'";
  7793. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,features', $order_str, $start, $perpage);
  7794. }
  7795. //取得信息列表
  7796. $rows = array();
  7797. $list = array();
  7798. foreach ($info_list as $key => $value) {
  7799. $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'] . '"');
  7800. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7801. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7802. $rows[$key] = $value;
  7803. $warehouse = $this->warehouse->read($value['warehouse']);
  7804. $rows[$key]['warehouse'] = $warehouse['title'];
  7805. $rows[$key]['features'] = $g;
  7806. $rows[$key]['a'] = $x;
  7807. $rows[$key]['b'] = $s;
  7808. }
  7809. $title = "总统计表";
  7810. $titlename = "<table border=1>
  7811. <tr><th colspan='6' align='center'><h3>" . $title . "<h3></th></tr>
  7812. <tr align='center'>
  7813. <td>仓库</td>
  7814. <td>SKU</td>
  7815. <td>产品名称</td>
  7816. <td>录入总量</td>
  7817. <td>取出总量</td>
  7818. <td>剩余总量</td>
  7819. </tr>
  7820. </table>";
  7821. $filename = $title . ".xls";
  7822. $tail = "";
  7823. $this->excel->get_fz2($rows, $titlename, $filename, $tail);
  7824. }
  7825. $vip = 0;
  7826. if (isset($_SESSION['api'])) {
  7827. $user = $this->user->get_api($_SESSION['api']);
  7828. if ($user['vip'] == 1) {
  7829. $vip = 1;
  7830. }
  7831. } else {
  7832. header('Location: /');
  7833. exit;
  7834. }
  7835. $post = $this->input->post(NULL, TRUE);
  7836. if (isset($post['page'])) {
  7837. $page = $this->input->post('page', true);
  7838. $perpage = $this->input->post('perpage', true);
  7839. $category = $this->input->post('category', true);
  7840. $size = $this->input->post('size', true);
  7841. $grade = $this->input->post('grade', true);
  7842. $color = $this->input->post('color', true);
  7843. $lowe = $this->input->post('lowe', true);
  7844. $sku = $this->input->post('sku');
  7845. $title = $this->input->post('title');
  7846. $warehouse = $arg_array[0];
  7847. $usa = $this->input->post('usa', true);
  7848. $purchase = $this->input->post('purchase', true);
  7849. $lacetype = $this->input->post('lacetype', true);
  7850. $haircap = $this->input->post('haircap', true);
  7851. $density = $this->input->post('density', true);
  7852. $title = $this->input->post('title', true);
  7853. $state = $this->input->post('state', true);
  7854. $ktime = $this->input->post('ktime', true);
  7855. $jtime = $this->input->post('jtime', true);
  7856. $ktime = strtotime($ktime);
  7857. $jtime = strtotime($jtime);
  7858. $where = "state=11";
  7859. $gj = "";
  7860. $ck = "";
  7861. if ($lacetype) {
  7862. $where .= " and features like '%-$lacetype-%'";
  7863. }
  7864. if ($category) {
  7865. $where .= " and features like '%-$category-%'";
  7866. }
  7867. if ($size) {
  7868. $where .= " and features like '%-$size-%'";
  7869. }
  7870. if ($grade) {
  7871. $where .= " and features like '%-$grade-%'";
  7872. }
  7873. if ($color) {
  7874. $where .= " and features like '%-$color-%'";
  7875. }
  7876. if ($lowe) {
  7877. $where .= " and features like '%-$lowe-%'";
  7878. }
  7879. if ($haircap) {
  7880. $where .= " and features like '%-$haircap-%'";
  7881. }
  7882. if ($density) {
  7883. $where .= " and features like '%-$density-%'";
  7884. }
  7885. if ($usa) {
  7886. if (!$warehouse) {
  7887. $where .= " and (warehouse = '5' or warehouse = '8')";
  7888. }
  7889. }
  7890. if ($warehouse) {
  7891. $where .= " and warehouse = '$warehouse'";
  7892. }
  7893. if ($purchase) {
  7894. $where .= " and purchase = '$purchase'";
  7895. }
  7896. if ($state) {
  7897. $where .= " and state = '$state'";
  7898. }
  7899. if ($ktime && $jtime) {
  7900. $gj = " and enter > '$ktime' and enter < '$jtime'";
  7901. $ck = " and outk > '$ktime' and outk < '$jtime'";
  7902. }
  7903. //数据排序
  7904. $order_str = "id desc";
  7905. $xs = 0;
  7906. $rows = array();
  7907. $list = array();
  7908. if (empty($page)) {
  7909. $start = 0;
  7910. $perpage = 1;
  7911. } else {
  7912. $start = ($page - 1) * $perpage;
  7913. }
  7914. if ($sku || $title) {
  7915. if ($title) {
  7916. $title = trim($title, ' ');
  7917. $title = trim($title, ' ');
  7918. $where .= " and title like '%$title%'";
  7919. } else {
  7920. $sku = trim($sku, ' ');
  7921. $sku = trim($sku, ' ');
  7922. $where .= " and sku like '%$sku%'";
  7923. }
  7924. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7925. foreach ($info_list as $key => $value) {
  7926. $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'] . '"');
  7927. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7928. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7929. $rows[$key] = $value;
  7930. $warehouse = $this->warehouse->read($value['warehouse']);
  7931. $rows[$key]['warehouse'] = $warehouse['title'];
  7932. $rows[$key]['features'] = $g;
  7933. $rows[$key]['a'] = $x;
  7934. $rows[$key]['b'] = $s;
  7935. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7936. $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天销量
  7937. $yj = $c / ($xl / 30);
  7938. if ($yj < 7) {
  7939. $rows[$key]['y'] = round($yj) . '天销量';
  7940. } else {
  7941. $rows[$key]['y'] = '正常';
  7942. }
  7943. }
  7944. } else {
  7945. //$where .= " and time > '$ktime' and time < '$jtime'";
  7946. $info_list = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'id,warehouse,sku,title,features', $order_str, $start, $perpage);
  7947. foreach ($info_list as $key => $value) {
  7948. $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'] . '"');
  7949. $x = $this->whlabel->find_count($where . ' and oldstate = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "1" and features = "' . $value['features'] . '"');
  7950. $s = $this->whlabel->find_count($where . ' and state = "11" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "8" and features = "' . $value['features'] . '"');
  7951. $zs[$key] = $value;
  7952. $warehouse = $this->warehouse->read($value['warehouse']);
  7953. $zs[$key]['warehouse'] = $warehouse['title'];
  7954. $zs[$key]['features'] = $g;
  7955. $zs[$key]['a'] = $x;
  7956. $zs[$key]['b'] = $s;
  7957. $kc = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '" and state = 0 and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'details,cpid'); //现有库存
  7958. $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天销量
  7959. $yj = $c / ($xl / 30);
  7960. if ($yj < 7) {
  7961. $zs[$key]['y'] = round($yj) . '天销量';
  7962. $rows[$key] = $zs[$key];
  7963. }
  7964. }
  7965. }
  7966. $total = count($this->whlabel->find_pc($where, 'sku,features,warehouse', 'id'));
  7967. $pagenum = ceil($total / $perpage);
  7968. $over = $total - ($start + $perpage);
  7969. $rows = array('total' => $total, 'over' => $over, 'pagenum' => $pagenum, 'rows' => ($rows));
  7970. echo json_encode($rows);
  7971. exit;
  7972. }
  7973. $this->data['arg_array'] = $arg_array[0];
  7974. $this->_Template('whlabel_fcjxc', $this->data);
  7975. }
  7976. public function _0kcdel()
  7977. {
  7978. $dir = '/data/excel/' . date('Ymd', time()) . '/';
  7979. $config['upload_path'] = '.' . $dir;
  7980. $config['file_name'] = date('Ymd_His_', time()) . rand(1000, 9999);
  7981. $config['allowed_types'] = 'xls|xlsx|csv';
  7982. $config['max_size'] = 10240;
  7983. $this->load->library('upload', $config);
  7984. $this->upload->initialize($config);
  7985. if ($this->upload->do_upload('userfile')) {
  7986. $full_path = $dir . $this->upload->data('file_name');
  7987. $fileName = '.' . $full_path;
  7988. if (!file_exists($fileName)) {
  7989. echo json_encode(array('msg' => "上传失败,请重试", 'success' => false));
  7990. exit;
  7991. } else {
  7992. require_once "./data/excel/PHPExcel/IOFactory.php";
  7993. @$phpExcel = PHPExcel_IOFactory::load($fileName); // 载入当前文件
  7994. @$phpExcel->setActiveSheetIndex(0); // 设置为默认表
  7995. $sheetCount = $phpExcel->getSheetCount(); // 获取表格数量
  7996. $row = $phpExcel->getActiveSheet()->getHighestRow(); // 获取行数
  7997. $column = $phpExcel->getActiveSheet()->getHighestColumn(); // 获取列数
  7998. ++$column; //如果列数大于26行
  7999. $list = array();
  8000. for ($i = 2; $i <= $row; $i++) // 行数循环
  8001. {
  8002. $data = array();
  8003. for ($c = 'A'; $c != $column; $c++) // 列数循环
  8004. {
  8005. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  8006. }
  8007. $list[] = $data;
  8008. }
  8009. }
  8010. $i = 0;
  8011. $j = 0;
  8012. $ed = array();
  8013. foreach ($list as $key => $value) {
  8014. $time = time();
  8015. if ($value['0'] == "" || $value['1'] == "") {
  8016. continue;
  8017. }
  8018. $warehouse = $this->warehouse->get_title($value['0']);
  8019. $sku = $value['1'];
  8020. $d = $this->whlabel->get_warehousesku($warehouse['id'], $sku);
  8021. if (!$d) //如果没有这个SKU
  8022. {
  8023. $ed[] = array($sku . '-库存中不存在此SKU');
  8024. $j++;
  8025. continue;
  8026. }
  8027. if (!isset($warehouse['id'])) {
  8028. $ed[] = array($sku . '-仓库名错误!');
  8029. $j++;
  8030. continue;
  8031. }
  8032. $z = $this->whlabel->find_count('sku = "' . $sku . '" and zd = "" and state = 0 and warehouse = "' . $warehouse['id'] . '"');
  8033. if ($z < 1) {
  8034. $z = $this->whlabel->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '"');
  8035. foreach ($z as $v) {
  8036. $zt = $this->whlabeltransport->find_all('sku = "' . $sku . '" and warehouse = "' . $warehouse['id'] . '" and features = "' . $d['features'] . '" and cz = "0"');
  8037. if (count($zt) > 0) {
  8038. $ed[] = array($sku . '-有在途库存无法删除!');
  8039. $j++;
  8040. continue;
  8041. }
  8042. $tmp_info = $v;
  8043. $tmp_info['del_time'] = time();
  8044. $this->db->insert('whlabelscbf',$tmp_info);
  8045. $this->whlabel->remove($v['id']);
  8046. }
  8047. } else {
  8048. $ed[] = array($sku . '-非0库存!');
  8049. $j++;
  8050. continue;
  8051. }
  8052. }
  8053. if ($j > 0) {
  8054. $tt = date('Ymd', time());
  8055. $title = '删除0库存错误信息-' . $tt;
  8056. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  8057. $tail = "\n";
  8058. $filename = $title . ".xls";
  8059. $ecl = $this->excel->get_fz3($ed, $titlename, $filename, $tail);
  8060. $dir = '/data/excel/' . $time . '/';
  8061. $file_name = 'error_' . $time . rand(1000, 9999);
  8062. if (!is_dir('.' . $dir)) mkdir('.' . $dir, 0777);
  8063. $myfile = fopen("." . $dir . $file_name . ".xls", "w") or die();
  8064. fwrite($myfile, $ecl);
  8065. fclose($myfile);
  8066. $error = $dir . $file_name . '.xls';
  8067. echo json_encode(array('msg' => '导入成功,' . $j . '条异常,', 'error' => $error, 'success' => true));
  8068. exit;
  8069. } else {
  8070. echo json_encode(array('msg' => '导入成功!', 'error' => 1, 'success' => true));
  8071. exit;
  8072. }
  8073. }
  8074. }
  8075. public function _gbhtype()
  8076. {
  8077. $post = $this->input->post(NULL, TRUE);
  8078. if (isset($post['s'])) {
  8079. $n = $this->input->post('n');
  8080. $d = $this->input->post('s');
  8081. if (!$d) {
  8082. echo json_encode(array('msg' => '未选择需要更改的商品', 'success' => false));
  8083. exit;
  8084. }
  8085. $d = explode(',', trim($d, ','));
  8086. $t = $this->whlabel_type->read($n);
  8087. //循环删除记录
  8088. foreach ($d as $v) {
  8089. $u = $this->whlabel->read($v);
  8090. $data = $this->whlabel->find_all("sku = '" . $u['sku'] . "' and purchase = '" . $u['purchase'] . "' and features = '" . $u['features'] . "' and warehouse = '" . $u['warehouse'] . "'");
  8091. foreach ($data as $val) {
  8092. $this->whlabel->save(array('type' => $n), $val['id']);
  8093. }
  8094. }
  8095. echo json_encode(array('d' => $d, 't' => $t['title'], 'msg' => '修改成功!', 'success' => true));
  8096. }
  8097. }
  8098. //出库、退库导出
  8099. public function _dccrtype()
  8100. {
  8101. $classid = $this->classid->sku();
  8102. $pm = $classid;
  8103. $typeclass = array();
  8104. $tc = $this->typeclass->find_all();
  8105. foreach ($tc as $v) {
  8106. $typeclass[$v['id']] = $v;
  8107. }
  8108. $prc = array();
  8109. $purchase = $this->purchase->find_all();
  8110. foreach ($purchase as $k => $v) {
  8111. $prc[$v['id']] = $v['title'];
  8112. }
  8113. if (isset($_GET['sid'])) {
  8114. $wh = array();
  8115. $w = $this->warehouse->find_all('1=1', 'id,title');
  8116. foreach ($w as $v) {
  8117. $wh[$v['id']] = $v['title'];
  8118. }
  8119. $type = $this->input->get('excel', true);
  8120. $category = $this->input->get('category', true);
  8121. $size = $this->input->get('size', true);
  8122. $grade = $this->input->get('grade', true);
  8123. $color = $this->input->get('color', true);
  8124. $lowe = $this->input->get('lowe', true);
  8125. $sku = $this->input->get('sku', true);
  8126. $warehouse = $this->input->get('warehouse', true);
  8127. $lacetype = $this->input->get('lacetype', true);
  8128. $lacecolor = $this->input->get('lacecolor', true);
  8129. $density = $this->input->get('density', true);
  8130. $haircap = $this->input->get('haircap', true);
  8131. $purchase = $this->input->get('purchase', true);
  8132. $title = $this->input->get('title', true);
  8133. $state = $this->input->get('state', true);
  8134. $sid = $this->input->get('sid', true);
  8135. $ktime = $this->input->get('ktime', true);
  8136. $jtime = $this->input->get('jtime', true);
  8137. $ktime = strtotime($ktime);
  8138. $jtime = strtotime($jtime);
  8139. $where = "1=1";
  8140. $gj = "";
  8141. $ck = "";
  8142. if ($category) {
  8143. $where .= " and features like '%-$category-%'";
  8144. }
  8145. if ($size) {
  8146. $where .= " and features like '%-$size-%'";
  8147. }
  8148. if ($grade) {
  8149. $where .= " and features like '%-$grade-%'";
  8150. }
  8151. if ($color) {
  8152. $where .= " and features like '%-$color-%'";
  8153. }
  8154. if ($lowe) {
  8155. $where .= " and features like '%-$lowe-%'";
  8156. }
  8157. if ($warehouse) {
  8158. $where .= " and warehouse = '$warehouse'";
  8159. }
  8160. if ($purchase) {
  8161. $where .= " and purchase = '$purchase'";
  8162. }
  8163. if ($state) {
  8164. $where .= " and state = '$state'";
  8165. }
  8166. if ($lacetype) {
  8167. $where .= " and features like '%-$lacetype-%'";
  8168. }
  8169. if ($lacecolor) {
  8170. $where .= " and features like '%-$lacecolor-%'";
  8171. }
  8172. if ($density) {
  8173. $where .= " and features like '%-$density-%'";
  8174. }
  8175. if ($haircap) {
  8176. $where .= " and features like '%-$haircap-%'";
  8177. }
  8178. if ($title) {
  8179. $title = trim($title, ' ');
  8180. $title = trim($title, ' ');
  8181. $where .= " and title like '%$title%'";
  8182. }
  8183. if ($sku) {
  8184. $sku = trim($sku, ' ');
  8185. $sku = trim($sku, ' ');
  8186. $where .= " and sku like '%$sku%'";
  8187. }
  8188. if ($ktime && $jtime) {
  8189. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  8190. }
  8191. $sidwhere = '';
  8192. if ($sid) {
  8193. $sd = "";
  8194. $s = explode(',', trim($sid, ','));
  8195. foreach ($s as $value) {
  8196. $sd .= " id = " . $value . " or";
  8197. }
  8198. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8199. }
  8200. //数据排序
  8201. $order_str = "time desc";
  8202. if (empty($page)) {
  8203. $start = 0;
  8204. $perpage = 1;
  8205. } else {
  8206. $start = ($page - 1) * $perpage;
  8207. }
  8208. $wh = array();
  8209. $w = $this->warehouse->find_all('1=1', 'id,title');
  8210. foreach ($w as $v) {
  8211. $wh[$v['id']] = $v['title'];
  8212. }
  8213. $wt = array();
  8214. $whlabel_type = $this->whlabel_type->find_all();
  8215. foreach ($whlabel_type as $v) {
  8216. $wt[$v['id']] = $v['title'];
  8217. }
  8218. $classid = $this->classid->sku();
  8219. $list = array();
  8220. $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');
  8221. foreach ($rows_r as $key => $value) {
  8222. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  8223. $pm = $classid;
  8224. $jm = $classid;
  8225. $rows_r[$key]['enter'] = '入库';
  8226. $rows_r[$key]['time'] = $value['enter'];
  8227. if ($value['rktype'] == 1) {
  8228. $rows_r[$key]['rktype'] = '采购入库';
  8229. } else if ($value['rktype'] == 2) {
  8230. $rows_r[$key]['rktype'] = '盘盈调整';
  8231. } else if ($value['rktype'] == 3) {
  8232. $rows_r[$key]['rktype'] = '其他调整入库';
  8233. } else if ($value['rktype'] == 4) {
  8234. $rows_r[$key]['rktype'] = '其他调整入库';
  8235. } else if ($value['rktype'] == 5) {
  8236. $rows_r[$key]['rktype'] = '退库入库';
  8237. } else if ($value['rktype'] == 6) {
  8238. $rows_r[$key]['rktype'] = '退货可用入库';
  8239. } else if ($value['rktype'] == 7) {
  8240. $rows_r[$key]['rktype'] = '形态转换入库';
  8241. } else {
  8242. $rows_r[$key]['rktype'] = '';
  8243. }
  8244. $features = explode('-', trim($value['features'], '-'));
  8245. foreach ($features as $v) {
  8246. if (isset($typeclass[$v])) {
  8247. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8248. $pm[$typeclass[$v]['classid']] = $zh[0];
  8249. }
  8250. if (isset($typeclass[$v])) {
  8251. if (isset($jm[$typeclass[$v]['classid']])) {
  8252. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8253. }
  8254. }
  8255. }
  8256. $zh = implode(" ", $pm);
  8257. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8258. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8259. $rows_r[$key]['zh'] = $zh;
  8260. $jm = array_filter($jm);
  8261. $rows_r[$key]['features'] = implode("-", $jm);
  8262. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  8263. }
  8264. $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');
  8265. foreach ($rows_c as $key => $value) {
  8266. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  8267. $pm = $classid;
  8268. $jm = $classid;
  8269. $rows_c[$key]['time'] = $value['outk'];
  8270. $rows_c[$key]['outk'] = '出库';
  8271. if ($value['cktype'] == 1) {
  8272. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  8273. } else if ($value['cktype'] == 2) {
  8274. $rows_c[$key]['cktype'] = '美国销售调货出库';
  8275. } else if ($value['cktype'] == 3) {
  8276. $rows_c[$key]['cktype'] = '盘亏调整';
  8277. } else if ($value['cktype'] == 4) {
  8278. $rows_c[$key]['cktype'] = '其他调整出库';
  8279. } else if ($value['cktype'] == 5) {
  8280. $rows_c[$key]['cktype'] = '形态转换出库';
  8281. } else {
  8282. $rows_c[$key]['cktype'] = '';
  8283. }
  8284. unset($rows_c[$key]['state']);
  8285. $features = explode('-', trim($value['features'], '-'));
  8286. foreach ($features as $v) {
  8287. if (isset($typeclass[$v])) {
  8288. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  8289. $pm[$typeclass[$v]['classid']] = $zh[0];
  8290. }
  8291. if (isset($typeclass[$v])) {
  8292. if (isset($jm[$typeclass[$v]['classid']])) {
  8293. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  8294. }
  8295. }
  8296. }
  8297. $zh = implode(" ", $pm);
  8298. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  8299. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8300. $rows_c[$key]['zh'] = $zh;
  8301. $jm = array_filter($jm);
  8302. $rows_c[$key]['features'] = implode("-", $jm);
  8303. $rows_c[$key]['number'] = 1;
  8304. }
  8305. $merged = $rows_r;
  8306. foreach ($rows_c as $key => $value) {
  8307. if (isset($merged[$key])) {
  8308. $merged[] = $value;
  8309. } else {
  8310. $merged[$key] = $value;
  8311. }
  8312. }
  8313. usort($merged, function ($a, $b) {
  8314. return $a['time'] - $b['time'];
  8315. });
  8316. foreach ($merged as $key => $value) {
  8317. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  8318. }
  8319. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  8320. $titlename = "<table border=1>
  8321. <tr align='center'>
  8322. <td>仓库</td>
  8323. <td>SKU</td>
  8324. <td>商品名称</td>
  8325. <td>仓库品名</td>
  8326. <td>料号</td>
  8327. <td>时间</td>
  8328. <td>操作</td>
  8329. <td>类型</td>
  8330. <td>数量</td>
  8331. <td>备注</td>
  8332. </tr>
  8333. </table>";
  8334. $filename = $title . ".xlsx";
  8335. $tail = "";
  8336. $this->excelxh->get_fz2($merged, $titlename, $filename, $tail);
  8337. }
  8338. }
  8339. /*************************************处理exceljs导出****************************************************/
  8340. public function _excelrjs(){
  8341. if (isset($_GET['excel'])) {
  8342. $category = $this->input->get('category', true);
  8343. $size = $this->input->get('size', true);
  8344. $grade = $this->input->get('grade', true);
  8345. $color = $this->input->get('color', true);
  8346. $lowe = $this->input->get('lowe', true);
  8347. $sku = $this->input->get('sku', true);
  8348. $warehouse = $this->input->get('warehouse', true);
  8349. $purchase = $this->input->get('purchase', true);
  8350. $ktime = $this->input->get('ktime', true);
  8351. $jtime = $this->input->get('jtime', true);
  8352. $ktime = strtotime($ktime);
  8353. $jtime = strtotime($jtime);
  8354. $where = "1=1";
  8355. $gj = "";
  8356. $ck = "";
  8357. if ($category) {
  8358. $where .= " and features like '%-$category-%'";
  8359. }
  8360. if ($size) {
  8361. $where .= " and features like '%-$size-%'";
  8362. }
  8363. if ($grade) {
  8364. $where .= " and features like '%-$grade-%'";
  8365. }
  8366. if ($color) {
  8367. $where .= " and features like '%-$color-%'";
  8368. }
  8369. if ($lowe) {
  8370. $where .= " and features like '%-$lowe-%'";
  8371. }
  8372. if ($warehouse) {
  8373. $where .= " and warehouse = '$warehouse'";
  8374. }
  8375. if ($purchase) {
  8376. $where .= " and purchase = '$purchase'";
  8377. }
  8378. if ($sku) {
  8379. $where .= " and sku = '$sku'";
  8380. }
  8381. if ($ktime && $jtime) {
  8382. $where .= " and enter > '$ktime' and enter < '$jtime' and state != 9";
  8383. }
  8384. //数据排序
  8385. $order_str = "id desc";
  8386. if (empty($page)) {
  8387. $start = 0;
  8388. $perpage = 1;
  8389. } else {
  8390. $start = ($page - 1) * $perpage;
  8391. }
  8392. $list = array();
  8393. $rows = $this->whlabel->find_pc($where, 'enter,sku,warehouse', '*', $order_str);
  8394. foreach ($rows as $value) {
  8395. $ck = $this->warehouse->read($value['warehouse']);
  8396. $warehouse = $ck['title'];
  8397. $tkck = $this->warehouse->read($value['retreatwarehouse']); //退库仓库
  8398. $retreatwarehouse = $tkck['title'];
  8399. $gy = $this->purchase->read($value['purchase']);
  8400. $purchase = $gy['title'];
  8401. $g = $this->whlabel->find_count($where . ' and enter = "' . $value['enter'] . '" and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '"');
  8402. $list[] = array('warehouse' => $warehouse, 'sku' => $value['sku'], 'title' => $value['title'], 'time' => date('Y-m-d H:i:s', $value['enter']), 'number' => $g);
  8403. }
  8404. if(empty($list)){
  8405. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8406. }else{
  8407. $final_list = [];
  8408. foreach($list as $v){
  8409. $final_list[] = array_values($v);
  8410. }
  8411. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "入库详情";
  8412. array_unshift($final_list,[
  8413. "仓库","SKU","商品名称","时间","数量"
  8414. ]);
  8415. array_unshift($final_list,[
  8416. $title,"","","",""
  8417. ]);
  8418. $merges = [
  8419. [
  8420. "s"=>["r"=>0,"c"=>0],
  8421. "e"=>["r"=>0,"c"=>4]
  8422. ]
  8423. ];
  8424. $cols = [
  8425. ["wch"=>"10"],["wch"=>"50"],["wch"=>"50"],["wch"=>"20"],["wch"=>"10"],
  8426. ];
  8427. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['data' => $final_list,'title'=>$title,'cols' => $cols,'merges' => $merges])));
  8428. }
  8429. }
  8430. }
  8431. //出库、退库导出
  8432. public function _excelctjs()
  8433. {
  8434. $classid = $this->classid->sku();
  8435. $pm = $classid;
  8436. $typeclass = array();
  8437. $tc = $this->typeclass->find_all();
  8438. foreach ($tc as $v) {
  8439. $typeclass[$v['id']] = $v;
  8440. }
  8441. $prc = array();
  8442. $purchase = $this->purchase->find_all();
  8443. foreach ($purchase as $k => $v) {
  8444. $prc[$v['id']] = $v['title'];
  8445. }
  8446. if (isset($_GET['excel'])) {
  8447. $wh = array();
  8448. $w = $this->warehouse->find_all('1=1', 'id,title');
  8449. foreach ($w as $v) {
  8450. $wh[$v['id']] = $v['title'];
  8451. }
  8452. $type = $this->input->get('excel', true);
  8453. $category = $this->input->get('category', true);
  8454. $size = $this->input->get('size', true);
  8455. $grade = $this->input->get('grade', true);
  8456. $color = $this->input->get('color', true);
  8457. $lowe = $this->input->get('lowe', true);
  8458. $sku = $this->input->get('sku', true);
  8459. $title = $this->input->get('title', true);
  8460. $warehouse = $this->input->get('warehouse', true);
  8461. $purchase = $this->input->get('purchase', true);
  8462. $lacetype = $this->input->get('lacetype', true);
  8463. $haircap = $this->input->get('haircap', true);
  8464. $lacecolor = $this->input->get('lacecolor', true);
  8465. $density = $this->input->get('density', true);
  8466. $details = $this->input->get('details', true);
  8467. $state = $this->input->get('state', true);
  8468. $shop = $this->input->get('shop', true);
  8469. $hairnumber = $this->input->get('hairnumber', true);
  8470. $type_leixi = $this->input->get('type', true);
  8471. $cpbz = $this->input->get('cpbz', true);
  8472. $sm = $this->input->get('sm', true);
  8473. $sid = $this->input->get('sid', true);
  8474. $ktime = $this->input->get('ktime', true);
  8475. $jtime = $this->input->get('jtime', true);
  8476. $ktime = strtotime($ktime);
  8477. $jtime = strtotime($jtime);
  8478. //$where = " 1=1 ";
  8479. //发现数据表中有20多万条数据是没有sku的,所以这里加上sku判断,避免导出空数据
  8480. $where = " sku != '' ";
  8481. $gj = "";
  8482. $ck = "";
  8483. if ($category) {
  8484. $where .= " and features like '%-$category-%'";
  8485. }
  8486. if ($size) {
  8487. $where .= " and features like '%-$size-%'";
  8488. }
  8489. if ($grade) {
  8490. $where .= " and features like '%-$grade-%'";
  8491. }
  8492. if ($color) {
  8493. $where .= " and features like '%-$color-%'";
  8494. }
  8495. if ($lowe) {
  8496. $where .= " and features like '%-$lowe-%'";
  8497. }
  8498. if ($warehouse) {
  8499. $where .= " and warehouse = '$warehouse'";
  8500. }
  8501. if ($purchase) {
  8502. $where .= " and purchase = '$purchase'";
  8503. }
  8504. if ($state) {
  8505. $where .= " and state = '$state'";
  8506. }
  8507. if ($lacetype) {
  8508. $where .= " and features like '%-$lacetype-%'";
  8509. }
  8510. if ($lacecolor) {
  8511. $where .= " and features like '%-$lacecolor-%'";
  8512. }
  8513. if ($density) {
  8514. $where .= " and features like '%-$density-%'";
  8515. }
  8516. if ($haircap) {
  8517. $where .= " and features like '%-$haircap-%'";
  8518. }
  8519. if ($details) {
  8520. $where .= " and details = '$details'";
  8521. }
  8522. if ($shop) {
  8523. $where .= " and shop like '%$shop%'";
  8524. }
  8525. if ($title) {
  8526. $title = trim($title, ' ');
  8527. $title = trim($title, ' ');
  8528. $where .= " and title like '%$title%'";
  8529. }
  8530. if (!empty($hairnumber)) {
  8531. $where .= " and features like '%-128-%' ";
  8532. if ($hairnumber < 0) {
  8533. $class_list = $this->typeclass->find_all('classid = 43');
  8534. foreach ($class_list as $v) {
  8535. $where .= " and features not like '%-" . $v['id'] . "-%'";
  8536. }
  8537. } else {
  8538. $where .= " and features like '%-$hairnumber-%'";
  8539. }
  8540. }
  8541. if ($type_leixi) {
  8542. $where .= " and type = '$type_leixi'";
  8543. }
  8544. if ($cpbz) {
  8545. $where .= " and cpbz like '%$cpbz%' ";
  8546. }
  8547. if ($sm) {
  8548. $where .= " and sm like '%$sm%' ";
  8549. }
  8550. if ($sku) {
  8551. $sku = trim($sku, ' ');
  8552. $sku = trim($sku, ' ');
  8553. $where .= " and sku like '%$sku%'";
  8554. }
  8555. if ($ktime && $jtime) {
  8556. if ($type == 1) {
  8557. $tl = '出库';
  8558. $where .= " and state= '1' and outk > '$ktime' and outk < '$jtime'";
  8559. } else if ($type == 2) {
  8560. $tl = '退库';
  8561. $where .= " and state= '2' and retreat > '$ktime' and retreat < '$jtime'";
  8562. } else if ($type == 3) {
  8563. $gj = " and enter > '$ktime' and enter < '$jtime'";
  8564. $ck = " and outk > '$ktime' and outk < '$jtime'";
  8565. } else if ($type == 4) {
  8566. $tl = '出库+零售';
  8567. $where .= " and (state= '1' or state= '10') and outk > '$ktime' and outk < '$jtime'";
  8568. } else if ($type == 5) {
  8569. $tl = '零售';
  8570. $where .= " and state= '10' and outk > '$ktime' and outk < '$jtime'";
  8571. }
  8572. }
  8573. $sidwhere = '';
  8574. if ($sid) {
  8575. $sd = "";
  8576. $s = explode(',', trim($sid, ','));
  8577. foreach ($s as $value) {
  8578. $sd .= " id = " . $value . " or";
  8579. }
  8580. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  8581. }
  8582. //数据排序
  8583. $order_str = "time desc";
  8584. if (empty($page)) {
  8585. $start = 0;
  8586. $perpage = 1;
  8587. } else {
  8588. $start = ($page - 1) * $perpage;
  8589. }
  8590. //取得信息列表
  8591. if ($type != 3 && $type != 5) {
  8592. if ($type == 1 || $type == 4) {
  8593. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,outk', $order_str);
  8594. foreach ($info_list as $key => $value) {
  8595. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8596. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8597. $warehouse = $this->warehouse->read($value['warehouse']);
  8598. $info_list[$key]['warehouse'] = $warehouse['title'];
  8599. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8600. $features = explode('-', trim($features, '-'));
  8601. $pm = $classid;
  8602. foreach ($features as $k => $v) {
  8603. if ($v != 0) {
  8604. if (!isset($typeclass[$v])) {
  8605. continue;
  8606. }
  8607. if (isset($pm[$typeclass[$v]['classid']])) {
  8608. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8609. $tz = explode('|', $typeclass[$v]['zh']);
  8610. $pm[$typeclass[$v]['classid']] = $tz[0];
  8611. } else {
  8612. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8613. }
  8614. }
  8615. }
  8616. }
  8617. $zh = implode(" ", $pm);
  8618. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8619. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8620. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8621. $info_list[$key]['features'] = $zh;
  8622. }
  8623. $final_list = [];
  8624. foreach($info_list as $k=>$v){
  8625. $number = "";
  8626. if(!empty($v['orderinfo'])){
  8627. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8628. if(!empty($tmp_info['number'])){
  8629. $number = $tmp_info['number'];
  8630. }
  8631. }
  8632. $final_list[] = [
  8633. 'warehouse'=>$v['warehouse'],
  8634. 'purchase'=>$v['purchase'],
  8635. 'sku'=>$v['sku'],
  8636. 'title'=>$v['title'],
  8637. 'features'=>$v['features'],
  8638. 'label'=>$v['label'],
  8639. 'orderinfo'=>$v['orderinfo'],
  8640. 'number'=>$number,
  8641. 'waybill'=>$v['waybill'],
  8642. 'outk'=>$v['outk'],
  8643. ];
  8644. }
  8645. } else {
  8646. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,orderinfo,waybill,retreat', $order_str);
  8647. foreach ($info_list as $key => $value) {
  8648. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8649. $info_list[$key]['retreat'] = date('Y-m-d H:i:s', $value['retreat']); //减12调整美国时间
  8650. $warehouse = $this->warehouse->read($value['warehouse']);
  8651. $info_list[$key]['warehouse'] = $warehouse['title'];
  8652. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8653. $features = explode('-', trim($features, '-'));
  8654. $pm = $classid;
  8655. foreach ($features as $k => $v) {
  8656. if ($v != 0) {
  8657. if (!isset($typeclass[$v])) {
  8658. continue;
  8659. }
  8660. if (isset($pm[$typeclass[$v]['classid']])) {
  8661. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8662. $tz = explode('|', $typeclass[$v]['zh']);
  8663. $pm[$typeclass[$v]['classid']] = $tz[0];
  8664. } else {
  8665. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8666. }
  8667. }
  8668. }
  8669. }
  8670. $zh = implode(" ", $pm);
  8671. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8672. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8673. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8674. $info_list[$key]['features'] = $zh;
  8675. }
  8676. $final_list = [];
  8677. foreach($info_list as $k=>$v){
  8678. $number = "";
  8679. if(!empty($v['orderinfo'])){
  8680. $tmp_info = $this->logic_order->getInfo('orderinfo = "'.$v['orderinfo'].'"','orderinfo,number,librarytime');
  8681. if(!empty($tmp_info['number'])){
  8682. $number = $tmp_info['number'];
  8683. }
  8684. }
  8685. $final_list[] = [
  8686. 'warehouse'=>$v['warehouse'],
  8687. 'purchase'=>$v['purchase'],
  8688. 'sku'=>$v['sku'],
  8689. 'title'=>$v['title'],
  8690. 'features'=>$v['features'],
  8691. 'label'=>$v['label'],
  8692. 'orderinfo'=>$v['orderinfo'],
  8693. 'number'=>$number,
  8694. 'waybill'=>$v['waybill'],
  8695. 'retreat'=>$v['retreat'],
  8696. ];
  8697. }
  8698. }
  8699. if(empty($final_list)){
  8700. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8701. }else{
  8702. $end_list = [];
  8703. foreach($final_list as $v){
  8704. $end_list[] = array_values($v);
  8705. }
  8706. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime).$tl . "详情";
  8707. array_unshift($end_list,[
  8708. "仓库","供应商","SKU","商品名称","商品中文","标签","订单号","订单编码","运单号",$tl . "时间(中国时间)"
  8709. ]);
  8710. array_unshift($end_list,[
  8711. $title,"","","","","","","","",""
  8712. ]);
  8713. $merges = [
  8714. [
  8715. "s"=>["r"=>0,"c"=>0],
  8716. "e"=>["r"=>0,"c"=>9]
  8717. ]
  8718. ];
  8719. $cols = [
  8720. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"15"],
  8721. ];
  8722. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8723. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8724. ] )));
  8725. }
  8726. } else if ($type == 5) {
  8727. $info_list = $this->whlabel->find_all($where, 'warehouse,purchase,sku,title,features,label,outk', $order_str);
  8728. foreach ($info_list as $key => $value) {
  8729. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8730. $info_list[$key]['outk'] = date('Y-m-d H:i:s', $value['outk']); //减12调整美国时间
  8731. $warehouse = $this->warehouse->read($value['warehouse']);
  8732. $info_list[$key]['warehouse'] = $warehouse['title'];
  8733. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8734. $features = explode('-', trim($features, '-'));
  8735. $pm = $classid;
  8736. foreach ($features as $k => $v) {
  8737. if ($v != 0) {
  8738. if (!isset($typeclass[$v])) {
  8739. continue;
  8740. }
  8741. if (isset($pm[$typeclass[$v]['classid']])) {
  8742. if (stripos($typeclass[$v]['zh'], '|') !== false) {
  8743. $tz = explode('|', $typeclass[$v]['zh']);
  8744. $pm[$typeclass[$v]['classid']] = $tz[0];
  8745. } else {
  8746. $pm[$typeclass[$v]['classid']] = $typeclass[$v]['zh'];
  8747. }
  8748. }
  8749. }
  8750. }
  8751. $zh = implode(" ", $pm);
  8752. $zh = str_replace('自然色 ', '', trim($zh, ' '));
  8753. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  8754. $zh = preg_replace("/\r\n|\r|\n/", '', $zh);
  8755. $info_list[$key]['features'] = $zh;
  8756. }
  8757. if(empty($info_list)){
  8758. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8759. }else{
  8760. $final_list = [];
  8761. foreach($info_list as $v){
  8762. $final_list[] = array_values($v);
  8763. }
  8764. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) .$tl. "详情";
  8765. array_unshift($final_list,[
  8766. "仓库","供应商","SKU","商品名称","商品中文","标签", $tl . "时间(中国时间)"
  8767. ]);
  8768. array_unshift($final_list,[
  8769. $title,"","","","","","",
  8770. ]);
  8771. $merges = [
  8772. [
  8773. "s"=>["r"=>0,"c"=>0],
  8774. "e"=>["r"=>0,"c"=>6]
  8775. ]
  8776. ];
  8777. $cols = [
  8778. ["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"20"]
  8779. ];
  8780. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[ 'data' => $final_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols])));
  8781. }
  8782. } else {
  8783. $wh = array();
  8784. $w = $this->warehouse->find_all('1=1', 'id,title');
  8785. foreach ($w as $v) {
  8786. $wh[$v['id']] = $v['title'];
  8787. }
  8788. $wt = array();
  8789. $whlabel_type = $this->whlabel_type->find_all();
  8790. foreach ($whlabel_type as $v) {
  8791. $wt[$v['id']] = $v['title'];
  8792. }
  8793. $classid = $this->classid->sku();
  8794. $list = array();
  8795. $rows = $this->whlabel->find_pc($where . $sidwhere, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,sku,title,features,cpbz,sm,type');
  8796. foreach ($rows as $key => $value) {
  8797. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8798. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8799. $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');
  8800. $details = array();
  8801. $cpid = array();
  8802. $cpbz = array();
  8803. $c = 0;
  8804. $g = 0;
  8805. $x = 0;
  8806. $t = 0;
  8807. $s = 0;
  8808. $q = 0;
  8809. foreach ($sd as $k => $v) {
  8810. if ($v['state'] == 0) {
  8811. $c++;
  8812. }
  8813. if ($v['state'] != 9) {
  8814. $g++;
  8815. }
  8816. if ($v['outk'] > 1) {
  8817. $x++;
  8818. }
  8819. if ($v['retreat'] > 0) {
  8820. $t++;
  8821. }
  8822. if ($v['state'] == 8) {
  8823. $s++;
  8824. }
  8825. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  8826. $q++;
  8827. }
  8828. $details[$v['details']] = $v['details'];
  8829. if ($v['cpid'] != 0) {
  8830. $cpid[$v['cpid']] = $v['cpid'];
  8831. }
  8832. if ($v['cpbz'] != '') {
  8833. $cpbz[$v['cpbz']] = $v['cpbz'];
  8834. }
  8835. }
  8836. if (isset($wt[$value['type']])) {
  8837. $rows[$key]['type'] = $wt[$value['type']];
  8838. } else {
  8839. $rows[$key]['type'] = '未设置';
  8840. }
  8841. $rows[$key]['details'] = implode("、", $details);
  8842. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  8843. $ftime = time() - 15 * 24 * 3600;
  8844. $rows[$key]['warehouse'] = $wh[$value['warehouse']];
  8845. $rows[$key]['cpbz'] = ($cpbz) ? implode(" ", $cpbz) : '';
  8846. $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);
  8847. $rows[$key]['c'] = $c;
  8848. $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);
  8849. $rows[$key]['t'] = $t;
  8850. $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'] . '"');
  8851. $rows[$key]['z'] = $z;
  8852. // $jm = $classid;
  8853. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  8854. $features = explode('-', trim($features, '-'));
  8855. $rows[$key]['asd'] = $typeclass[$features[0]]['title'];
  8856. }
  8857. $tmp_list = $this->logic_whlabel->dataTran($rows,['pm','weight']);
  8858. $final_list =[];
  8859. foreach($tmp_list as $k=>$v){
  8860. $final_list[] = [
  8861. "warehouse"=>$v['warehouse'],
  8862. "purchase"=>$v['purchase'],
  8863. "details"=>$v['details'],
  8864. "cpid"=>$v['cpid'],
  8865. "sku"=>$v['sku'],
  8866. "title"=>$v['title'],
  8867. "features"=>$v['pm'],
  8868. "cpbz"=>$v['cpbz'],
  8869. "sm"=>$v['sm'],
  8870. "type"=>$v['type'],
  8871. "g"=>$v["g"],
  8872. "c"=>$v["c"],
  8873. "x"=>$v["x"],
  8874. "t"=>$v["t"],
  8875. "z"=>$v["z"],
  8876. "jm"=>$v["jm"],
  8877. "weight"=>$v["weight"],
  8878. "asd"=>$v["asd"],
  8879. ];
  8880. }
  8881. if(empty($final_list)){
  8882. exit(json_encode(array('code' => 0, 'msg' => '没有合适数据')));
  8883. }else{
  8884. $end_list = [];
  8885. foreach($final_list as $v){
  8886. $end_list[] = array_values($v);
  8887. }
  8888. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '进销存详情';
  8889. array_unshift($end_list,[
  8890. "仓库","供应商","位置","库存编码","SKU","商品名称","商品中文","产品备注","说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "占单数量", "料号", "重量", "类目"
  8891. ]);
  8892. array_unshift($end_list,[
  8893. $title,"","","","","","","","","","","","","","","","","",""
  8894. ]);
  8895. $merges = [
  8896. [
  8897. "s"=>["r"=>0,"c"=>0],
  8898. "e"=>["r"=>0,"c"=>6]
  8899. ]
  8900. ];
  8901. $cols = [
  8902. ["wch"=>"10"],["wch"=>"20"],["wch"=>"20"],["wch"=>"20"],["wch"=>"40"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"15"],
  8903. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  8904. ];
  8905. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>[
  8906. 'data' => $end_list,'title'=>$title,'merges'=>$merges,'cols'=>$cols
  8907. ])));
  8908. }
  8909. }
  8910. }
  8911. }
  8912. public function _exceljxcjs(){
  8913. $classid = $this->classid->sku();
  8914. $pm = $classid;
  8915. $typeclass = array();
  8916. $tc = $this->typeclass->find_all();
  8917. foreach ($tc as $v) {
  8918. $typeclass[$v['id']] = $v;
  8919. }
  8920. $prc = array();
  8921. $purchase = $this->purchase->find_all();
  8922. foreach ($purchase as $k => $v) {
  8923. $prc[$v['id']] = $v['title'];
  8924. }
  8925. if(!isset($_GET['excel'])){
  8926. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  8927. }
  8928. $where = "sku != 'Preset'";
  8929. //数据排序
  8930. $order_str = "id desc";
  8931. if (empty($page)) {
  8932. $start = 0;
  8933. $perpage = 1;
  8934. } else {
  8935. $start = ($page - 1) * $perpage;
  8936. }
  8937. $category = $this->input->get('category', true);
  8938. $warehouse = $this->input->get('warehouse', true);
  8939. $excelid = $this->input->get('sid', true);
  8940. if ($category) {
  8941. $where .= " and features like '%-$category-%'";
  8942. }
  8943. if ($warehouse) {
  8944. $where .= " and warehouse = '$warehouse'";
  8945. }
  8946. $xzid = '';
  8947. if ($excelid) {
  8948. $excelid = explode(',', trim($excelid, ','));
  8949. foreach ($excelid as $key => $value) {
  8950. $xzid .= " id = " . $value . " or";
  8951. }
  8952. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  8953. }
  8954. $wt = array();
  8955. $whlabel_type = $this->whlabel_type->find_all();
  8956. foreach ($whlabel_type as $v) {
  8957. $wt[$v['id']] = $v['title'];
  8958. }
  8959. $wh = array();
  8960. $w = $this->warehouse->find_all('1=1', 'id,title');
  8961. foreach ($w as $v) {
  8962. $wh[$v['id']] = $v['title'];
  8963. }
  8964. $list = array();
  8965. $rows = $this->whlabel->find_pc($where, 'sku,purchase,features,warehouse', 'warehouse,purchase,details,cpid,dbcontent,sku,cs,bs,title,features,cpbz,sm,type,number');
  8966. foreach ($rows as $key => $value) {
  8967. if (isset($wt[$value['type']])) {
  8968. $rows[$key]['type'] = $wt[$value['type']];
  8969. } else {
  8970. $rows[$key]['type'] = '未设置';
  8971. }
  8972. $bm = '03';
  8973. $bmpx = array(13 => '', 16 => '', 18 => '', 25 => '', 26 => '', 41 => '');
  8974. $rows[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  8975. $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');
  8976. $details = array();
  8977. $cpid = array();
  8978. $cpbz = array();
  8979. $c = 0;
  8980. $g = 0;
  8981. $x = 0;
  8982. $t = 0;
  8983. $s = 0;
  8984. $q = 0;
  8985. foreach ($sd as $k => $v) {
  8986. if ($v['state'] == 0) {
  8987. $c++;
  8988. if ($v['cpid'] != 0) {
  8989. $cpid[$v['cpid']] = $v['cpid'];
  8990. }
  8991. if ($v['cpbz'] != '') {
  8992. $cpbz[$v['cpbz']] = $v['cpbz'];
  8993. }
  8994. }
  8995. if ($v['state'] != 9) {
  8996. $g++;
  8997. }
  8998. if ($v['state'] == 1) {
  8999. $x++;
  9000. }
  9001. if ($v['state'] == 2) {
  9002. $t++;
  9003. }
  9004. if ($v['state'] == 8) {
  9005. $s++;
  9006. }
  9007. if ($v['state'] == "3" || $v['state'] == "4" || $v['state'] == "5" || $v['state'] == "6" || $v['state'] == "7") {
  9008. $q++;
  9009. }
  9010. $details[$v['details']] = $v['details'];
  9011. }
  9012. $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'] . '"');
  9013. $rows[$key]['details'] = implode("、", $details);
  9014. $rows[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9015. $number = $value['number'];
  9016. $ftime = time() - 15 * 24 * 3600;
  9017. $rows[$key]['warehouse'] = isset($wh[$value['warehouse']])?$wh[$value['warehouse']]:"??";
  9018. $rows[$key]['number'] = $g;
  9019. $rows[$key]['c'] = $c;
  9020. $rows[$key]['x'] = $x;
  9021. $rows[$key]['t'] = $t;
  9022. $rows[$key]['s'] = $s;
  9023. $rows[$key]['q'] = $q;
  9024. $rows[$key]['z'] = $z;
  9025. $features = str_replace(array('-163-', '-164-', '-165-', '-166-'), '-', $value['features']);
  9026. $features = explode('-', trim($features, '-'));
  9027. $rows[$key]['dbcontent'] = isset($typeclass[$features[0]])?$typeclass[$features[0]]['title']:" ??";
  9028. }
  9029. $list = $this->logic_whlabel->dataTran($rows, ['pm', 'weight']);
  9030. $final_list = [];
  9031. foreach ($list as $k => $v) {
  9032. if (empty($v['sku'])) {
  9033. continue;
  9034. }
  9035. $final_list[] = [
  9036. $v["warehouse"],
  9037. $v["purchase"],
  9038. $v["details"],
  9039. $v["cpid"],
  9040. $v["dbcontent"],
  9041. $v["sku"],
  9042. $v["bm"],
  9043. $v["jm"],
  9044. $v["title"],
  9045. $v["pm"],
  9046. $v["cpbz"],
  9047. $v["sm"],
  9048. $v["type"],
  9049. $v["number"],
  9050. $v["c"],
  9051. $v["x"],
  9052. $v["t"],
  9053. $v["s"],
  9054. $v["q"],
  9055. $v["z"],
  9056. $v['weight'],
  9057. ];
  9058. }
  9059. if(empty($final_list)){
  9060. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9061. }
  9062. $title = "总进销存统计表";
  9063. $first_row = ["仓库", "供应商", "位置", "库存编码", "类目", "SKU", "用友编码", "用友料号", "商品名称", "商品中文", "产品备注", "说明", "类型", "入库总量", "库存数量", "销售数量", "退货数量", "删除数量", "其它操作", "占单数量", "重量(g)"];
  9064. $merges = [
  9065. [
  9066. "s"=>["r"=>0,"c"=>0],
  9067. "e"=>["r"=>0,"c"=>21]
  9068. ]
  9069. ];
  9070. $cols = [
  9071. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"30"],["wch"=>"40"],
  9072. ["wch"=>"40"],["wch"=>"40"],["wch"=>"20"],["wch"=>"20"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9073. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],
  9074. ];
  9075. array_unshift($final_list, $first_row);
  9076. array_unshift($final_list, [$title,"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""]);
  9077. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9078. }
  9079. public function _summaryjs($arg_array)
  9080. {
  9081. $prc = array();
  9082. $purchase = $this->purchase->find_all();
  9083. foreach ($purchase as $k => $v) {
  9084. $prc[$v['id']] = $v['title'];
  9085. }
  9086. if (isset($_GET['excel'])) {
  9087. $ktime = $this->input->get('ktime', true);
  9088. $jtime = $this->input->get('jtime', true);
  9089. $ktime = strtotime($ktime);
  9090. $jtime = strtotime($jtime);
  9091. $where = "1=1";
  9092. if ($ktime && $jtime) {
  9093. $where .= " and outk > '$ktime' and outk < '$jtime'";
  9094. }
  9095. //数据排序
  9096. $order_str = "time desc";
  9097. if (empty($page)) {
  9098. $start = 0;
  9099. $perpage = 1;
  9100. } else {
  9101. $start = ($page - 1) * $perpage;
  9102. }
  9103. //取得信息列表
  9104. $info_list = $this->whlabel->find_pc($where, 'sku', 'warehouse,purchase,details,cpid,sku,title');
  9105. foreach ($info_list as $key => $value) {
  9106. $info_list[$key]['purchase'] = (isset($prc[$value['purchase']])) ? $prc[$value['purchase']] : '未知';
  9107. $warehouse = $this->warehouse->read($value['warehouse']);
  9108. $info_list[$key]['warehouse'] = $warehouse['title'];
  9109. $x = $this->whlabel->find_all($where . ' and sku = "' . $value['sku'] . '"', 'details,cpid');
  9110. $details = array();
  9111. $cpid = array();
  9112. foreach ($x as $k => $v) {
  9113. if ($v['details'] != '') {
  9114. $details[$v['details']] = $v['details'];
  9115. }
  9116. if ($v['cpid'] != 0) {
  9117. $cpid[$v['cpid']] = $v['cpid'];
  9118. }
  9119. }
  9120. $info_list[$key]['details'] = ($details) ? implode(" ", $details) : '';
  9121. $info_list[$key]['cpid'] = ($cpid) ? implode(" ", $cpid) : '';
  9122. $s = $this->whlabel->find_count('state = 0 and sku = "' . $value['sku'] . '"');
  9123. $info_list[$key]['s'] = $s;
  9124. $info_list[$key]['x'] = count($x);
  9125. }
  9126. if(empty($info_list)){
  9127. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9128. }
  9129. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . '出库汇总详情';
  9130. $first_row = ["仓库", "供应商", "出库位置", "出库编码", "SKU", "产品名", "总剩余库存", date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) ."销售数量"];
  9131. $merges = [
  9132. [
  9133. "s"=>["r"=>0,"c"=>0],
  9134. "e"=>["r"=>0,"c"=>7]
  9135. ]
  9136. ];
  9137. $cols = [
  9138. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"15"],["wch"=>"30"],
  9139. ];
  9140. $final_list = [];
  9141. foreach($info_list as $k => $v){
  9142. $final_list[] = array_values($v);
  9143. }
  9144. array_unshift($final_list, $first_row);
  9145. array_unshift($final_list,[
  9146. $title,"","","","","","","","",
  9147. ]);
  9148. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9149. $titlename = "<table border=1>
  9150. <tr align='center'>
  9151. <td>仓库</td>
  9152. <td>供应商</td>
  9153. <td>出库位置</td>
  9154. <td>出库编码</td>
  9155. <td>SKU</td>
  9156. <td>产品名</td>
  9157. <td>总剩余库存</td>
  9158. <td>" . date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime) . "销售数量</td>
  9159. </tr>
  9160. </table>";
  9161. $filename = $title . ".xls";
  9162. $tail = "";
  9163. $this->excel->get_fz2($info_list, $titlename, $filename, $tail);
  9164. }
  9165. }
  9166. public function _uckjs()
  9167. {
  9168. if (isset($_GET['excel'])) {
  9169. $tc = array();
  9170. $typeclass = $this->typeclass->find_all();
  9171. foreach ($typeclass as $v) {
  9172. $tc[$v['id']] = $v['zh'];
  9173. }
  9174. $first_row = [
  9175. '类别','颜色','曲度','名称','SKU','月初库存','剩余库存','在途数量','预达日期'
  9176. ];
  9177. $t = array();
  9178. $rq = '';
  9179. $ts = strtotime(date("Y-m-d", time())) - strtotime(date("Y-m", time()));
  9180. $ts = $ts / (24 * 3600);
  9181. for ($i = 0; $i < $ts; $i++) {
  9182. $t[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9183. $first_row[] = date("Y-m-d", strtotime('-' . ($ts - $i) . ' day'));
  9184. }
  9185. $day_len = count($t);
  9186. $first_row[] = "本月出库";
  9187. $merges = [
  9188. ];
  9189. $info_list = $this->whlabel->find_pc("warehouse = '5'", 'sku', 'warehouse,sku,features');
  9190. $excel_key = 1;
  9191. $final_list = [];
  9192. foreach ($info_list as $k => $v) {
  9193. $features = explode('-', trim($v['features'], '-'));
  9194. if (!isset($features[3]) || !isset($features[4])) {
  9195. continue;
  9196. }
  9197. $tmp = [];
  9198. $tmp[0] = $tc[$features[0]]; //类型
  9199. $tmp[1] = ($features[3] != 57) ? $tc[$features[3]] : ''; //颜色,自然色不显示
  9200. $tmp[2] = $tc[$features[4]]; //曲度
  9201. $tmp[3] = '';
  9202. if (isset($data[$k][1])) {
  9203. $tmp[3] .=$tmp[1];
  9204. }
  9205. if (isset($data[$k][2])) {
  9206. $tmp[3] .= $tmp[2];
  9207. }
  9208. if (isset($features[5])) {
  9209. $tmp[3] .= $tc[$features[5]];
  9210. }
  9211. if (isset($features[2])) {
  9212. $tmp[3] .= $tc[$features[2]];
  9213. }
  9214. //$data[$k][3] 颜色,曲度,头套种类,尺寸
  9215. $tmp[4] = $v['sku'];
  9216. $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())) . '))'); //月初库存
  9217. $tmp[6] = $this->whlabel->find_count('sku = "' . $v['sku'] . '" and state = 0 and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '"'); //剩余库存
  9218. $tmp[7] ="";
  9219. $tmp[8] ="";
  9220. $byck = 0;
  9221. foreach ($t as $vv) {
  9222. $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));
  9223. $tmp[] = ($sl > 0) ? $sl : '';
  9224. $byck += $sl;
  9225. }
  9226. $tmp[] = ($byck > 0) ? $byck : '';
  9227. $zt = $this->whlabeltransport->find_all('sku = "' . $v['sku'] . '" and warehouse = "' . $v['warehouse'] . '" and features = "' . $v['features'] . '" and cz = "0"');
  9228. // $ztrq = '';
  9229. // $ztsl = '';
  9230. // if (count($zt) > 0) {
  9231. // foreach ($zt as $vv) {
  9232. // $ztrq .= date('Y-m-d', $vv['stime']) . '<br>';
  9233. // $ztsl .= $vv['num'] . '<br>';
  9234. // }
  9235. // }
  9236. if(empty($zt)){
  9237. $final_list[] = $tmp;
  9238. $excel_key = $excel_key + 1;
  9239. }else{
  9240. $len = count($zt);
  9241. if($len == 1){
  9242. $tmp[7] = $zt[0]['num'] ;
  9243. $tmp[8] = date('Y-m-d', $zt[0]['stime']);
  9244. $final_list[] = $tmp;
  9245. $excel_key = $excel_key + 1;
  9246. }else{
  9247. foreach($zt as $vv){
  9248. $tmp[7] = "";
  9249. $tmp[8] = "";
  9250. $tmp[7] = $vv['num'];
  9251. $tmp[8] = date('Y-m-d', $vv['stime']) ;
  9252. $final_list[] = $tmp;
  9253. }
  9254. $merges[] = [
  9255. "s"=>["r"=>$excel_key,"c"=>0],
  9256. "e"=>["r"=>$excel_key+$len-1,"c"=>0]
  9257. ];
  9258. $merges[] = [
  9259. "s"=>["r"=>$excel_key,"c"=>1],
  9260. "e"=>["r"=>$excel_key+$len-1,"c"=>1]
  9261. ];
  9262. $merges[] = [
  9263. "s"=>["r"=>$excel_key,"c"=>2],
  9264. "e"=>["r"=>$excel_key+$len-1,"c"=>2]
  9265. ];
  9266. $merges[] = [
  9267. "s"=>["r"=>$excel_key,"c"=>3],
  9268. "e"=>["r"=>$excel_key+$len-1,"c"=>3]
  9269. ];
  9270. $merges[] = [
  9271. "s"=>["r"=>$excel_key,"c"=>4],
  9272. "e"=>["r"=>$excel_key+$len-1,"c"=>4]
  9273. ];
  9274. $merges[] = [
  9275. "s"=>["r"=>$excel_key,"c"=>5],
  9276. "e"=>["r"=>$excel_key+$len-1,"c"=>5]
  9277. ];
  9278. $merges[] = [
  9279. "s"=>["r"=>$excel_key,"c"=>6],
  9280. "e"=>["r"=>$excel_key+$len-1,"c"=>6]
  9281. ];
  9282. for($i=1;$i<=$day_len;$i++){
  9283. $merges[] = [
  9284. "s"=>["r"=>$excel_key,"c"=>8+$i],
  9285. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$i]
  9286. ];
  9287. }
  9288. $merges[] = [
  9289. "s"=>["r"=>$excel_key,"c"=>8+$day_len+1],
  9290. "e"=>["r"=>$excel_key+$len-1,"c"=>8+$day_len+1]
  9291. ];
  9292. $excel_key = $excel_key + $len;
  9293. }
  9294. }
  9295. }
  9296. $title = "详情 " . date("Y-m-d", time());
  9297. if(empty($final_list)){
  9298. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9299. }
  9300. $cols = [
  9301. ["wch"=>"10"],["wch"=>"10"],["wch"=>"10"],["wch"=>"40"],["wch"=>"40"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9302. ];
  9303. array_unshift($final_list, $first_row);
  9304. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9305. }
  9306. }
  9307. public function _whlabelexcelzhjs(){
  9308. if(empty($_GET['excel'])){
  9309. exit(json_encode(array('code' => 0, 'msg' => '请求参数缺失')));
  9310. }
  9311. $where = "sku != 'Preset' and sku != '' ";
  9312. //数据排序
  9313. $order_str = "id desc";
  9314. if (empty($page)) {
  9315. $start = 0;
  9316. $perpage = 1;
  9317. } else {
  9318. $start = ($page - 1) * $perpage;
  9319. }
  9320. $category = $this->input->get('category', true);
  9321. $warehouse = $this->input->get('warehouse', true);
  9322. $excelid = $this->input->get('sid', true);
  9323. if ($category) {
  9324. $where .= " and features like '%-$category-%'";
  9325. }
  9326. if ($warehouse) {
  9327. $where .= " and warehouse = '$warehouse'";
  9328. }
  9329. $xzid = '';
  9330. if ($excelid) {
  9331. $excelid = explode(',', trim($excelid, ','));
  9332. foreach ($excelid as $key => $value) {
  9333. $xzid .= " id = " . $value . " or";
  9334. }
  9335. $xzid = " and (" . rtrim($xzid, 'or') . ")";;
  9336. }
  9337. $merges = [
  9338. [
  9339. "s"=>["r"=>0,"c"=>0],
  9340. "e"=>["r"=>0,"c"=>6]
  9341. ]
  9342. ];
  9343. $rows = $this->whlabel->find_pc($where, 'sku,features,warehouse', 'warehouse,sku,title,number,features');
  9344. $excel_index = 2;
  9345. $final_list = [];
  9346. foreach ($rows as $key => $value) {
  9347. $c = $this->whlabel->find_count($where . ' and sku = "' . $value['sku'] . '" and warehouse = "' . $value['warehouse'] . '" and state = "0" and features = "' . $value['features'] . '"');
  9348. $zh = '';
  9349. $zt_list = $this->whlabeltransport->find_all('sku = "' . $value['sku'] . '" and time = "0" and warehouse = "' . $value['warehouse'] . '" and features = "' . $value['features'] . '"', 'num,stime');
  9350. // foreach ($zt_list as $v) {
  9351. // $zh .= $v['num'] . " / " . date('Y-m-d', $v['stime']) . "<br>";
  9352. // }
  9353. $zt = array_sum(array_column($zt_list, 'num'));
  9354. $number = $value['number'];
  9355. $ftime = time() - 15 * 24 * 3600;
  9356. $warehouse = $this->warehouse->read($value['warehouse']);
  9357. // $rows[$key]['warehouse'] = $warehouse['title'];
  9358. // $rows[$key]['number'] = $c;
  9359. // $rows[$key]['features'] = $zh;
  9360. //$rows[$key]['hb'] = $c + $zt;
  9361. $tmp = [];
  9362. $tmp[0] = $warehouse['title'];
  9363. $tmp[1] = $value['sku'];
  9364. $tmp[2] = $value['title'];
  9365. $tmp[3] = $c;
  9366. $tmp[4] = "";
  9367. $tmp[5] = $c + $zt;
  9368. if(empty($zt_list)){
  9369. $tmp[4] = "";
  9370. $final_list[] = $tmp;
  9371. $excel_index = $excel_index + 1;
  9372. }else{
  9373. if(count($zt_list) == 1){
  9374. $tmp[4] = "";
  9375. $tmp[4] = $zt_list[0]['num'] . " / " . date('Y-m-d', $zt_list[0]['stime']);
  9376. $final_list[] = $tmp;
  9377. $excel_index = $excel_index + 1;
  9378. }else{
  9379. $len = count($zt_list);
  9380. foreach ($zt_list as $v){
  9381. $tmp[4] = "";
  9382. $tmp[4] = $v['num'] . " / " . date('Y-m-d', $v['stime']);
  9383. $final_list[] = $tmp;
  9384. }
  9385. $merges[] = [
  9386. "s"=>["r"=>$excel_index,"c"=>0],
  9387. "e"=>["r"=>$excel_index+$len-1,"c"=>0]
  9388. ];
  9389. $merges[] = [
  9390. "s"=>["r"=>$excel_index,"c"=>1],
  9391. "e"=>["r"=>$excel_index+$len-1,"c"=>1]
  9392. ];
  9393. $merges[] = [
  9394. "s"=>["r"=>$excel_index,"c"=>2],
  9395. "e"=>["r"=>$excel_index+$len-1,"c"=>2]
  9396. ];
  9397. $merges[] = [
  9398. "s"=>["r"=>$excel_index,"c"=>3],
  9399. "e"=>["r"=>$excel_index+$len-1,"c"=>3]
  9400. ];
  9401. $merges[] = [
  9402. "s"=>["r"=>$excel_index,"c"=>5],
  9403. "e"=>["r"=>$excel_index+$len-1,"c"=>5]
  9404. ];
  9405. $excel_index = $excel_index + $len;
  9406. }
  9407. }
  9408. }
  9409. $first_row = [
  9410. '仓库','SKU','产品','库存数量','在途数量及预达日期','在途+库存数量',
  9411. ];
  9412. $title = "导出库存数据及在途中数据" . date('Y-m-d', time());
  9413. if(empty($final_list)){
  9414. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9415. }
  9416. $cols = [
  9417. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"10"],["wch"=>"15"],["wch"=>"15"],
  9418. ];
  9419. array_unshift($final_list, $first_row);
  9420. array_unshift($final_list, [
  9421. $title,"","","","",""
  9422. ]);
  9423. $end_list = [];
  9424. foreach ($final_list as $key => $value) {
  9425. $end_list[] = array_values($value);
  9426. }
  9427. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9428. }
  9429. //出库、退库导出
  9430. public function _dccrtypejs()
  9431. {
  9432. $classid = $this->classid->sku();
  9433. $pm = $classid;
  9434. $typeclass = array();
  9435. $tc = $this->typeclass->find_all();
  9436. foreach ($tc as $v) {
  9437. $typeclass[$v['id']] = $v;
  9438. }
  9439. $prc = array();
  9440. $purchase = $this->purchase->find_all();
  9441. foreach ($purchase as $k => $v) {
  9442. $prc[$v['id']] = $v['title'];
  9443. }
  9444. if (isset($_GET['sid'])) {
  9445. $wh = array();
  9446. $w = $this->warehouse->find_all('1=1', 'id,title');
  9447. foreach ($w as $v) {
  9448. $wh[$v['id']] = $v['title'];
  9449. }
  9450. $type = $this->input->get('excel', true);
  9451. $category = $this->input->get('category', true);
  9452. $size = $this->input->get('size', true);
  9453. $grade = $this->input->get('grade', true);
  9454. $color = $this->input->get('color', true);
  9455. $lowe = $this->input->get('lowe', true);
  9456. $sku = $this->input->get('sku', true);
  9457. $warehouse = $this->input->get('warehouse', true);
  9458. $lacetype = $this->input->get('lacetype', true);
  9459. $lacecolor = $this->input->get('lacecolor', true);
  9460. $density = $this->input->get('density', true);
  9461. $haircap = $this->input->get('haircap', true);
  9462. $purchase = $this->input->get('purchase', true);
  9463. $title = $this->input->get('title', true);
  9464. $state = $this->input->get('state', true);
  9465. $sid = $this->input->get('sid', true);
  9466. $ktime = $this->input->get('ktime', true);
  9467. $jtime = $this->input->get('jtime', true);
  9468. $ktime = strtotime($ktime);
  9469. $jtime = strtotime($jtime);
  9470. $where = "1=1";
  9471. $gj = "";
  9472. $ck = "";
  9473. if ($category) {
  9474. $where .= " and features like '%-$category-%'";
  9475. }
  9476. if ($size) {
  9477. $where .= " and features like '%-$size-%'";
  9478. }
  9479. if ($grade) {
  9480. $where .= " and features like '%-$grade-%'";
  9481. }
  9482. if ($color) {
  9483. $where .= " and features like '%-$color-%'";
  9484. }
  9485. if ($lowe) {
  9486. $where .= " and features like '%-$lowe-%'";
  9487. }
  9488. if ($warehouse) {
  9489. $where .= " and warehouse = '$warehouse'";
  9490. }
  9491. if ($purchase) {
  9492. $where .= " and purchase = '$purchase'";
  9493. }
  9494. if ($state) {
  9495. $where .= " and state = '$state'";
  9496. }
  9497. if ($lacetype) {
  9498. $where .= " and features like '%-$lacetype-%'";
  9499. }
  9500. if ($lacecolor) {
  9501. $where .= " and features like '%-$lacecolor-%'";
  9502. }
  9503. if ($density) {
  9504. $where .= " and features like '%-$density-%'";
  9505. }
  9506. if ($haircap) {
  9507. $where .= " and features like '%-$haircap-%'";
  9508. }
  9509. if ($title) {
  9510. $title = trim($title, ' ');
  9511. $title = trim($title, ' ');
  9512. $where .= " and title like '%$title%'";
  9513. }
  9514. if ($sku) {
  9515. $sku = trim($sku, ' ');
  9516. $sku = trim($sku, ' ');
  9517. $where .= " and sku like '%$sku%'";
  9518. }
  9519. if ($ktime && $jtime) {
  9520. //$where .= " and ((enter > '$ktime' and enter < '$jtime') or (outk > '$ktime' and outk < '$jtime'))";
  9521. }
  9522. $sidwhere = '';
  9523. if ($sid) {
  9524. $sd = "";
  9525. $s = explode(',', trim($sid, ','));
  9526. foreach ($s as $value) {
  9527. $sd .= " id = " . $value . " or";
  9528. }
  9529. $sidwhere = " and (" . rtrim($sd, 'or') . ")";
  9530. }
  9531. //数据排序
  9532. $order_str = "time desc";
  9533. if (empty($page)) {
  9534. $start = 0;
  9535. $perpage = 1;
  9536. } else {
  9537. $start = ($page - 1) * $perpage;
  9538. }
  9539. $wh = array();
  9540. $w = $this->warehouse->find_all('1=1', 'id,title');
  9541. foreach ($w as $v) {
  9542. $wh[$v['id']] = $v['title'];
  9543. }
  9544. $wt = array();
  9545. $whlabel_type = $this->whlabel_type->find_all();
  9546. foreach ($whlabel_type as $v) {
  9547. $wt[$v['id']] = $v['title'];
  9548. }
  9549. $classid = $this->classid->sku();
  9550. $list = array();
  9551. $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');
  9552. foreach ($rows_r as $key => $value) {
  9553. $rows_r[$key]['warehouse'] = $wh[$value['warehouse']];
  9554. $pm = $classid;
  9555. $jm = $classid;
  9556. $rows_r[$key]['enter'] = '入库';
  9557. $rows_r[$key]['time'] = $value['enter'];
  9558. if ($value['rktype'] == 1) {
  9559. $rows_r[$key]['rktype'] = '采购入库';
  9560. } else if ($value['rktype'] == 2) {
  9561. $rows_r[$key]['rktype'] = '盘盈调整';
  9562. } else if ($value['rktype'] == 3) {
  9563. $rows_r[$key]['rktype'] = '其他调整入库';
  9564. } else if ($value['rktype'] == 4) {
  9565. $rows_r[$key]['rktype'] = '其他调整入库';
  9566. } else if ($value['rktype'] == 5) {
  9567. $rows_r[$key]['rktype'] = '退库入库';
  9568. } else if ($value['rktype'] == 6) {
  9569. $rows_r[$key]['rktype'] = '退货可用入库';
  9570. } else if ($value['rktype'] == 7) {
  9571. $rows_r[$key]['rktype'] = '形态转换入库';
  9572. } else {
  9573. $rows_r[$key]['rktype'] = '';
  9574. }
  9575. $features = explode('-', trim($value['features'], '-'));
  9576. foreach ($features as $v) {
  9577. if (isset($typeclass[$v])) {
  9578. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9579. $pm[$typeclass[$v]['classid']] = $zh[0];
  9580. }
  9581. if (isset($typeclass[$v])) {
  9582. if (isset($jm[$typeclass[$v]['classid']])) {
  9583. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9584. }
  9585. }
  9586. }
  9587. $zh = implode(" ", $pm);
  9588. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9589. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9590. $rows_r[$key]['zh'] = $zh;
  9591. $jm = array_filter($jm);
  9592. $rows_r[$key]['features'] = implode("-", $jm);
  9593. $rows_r[$key]['number'] = $this->whlabel->find_count($where . " and enter = '" . $value['enter'] . "' " . $sidwhere);
  9594. }
  9595. $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');
  9596. foreach ($rows_c as $key => $value) {
  9597. $rows_c[$key]['warehouse'] = $wh[$value['warehouse']];
  9598. $pm = $classid;
  9599. $jm = $classid;
  9600. $rows_c[$key]['time'] = $value['outk'];
  9601. $rows_c[$key]['outk'] = '出库';
  9602. if ($value['cktype'] == 1) {
  9603. $rows_c[$key]['cktype'] = (($value['state']==10)&&($value['warehouse']== 5))?'美国销售调货出库': '销售出库';
  9604. } else if ($value['cktype'] == 2) {
  9605. $rows_c[$key]['cktype'] = '美国销售调货出库';
  9606. } else if ($value['cktype'] == 3) {
  9607. $rows_c[$key]['cktype'] = '盘亏调整';
  9608. } else if ($value['cktype'] == 4) {
  9609. $rows_c[$key]['cktype'] = '其他调整出库';
  9610. } else if ($value['cktype'] == 5) {
  9611. $rows_c[$key]['cktype'] = '形态转换出库';
  9612. } else {
  9613. $rows_c[$key]['cktype'] = '';
  9614. }
  9615. unset($rows_c[$key]['state']);
  9616. $features = explode('-', trim($value['features'], '-'));
  9617. foreach ($features as $v) {
  9618. if (isset($typeclass[$v])) {
  9619. $zh = explode('|', trim($typeclass[$v]['zh'], '|'));
  9620. $pm[$typeclass[$v]['classid']] = $zh[0];
  9621. }
  9622. if (isset($typeclass[$v])) {
  9623. if (isset($jm[$typeclass[$v]['classid']])) {
  9624. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  9625. }
  9626. }
  9627. }
  9628. $zh = implode(" ", $pm);
  9629. $zh = str_replace('自然色 ', '', rtrim($zh, ' '));
  9630. $zh = str_replace(array(' ', ' ', ' ', ' ', ' ', ' ', ' '), ' ', $zh);
  9631. $rows_c[$key]['zh'] = $zh;
  9632. $jm = array_filter($jm);
  9633. $rows_c[$key]['features'] = implode("-", $jm);
  9634. $rows_c[$key]['number'] = 1;
  9635. }
  9636. $merged = $rows_r;
  9637. foreach ($rows_c as $key => $value) {
  9638. if (isset($merged[$key])) {
  9639. $merged[] = $value;
  9640. } else {
  9641. $merged[$key] = $value;
  9642. }
  9643. }
  9644. usort($merged, function ($a, $b) {
  9645. return $a['time'] - $b['time'];
  9646. });
  9647. foreach ($merged as $key => $value) {
  9648. $merged[$key]['time'] = date('Y-m-d H:i:s', $value['time']);
  9649. }
  9650. $title = date('Y-m-d', $ktime) . '至' . date('Y-m-d', $jtime);
  9651. $first_row = ["仓库","SKU","商品名称","仓库品名","料号","时间","操作","类型","数量","备注"];
  9652. $cols = [
  9653. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],["wch"=>"30"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],["wch"=>"15"],
  9654. ];
  9655. $final_list= [];
  9656. foreach($merged as $key => $value){
  9657. $final_list[] = array_values($value) ;
  9658. }
  9659. if(empty($merged)){
  9660. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9661. }
  9662. array_unshift($final_list, $first_row);
  9663. $end_list = [];
  9664. foreach ($final_list as $key => $value) {
  9665. $end_list[] = array_values($value);
  9666. }
  9667. $merges = [];
  9668. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $end_list,'title'=>$title,'cols' => $cols])));
  9669. }
  9670. }
  9671. public function _errorexceljs()
  9672. {
  9673. $post = $this->input->post(NULL, TRUE);
  9674. if (isset($_GET['page'])) {
  9675. $page = $this->input->get('page', true);
  9676. $perpage = $this->input->get('perpage', true);
  9677. $sku = $this->input->get('sku', true);
  9678. $warehouse = $this->input->get('warehouse', true);
  9679. $ktime = $this->input->get('ktime', true);
  9680. $jtime = $this->input->get('jtime', true);
  9681. $ktime = strtotime($ktime);
  9682. $jtime = strtotime($jtime);
  9683. $where = "sku != 'Preset'";
  9684. $gj = '';
  9685. if ($sku) {
  9686. $where .= " and sku like '%$sku%'";
  9687. } else {
  9688. if ($ktime && $jtime) {
  9689. $gj = " and time > '$ktime' and time < '$jtime'";
  9690. }
  9691. }
  9692. if ($warehouse) {
  9693. $where .= " and warehouse = '$warehouse'";
  9694. }
  9695. //数据排序
  9696. $order_str = "id desc";
  9697. if (empty($page)) {
  9698. $start = 0;
  9699. $perpage = 1;
  9700. } else {
  9701. $start = ($page - 1) * $perpage;
  9702. }
  9703. //取得信息列表
  9704. $rows = array();
  9705. $list = array();
  9706. $info_list = $this->whlabel->find_pc($where, 'warehouse,features,sku', '*');
  9707. foreach ($info_list as $value) {
  9708. $warehouse = $this->warehouse->read($value['warehouse']);
  9709. $c = $this->whlabel->find_count('sku = "' . $value['sku'] . '" and state = "0" and warehouse = "' . $value['warehouse'] . '"');
  9710. $number = $value['number'];
  9711. $ftime = time() - 15 * 24 * 3600;
  9712. if ($c < 1) {
  9713. $list[] = array('warehouse' => $warehouse['title'], 'sku' => $value['sku'], 'title' => $value['title'], 'c' => $c);
  9714. }
  9715. }
  9716. $title = "0库存汇总";
  9717. $first_row = ["仓库","SKU","产品","当前库存"];
  9718. $cols = [
  9719. ["wch"=>"15"],["wch"=>"30"],["wch"=>"30"],["wch"=>"15"],
  9720. ];
  9721. $final_list= [];
  9722. foreach($list as $key => $value){
  9723. $final_list[] = array_values($value) ;
  9724. }
  9725. if(empty($final_list)){
  9726. exit(json_encode(array('code' => 0, 'msg' => '无符合条件数据')));
  9727. }
  9728. array_unshift($final_list, $first_row);
  9729. $merges = [];
  9730. exit(json_encode(array('code' => 1,'msg'=>"获取成功",'data'=>['merges'=>$merges, 'data' => $final_list,'title'=>$title,'cols' => $cols])));
  9731. }
  9732. }
  9733. }